@@ -12,9 +12,84 @@ TEST(CompareRecursive, CompareValues) {
1212 EXPECT_TRUE (CompareRecursive (1.0 , 1.0 ));
1313 EXPECT_TRUE (CompareRecursive (1 .0L , 1 .0L ));
1414
15+ EXPECT_TRUE (CompareRecursive (' a' , ' a' ));
16+ }
17+
18+ TEST (CompareRecursive, CompareStrings) {
19+ // literals
1520 EXPECT_TRUE (CompareRecursive (" 1.0L" , " 1.0L" ));
16- EXPECT_TRUE (CompareRecursive (std::string{" 1.0L" }, std::string{" 1.0L" }));
21+ EXPECT_TRUE (CompareRecursive (" 1.0L" , std::string (" 1.0L" )));
22+ EXPECT_TRUE (CompareRecursive (std::string (" 1.0L" ), " 1.0L" ));
23+ EXPECT_TRUE (CompareRecursive (" 1.0L" , std::string_view (" 1.0L" )));
24+ EXPECT_TRUE (CompareRecursive (std::string_view (" 1.0L" ), " 1.0L" ));
25+
26+ // array
27+ const char str[] = " 1.0L" ;
28+ EXPECT_TRUE (CompareRecursive (" 1.0L" , str));
29+ EXPECT_TRUE (CompareRecursive (str, " 1.0L" ));
30+ EXPECT_TRUE (CompareRecursive (str, str));
31+ EXPECT_TRUE (CompareRecursive (str, std::string (" 1.0L" )));
32+ EXPECT_TRUE (CompareRecursive (std::string (" 1.0L" ), str));
33+ EXPECT_TRUE (CompareRecursive (str, std::string_view (" 1.0L" )));
34+ EXPECT_TRUE (CompareRecursive (std::string_view (" 1.0L" ), str));
35+
36+ // pointer
37+ const char *str2 = " 1.0L" ;
38+ EXPECT_TRUE (CompareRecursive (" 1.0L" , str2));
39+ EXPECT_TRUE (CompareRecursive (str2, " 1.0L" ));
40+ EXPECT_TRUE (CompareRecursive (str2, str2));
41+ EXPECT_TRUE (CompareRecursive (str2, str));
42+ EXPECT_TRUE (CompareRecursive (str, str2));
43+ EXPECT_TRUE (CompareRecursive (str2, std::string (" 1.0L" )));
44+ EXPECT_TRUE (CompareRecursive (std::string (" 1.0L" ), str2));
45+ EXPECT_TRUE (CompareRecursive (str2, std::string_view (" 1.0L" )));
46+ EXPECT_TRUE (CompareRecursive (std::string_view (" 1.0L" ), str2));
47+
48+ // string & string_view
49+ EXPECT_TRUE (CompareRecursive (std::string{" 1.0L" }, std::string{" 1.0L" }));
1750 EXPECT_TRUE (CompareRecursive (std::string_view{" 1.0L" }, std::string_view{" 1.0L" }));
51+ EXPECT_TRUE (CompareRecursive (std::string{" 1.0L" }, std::string_view{" 1.0L" }));
52+ EXPECT_TRUE (CompareRecursive (std::string_view{" 1.0L" }, std::string{" 1.0L" }));
53+ }
54+
55+ TEST (CompareRecursive, CompareContainerOfStrings) {
56+ const std::vector<const char *> vector_of_cstrings = {
57+ " abc" ,
58+ " cde" ,
59+ " ghi"
60+ };
61+
62+ const std::vector<std::string> vector_of_strings = {
63+ " abc" ,
64+ " cde" ,
65+ " ghi"
66+ };
67+
68+ const std::vector<std::string_view> vector_of_string_views = {
69+ " abc" ,
70+ " cde" ,
71+ " ghi"
72+ };
73+
74+ {
75+ // same values, but different pointers
76+ const std::vector<const char *> vector_of_cstrings2 = {
77+ vector_of_strings[0 ].data (),
78+ vector_of_strings[1 ].data (),
79+ vector_of_strings[2 ].data (),
80+ };
81+ EXPECT_TRUE (CompareRecursive (vector_of_cstrings, vector_of_cstrings2));
82+ }
83+
84+ EXPECT_TRUE (CompareRecursive (vector_of_strings, vector_of_strings));
85+ EXPECT_TRUE (CompareRecursive (vector_of_strings, vector_of_cstrings));
86+ EXPECT_TRUE (CompareRecursive (vector_of_cstrings, vector_of_strings));
87+
88+ EXPECT_TRUE (CompareRecursive (vector_of_string_views, vector_of_string_views));
89+ EXPECT_TRUE (CompareRecursive (vector_of_strings, vector_of_string_views));
90+ EXPECT_TRUE (CompareRecursive (vector_of_string_views, vector_of_strings));
91+ EXPECT_TRUE (CompareRecursive (vector_of_strings, vector_of_string_views));
92+ EXPECT_TRUE (CompareRecursive (vector_of_string_views, vector_of_strings));
1893}
1994
2095TEST (CompareRecursive, CompareContainers) {
0 commit comments