コード例 #1
0
  @Test
  public void testGetCapacityUnit() {
    pv.setCapacity(1L, MemoryUnit.Ki);
    MemoryUnit unit = pv.getCapacityUnit();
    assertEquals(MemoryUnit.Ki, unit);

    pv.setCapacity(1L, MemoryUnit.Pi);
    unit = pv.getCapacityUnit();
    assertEquals(MemoryUnit.Pi, unit);
  }
コード例 #2
0
  @Test
  public void testSetCapacity() {
    pv.setCapacity(1L, MemoryUnit.Ki);
    long capacity = pv.getCapacity();
    assertEquals(1024L, capacity);

    pv.setCapacity(31L, MemoryUnit.Ti);
    capacity = pv.getCapacity(MemoryUnit.Ti);
    assertEquals(31L, capacity);
  }
コード例 #3
0
 @Test(expected = ArithmeticException.class)
 public void testSetCapacityOverflow() {
   /*
    * 2^4 * 2 ^60 = 2^64, LONG_MAX is only 2^64-1
    */
   pv.setCapacity(16L, MemoryUnit.Ei);
   pv.getCapacity();
 }
コード例 #4
0
  @Test
  public void testGetCapacityString() {
    pv.setCapacity(13L, MemoryUnit.Pi);
    long capacity = pv.getCapacity("Ki");
    assertEquals(14293651161088L, capacity);

    capacity = pv.getCapacity("Ti");
    assertEquals(13312L, capacity);

    capacity = pv.getCapacity("Pi");
    assertEquals(13L, capacity);
  }
コード例 #5
0
 @Test
 public void testGetCapacity() {
   pv.setCapacity(13L, MemoryUnit.Pi);
   long capacity = pv.getCapacity();
   assertEquals(14636698788954112L, capacity);
 }