Debian Codegraph @

src/mpt/string/tests/tests_string_utility.hpp

raw
1 /* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */
2
3 #ifndef MPT_STRING_TESTS_STRING_UTILITY_HPP
4 #define MPT_STRING_TESTS_STRING_UTILITY_HPP
5
6
7
8 #include "mpt/base/detect.hpp"
9 #include "mpt/base/namespace.hpp"
10 #include "mpt/string/utility.hpp"
11 #include "mpt/test/test.hpp"
12 #include "mpt/test/test_macros.hpp"
13
14 #include <string>
15
16 #include <cstddef>
17
18
19
20 namespace mpt {
21 inline namespace MPT_INLINE_NS {
22
23
24
25 namespace tests {
26 namespace string {
27 namespace utility {
28
29 #if MPT_COMPILER_CLANG
30 #pragma clang diagnostic push
31 #pragma clang diagnostic ignored "-Wglobal-constructors"
32 #endif
33 MPT_TEST_GROUP_INLINE("mpt/string/utility")
34 #if MPT_COMPILER_CLANG
35 #pragma clang diagnostic pop
36 #endif
37 {
38 MPT_TEST_EXPECT_EQUAL(mpt::trim_left(std::string(" ")), "");
39 MPT_TEST_EXPECT_EQUAL(mpt::trim_right(std::string(" ")), "");
40 MPT_TEST_EXPECT_EQUAL(mpt::trim(std::string(" ")), "");
41
42 // weird things with std::string containing \0 in the middle and trimming \0
43 MPT_TEST_EXPECT_EQUAL(std::string("\0\ta\0b ", 6).length(), (std::size_t)6);
44 MPT_TEST_EXPECT_EQUAL(mpt::trim_right(std::string("\0\ta\0b ", 6)), std::string("\0\ta\0b", 5));
45 MPT_TEST_EXPECT_EQUAL(mpt::trim(std::string("\0\ta\0b\0", 6), std::string("\0", 1)), std::string("\ta\0b", 4));
46 }
47
48 } // namespace utility
49 } // namespace string
50 } // namespace tests
51
52
53
54 } // namespace MPT_INLINE_NS
55 } // namespace mpt
56
57
58
59 #endif // MPT_STRING_TESTS_STRING_UTILITY_HPP