mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-08-04 01:36:10 -04:00
New std::string test
This commit is contained in:
parent
910791146c
commit
74ccef87d1
@ -440,6 +440,25 @@ void test_compare(){
|
|||||||
CHECK(e.compare(e) == 0, "Invalid std::string::compare");
|
CHECK(e.compare(e) == 0, "Invalid std::string::compare");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_assign_sv(){
|
||||||
|
std::string a = "bcd";
|
||||||
|
std::string b = "abcde";
|
||||||
|
std::string_view sb = b;
|
||||||
|
std::string c = "def";
|
||||||
|
|
||||||
|
a = sb;
|
||||||
|
|
||||||
|
CHECK(!a.empty(), "String mustn't be empty");
|
||||||
|
CHECK(a.size() == 5, "Invalid size");
|
||||||
|
CHECK(strcmp(a.c_str(), "abcde") == 0, "Invalid content");
|
||||||
|
|
||||||
|
a = static_cast<std::string_view>(c);
|
||||||
|
|
||||||
|
CHECK(!a.empty(), "String mustn't be empty");
|
||||||
|
CHECK(a.size() == 3, "Invalid size");
|
||||||
|
CHECK(strcmp(a.c_str(), "def") == 0, "Invalid content");
|
||||||
|
}
|
||||||
|
|
||||||
} //end of anonymous namespace
|
} //end of anonymous namespace
|
||||||
|
|
||||||
void string_tests(){
|
void string_tests(){
|
||||||
@ -457,4 +476,5 @@ void string_tests(){
|
|||||||
test_operators_short_to_long();
|
test_operators_short_to_long();
|
||||||
test_operators_long_to_short();
|
test_operators_long_to_short();
|
||||||
test_compare();
|
test_compare();
|
||||||
|
test_assign_sv();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user