Skip to content

Commit d1fb7e6

Browse files
committed
Added monotonicity unittest
1 parent fd076c9 commit d1fb7e6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

std/uuid.d

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,7 @@ class MonotonicUUIDsFactory
14521452
}
14531453
}
14541454

1455+
///
14551456
unittest
14561457
{
14571458
import std.conv : to;
@@ -1503,6 +1504,26 @@ unittest
15031504
}
15041505
}
15051506

1507+
///
1508+
unittest
1509+
{
1510+
import std.datetime.stopwatch;
1511+
1512+
auto f = new shared MonotonicUUIDsFactory;
1513+
1514+
UUID[100_000] uuids = void;
1515+
1516+
auto sw = StopWatch(AutoStart.yes); // for debugging purposes
1517+
1518+
foreach(ref u; uuids)
1519+
u = f.createUUIDv7_method3;
1520+
1521+
sw.stop;
1522+
1523+
foreach(i; 1 .. uuids.length)
1524+
assert(uuids[i-1].v7Timestamp_method3 < uuids[i].v7Timestamp_method3);
1525+
}
1526+
15061527
/**
15071528
* This function returns a timestamp + random based UUID aka. uuid v7.
15081529
*/

0 commit comments

Comments
 (0)