Skip to content

Commit

Permalink
small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
krisskross committed Jan 25, 2015
1 parent cae8fbf commit f91bcc8
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions lmdbjni/src/test/java/org/fusesource/lmdbjni/BufferCursorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ public void testDelete() {
public void testOverwrite() {
try (BufferCursor cursor = db.bufferCursorWriter()) {
assertTrue(cursor.seek(Bytes.fromLong(0)));
cursor.valWriteByte(100);
assertTrue(cursor.overwrite());
assertTrue(cursor.valWriteByte(100).overwrite());
assertTrue(cursor.first());
assertThat(cursor.keyLong(0), is(0L));
assertThat(cursor.valByte(0), is((byte) 100));
cursor.valWriteByte(200);
assertTrue(cursor.overwrite());
assertTrue(cursor.valWriteByte(200).overwrite());
assertTrue(cursor.first());
assertThat(cursor.keyLong(0), is(0L));
assertThat(cursor.valByte(0), is((byte) 200));
Expand All @@ -154,8 +152,7 @@ public void testOverwrite() {
@Test
public void testAppend() {
try (BufferCursor cursor = db.bufferCursorWriter()) {
cursor.keyWriteByte(100).valWriteByte(100);
cursor.append();
cursor.keyWriteByte(100).valWriteByte(100).append();
assertTrue(cursor.first());
assertThat(cursor.keyLong(0), is(0L));
assertThat(cursor.valLong(0), is(0L));
Expand All @@ -179,14 +176,18 @@ public void testAppend() {
public void testPut() {
try (BufferCursor cursor = db.bufferCursorWriter()) {
assertTrue(cursor.seek(new byte[]{1}));
cursor.keyWriteByte(1).valWriteByte(100);
assertFalse(cursor.put());
assertFalse(cursor
.keyWriteByte(1)
.valWriteByte(100)
.put());
assertTrue(cursor.seek(new byte[]{1}));
assertTrue(cursor.first());
assertThat(cursor.keyLong(0), is(0L));
assertThat(cursor.valLong(0), is(0L));
cursor.keyWriteByte(111).valWriteByte(121);
assertTrue(cursor.put());
assertTrue(cursor
.keyWriteByte(111)
.valWriteByte(121)
.put());
assertTrue(cursor.seek(new byte[]{111}));
assertThat(cursor.keyByte(0), is((byte) 111));
assertThat(cursor.valByte(0), is((byte) 121));
Expand Down Expand Up @@ -216,8 +217,8 @@ public void testWriteDataTypes() {
.valWriteFloat(5.0f)
.valWriteDouble(6.0)
.valWriteBytes(new byte[]{1, 2, 3})
.valWriteUtf8("cba");
cursor.overwrite();
.valWriteUtf8("cba")
.overwrite();
}

try (BufferCursor cursor = db.bufferCursorWriter()) {
Expand Down Expand Up @@ -247,8 +248,8 @@ public void testWriteStrings() {
cursor.keyWriteUtf8("abc")
.keyWriteUtf8("def")
.valWriteUtf8("ghi")
.valWriteUtf8("jkl");
cursor.overwrite();
.valWriteUtf8("jkl")
.overwrite();
}

try (BufferCursor cursor = db.bufferCursorWriter()) {
Expand Down

0 comments on commit f91bcc8

Please sign in to comment.