From b3fcb1dd2ecd1eeeb82f812bc94cc1b9880c5db9 Mon Sep 17 00:00:00 2001 From: IshanGrover2004 Date: Sat, 24 Aug 2024 10:46:12 +0530 Subject: [PATCH] fix: unit test error & build issues --- src/rust/src/decoder/mod.rs | 10 +++++----- src/rust/src/lib.rs | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/rust/src/decoder/mod.rs b/src/rust/src/decoder/mod.rs index f8ab4fcf4..fd88eeb8d 100644 --- a/src/rust/src/decoder/mod.rs +++ b/src/rust/src/decoder/mod.rs @@ -95,7 +95,7 @@ impl<'a> Dtvcc<'a> { w.memory_reserved = 0; }); - unsafe { dtvcc_windows_reset(decoder.as_mut()) }; + decoder.handle_reset(); *d = Some(decoder); }); @@ -326,8 +326,8 @@ mod test { #[test] fn test_process_cc_data() { - let mut dtvcc_ctx = get_zero_allocated_obj::(); - let mut decoder = Dtvcc::new(&mut dtvcc_ctx); + let mut dtvcc_settings = get_zero_allocated_obj::(); + let mut decoder = Dtvcc::new(&mut dtvcc_settings); // Case 1: cc_type = 2 let mut dtvcc_report = ccx_decoder_dtvcc_report::default(); @@ -369,8 +369,8 @@ mod test { #[test] fn test_process_current_packet() { - let mut dtvcc_ctx = get_zero_allocated_obj::(); - let mut decoder = Dtvcc::new(&mut dtvcc_ctx); + let mut dtvcc_settings = get_zero_allocated_obj::(); + let mut decoder = Dtvcc::new(&mut dtvcc_settings); // Case 1: Without providing last_sequence let mut dtvcc_report = ccx_decoder_dtvcc_report::default(); diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index db0f7f344..5e34334c3 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -347,6 +347,10 @@ pub unsafe extern "C" fn ccxr_parse_parameters( #[cfg(test)] mod test { + use std::ffi::c_void; + + use utils::get_zero_allocated_obj; + use super::*; #[test] @@ -381,13 +385,18 @@ mod test { #[test] fn test_do_cb() { - let mut dtvcc_ctx = utils::get_zero_allocated_obj::(); - let mut dtvcc = Dtvcc::new(&mut dtvcc_ctx); + // Setting up `Dtvcc` & `lib_cc_decode` + let mut dtvcc_settings = get_zero_allocated_obj::(); + dtvcc_settings.report = Box::into_raw(Box::new(ccx_decoder_dtvcc_report::default())); + println!("THK"); + let dtvcc = Dtvcc::new(&mut dtvcc_settings); + println!("THK"); let mut decoder_ctx = lib_cc_decode::default(); + decoder_ctx.dtvcc_rust = Box::into_raw(Box::new(dtvcc)) as *mut c_void; let cc_block = [0x97, 0x1F, 0x3C]; - assert!(do_cb(&mut decoder_ctx, &mut dtvcc, &cc_block)); + assert!(do_cb(&mut decoder_ctx, &cc_block)); assert_eq!(decoder_ctx.current_field, 3); assert_eq!(decoder_ctx.cc_stats[3], 1); assert_eq!(decoder_ctx.processed_enough, 0);