peter-lawrey / Java-Chronicle

Java Indexed Record Chronicle
1.22k stars 193 forks source link

writeBoolean() / readBoolean() flips the value #9

Closed AMilassin closed 12 years ago

AMilassin commented 12 years ago

Using the writeBoolean() and readBoolean() helper methods to transfer a boolean value makes the actual value to flip in the process.


sample JUnit test:

@Test
public void test_boolean() throws Exception {
    String testPath = "temp" + File.separator + "chroncle-bool-test";
    IndexedChronicle tsc = new IndexedChronicle(testPath, 12);
    tsc.useUnsafe(false);
    deleteOnExit(testPath);

    tsc.clear();

    Excerpt<IndexedChronicle> excerpt = tsc.createExcerpt();
    excerpt.startExcerpt(2);
    excerpt.writeBoolean(false);
    excerpt.writeBoolean(true);
    excerpt.finish();

    excerpt.index(0);
    boolean one = excerpt.readBoolean();
    boolean onetwo = excerpt.readBoolean();
    tsc.close();

    Assert.assertEquals(false, one);
    Assert.assertEquals(true, onetwo);
}
peter-lawrey commented 12 years ago

Fixed now. Thank you very much for the unit test.