summaryrefslogtreecommitdiff
path: root/test/unit/util/integer_black.h
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2012-11-26 21:38:28 +0000
committerTim King <taking@cs.nyu.edu>2012-11-26 21:38:28 +0000
commit1e4c37a3ef7b1c16914b181c189716aa4a3df6b8 (patch)
treee8e905504deaface2e563adb54564d04cf7e568b /test/unit/util/integer_black.h
parenta7aad4ae3a1cd80f0e035e1a77b8e42c38c99c8d (diff)
Improved implementation of Integer::length() with CLN enabled. Additional tests to sanity check both versions CLN and GMP versions of length.
Diffstat (limited to 'test/unit/util/integer_black.h')
-rw-r--r--test/unit/util/integer_black.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/unit/util/integer_black.h b/test/unit/util/integer_black.h
index ead11e4df..d2f697637 100644
--- a/test/unit/util/integer_black.h
+++ b/test/unit/util/integer_black.h
@@ -366,4 +366,25 @@ public:
TS_ASSERT( ! Integer(64).testBit(1) );
TS_ASSERT( ! Integer(64).testBit(0) );
}
+
+ unsigned int internalLength(int i){
+ if ( i == 0){
+ return 1;
+ }else{
+ int absi = i < 0 ? -i : i;
+ unsigned int n = 0;
+ int powN = 1;
+ do {
+ powN <<= 1;
+ ++n;
+ }while(absi >= powN);
+ return n;
+ }
+ }
+
+ void testTestLength() {
+ for(int i = -17; i <= 17; ++i){
+ TS_ASSERT_EQUALS(Integer(i).length(), internalLength(i));
+ }
+ }
};
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback