1+ use crate :: frame:: value:: CqlTimeuuid ;
12use crate :: frame:: { response:: result:: CqlValue , types:: RawValue , value:: LegacyBatchValuesIterator } ;
23use crate :: types:: serialize:: batch:: { BatchValues , BatchValuesIterator , LegacyBatchValuesAdapter } ;
34use crate :: types:: serialize:: row:: { RowSerializationContext , SerializeRow } ;
@@ -12,9 +13,11 @@ use super::value::{
1213use bigdecimal:: BigDecimal ;
1314use bytes:: BufMut ;
1415use num_bigint:: BigInt ;
16+ use std:: collections:: hash_map:: DefaultHasher ;
1517use std:: collections:: { BTreeMap , BTreeSet , HashMap , HashSet } ;
16- use std:: hash:: { BuildHasherDefault , Hasher } ;
18+ use std:: hash:: { BuildHasherDefault , Hash , Hasher } ;
1719use std:: net:: { IpAddr , Ipv4Addr , Ipv6Addr } ;
20+ use std:: str:: FromStr ;
1821use std:: { borrow:: Cow , convert:: TryInto } ;
1922use uuid:: Uuid ;
2023
@@ -538,6 +541,24 @@ fn timeuuid_serialization() {
538541 }
539542}
540543
544+ #[ test]
545+ fn timeuuid_ordering_properties ( ) {
546+ let x = CqlTimeuuid :: from_str ( "00000000-0000-1000-8080-808080808080" ) . unwrap ( ) ;
547+ let y = CqlTimeuuid :: from_str ( "00000000-0000-2000-8080-808080808080" ) . unwrap ( ) ;
548+
549+ let cmp_res = x. cmp ( & y) ;
550+ assert_eq ! ( std:: cmp:: Ordering :: Equal , cmp_res) ;
551+
552+ assert_eq ! ( x, y) ;
553+
554+ let compute_hash = |x : & CqlTimeuuid | {
555+ let mut hasher = DefaultHasher :: new ( ) ;
556+ x. hash ( & mut hasher) ;
557+ hasher. finish ( )
558+ } ;
559+ assert_eq ! ( compute_hash( & x) , compute_hash( & y) ) ;
560+ }
561+
541562#[ test]
542563fn cqlduration_serialization ( ) {
543564 let duration = CqlDuration {
0 commit comments