|
|
@ -130,10 +130,10 @@ using char_type_combos = ::testing::Types< |
|
|
|
std::pair<char32_t, char>, std::pair<char32_t, char8_t>, std::pair<char32_t, char16_t>, std::pair<char32_t, char32_t>>; |
|
|
|
|
|
|
|
template<typename T> |
|
|
|
class UnicodeAbcdTest : public ::testing::Test { |
|
|
|
class UnicodeFullTest : public ::testing::Test { |
|
|
|
public: |
|
|
|
}; |
|
|
|
TYPED_TEST_SUITE(UnicodeAbcdTest, char_type_combos); |
|
|
|
TYPED_TEST_SUITE(UnicodeFullTest, char_type_combos); |
|
|
|
|
|
|
|
template<typename CharT, size_t InLength> |
|
|
|
std::basic_string<CharT> make_str(const char32_t (&in_str)[InLength]) { |
|
|
@ -147,7 +147,7 @@ std::basic_string<CharT> make_str(const char32_t (&in_str)[InLength]) { |
|
|
|
|
|
|
|
/** string_cast */ |
|
|
|
|
|
|
|
TYPED_TEST(UnicodeAbcdTest, string_cast) { |
|
|
|
TYPED_TEST(UnicodeFullTest, string_cast) { |
|
|
|
auto abcd_str = make_str<typename TypeParam::first_type>(U"ABCD"); |
|
|
|
std::basic_string_view<typename TypeParam::first_type> abcd_string_view = abcd_str; |
|
|
|
|
|
|
@ -168,7 +168,7 @@ TEST(UTF8Test, string_view_cast) { |
|
|
|
|
|
|
|
/** equals */ |
|
|
|
|
|
|
|
TYPED_TEST(UnicodeAbcdTest, equals) { |
|
|
|
TYPED_TEST(UnicodeFullTest, equals) { |
|
|
|
// TypeParam::first_type == TypeParam::second_type
|
|
|
|
EXPECT_TRUE(equals(make_str<typename TypeParam::first_type>(U"ABCD"), |
|
|
|
make_str<typename TypeParam::second_type>(U"ABCD"))); |
|
|
@ -184,7 +184,7 @@ TYPED_TEST(UnicodeAbcdTest, equals) { |
|
|
|
|
|
|
|
/** equalsi */ |
|
|
|
|
|
|
|
TYPED_TEST(UnicodeAbcdTest, equalsi) { |
|
|
|
TYPED_TEST(UnicodeFullTest, equalsi) { |
|
|
|
// TypeParam::first_type == TypeParam::second_type
|
|
|
|
EXPECT_TRUE(equalsi(make_str<typename TypeParam::first_type>(U"ABCD"), |
|
|
|
make_str<typename TypeParam::second_type>(U"ABCD"))); |
|
|
@ -200,7 +200,7 @@ TYPED_TEST(UnicodeAbcdTest, equalsi) { |
|
|
|
|
|
|
|
/** starts_with */ |
|
|
|
|
|
|
|
TYPED_TEST(UnicodeAbcdTest, starts_with) { |
|
|
|
TYPED_TEST(UnicodeFullTest, starts_with) { |
|
|
|
// TypeParam::first_type == TypeParam::second_type
|
|
|
|
EXPECT_TRUE(starts_with(make_str<typename TypeParam::first_type>(U"ABCD"), |
|
|
|
make_str<typename TypeParam::second_type>(U"ABCD"))); |
|
|
@ -240,7 +240,7 @@ TYPED_TEST(UnicodeAbcdTest, starts_with) { |
|
|
|
|
|
|
|
/** starts_withi */ |
|
|
|
|
|
|
|
TYPED_TEST(UnicodeAbcdTest, starts_withi) { |
|
|
|
TYPED_TEST(UnicodeFullTest, starts_withi) { |
|
|
|
// TypeParam::first_type == TypeParam::second_type
|
|
|
|
EXPECT_TRUE(starts_withi(make_str<typename TypeParam::first_type>(U"ABCD"), |
|
|
|
make_str<typename TypeParam::second_type>(U"ABCD"))); |
|
|
@ -285,6 +285,105 @@ TYPED_TEST(UnicodeAbcdTest, starts_withi) { |
|
|
|
make_str<typename TypeParam::second_type>(U"del"))); |
|
|
|
} |
|
|
|
|
|
|
|
TYPED_TEST(UnicodeFullTest, find) { |
|
|
|
auto abcd_str = make_str<typename TypeParam::first_type>(U"ABCD"); |
|
|
|
|
|
|
|
// Empty substring
|
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"")), 0); |
|
|
|
|
|
|
|
// Single-characters
|
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"A")), 0); |
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"B")), 1); |
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"C")), 2); |
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"D")), 3); |
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"E")), decltype(abcd_str)::npos); |
|
|
|
|
|
|
|
// Two characters
|
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"AB")), 0); |
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"BC")), 1); |
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"CD")), 2); |
|
|
|
EXPECT_EQ(find(abcd_str, make_str<typename TypeParam::second_type>(U"DA")), decltype(abcd_str)::npos); |
|
|
|
|
|
|
|
auto double_abcd_str = make_str<typename TypeParam::first_type>(U"AABBCCDD"); |
|
|
|
|
|
|
|
// Single-characters
|
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"A")), 0); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"B")), 2); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"C")), 4); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"D")), 6); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"E")), decltype(double_abcd_str)::npos); |
|
|
|
|
|
|
|
// Two characters
|
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"AA")), 0); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"AB")), 1); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"BB")), 2); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"BC")), 3); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"CC")), 4); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"CD")), 5); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"DD")), 6); |
|
|
|
EXPECT_EQ(find(double_abcd_str, make_str<typename TypeParam::second_type>(U"DA")), decltype(double_abcd_str)::npos); |
|
|
|
} |
|
|
|
|
|
|
|
TYPED_TEST(UnicodeFullTest, findi) { |
|
|
|
auto abcd_str = make_str<typename TypeParam::first_type>(U"ABCD"); |
|
|
|
|
|
|
|
// Empty substring
|
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"")), 0); |
|
|
|
|
|
|
|
// Single-characters
|
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"A")), 0); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"B")), 1); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"C")), 2); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"D")), 3); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"E")), decltype(abcd_str)::npos); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"a")), 0); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"b")), 1); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"c")), 2); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"d")), 3); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"e")), decltype(abcd_str)::npos); |
|
|
|
|
|
|
|
// Two characters
|
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"AB")), 0); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"BC")), 1); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"CD")), 2); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"DA")), decltype(abcd_str)::npos); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"ab")), 0); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"bc")), 1); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"cd")), 2); |
|
|
|
EXPECT_EQ(findi(abcd_str, make_str<typename TypeParam::second_type>(U"da")), decltype(abcd_str)::npos); |
|
|
|
|
|
|
|
auto double_abcd_str = make_str<typename TypeParam::first_type>(U"AABBCCDD"); |
|
|
|
|
|
|
|
// Single-characters
|
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"A")), 0); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"B")), 2); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"C")), 4); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"D")), 6); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"E")), decltype(double_abcd_str)::npos); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"a")), 0); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"b")), 2); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"c")), 4); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"d")), 6); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"e")), decltype(double_abcd_str)::npos); |
|
|
|
|
|
|
|
// Two characters
|
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"AA")), 0); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"AB")), 1); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"BB")), 2); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"BC")), 3); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"CC")), 4); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"CD")), 5); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"DD")), 6); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"DA")), decltype(double_abcd_str)::npos); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"aa")), 0); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"ab")), 1); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"bb")), 2); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"bc")), 3); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"cc")), 4); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"cd")), 5); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"dd")), 6); |
|
|
|
EXPECT_EQ(findi(double_abcd_str, make_str<typename TypeParam::second_type>(U"da")), decltype(double_abcd_str)::npos); |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* Folding test |
|
|
|