Skip to content

Commit b5cb634

Browse files
vatsalkeshavvats004
authored and
vats004
committed
run cargo fmt
1 parent 223d6fb commit b5cb634

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

src/rust/lib_ccxr/src/decoder_xds/functions_xds.rs

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,16 +1118,14 @@ pub fn xds_cea608_test(ctx: &mut CcxDecodersXdsContext, sub: &mut CcSubtitle) {
11181118
#[cfg(test)]
11191119
mod tests {
11201120
use super::*;
1121-
use std::ffi::CStr;
11221121

11231122
#[test]
11241123
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();
11261125
let xds_write_to_file = 1;
11271126

11281127
let ctx = ccx_decoders_xds_init_library(timing, xds_write_to_file);
11291128

1130-
// Check initial values
11311129
assert_eq!(ctx.current_xds_min, -1);
11321130
assert_eq!(ctx.current_xds_hour, -1);
11331131
assert_eq!(ctx.current_xds_date, -1);
@@ -1142,7 +1140,6 @@ mod tests {
11421140
assert_eq!(ctx.cur_xds_packet_type, 0);
11431141
assert_eq!(ctx.xds_write_to_file, xds_write_to_file);
11441142

1145-
// Check that all buffers are initialized correctly
11461143
for buffer in ctx.xds_buffers.iter() {
11471144
assert_eq!(buffer.in_use, 0);
11481145
assert_eq!(buffer.xds_class, -1);
@@ -1151,12 +1148,10 @@ mod tests {
11511148
assert!(buffer.bytes.iter().all(|&b| b == 0));
11521149
}
11531150

1154-
// Check that all program descriptions are initialized to zero
11551151
for description in ctx.xds_program_description.iter() {
11561152
assert!(description.iter().all(|&b| b == 0));
11571153
}
11581154

1159-
// Check that network name, program name, call letters, and program type are initialized to zero
11601155
assert!(ctx.current_xds_network_name.iter().all(|&b| b == 0));
11611156
assert!(ctx.current_xds_program_name.iter().all(|&b| b == 0));
11621157
assert!(ctx.current_xds_call_letters.iter().all(|&b| b == 0));
@@ -1170,7 +1165,6 @@ mod tests {
11701165

11711166
let ctx = ccx_decoders_xds_init_library(timing, xds_write_to_file);
11721167

1173-
// Check that the `xds_write_to_file` flag is set correctly
11741168
assert_eq!(ctx.xds_write_to_file, xds_write_to_file);
11751169
}
11761170

@@ -1181,7 +1175,6 @@ mod tests {
11811175

11821176
let ctx = ccx_decoders_xds_init_library(timing.clone(), xds_write_to_file);
11831177

1184-
// Check that the timing context is correctly assigned
11851178
assert_eq!(ctx.timing, timing);
11861179
}
11871180

@@ -1351,7 +1344,6 @@ mod tests {
13511344
// Call the function to clear the buffer
13521345
clear_xds_buffer(&mut ctx, buffer_index);
13531346

1354-
// Verify that the buffer was cleared
13551347
let buffer = &ctx.xds_buffers[buffer_index as usize];
13561348
assert_eq!(buffer.in_use, 0);
13571349
assert_eq!(buffer.xds_class, -1);
@@ -1398,15 +1390,13 @@ mod tests {
13981390
// Call the function to clear the buffer
13991391
clear_xds_buffer(&mut ctx, buffer_index);
14001392

1401-
// Verify that only the specified buffer was cleared
14021393
let cleared_buffer = &ctx.xds_buffers[buffer_index as usize];
14031394
assert_eq!(cleared_buffer.in_use, 0);
14041395
assert_eq!(cleared_buffer.xds_class, -1);
14051396
assert_eq!(cleared_buffer.xds_type, -1);
14061397
assert_eq!(cleared_buffer.used_bytes, 0);
14071398
assert!(cleared_buffer.bytes.iter().all(|&b| b == 0));
14081399

1409-
// Verify that other buffers remain unchanged
14101400
let untouched_buffer = &ctx.xds_buffers[0];
14111401
assert_eq!(untouched_buffer.in_use, 1);
14121402
assert_eq!(untouched_buffer.xds_class, 2);
@@ -1480,7 +1470,7 @@ mod tests {
14801470
let mut ctx = CcxDecodersXdsContext::default();
14811471
ctx.xds_write_to_file = 0; // Disable writing XDS data
14821472

1483-
let c1 = 0x50; // CGMS: Copy permitted (no restrictions)
1473+
let c1 = 0x50;
14841474
let c2 = 0x40; // APS: No APS, RCD: 0
14851475

14861476
xds_do_copy_generation_management_system(&mut sub, &mut ctx, c1, c2);
@@ -1496,7 +1486,7 @@ mod tests {
14961486
let mut ctx = CcxDecodersXdsContext::default();
14971487
ctx.xds_write_to_file = 1; // Enable writing XDS data
14981488

1499-
let c1 = 0x10; // Invalid CGMS data (c1_6 is 0)
1489+
let c1 = 0x10;
15001490
let c2 = 0x40; // APS: No APS, RCD: 0
15011491

15021492
xds_do_copy_generation_management_system(&mut sub, &mut ctx, c1, c2);
@@ -1512,7 +1502,7 @@ mod tests {
15121502
let mut ctx = CcxDecodersXdsContext::default();
15131503
ctx.xds_write_to_file = 0; // Disable writing XDS data
15141504

1515-
let c1 = 0x58; // US TV parental guidelines: TV-14 (Parents Strongly Cautioned)
1505+
let c1 = 0x58;
15161506
let c2 = 0x10; // Content: Violence
15171507

15181508
xds_do_content_advisory(&mut sub, &mut ctx, c1, c2);
@@ -1526,7 +1516,7 @@ mod tests {
15261516
fn test_xds_do_content_advisory_invalid_data() {
15271517
let mut sub = CcSubtitle::default();
15281518
let mut ctx = CcxDecodersXdsContext::default();
1529-
ctx.xds_write_to_file = 1; // Enable writing XDS data
1519+
ctx.xds_write_to_file = 1;
15301520

15311521
let c1 = 0x10; // Invalid data (c1_6 is 0)
15321522
let c2 = 0x40; // No additional content
@@ -1542,15 +1532,13 @@ mod tests {
15421532
fn test_xds_do_misc_invalid_payload() {
15431533
let mut ctx = CcxDecodersXdsContext::default();
15441534
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;
15461536

1547-
// Simulate an invalid payload
15481537
let payload: [u8; 4] = [0x00, 0x00, 0x3C, 0x12];
15491538
ctx.cur_xds_payload = payload.as_ptr() as *mut u8;
15501539

15511540
let result = xds_do_misc(&ctx);
15521541

1553-
// Verify the function did not process the payload
15541542
assert_eq!(result, 1); // Still returns 1 but does not process
15551543
}
15561544

@@ -1572,7 +1560,6 @@ mod tests {
15721560
ctx.cur_xds_packet_type = 0x99; // Unsupported packet type
15731561
ctx.cur_xds_payload_length = 5;
15741562

1575-
// Simulate a valid payload
15761563
let payload: [u8; 5] = [0x00, 0x00, 0x25, 0x00, 0x00];
15771564
ctx.cur_xds_payload = payload.as_ptr() as *mut u8;
15781565

@@ -1589,13 +1576,11 @@ mod tests {
15891576
ctx.cur_xds_packet_type = XDS_TYPE_PIN_START_TIME as i64;
15901577
ctx.cur_xds_payload_length = 4; // Invalid length (less than required)
15911578

1592-
// Simulate an invalid payload
15931579
let payload: [u8; 4] = [0x00, 0x00, 0x15, 0x10];
15941580
ctx.cur_xds_payload = payload.as_ptr() as *mut u8;
15951581

15961582
let result = xds_do_current_and_future(&mut sub, &mut ctx);
15971583

1598-
// Verify the function did not process the payload
15991584
assert_eq!(result, 1); // Still returns 1 but does not process
16001585
assert_eq!(sub.nb_data, 0);
16011586
assert!(!sub.got_output);
@@ -1606,7 +1591,6 @@ mod tests {
16061591
let mut sub = CcSubtitle::default();
16071592
let mut ctx = CcxDecodersXdsContext::default();
16081593

1609-
// Simulate an empty XDS buffer
16101594
ctx.cur_xds_buffer_idx = 0;
16111595
ctx.xds_buffers[0].in_use = 0;
16121596

@@ -1624,16 +1608,14 @@ mod tests {
16241608
let mut sub = CcSubtitle::default();
16251609
let mut ctx = CcxDecodersXdsContext::default();
16261610
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;
16281612

1629-
// Simulate an invalid payload
16301613
let payload: [u8; 4] = [0x00, 0x00, b'W', b'A'];
16311614
ctx.cur_xds_payload = payload.as_ptr() as *mut u8;
16321615

16331616
let result = xds_do_channel(&mut sub, &mut ctx);
16341617

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);
16371619
assert_eq!(sub.nb_data, 0);
16381620
assert!(!sub.got_output);
16391621
}
@@ -1643,10 +1625,8 @@ mod tests {
16431625
let mut ctx = CcxDecodersXdsContext::default();
16441626
let mut sub = CcSubtitle::default();
16451627

1646-
// Call the debug test function without any valid data
16471628
do_end_of_xds(&mut sub, &mut ctx, 0x2a);
16481629

1649-
// Verify that the subtitle structure was not updated
16501630
assert_eq!(sub.nb_data, 0);
16511631
assert!(!sub.got_output);
16521632
}
@@ -1656,10 +1636,8 @@ mod tests {
16561636
let mut ctx = CcxDecodersXdsContext::default();
16571637
let mut sub = CcSubtitle::default();
16581638

1659-
// Call the CEA-608 test function without any valid data
16601639
do_end_of_xds(&mut sub, &mut ctx, 0x1d);
16611640

1662-
// Verify that the subtitle structure was not updated
16631641
assert_eq!(sub.nb_data, 0);
16641642
assert!(!sub.got_output);
16651643
}

src/rust/lib_ccxr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pub mod activity;
22
pub mod common;
3+
pub mod decoder_xds;
34
pub mod hardsubx;
45
pub mod subtitle;
56
pub mod teletext;
67
pub mod time;
78
pub mod util;
8-
pub mod decoder_xds;

0 commit comments

Comments
 (0)