@@ -1118,16 +1118,14 @@ pub fn xds_cea608_test(ctx: &mut CcxDecodersXdsContext, sub: &mut CcSubtitle) {
1118
1118
#[ cfg( test) ]
1119
1119
mod tests {
1120
1120
use super :: * ;
1121
- use std:: ffi:: CStr ;
1122
1121
1123
1122
#[ test]
1124
1123
fn test_ccx_decoders_xds_init_library_initialization ( ) {
1125
- let timing = TimingContext :: new ( ) ; // Assuming `TimingContext::new()` initializes a valid context
1124
+ let timing = TimingContext :: new ( ) ;
1126
1125
let xds_write_to_file = 1 ;
1127
1126
1128
1127
let ctx = ccx_decoders_xds_init_library ( timing, xds_write_to_file) ;
1129
1128
1130
- // Check initial values
1131
1129
assert_eq ! ( ctx. current_xds_min, -1 ) ;
1132
1130
assert_eq ! ( ctx. current_xds_hour, -1 ) ;
1133
1131
assert_eq ! ( ctx. current_xds_date, -1 ) ;
@@ -1142,7 +1140,6 @@ mod tests {
1142
1140
assert_eq ! ( ctx. cur_xds_packet_type, 0 ) ;
1143
1141
assert_eq ! ( ctx. xds_write_to_file, xds_write_to_file) ;
1144
1142
1145
- // Check that all buffers are initialized correctly
1146
1143
for buffer in ctx. xds_buffers . iter ( ) {
1147
1144
assert_eq ! ( buffer. in_use, 0 ) ;
1148
1145
assert_eq ! ( buffer. xds_class, -1 ) ;
@@ -1151,12 +1148,10 @@ mod tests {
1151
1148
assert ! ( buffer. bytes. iter( ) . all( |& b| b == 0 ) ) ;
1152
1149
}
1153
1150
1154
- // Check that all program descriptions are initialized to zero
1155
1151
for description in ctx. xds_program_description . iter ( ) {
1156
1152
assert ! ( description. iter( ) . all( |& b| b == 0 ) ) ;
1157
1153
}
1158
1154
1159
- // Check that network name, program name, call letters, and program type are initialized to zero
1160
1155
assert ! ( ctx. current_xds_network_name. iter( ) . all( |& b| b == 0 ) ) ;
1161
1156
assert ! ( ctx. current_xds_program_name. iter( ) . all( |& b| b == 0 ) ) ;
1162
1157
assert ! ( ctx. current_xds_call_letters. iter( ) . all( |& b| b == 0 ) ) ;
@@ -1170,7 +1165,6 @@ mod tests {
1170
1165
1171
1166
let ctx = ccx_decoders_xds_init_library ( timing, xds_write_to_file) ;
1172
1167
1173
- // Check that the `xds_write_to_file` flag is set correctly
1174
1168
assert_eq ! ( ctx. xds_write_to_file, xds_write_to_file) ;
1175
1169
}
1176
1170
@@ -1181,7 +1175,6 @@ mod tests {
1181
1175
1182
1176
let ctx = ccx_decoders_xds_init_library ( timing. clone ( ) , xds_write_to_file) ;
1183
1177
1184
- // Check that the timing context is correctly assigned
1185
1178
assert_eq ! ( ctx. timing, timing) ;
1186
1179
}
1187
1180
@@ -1351,7 +1344,6 @@ mod tests {
1351
1344
// Call the function to clear the buffer
1352
1345
clear_xds_buffer ( & mut ctx, buffer_index) ;
1353
1346
1354
- // Verify that the buffer was cleared
1355
1347
let buffer = & ctx. xds_buffers [ buffer_index as usize ] ;
1356
1348
assert_eq ! ( buffer. in_use, 0 ) ;
1357
1349
assert_eq ! ( buffer. xds_class, -1 ) ;
@@ -1398,15 +1390,13 @@ mod tests {
1398
1390
// Call the function to clear the buffer
1399
1391
clear_xds_buffer ( & mut ctx, buffer_index) ;
1400
1392
1401
- // Verify that only the specified buffer was cleared
1402
1393
let cleared_buffer = & ctx. xds_buffers [ buffer_index as usize ] ;
1403
1394
assert_eq ! ( cleared_buffer. in_use, 0 ) ;
1404
1395
assert_eq ! ( cleared_buffer. xds_class, -1 ) ;
1405
1396
assert_eq ! ( cleared_buffer. xds_type, -1 ) ;
1406
1397
assert_eq ! ( cleared_buffer. used_bytes, 0 ) ;
1407
1398
assert ! ( cleared_buffer. bytes. iter( ) . all( |& b| b == 0 ) ) ;
1408
1399
1409
- // Verify that other buffers remain unchanged
1410
1400
let untouched_buffer = & ctx. xds_buffers [ 0 ] ;
1411
1401
assert_eq ! ( untouched_buffer. in_use, 1 ) ;
1412
1402
assert_eq ! ( untouched_buffer. xds_class, 2 ) ;
@@ -1480,7 +1470,7 @@ mod tests {
1480
1470
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1481
1471
ctx. xds_write_to_file = 0 ; // Disable writing XDS data
1482
1472
1483
- let c1 = 0x50 ; // CGMS: Copy permitted (no restrictions)
1473
+ let c1 = 0x50 ;
1484
1474
let c2 = 0x40 ; // APS: No APS, RCD: 0
1485
1475
1486
1476
xds_do_copy_generation_management_system ( & mut sub, & mut ctx, c1, c2) ;
@@ -1496,7 +1486,7 @@ mod tests {
1496
1486
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1497
1487
ctx. xds_write_to_file = 1 ; // Enable writing XDS data
1498
1488
1499
- let c1 = 0x10 ; // Invalid CGMS data (c1_6 is 0)
1489
+ let c1 = 0x10 ;
1500
1490
let c2 = 0x40 ; // APS: No APS, RCD: 0
1501
1491
1502
1492
xds_do_copy_generation_management_system ( & mut sub, & mut ctx, c1, c2) ;
@@ -1512,7 +1502,7 @@ mod tests {
1512
1502
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1513
1503
ctx. xds_write_to_file = 0 ; // Disable writing XDS data
1514
1504
1515
- let c1 = 0x58 ; // US TV parental guidelines: TV-14 (Parents Strongly Cautioned)
1505
+ let c1 = 0x58 ;
1516
1506
let c2 = 0x10 ; // Content: Violence
1517
1507
1518
1508
xds_do_content_advisory ( & mut sub, & mut ctx, c1, c2) ;
@@ -1526,7 +1516,7 @@ mod tests {
1526
1516
fn test_xds_do_content_advisory_invalid_data ( ) {
1527
1517
let mut sub = CcSubtitle :: default ( ) ;
1528
1518
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1529
- ctx. xds_write_to_file = 1 ; // Enable writing XDS data
1519
+ ctx. xds_write_to_file = 1 ;
1530
1520
1531
1521
let c1 = 0x10 ; // Invalid data (c1_6 is 0)
1532
1522
let c2 = 0x40 ; // No additional content
@@ -1542,15 +1532,13 @@ mod tests {
1542
1532
fn test_xds_do_misc_invalid_payload ( ) {
1543
1533
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1544
1534
ctx. cur_xds_packet_type = XDS_TYPE_TIME_OF_DAY as i64 ;
1545
- ctx. cur_xds_payload_length = 4 ; // Invalid length (less than required)
1535
+ ctx. cur_xds_payload_length = 4 ;
1546
1536
1547
- // Simulate an invalid payload
1548
1537
let payload: [ u8 ; 4 ] = [ 0x00 , 0x00 , 0x3C , 0x12 ] ;
1549
1538
ctx. cur_xds_payload = payload. as_ptr ( ) as * mut u8 ;
1550
1539
1551
1540
let result = xds_do_misc ( & ctx) ;
1552
1541
1553
- // Verify the function did not process the payload
1554
1542
assert_eq ! ( result, 1 ) ; // Still returns 1 but does not process
1555
1543
}
1556
1544
@@ -1572,7 +1560,6 @@ mod tests {
1572
1560
ctx. cur_xds_packet_type = 0x99 ; // Unsupported packet type
1573
1561
ctx. cur_xds_payload_length = 5 ;
1574
1562
1575
- // Simulate a valid payload
1576
1563
let payload: [ u8 ; 5 ] = [ 0x00 , 0x00 , 0x25 , 0x00 , 0x00 ] ;
1577
1564
ctx. cur_xds_payload = payload. as_ptr ( ) as * mut u8 ;
1578
1565
@@ -1589,13 +1576,11 @@ mod tests {
1589
1576
ctx. cur_xds_packet_type = XDS_TYPE_PIN_START_TIME as i64 ;
1590
1577
ctx. cur_xds_payload_length = 4 ; // Invalid length (less than required)
1591
1578
1592
- // Simulate an invalid payload
1593
1579
let payload: [ u8 ; 4 ] = [ 0x00 , 0x00 , 0x15 , 0x10 ] ;
1594
1580
ctx. cur_xds_payload = payload. as_ptr ( ) as * mut u8 ;
1595
1581
1596
1582
let result = xds_do_current_and_future ( & mut sub, & mut ctx) ;
1597
1583
1598
- // Verify the function did not process the payload
1599
1584
assert_eq ! ( result, 1 ) ; // Still returns 1 but does not process
1600
1585
assert_eq ! ( sub. nb_data, 0 ) ;
1601
1586
assert ! ( !sub. got_output) ;
@@ -1606,7 +1591,6 @@ mod tests {
1606
1591
let mut sub = CcSubtitle :: default ( ) ;
1607
1592
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1608
1593
1609
- // Simulate an empty XDS buffer
1610
1594
ctx. cur_xds_buffer_idx = 0 ;
1611
1595
ctx. xds_buffers [ 0 ] . in_use = 0 ;
1612
1596
@@ -1624,16 +1608,14 @@ mod tests {
1624
1608
let mut sub = CcSubtitle :: default ( ) ;
1625
1609
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1626
1610
ctx. cur_xds_packet_type = XDS_TYPE_CALL_LETTERS_AND_CHANNEL as i64 ;
1627
- ctx. cur_xds_payload_length = 4 ; // Invalid length (less than required)
1611
+ ctx. cur_xds_payload_length = 4 ;
1628
1612
1629
- // Simulate an invalid payload
1630
1613
let payload: [ u8 ; 4 ] = [ 0x00 , 0x00 , b'W' , b'A' ] ;
1631
1614
ctx. cur_xds_payload = payload. as_ptr ( ) as * mut u8 ;
1632
1615
1633
1616
let result = xds_do_channel ( & mut sub, & mut ctx) ;
1634
1617
1635
- // Verify the function did not process the payload
1636
- assert_eq ! ( result, 1 ) ; // Still returns 1 but does not process
1618
+ assert_eq ! ( result, 1 ) ;
1637
1619
assert_eq ! ( sub. nb_data, 0 ) ;
1638
1620
assert ! ( !sub. got_output) ;
1639
1621
}
@@ -1643,10 +1625,8 @@ mod tests {
1643
1625
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1644
1626
let mut sub = CcSubtitle :: default ( ) ;
1645
1627
1646
- // Call the debug test function without any valid data
1647
1628
do_end_of_xds ( & mut sub, & mut ctx, 0x2a ) ;
1648
1629
1649
- // Verify that the subtitle structure was not updated
1650
1630
assert_eq ! ( sub. nb_data, 0 ) ;
1651
1631
assert ! ( !sub. got_output) ;
1652
1632
}
@@ -1656,10 +1636,8 @@ mod tests {
1656
1636
let mut ctx = CcxDecodersXdsContext :: default ( ) ;
1657
1637
let mut sub = CcSubtitle :: default ( ) ;
1658
1638
1659
- // Call the CEA-608 test function without any valid data
1660
1639
do_end_of_xds ( & mut sub, & mut ctx, 0x1d ) ;
1661
1640
1662
- // Verify that the subtitle structure was not updated
1663
1641
assert_eq ! ( sub. nb_data, 0 ) ;
1664
1642
assert ! ( !sub. got_output) ;
1665
1643
}
0 commit comments