19 Commits

Author SHA1 Message Date
Julian Brost
784867b3f7 Avoid undefined behavior in string/vector_move test
vec[1] is equivalent to vec[vec.size()] at that point and thus not a valid
element of the vector, making the use of operator[] undefined behavior here.
With some compiler flags (like those used in package builds on RHEL and
similar), the compiler (rightfully) aborts the program on this out of bounds
access:

     68/178 Test  #68: base-base_string/vector_move ............................................***Failed    0.01 sec
    /usr/include/c++/14/bits/stl_vector.h:1130: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = icinga::String; _Alloc = std::allocator<icinga::String>; reference = icinga::String&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
    Running 1 test case...
    unknown location(0): fatal error: in "base_string/vector_move": signal: SIGABRT (application abort requested)
    /builds/packages/icinga2/packaging/fedora/41/BUILD/icinga2-2.14.5+467.g206d7cda1-build/icinga2-2.14.5+467.g206d7cda1/test/base-string.cpp(120): last checkpoint
    *** 1 failure is detected in the test module "icinga2"

This commit fixes this by taking the indirection through .data() and using
plain pointer arithmetic instead.
2025-03-10 09:28:33 +01:00
Yonas Habteab
3e9292a349 Value: Add a specialized rvalue reference of Get()
The move `String(Value&&)` constructor tries to partially move `String`
values from a `Value` type. However, since there was no an appropriate
`Value::Get<T>()` implementation that binds to the requested move
operation, the compiler will actually not move the value but copy it
instead as the only available implementation of `Value::Get<T>()`
returns a const reference `const T&`. This commit adds a new overload
that returns a non-const reference and allows to optionally move the string
value of a Value type.
2025-03-07 10:16:31 +01:00
Julian Brost
e308552ecc Add test that std::vector<icinga::String> uses move overloads 2025-03-06 13:02:40 +01:00
Michael Friedrich
d14a88235d Replace Copyright header with a short version, part I
CLion -> replace in path
2019-02-25 14:48:22 +01:00
Michael Friedrich
dab53448bc icinga.com: Update *.{h,c}pp 2018-10-18 09:27:04 +02:00
Michael Insel
158ae2188e Change copyright header for 2018 2018-01-02 12:08:55 +01:00
Michael Friedrich
b7caf0820d Ensure that *.icinga.com is used everywhere
fixes #13897
fixes #13277
2017-01-10 17:19:12 +01:00
Gunnar Beutner
1dc4ab367e Fix: Unit tests randomly crash after the tests have completed
fixes #12610
2016-09-07 08:25:53 +02:00
Gunnar Beutner
288413f046 Replace BOOST_FOREACH with range-based for loops
fixes #12538
2016-08-25 06:46:17 +02:00
Gunnar Beutner
599929b0f6 Update copyright headers for 2016 2016-01-12 08:29:59 +01:00
Jean Flach
f1a1dfb26e Update use of String::Trim()
fixes #9704
2015-08-27 18:06:20 +02:00
Michael Friedrich
78bfd0204c Update copyright year 2015-01-22 12:00:23 +01:00
Gunnar Beutner
739cb43289 Rename qstring.{cpp,hpp} to string.{cpp,hpp} 2014-10-19 14:52:07 +02:00
Gunnar Beutner
632026cd9f Rename C++ header files.
Fixes #6291
2014-05-25 16:27:14 +02:00
Michael Friedrich
ce737ff2f3 Change copyright header (again).
Fixes #5424
2014-03-19 11:42:47 +01:00
Michael Friedrich
555d72150a Update copyright header.
Fixes #5424
2014-01-09 00:32:11 +01:00
Michael Friedrich
7fa9188df8 Add String::Contains().
Refs #5355
2013-12-17 18:34:05 +01:00
Gunnar Beutner
bf1a800e39 Update copyright information. 2013-09-25 07:45:56 +02:00
Gunnar Beutner
2e81c28444 Add more unit tests. 2013-09-02 13:08:29 +02:00