Test IsString<String> and IsString<StringSumHelper>

This commit is contained in:
Benoit Blanchon
2022-10-31 18:02:07 +01:00
parent c3d5e9382d
commit b8d1dccb21
2 changed files with 9 additions and 24 deletions

View File

@ -62,7 +62,7 @@ class String {
size_t _maxCapacity; size_t _maxCapacity;
}; };
class StringSumHelper; class StringSumHelper : public ::String {};
inline bool operator==(const std::string& lhs, const ::String& rhs) { inline bool operator==(const std::string& lhs, const ::String& rhs) {
return lhs == rhs.c_str(); return lhs == rhs.c_str();

View File

@ -87,29 +87,14 @@ TEST_CASE("custom_string") {
} }
TEST_CASE("IsString<T>") { TEST_CASE("IsString<T>") {
SECTION("std::string") { CHECK(IsString<std::string>::value == true);
CHECK(IsString<std::string>::value == true); CHECK(IsString<std::basic_string<wchar_t> >::value == false);
} CHECK(IsString<custom_string>::value == true);
CHECK(IsString<const __FlashStringHelper*>::value == true);
SECTION("basic_string<wchar_t>") { CHECK(IsString<const char*>::value == true);
CHECK(IsString<std::basic_string<wchar_t> >::value == false); CHECK(IsString<const char[8]>::value == true);
} CHECK(IsString< ::String>::value == true);
CHECK(IsString< ::StringSumHelper>::value == true);
SECTION("custom_string") {
CHECK(IsString<custom_string>::value == true);
}
SECTION("const __FlashStringHelper*") {
CHECK(IsString<const __FlashStringHelper*>::value == true);
}
SECTION("const char*") {
CHECK(IsString<const char*>::value == true);
}
SECTION("const char[]") {
CHECK(IsString<const char[8]>::value == true);
}
} }
TEST_CASE("stringCompare") { TEST_CASE("stringCompare") {