Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-8655 Off Heap Size Estimation rounds improperly
* Make sure to round up to 16 properly * Added tests
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
core/src/test/java/org/infinispan/container/offheap/UnpooledOffHeapMemoryAllocatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.infinispan.container.offheap; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* @author wburns | ||
* @since 9.0 | ||
*/ | ||
@Test(groups = "functional", testName = "container.offheap.UnpooledOffHeapMemoryAllocatorTest") | ||
public class UnpooledOffHeapMemoryAllocatorTest { | ||
|
||
@DataProvider(name = "roundings") | ||
Object[][] roundings() { | ||
return new Object[][] { | ||
{ 2, 16 }, | ||
{ 14, 32 }, | ||
{ 23, 32 }, | ||
{ 32, 48 }, | ||
{ 123, 144 }, | ||
{ 43, 64 }, | ||
{ 73, 96 }, | ||
}; | ||
} | ||
|
||
@Test(dataProvider = "roundings") | ||
public void testRoundings(long original, long expected) { | ||
// The estimate adds 8 and rounds up to 16 | ||
assertEquals(expected, UnpooledOffHeapMemoryAllocator.estimateSizeOverhead(original)); | ||
} | ||
} |