77#include < xtd/environment>
88#include < xtd/literals>
99#include < xtd/size_object>
10+ #include < xtd/string_comparer>
1011
1112using namespace xtd ;
1213using namespace xtd ::collections::generic;
@@ -123,43 +124,28 @@ namespace xtd::collections::generic::tests {
123124 }
124125
125126 void test_method_ (constructor_with_ienumerable_and_equality_comparer) {
126- struct lower_string_comparer : iequality_comparer<string> {
127- bool equals (const string& x, const string& y) const noexcept override {return x.to_lower ().equals (y.to_lower ());}
128- xtd::size get_hash_code (const string& obj) const noexcept override {return obj.to_lower ().get_hash_code ();}
129- };
130-
131127 const ienumerable<key_value_pair<string, string>>& items1 = array<key_value_pair<string, string>> {{" one" , " one" }, {" oNe" , " oNe" }, {" OnE" , " OnE" }, {" ONE" , " ONE" }};
132128 auto items2 = dictionary<string, string>(items1);
133129 collection_assert::are_equivalent (array<key_value_pair<string, string>> {{" one" , " one" }, {" oNe" , " oNe" }, {" OnE" , " OnE" }, {" ONE" , " ONE" }}, items2);
134- assert ::throws<argument_exception>([&]{items2 = dictionary<string, string>(items1, lower_string_comparer {} );});
130+ assert ::throws<argument_exception>([&]{items2 = dictionary<string, string>(items1, string_comparer::ordinal_ignore_case () );});
135131 }
136132
137133 void test_method_ (constructor_with_equality_comparer) {
138- struct lower_string_comparer : iequality_comparer<string> {
139- bool equals (const string& x, const string& y) const noexcept override {return x.to_lower ().equals (y.to_lower ());}
140- xtd::size get_hash_code (const string& obj) const noexcept override {return obj.to_lower ().get_hash_code ();}
141- };
142-
143134 auto items = dictionary<string, string> {};
144135 items.add (" one" , " one" );
145136 items.add (" oNe" , " oNe" );
146137 items.add (" OnE" , " OnE" );
147138 items.add (" ONE" , " ONE" );
148139 collection_assert::are_equivalent (array<key_value_pair<string, string>> {{" one" , " one" }, {" oNe" , " oNe" }, {" OnE" , " OnE" }, {" ONE" , " ONE" }}, items);
149140
150- items = dictionary<string, string> {lower_string_comparer {} };
141+ items = dictionary<string, string> {string_comparer::ordinal_ignore_case () };
151142 items.add (" one" , " one" );
152143 assert ::throws<argument_exception>([&]{items.add (" oNe" , " oNe" );});
153144 assert ::throws<argument_exception>([&]{items.add (" OnE" , " OnE" );});
154145 assert ::throws<argument_exception>([&]{items.add (" ONE" , " ONE" );});
155146 }
156147
157148 void test_method_ (constructor_with_capacity_and_equality_comparer) {
158- struct lower_string_comparer : iequality_comparer<string> {
159- bool equals (const string& x, const string& y) const noexcept override {return x.to_lower ().equals (y.to_lower ());}
160- xtd::size get_hash_code (const string& obj) const noexcept override {return obj.to_lower ().get_hash_code ();}
161- };
162-
163149 auto items = dictionary<string, string> {10_z};
164150 assert::is_greater_or_equal (items.capacity (), 10_z);
165151 items.add (" one" , " one" );
@@ -168,7 +154,7 @@ namespace xtd::collections::generic::tests {
168154 items.add (" ONE" , " ONE" );
169155 collection_assert::are_equivalent (array<key_value_pair<string, string>> {{" one" , " one" }, {" oNe" , " oNe" }, {" OnE" , " OnE" }, {" ONE" , " ONE" }}, items);
170156
171- items = dictionary<string, string> {10_z, lower_string_comparer {} };
157+ items = dictionary<string, string> {10_z, string_comparer::ordinal_ignore_case () };
172158 assert::is_greater_or_equal (items.capacity (), 10_z);
173159 items.add (" one" , " one" );
174160 assert ::throws<argument_exception>([&]{items.add (" oNe" , " oNe" );});
0 commit comments