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

Unified Diff: tests/corelib/integer_to_radix_string_test.dart

Issue 10937011: Bug cleanup: unify on allowing radices from 2 to 36 in (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 3 months 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 | « runtime/lib/integers.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/integer_to_radix_string_test.dart
diff --git a/tests/corelib/integer_to_radix_string_test.dart b/tests/corelib/integer_to_radix_string_test.dart
index 35454bfde973d7ce67e3dd6e879076792c5e7f8c..24343931f7c8c1193cb4686c8b7cb5b90c7fed5e 100644
--- a/tests/corelib/integer_to_radix_string_test.dart
+++ b/tests/corelib/integer_to_radix_string_test.dart
@@ -3,6 +3,25 @@
// BSD-style license that can be found in the LICENSE file.
main() {
- // Just make sure that we use lower-case characters.
- Expect.equals("abcd", (0xabcd).toRadixString(16));
-}
+ // Test that we accept radix 2 to 36 and that we use lower-case
+ // letters.
+ var expected = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+ 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+ 'u', 'v', 'w', 'x', 'y', 'z'];
+ for (var radix = 2; radix < 37; radix++) {
+ for (var i = 0; i < radix; i++) {
+ Expect.equals(expected[i], i.toRadixString(radix));
+ }
+ }
+
+ var illegalRadices = [ -1, 0, 1, 37 ];
+ for (var radix in illegalRadices) {
+ try {
+ 42.toRadixString(radix);
+ Expect.fail("Exception expected");
+ } on IllegalArgumentException catch (e) {
+ // Nothing to do.
+ }
+ }
+}
« no previous file with comments | « runtime/lib/integers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698