package net.openhft.chronicle.core.time;

import org.junit.Test;

import static org.junit.Assert.assertTrue;

public class UniqueMicroTimeProviderTest {

    @Test
    public void currentTimeMicros() {
        UniqueMicroTimeProvider tp = new UniqueMicroTimeProvider();
        SetTimeProvider stp = new SetTimeProvider();
        tp.provider(stp);
        long last = 0;
        for (int i = 0; i < 4_000; i++) {
            stp.advanceNanos(i);
            long time = tp.currentTimeMicros();
            assertTrue(time > last);
            last = time;
        }
    }

    @Test
    public void currentTimeNanos() {
        UniqueMicroTimeProvider tp = new UniqueMicroTimeProvider();
        SetTimeProvider stp = new SetTimeProvider();
        tp.provider(stp);
        long last = 0;
        for (int i = 0; i < 4_000; i++) {
            stp.advanceNanos(i);
            long time = tp.currentTimeNanos();
            assertTrue(time / 1000 > last);
            last = time / 1000;
        }
    }
}
@@ -59,16 +59,61 @@
 .Test;%0A%0A
+import static org.junit.Assert.assertEquals;%0A
 import s
@@ -147,16 +147,16 @@
 rtTrue;%0A
-
 %0Apublic 
@@ -350,32 +350,78 @@
 SetTimeProvider(
+SystemTimeProvider.INSTANCE.currentTimeNanos()
 );%0A        tp.pr
@@ -575,24 +575,81 @@
 meMicros();%0A
+            assertEquals(LongTime.toMicros(time), time);%0A
             
@@ -872,32 +872,78 @@
 SetTimeProvider(
+SystemTimeProvider.INSTANCE.currentTimeNanos()
 );%0A        tp.pr
@@ -1045,32 +1045,32 @@
 dvanceNanos(i);%0A
-
             long
@@ -1096,24 +1096,80 @@
 imeNanos();%0A
+            assertEquals(LongTime.toNanos(time), time);%0A
             

test to ensure UniqueMicroTimeProvider provides output in correct units