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

Side by Side Diff: pkg/fixnum/test/int_64_test.dart

Issue 23490010: Fix assert in int64 and add test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/fixnum/lib/src/int64.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library int64test; 5 library int64test;
6 import 'package:fixnum/fixnum.dart'; 6 import 'package:fixnum/fixnum.dart';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 8
9 void main() { 9 void main() {
10 group("arithmetic operators", () { 10 group("arithmetic operators", () {
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 expect(Int64.parseRadix(s, r).toString(), x); 555 expect(Int64.parseRadix(s, r).toString(), x);
556 } 556 }
557 check('ghoul', 36, '27699213'); 557 check('ghoul', 36, '27699213');
558 check('ghoul', 35, '24769346'); 558 check('ghoul', 35, '24769346');
559 // Min and max value. 559 // Min and max value.
560 check("-9223372036854775808", 10, "-9223372036854775808"); 560 check("-9223372036854775808", 10, "-9223372036854775808");
561 check("9223372036854775807", 10, "9223372036854775807"); 561 check("9223372036854775807", 10, "9223372036854775807");
562 // Overflow during parsing. 562 // Overflow during parsing.
563 check("9223372036854775808", 10, "-9223372036854775808"); 563 check("9223372036854775808", 10, "-9223372036854775808");
564 }); 564 });
565
566 test("parseRadixN", () {
567 check(String s, int r) {
568 expect(Int64.parseRadix(s, r).toRadixString(r), s);
569 }
570 check("2ppp111222333", 33); // This value & radix requires three chunks.
571 });
565 }); 572 });
566 573
567 group("string representation", () { 574 group("string representation", () {
568 test("toString", () { 575 test("toString", () {
569 expect(new Int64.fromInt(0).toString(), "0"); 576 expect(new Int64.fromInt(0).toString(), "0");
570 expect(new Int64.fromInt(1).toString(), "1"); 577 expect(new Int64.fromInt(1).toString(), "1");
571 expect(new Int64.fromInt(-1).toString(), "-1"); 578 expect(new Int64.fromInt(-1).toString(), "-1");
572 expect(new Int64.fromInt(-10).toString(), "-10"); 579 expect(new Int64.fromInt(-10).toString(), "-10");
573 expect(Int64.MIN_VALUE.toString(), "-9223372036854775808"); 580 expect(Int64.MIN_VALUE.toString(), "-9223372036854775808");
574 expect(Int64.MAX_VALUE.toString(), "9223372036854775807"); 581 expect(Int64.MAX_VALUE.toString(), "9223372036854775807");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 expect(Int64.MAX_VALUE.toRadixString(10), "9223372036854775807"); 632 expect(Int64.MAX_VALUE.toRadixString(10), "9223372036854775807");
626 expect(Int64.MAX_VALUE.toRadixString(11), "1728002635214590697"); 633 expect(Int64.MAX_VALUE.toRadixString(11), "1728002635214590697");
627 expect(Int64.MAX_VALUE.toRadixString(12), "41a792678515120367"); 634 expect(Int64.MAX_VALUE.toRadixString(12), "41a792678515120367");
628 expect(Int64.MAX_VALUE.toRadixString(13), "10b269549075433c37"); 635 expect(Int64.MAX_VALUE.toRadixString(13), "10b269549075433c37");
629 expect(Int64.MAX_VALUE.toRadixString(14), "4340724c6c71dc7a7"); 636 expect(Int64.MAX_VALUE.toRadixString(14), "4340724c6c71dc7a7");
630 expect(Int64.MAX_VALUE.toRadixString(15), "160e2ad3246366807"); 637 expect(Int64.MAX_VALUE.toRadixString(15), "160e2ad3246366807");
631 expect(Int64.MAX_VALUE.toRadixString(16), "7fffffffffffffff"); 638 expect(Int64.MAX_VALUE.toRadixString(16), "7fffffffffffffff");
632 }); 639 });
633 }); 640 });
634 } 641 }
OLDNEW
« no previous file with comments | « pkg/fixnum/lib/src/int64.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698