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

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

Issue 23441004: More efficient Int64 parsing and printing. (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
« pkg/fixnum/lib/src/int64.dart ('K') | « 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 Int64 fact18 = _factorial(new Int64.fromInt(18)); 522 Int64 fact18 = _factorial(new Int64.fromInt(18));
523 Int64 fact17 = _factorial(new Int64.fromInt(17)); 523 Int64 fact17 = _factorial(new Int64.fromInt(17));
524 expect(fact18 ~/ fact17, new Int64.fromInt(18)); 524 expect(fact18 ~/ fact17, new Int64.fromInt(18));
525 }); 525 });
526 526
527 test("min, max values", () { 527 test("min, max values", () {
528 expect(new Int64.fromInt(1) << 63, Int64.MIN_VALUE); 528 expect(new Int64.fromInt(1) << 63, Int64.MIN_VALUE);
529 expect(-(Int64.MIN_VALUE + new Int64.fromInt(1)), Int64.MAX_VALUE); 529 expect(-(Int64.MIN_VALUE + new Int64.fromInt(1)), Int64.MAX_VALUE);
530 }); 530 });
531 531
532 group("parse", () {
533 test("parseRadix10", () {
534 checkInt(int x) {
535 expect(Int64.parseRadix('$x', 10), new Int64.fromInt(x));
536 }
537 expect(Int64.parseRadix('1000', 10), new Int64.fromInt(1000));
538 checkInt(0);
539 checkInt(1);
540 checkInt(12345678);
541 checkInt(-12345678);
542 });
543 });
544
532 group("string representation", () { 545 group("string representation", () {
533 test("toString", () { 546 test("toString", () {
534 expect(new Int64.fromInt(0).toString(), "0"); 547 expect(new Int64.fromInt(0).toString(), "0");
535 expect(new Int64.fromInt(1).toString(), "1"); 548 expect(new Int64.fromInt(1).toString(), "1");
536 expect(new Int64.fromInt(-1).toString(), "-1"); 549 expect(new Int64.fromInt(-1).toString(), "-1");
537 expect(new Int64.fromInt(-10).toString(), "-10"); 550 expect(new Int64.fromInt(-10).toString(), "-10");
538 expect(Int64.MIN_VALUE.toString(), "-9223372036854775808"); 551 expect(Int64.MIN_VALUE.toString(), "-9223372036854775808");
539 expect(Int64.MAX_VALUE.toString(), "9223372036854775807"); 552 expect(Int64.MAX_VALUE.toString(), "9223372036854775807");
540 553
541 int top = 922337201; 554 int top = 922337201;
(...skipping 22 matching lines...) Expand all
564 "-2021110011022210012102010021220101220222"); 577 "-2021110011022210012102010021220101220222");
565 expect(Int64.MIN_VALUE.toRadixString(4), 578 expect(Int64.MIN_VALUE.toRadixString(4),
566 "-20000000000000000000000000000000"); 579 "-20000000000000000000000000000000");
567 expect(Int64.MIN_VALUE.toRadixString(5), "-1104332401304422434310311213"); 580 expect(Int64.MIN_VALUE.toRadixString(5), "-1104332401304422434310311213");
568 expect(Int64.MIN_VALUE.toRadixString(6), "-1540241003031030222122212"); 581 expect(Int64.MIN_VALUE.toRadixString(6), "-1540241003031030222122212");
569 expect(Int64.MIN_VALUE.toRadixString(7), "-22341010611245052052301"); 582 expect(Int64.MIN_VALUE.toRadixString(7), "-22341010611245052052301");
570 expect(Int64.MIN_VALUE.toRadixString(8), "-1000000000000000000000"); 583 expect(Int64.MIN_VALUE.toRadixString(8), "-1000000000000000000000");
571 expect(Int64.MIN_VALUE.toRadixString(9), "-67404283172107811828"); 584 expect(Int64.MIN_VALUE.toRadixString(9), "-67404283172107811828");
572 expect(Int64.MIN_VALUE.toRadixString(10), "-9223372036854775808"); 585 expect(Int64.MIN_VALUE.toRadixString(10), "-9223372036854775808");
573 expect(Int64.MIN_VALUE.toRadixString(11), "-1728002635214590698"); 586 expect(Int64.MIN_VALUE.toRadixString(11), "-1728002635214590698");
574 expect(Int64.MIN_VALUE.toRadixString(12), "-41A792678515120368"); 587 expect(Int64.MIN_VALUE.toRadixString(12), "-41a792678515120368");
575 expect(Int64.MIN_VALUE.toRadixString(13), "-10B269549075433C38"); 588 expect(Int64.MIN_VALUE.toRadixString(13), "-10b269549075433c38");
576 expect(Int64.MIN_VALUE.toRadixString(14), "-4340724C6C71DC7A8"); 589 expect(Int64.MIN_VALUE.toRadixString(14), "-4340724c6c71dc7a8");
577 expect(Int64.MIN_VALUE.toRadixString(15), "-160E2AD3246366808"); 590 expect(Int64.MIN_VALUE.toRadixString(15), "-160e2ad3246366808");
578 expect(Int64.MIN_VALUE.toRadixString(16), "-8000000000000000"); 591 expect(Int64.MIN_VALUE.toRadixString(16), "-8000000000000000");
579 expect(Int64.MAX_VALUE.toRadixString(2), 592 expect(Int64.MAX_VALUE.toRadixString(2),
580 "111111111111111111111111111111111111111111111111111111111111111"); 593 "111111111111111111111111111111111111111111111111111111111111111");
581 expect(Int64.MAX_VALUE.toRadixString(3), 594 expect(Int64.MAX_VALUE.toRadixString(3),
582 "2021110011022210012102010021220101220221"); 595 "2021110011022210012102010021220101220221");
583 expect(Int64.MAX_VALUE.toRadixString(4), 596 expect(Int64.MAX_VALUE.toRadixString(4),
584 "13333333333333333333333333333333"); 597 "13333333333333333333333333333333");
585 expect(Int64.MAX_VALUE.toRadixString(5), "1104332401304422434310311212"); 598 expect(Int64.MAX_VALUE.toRadixString(5), "1104332401304422434310311212");
586 expect(Int64.MAX_VALUE.toRadixString(6), "1540241003031030222122211"); 599 expect(Int64.MAX_VALUE.toRadixString(6), "1540241003031030222122211");
587 expect(Int64.MAX_VALUE.toRadixString(7), "22341010611245052052300"); 600 expect(Int64.MAX_VALUE.toRadixString(7), "22341010611245052052300");
588 expect(Int64.MAX_VALUE.toRadixString(8), "777777777777777777777"); 601 expect(Int64.MAX_VALUE.toRadixString(8), "777777777777777777777");
589 expect(Int64.MAX_VALUE.toRadixString(9), "67404283172107811827"); 602 expect(Int64.MAX_VALUE.toRadixString(9), "67404283172107811827");
590 expect(Int64.MAX_VALUE.toRadixString(10), "9223372036854775807"); 603 expect(Int64.MAX_VALUE.toRadixString(10), "9223372036854775807");
591 expect(Int64.MAX_VALUE.toRadixString(11), "1728002635214590697"); 604 expect(Int64.MAX_VALUE.toRadixString(11), "1728002635214590697");
592 expect(Int64.MAX_VALUE.toRadixString(12), "41A792678515120367"); 605 expect(Int64.MAX_VALUE.toRadixString(12), "41a792678515120367");
593 expect(Int64.MAX_VALUE.toRadixString(13), "10B269549075433C37"); 606 expect(Int64.MAX_VALUE.toRadixString(13), "10b269549075433c37");
594 expect(Int64.MAX_VALUE.toRadixString(14), "4340724C6C71DC7A7"); 607 expect(Int64.MAX_VALUE.toRadixString(14), "4340724c6c71dc7a7");
595 expect(Int64.MAX_VALUE.toRadixString(15), "160E2AD3246366807"); 608 expect(Int64.MAX_VALUE.toRadixString(15), "160e2ad3246366807");
596 expect(Int64.MAX_VALUE.toRadixString(16), "7FFFFFFFFFFFFFFF"); 609 expect(Int64.MAX_VALUE.toRadixString(16), "7fffffffffffffff");
597 }); 610 });
598 }); 611 });
599 } 612 }
OLDNEW
« pkg/fixnum/lib/src/int64.dart ('K') | « pkg/fixnum/lib/src/int64.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698