@@ -81,8 +81,9 @@ public void RFC9562_V6_ReorderedTime() {
8181
8282 // V6 should contain a timestamp
8383 var info = V6 . Extract ( uuid ) ;
84- Assert . True ( info . Timestamp >= beforeGen . AddSeconds ( - 1 ) ) ;
85- Assert . True ( info . Timestamp <= afterGen . AddSeconds ( 1 ) ) ;
84+ // V6 uses 100-nanosecond intervals, so use tighter tolerance (100ms)
85+ Assert . True ( info . Timestamp >= beforeGen . AddMilliseconds ( - 100 ) ) ;
86+ Assert . True ( info . Timestamp <= afterGen . AddMilliseconds ( 100 ) ) ;
8687 }
8788
8889 [ Fact ( DisplayName = "RFC9562 Section 5.6 - V6 UUIDs are sortable by time" ) ]
@@ -192,6 +193,9 @@ public void RFC9562_V7_Uniqueness() {
192193 public void RFC9562_V7_MillisecondPrecision ( ) {
193194 // Generate multiple UUIDs within the same millisecond
194195 var uuids = new List < UUID > ( ) ;
196+ var startTime = DateTime . UtcNow ;
197+
198+ // Generate rapidly to likely get some in the same millisecond
195199 for ( int i = 0 ; i < 100 ; i ++ ) {
196200 uuids . Add ( V7 . Generate ( ) ) ;
197201 }
@@ -205,6 +209,22 @@ public void RFC9562_V7_MillisecondPrecision() {
205209
206210 // All should be unique despite potentially being generated in same millisecond
207211 Assert . Equal ( uuids . Count , uuids . Distinct ( ) . Count ( ) ) ;
212+
213+ // Verify that UUIDs with the same timestamp have identical timestamp bits but different random bits
214+ var grouped = uuids . GroupBy ( u => V7 . ExtractUtc ( u ) ) . Where ( g => g . Count ( ) > 1 ) . ToList ( ) ;
215+ if ( grouped . Any ( ) ) {
216+ // Found UUIDs with same millisecond timestamp
217+ var group = grouped . First ( ) ;
218+ var timestampMs = group . Key ;
219+
220+ // All UUIDs in this group should have same timestamp value
221+ foreach ( var uuid in group ) {
222+ Assert . Equal ( timestampMs , V7 . ExtractUtc ( uuid ) ) ;
223+ }
224+
225+ // But all UUIDs should be unique (different random portions)
226+ Assert . Equal ( group . Count ( ) , group . Distinct ( ) . Count ( ) ) ;
227+ }
208228 }
209229
210230 // ========== V8 Specific Tests (RFC 9562 Section 5.8) ==========
0 commit comments