diff options
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/util/integer_black.h | 21 |
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)); + } + } }; |