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

Unified Diff: pkg/fixnum/test/int_32_test.dart

Issue 34223002: Throw FormatException when Int32/Int64.parseRadix() encounters bad digit (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Formatting fix Created 7 years, 2 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 | « pkg/fixnum/lib/src/int64.dart ('k') | pkg/fixnum/test/int_64_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/fixnum/test/int_32_test.dart
diff --git a/pkg/fixnum/test/int_32_test.dart b/pkg/fixnum/test/int_32_test.dart
index e34f714cb82b29f79d8674dee5d9c8a190645f65..8ce782482e7ab8ea203f36c7d782181a68020731 100644
--- a/pkg/fixnum/test/int_32_test.dart
+++ b/pkg/fixnum/test/int_32_test.dart
@@ -304,6 +304,33 @@ void main() {
});
});
+ group("parse", () {
+ test("base 10", () {
+ checkInt(int x) {
+ expect(Int32.parseRadix('$x', 10), new Int32(x));
+ }
+ checkInt(0);
+ checkInt(1);
+ checkInt(1000);
+ checkInt(12345678);
+ checkInt(2147483647);
+ checkInt(2147483648);
+ checkInt(4294967295);
+ checkInt(4294967296);
+ expect(() => Int32.parseRadix('xyzzy', -1), throwsArgumentError);
+ expect(() => Int32.parseRadix('plugh', 10),
+ throwsA(new isInstanceOf<FormatException>()));
+ });
+
+ test("parseRadix", () {
+ check(String s, int r, String x) {
+ expect(Int32.parseRadix(s, r).toString(), x);
+ }
+ check('deadbeef', 16, '-559038737');
+ check('95', 12, '113');
+ });
+ });
+
group("string representation", () {
test("toString", () {
expect(new Int32(0).toString(), "0");
« no previous file with comments | « pkg/fixnum/lib/src/int64.dart ('k') | pkg/fixnum/test/int_64_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698