@@ -192,8 +192,9 @@ impl CqlValue {
192
192
self . as_cql_date ( ) . and_then ( |date| date. try_into ( ) . ok ( ) )
193
193
}
194
194
195
+ #[ cfg( test) ]
195
196
#[ cfg( feature = "time-03" ) ]
196
- pub fn as_date ( & self ) -> Option < time_03:: Date > {
197
+ fn as_date_03 ( & self ) -> Option < time_03:: Date > {
197
198
self . as_cql_date ( ) . and_then ( |date| date. try_into ( ) . ok ( ) )
198
199
}
199
200
@@ -209,8 +210,9 @@ impl CqlValue {
209
210
self . as_cql_timestamp ( ) . and_then ( |ts| ts. try_into ( ) . ok ( ) )
210
211
}
211
212
213
+ #[ cfg( test) ]
212
214
#[ cfg( feature = "time-03" ) ]
213
- pub fn as_offset_date_time ( & self ) -> Option < time_03:: OffsetDateTime > {
215
+ fn as_offset_date_time_03 ( & self ) -> Option < time_03:: OffsetDateTime > {
214
216
self . as_cql_timestamp ( ) . and_then ( |ts| ts. try_into ( ) . ok ( ) )
215
217
}
216
218
@@ -226,8 +228,9 @@ impl CqlValue {
226
228
self . as_cql_time ( ) . and_then ( |ts| ts. try_into ( ) . ok ( ) )
227
229
}
228
230
231
+ #[ cfg( test) ]
229
232
#[ cfg( feature = "time-03" ) ]
230
- pub fn as_time ( & self ) -> Option < time_03:: Time > {
233
+ fn as_time_03 ( & self ) -> Option < time_03:: Time > {
231
234
self . as_cql_time ( ) . and_then ( |ts| ts. try_into ( ) . ok ( ) )
232
235
}
233
236
@@ -1330,7 +1333,7 @@ mod tests {
1330
1333
super :: deser_cql_value ( & ColumnType :: Date , & mut ( 1u32 << 31 ) . to_be_bytes ( ) . as_ref ( ) )
1331
1334
. unwrap ( ) ;
1332
1335
1333
- assert_eq ! ( date. as_date ( ) , Some ( unix_epoch) ) ;
1336
+ assert_eq ! ( date. as_date_03 ( ) , Some ( unix_epoch) ) ;
1334
1337
1335
1338
// 2^31 - 30 when converted to time_03::Date is 1969-12-02
1336
1339
let before_epoch = Date :: from_calendar_date ( 1969 , December , 2 ) . unwrap ( ) ;
@@ -1340,7 +1343,7 @@ mod tests {
1340
1343
)
1341
1344
. unwrap ( ) ;
1342
1345
1343
- assert_eq ! ( date. as_date ( ) , Some ( before_epoch) ) ;
1346
+ assert_eq ! ( date. as_date_03 ( ) , Some ( before_epoch) ) ;
1344
1347
1345
1348
// 2^31 + 30 when converted to time_03::Date is 1970-01-31
1346
1349
let after_epoch = Date :: from_calendar_date ( 1970 , January , 31 ) . unwrap ( ) ;
@@ -1350,20 +1353,20 @@ mod tests {
1350
1353
)
1351
1354
. unwrap ( ) ;
1352
1355
1353
- assert_eq ! ( date. as_date ( ) , Some ( after_epoch) ) ;
1356
+ assert_eq ! ( date. as_date_03 ( ) , Some ( after_epoch) ) ;
1354
1357
1355
1358
// 0 and u32::MAX are out of NaiveDate range, fails with an error, not panics
1356
1359
assert_eq ! (
1357
1360
super :: deser_cql_value( & ColumnType :: Date , & mut 0_u32 . to_be_bytes( ) . as_ref( ) )
1358
1361
. unwrap( )
1359
- . as_date ( ) ,
1362
+ . as_date_03 ( ) ,
1360
1363
None
1361
1364
) ;
1362
1365
1363
1366
assert_eq ! (
1364
1367
super :: deser_cql_value( & ColumnType :: Date , & mut u32 :: MAX . to_be_bytes( ) . as_ref( ) )
1365
1368
. unwrap( )
1366
- . as_date ( ) ,
1369
+ . as_date_03 ( ) ,
1367
1370
None
1368
1371
) ;
1369
1372
}
@@ -1441,8 +1444,7 @@ mod tests {
1441
1444
let time =
1442
1445
super :: deser_cql_value ( & ColumnType :: Time , & mut ( 0i64 ) . to_be_bytes ( ) . as_ref ( ) ) . unwrap ( ) ;
1443
1446
1444
- dbg ! ( & time) ;
1445
- assert_eq ! ( time. as_time( ) , Some ( midnight) ) ;
1447
+ assert_eq ! ( time. as_time_03( ) , Some ( midnight) ) ;
1446
1448
1447
1449
// 10:10:30.500,000,001
1448
1450
let ( h, m, s, n) = ( 10 , 10 , 30 , 500_000_001 ) ;
@@ -1455,7 +1457,7 @@ mod tests {
1455
1457
)
1456
1458
. unwrap ( ) ;
1457
1459
1458
- assert_eq ! ( time. as_time ( ) , Some ( midnight) ) ;
1460
+ assert_eq ! ( time. as_time_03 ( ) , Some ( midnight) ) ;
1459
1461
1460
1462
// 23:59:59.999,999,999
1461
1463
let ( h, m, s, n) = ( 23 , 59 , 59 , 999_999_999 ) ;
@@ -1468,7 +1470,7 @@ mod tests {
1468
1470
)
1469
1471
. unwrap ( ) ;
1470
1472
1471
- assert_eq ! ( time. as_time ( ) , Some ( midnight) ) ;
1473
+ assert_eq ! ( time. as_time_03 ( ) , Some ( midnight) ) ;
1472
1474
}
1473
1475
1474
1476
#[ test]
@@ -1552,7 +1554,7 @@ mod tests {
1552
1554
let date = super :: deser_cql_value ( & ColumnType :: Timestamp , & mut 0i64 . to_be_bytes ( ) . as_ref ( ) )
1553
1555
. unwrap ( ) ;
1554
1556
1555
- assert_eq ! ( date. as_offset_date_time ( ) , Some ( unix_epoch) ) ;
1557
+ assert_eq ! ( date. as_offset_date_time_03 ( ) , Some ( unix_epoch) ) ;
1556
1558
1557
1559
// When converted to NaiveDateTime, this is 1969-12-01 11:29:29.5
1558
1560
let timestamp: i64 = -( ( ( ( 30 * 24 + 12 ) * 60 + 30 ) * 60 + 30 ) * 1000 + 500 ) ;
@@ -1567,7 +1569,7 @@ mod tests {
1567
1569
)
1568
1570
. unwrap ( ) ;
1569
1571
1570
- assert_eq ! ( date. as_offset_date_time ( ) , Some ( before_epoch) ) ;
1572
+ assert_eq ! ( date. as_offset_date_time_03 ( ) , Some ( before_epoch) ) ;
1571
1573
1572
1574
// when converted to NaiveDateTime, this is is 1970-01-31 12:30:30.5
1573
1575
let timestamp: i64 = ( ( ( 30 * 24 + 12 ) * 60 + 30 ) * 60 + 30 ) * 1000 + 500 ;
@@ -1582,20 +1584,20 @@ mod tests {
1582
1584
)
1583
1585
. unwrap ( ) ;
1584
1586
1585
- assert_eq ! ( date. as_offset_date_time ( ) , Some ( after_epoch) ) ;
1587
+ assert_eq ! ( date. as_offset_date_time_03 ( ) , Some ( after_epoch) ) ;
1586
1588
1587
1589
// 0 and u32::MAX are out of NaiveDate range, fails with an error, not panics
1588
1590
assert_eq ! (
1589
1591
super :: deser_cql_value( & ColumnType :: Timestamp , & mut i64 :: MIN . to_be_bytes( ) . as_ref( ) )
1590
1592
. unwrap( )
1591
- . as_offset_date_time ( ) ,
1593
+ . as_offset_date_time_03 ( ) ,
1592
1594
None
1593
1595
) ;
1594
1596
1595
1597
assert_eq ! (
1596
1598
super :: deser_cql_value( & ColumnType :: Timestamp , & mut i64 :: MAX . to_be_bytes( ) . as_ref( ) )
1597
1599
. unwrap( )
1598
- . as_offset_date_time ( ) ,
1600
+ . as_offset_date_time_03 ( ) ,
1599
1601
None
1600
1602
) ;
1601
1603
}
0 commit comments