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

Unified Diff: runtime/vm/bigint_operations_test.cc

Issue 8539034: Add methods for creating Bigint objects from unsigned 64-bit integers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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
« runtime/vm/bigint_operations.cc ('K') | « runtime/vm/bigint_operations.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bigint_operations_test.cc
diff --git a/runtime/vm/bigint_operations_test.cc b/runtime/vm/bigint_operations_test.cc
index ce04f0147ece9c46c739557414f745355921a970..f536bbca7786be0f98be6ab59ac98847d83af178 100644
--- a/runtime/vm/bigint_operations_test.cc
+++ b/runtime/vm/bigint_operations_test.cc
@@ -100,6 +100,35 @@ TEST_CASE(BigintInt64) {
}
+TEST_CASE(BigintUInt64) {
+ const uint64_t kMax =
+ static_cast<uint64_t>(DART_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF));
+
+ const Bigint& one = Bigint::Handle(BigintOperations::NewFromUInt64(1));
+ EXPECT(BigintOperations::FitsIntoInt64(one));
+ EXPECT(BigintOperations::FitsIntoUInt64(one));
+
+ Bigint& big = Bigint::Handle(BigintOperations::NewFromUInt64(kMax));
+ EXPECT(!BigintOperations::FitsIntoInt64(big));
+ EXPECT(BigintOperations::FitsIntoUInt64(big));
+
+ uint64_t back = BigintOperations::ToUInt64(big);
+ EXPECT_EQ(kMax, back);
+
+ big = BigintOperations::Add(big, one);
+ EXPECT(!BigintOperations::FitsIntoInt64(big));
+ EXPECT(!BigintOperations::FitsIntoUInt64(big));
+
+ big = BigintOperations::Subtract(big, one);
+ EXPECT(!BigintOperations::FitsIntoInt64(big));
+ EXPECT(BigintOperations::FitsIntoUInt64(big));
+
+ big = BigintOperations::ShiftRight(big, 1);
+ EXPECT(BigintOperations::FitsIntoInt64(big));
+ EXPECT(BigintOperations::FitsIntoUInt64(big));
+}
+
+
TEST_CASE(BigintDouble) {
Smi& smi = Smi::Handle(Smi::New(5));
Bigint& bigint = Bigint::Handle(BigintOperations::NewFromSmi(smi));
« runtime/vm/bigint_operations.cc ('K') | « runtime/vm/bigint_operations.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698