Chromium Code Reviews| 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..f019dc3ae5ace8a611ba0b0172b67ce659ecf96b 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"); |
| + } catch (e) { |
|
Lasse Reichstein Nielsen
2012/09/19 11:43:54
Add "on IllegalArgumentException"?
Mads Ager (google)
2012/09/19 14:16:13
Yes! Thanks, that caught another inconsistency. da
|
| + // Nothing to do. |
| + } |
| + } |
| +} |