@@ -287,22 +287,47 @@ private Binary timestampToInt96(String timestamp) {
287287 @ Test
288288 public void testInt96Comparator () {
289289 Binary [] valuesInAscendingOrder = {
290- timestampToInt96 ("2020-01-01T00:00:00.000" ),
291- timestampToInt96 ("2020-02-29T23:59:59.999" ),
292- timestampToInt96 ("2020-12-31T23:59:59.999" ),
293- timestampToInt96 ("2021-01-01T00:00:00.000" ),
294- timestampToInt96 ("2023-06-15T12:30:45.500" ),
295- timestampToInt96 ("2024-02-29T15:45:30.750" ),
296- timestampToInt96 ("2024-12-25T07:00:00.000" ),
297- timestampToInt96 ("2025-01-01T00:00:00.000" ),
298- timestampToInt96 ("2025-07-04T20:00:00.000" ),
299- timestampToInt96 ("2025-12-31T23:59:59.999" )
290+ timestampToInt96 ("2020-01-01T00:00:00.000" ),
291+ timestampToInt96 ("2020-01-01T10:00:00.000" ),
292+ timestampToInt96 ("2020-02-29T23:59:59.999" ),
293+ timestampToInt96 ("2020-12-31T23:59:59.999" ),
294+ timestampToInt96 ("2021-01-01T00:00:00.000" ),
295+ timestampToInt96 ("2023-06-15T12:30:45.500" ),
296+ timestampToInt96 ("2024-02-29T15:45:30.750" ),
297+ timestampToInt96 ("2024-12-25T07:00:00.000" ),
298+ timestampToInt96 ("2025-01-01T00:00:00.000" ),
299+ timestampToInt96 ("2025-07-04T20:00:00.000" ),
300+ timestampToInt96 ("2025-07-04T20:50:00.000" ),
301+ timestampToInt96 ("2025-12-31T23:59:59.999" )
300302 };
303+
304+ java .util .function .Function <Binary , Binary >[] perturb = new java .util .function .Function [] {
305+ (java .util .function .Function <Binary , Binary >) b -> b ,
306+ (java .util .function .Function <Binary , Binary >) b -> Binary .fromReusedByteArray (b .getBytes ()),
307+ (java .util .function .Function <Binary , Binary >) b -> Binary .fromConstantByteArray (b .getBytes ()),
308+ (java .util .function .Function <Binary , Binary >) b -> {
309+ byte [] originalBytes = b .getBytes ();
310+ byte [] paddedBuffer = new byte [originalBytes .length + 20 ];
311+ int offset = 10 ;
312+ for (int i = 0 ; i < paddedBuffer .length ; i ++) {
313+ paddedBuffer [i ] = (byte ) (0xAA + (i % 5 ));
314+ }
315+ System .arraycopy (originalBytes , 0 , paddedBuffer , offset , originalBytes .length );
316+ return Binary .fromReusedByteArray (paddedBuffer , offset , originalBytes .length );
317+ }
318+ };
319+
301320 for (int i = 0 ; i < valuesInAscendingOrder .length ; ++i ) {
302321 for (int j = 0 ; j < valuesInAscendingOrder .length ; ++j ) {
303322 Binary bi = valuesInAscendingOrder [i ];
304323 Binary bj = valuesInAscendingOrder [j ];
305- assertEquals (Integer .compare (i , j ), BINARY_AS_INT96_TIMESTAMP_COMPARATOR .compare (bi , bj ));
324+ for (java .util .function .Function <Binary , Binary > fi : perturb ) {
325+ for (java .util .function .Function <Binary , Binary > fj : perturb ) {
326+ Binary perturbedBi = fi .apply (bi );
327+ Binary perturbedBj = fj .apply (bj );
328+ assertEquals (Integer .compare (i , j ), BINARY_AS_INT96_TIMESTAMP_COMPARATOR .compare (perturbedBi , perturbedBj ));
329+ }
330+ }
306331 }
307332 }
308333 }
0 commit comments