Added some more unit tests to verify that NextPowerOfTwo() selects the next power of two when the argument is just one increment above an even power of two
git-svn-id: file:///srv/devel/repo-conversion/nusu@110 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
3731fc42ae
commit
14274a9460
|
@ -39,6 +39,9 @@ namespace Nuclex.Support {
|
||||||
Assert.AreEqual(2UL, IntegerHelper.NextPowerOf2(2UL));
|
Assert.AreEqual(2UL, IntegerHelper.NextPowerOf2(2UL));
|
||||||
Assert.AreEqual(4UL, IntegerHelper.NextPowerOf2(3UL));
|
Assert.AreEqual(4UL, IntegerHelper.NextPowerOf2(3UL));
|
||||||
Assert.AreEqual(4UL, IntegerHelper.NextPowerOf2(4UL));
|
Assert.AreEqual(4UL, IntegerHelper.NextPowerOf2(4UL));
|
||||||
|
Assert.AreEqual(
|
||||||
|
9223372036854775808UL, IntegerHelper.NextPowerOf2(4611686018427387905UL)
|
||||||
|
);
|
||||||
Assert.AreEqual(
|
Assert.AreEqual(
|
||||||
9223372036854775808UL, IntegerHelper.NextPowerOf2(9223372036854775807UL)
|
9223372036854775808UL, IntegerHelper.NextPowerOf2(9223372036854775807UL)
|
||||||
);
|
);
|
||||||
|
@ -57,6 +60,7 @@ namespace Nuclex.Support {
|
||||||
Assert.AreEqual(2L, IntegerHelper.NextPowerOf2(2L));
|
Assert.AreEqual(2L, IntegerHelper.NextPowerOf2(2L));
|
||||||
Assert.AreEqual(4L, IntegerHelper.NextPowerOf2(3L));
|
Assert.AreEqual(4L, IntegerHelper.NextPowerOf2(3L));
|
||||||
Assert.AreEqual(4L, IntegerHelper.NextPowerOf2(4L));
|
Assert.AreEqual(4L, IntegerHelper.NextPowerOf2(4L));
|
||||||
|
Assert.AreEqual(4611686018427387904L, IntegerHelper.NextPowerOf2(2305843009213693953L));
|
||||||
Assert.AreEqual(4611686018427387904L, IntegerHelper.NextPowerOf2(4611686018427387903L));
|
Assert.AreEqual(4611686018427387904L, IntegerHelper.NextPowerOf2(4611686018427387903L));
|
||||||
Assert.AreEqual(4611686018427387904L, IntegerHelper.NextPowerOf2(4611686018427387904L));
|
Assert.AreEqual(4611686018427387904L, IntegerHelper.NextPowerOf2(4611686018427387904L));
|
||||||
}
|
}
|
||||||
|
@ -71,6 +75,7 @@ namespace Nuclex.Support {
|
||||||
Assert.AreEqual(2U, IntegerHelper.NextPowerOf2(2U));
|
Assert.AreEqual(2U, IntegerHelper.NextPowerOf2(2U));
|
||||||
Assert.AreEqual(4U, IntegerHelper.NextPowerOf2(3U));
|
Assert.AreEqual(4U, IntegerHelper.NextPowerOf2(3U));
|
||||||
Assert.AreEqual(4U, IntegerHelper.NextPowerOf2(4U));
|
Assert.AreEqual(4U, IntegerHelper.NextPowerOf2(4U));
|
||||||
|
Assert.AreEqual(2147483648U, IntegerHelper.NextPowerOf2(1073741825U));
|
||||||
Assert.AreEqual(2147483648U, IntegerHelper.NextPowerOf2(2147483647U));
|
Assert.AreEqual(2147483648U, IntegerHelper.NextPowerOf2(2147483647U));
|
||||||
Assert.AreEqual(2147483648U, IntegerHelper.NextPowerOf2(2147483648U));
|
Assert.AreEqual(2147483648U, IntegerHelper.NextPowerOf2(2147483648U));
|
||||||
}
|
}
|
||||||
|
@ -85,6 +90,7 @@ namespace Nuclex.Support {
|
||||||
Assert.AreEqual(2, IntegerHelper.NextPowerOf2(2));
|
Assert.AreEqual(2, IntegerHelper.NextPowerOf2(2));
|
||||||
Assert.AreEqual(4, IntegerHelper.NextPowerOf2(3));
|
Assert.AreEqual(4, IntegerHelper.NextPowerOf2(3));
|
||||||
Assert.AreEqual(4, IntegerHelper.NextPowerOf2(4));
|
Assert.AreEqual(4, IntegerHelper.NextPowerOf2(4));
|
||||||
|
Assert.AreEqual(1073741824, IntegerHelper.NextPowerOf2(536870913));
|
||||||
Assert.AreEqual(1073741824, IntegerHelper.NextPowerOf2(1073741823));
|
Assert.AreEqual(1073741824, IntegerHelper.NextPowerOf2(1073741823));
|
||||||
Assert.AreEqual(1073741824, IntegerHelper.NextPowerOf2(1073741824));
|
Assert.AreEqual(1073741824, IntegerHelper.NextPowerOf2(1073741824));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user