Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: test/ignore_ascii_case_test.dart

Issue 2484163002: Fix bug in equalsIgnoreAsciiCase. (Closed)
Patch Set: Address comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/ignore_ascii_case_test.dart
diff --git a/test/ignore_ascii_case_test.dart b/test/ignore_ascii_case_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..787f76fd0a4cbbba9c398d4229bfabebb528c7f3
--- /dev/null
+++ b/test/ignore_ascii_case_test.dart
@@ -0,0 +1,58 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Tests case-ignoring compare and equality.
+
+import "package:collection/collection.dart";
+import "package:test/test.dart";
+
+main() {
+ test("equality ignore ASCII case", () {
+ var strings = [
+ "0@`aopz[{",
+ "0@`aopz[{",
+ "0@`Aopz[{",
+ "0@`aOpz[{",
+ "0@`AOpz[{",
+ "0@`aoPz[{",
+ "0@`AoPz[{",
+ "0@`aOPz[{",
+ "0@`AOPz[{",
+ "0@`aopZ[{",
+ "0@`AopZ[{",
+ "0@`aOpZ[{",
+ "0@`AOpZ[{",
+ "0@`aoPZ[{",
+ "0@`AoPZ[{",
+ "0@`aOPZ[{",
+ "0@`AOPZ[{",
+ ];
+
+ for (var s1 in strings) {
+ for (var s2 in strings) {
+ var reason = "$s1 =?= $s2";
+ expect(equalsIgnoreAsciiCase(s1, s2), true, reason: reason);
+ expect(hashIgnoreAsciiCase(s1), hashIgnoreAsciiCase(s2),
+ reason: reason);
+ }
+ }
+
+ var upperCaseLetters = "@`abcdefghijklmnopqrstuvwxyz[{åÅ";
+ var lowerCaseLetters = "@`ABCDEFGHIJKLMNOPQRSTUVWXYZ[{åÅ";
+ expect(equalsIgnoreAsciiCase(upperCaseLetters, lowerCaseLetters), true);
+
+ testChars(char1, char2, areEqual) {
+ expect(equalsIgnoreAsciiCase(char1, char2), areEqual,
+ reason: "$char1 ${areEqual ? "=" : "!"}= $char2");
+ }
+ for (int i = 0; i < upperCaseLetters.length; i++) {
+ for (int j = 0; i < upperCaseLetters.length; i++) {
+ testChars(upperCaseLetters[i], upperCaseLetters[j], i == j);
+ testChars(lowerCaseLetters[i], upperCaseLetters[j], i == j);
+ testChars(upperCaseLetters[i], lowerCaseLetters[j], i == j);
+ testChars(lowerCaseLetters[i], lowerCaseLetters[j], i == j);
+ }
+ }
+ });
+}
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698