Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
5 deletions.
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
48 changes: 48 additions & 0 deletions
48
src/test/java/net/openhft/chronicle/queue/impl/single/RollCycleEncodeSequenceTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,48 @@ | |||
package net.openhft.chronicle.queue.impl.single; | |||
|
|||
import net.openhft.chronicle.bytes.Bytes; | |||
import net.openhft.chronicle.bytes.ref.BinaryTwoLongReference; | |||
import net.openhft.chronicle.queue.RollCycles; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.junit.runners.Parameterized; | |||
|
|||
import java.util.Arrays; | |||
import java.util.Collection; | |||
|
|||
import static org.junit.Assert.assertEquals; | |||
|
|||
/** | |||
* Created by Jerry Shea on 22/11/17. | |||
*/ | |||
@RunWith(Parameterized.class) | |||
public class RollCycleEncodeSequenceTest { | |||
private final BinaryTwoLongReference longValue; | |||
private final RollCycleEncodeSequence rollCycleEncodeSequence; | |||
|
|||
@Parameterized.Parameters(name = "{0}") | |||
public static Collection<Object[]> data() { | |||
return Arrays.asList(new Object[][]{ | |||
{RollCycles.DAILY}, | |||
{RollCycles.HOURLY}, | |||
{RollCycles.MINUTELY}, | |||
{RollCycles.HUGE_DAILY} | |||
}); | |||
} | |||
|
|||
public RollCycleEncodeSequenceTest(final RollCycles cycle) { | |||
longValue = new BinaryTwoLongReference(); | |||
longValue.bytesStore(Bytes.elasticByteBuffer(),0, 16); | |||
rollCycleEncodeSequence = new RollCycleEncodeSequence(longValue, cycle.defaultIndexCount(), cycle.defaultIndexSpacing()); | |||
} | |||
|
|||
@Test | |||
public void forWritePosition() { | |||
longValue.setOrderedValue(1); | |||
longValue.setOrderedValue2(2); | |||
// a cast to int of this magic number was causing problems | |||
long forWritePosition = 0x8001cc54L; | |||
long sequence = rollCycleEncodeSequence.getSequence(forWritePosition); | |||
assertEquals(longValue.getValue2(), sequence); | |||
} | |||
} |