Beispiel #1
0
  @Test
  public void testCopy() {
    DataAccess da1 = createDataAccess(name);
    da1.create(1001 * 4);
    da1.setHeader(4, 12);
    da1.setInt(1 * 4, 1);
    da1.setInt(123 * 4, 321);
    da1.setInt(1000 * 4, 1111);

    DataAccess da2 = createDataAccess(name + "2");
    da2.create(10);
    da1.copyTo(da2);
    assertEquals(12, da2.getHeader(4));
    assertEquals(1, da2.getInt(1 * 4));
    assertEquals(321, da2.getInt(123 * 4));
    assertEquals(1111, da2.getInt(1000 * 4));

    da2.setInt(1 * 4, 2);
    assertEquals(2, da2.getInt(1 * 4));
    da2.flush();
    da1.flush();
    // make sure they are independent!
    assertEquals(1, da1.getInt(1 * 4));
    da1.close();
    da2.close();
  }
Beispiel #2
0
  @Test
  public void testHeader() {
    DataAccess da = createDataAccess(name);
    da.create(300);
    da.setHeader(7 * 4, 123);
    assertEquals(123, da.getHeader(7 * 4));
    da.setHeader(10 * 4, Integer.MAX_VALUE / 3);
    assertEquals(Integer.MAX_VALUE / 3, da.getHeader(10 * 4));

    da.setHeader(11 * 4, Helper.degreeToInt(123.321));
    assertEquals(123.321, Helper.intToDegree(da.getHeader(11 * 4)), 1e-4);
    da.flush();
    da.close();

    da = createDataAccess(name);
    assertTrue(da.loadExisting());
    assertEquals(123, da.getHeader(7 * 4));
    da.close();
  }