Skip to content

Commit

Permalink
fix: unit test error & build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
IshanGrover2004 committed Aug 24, 2024
1 parent e22215f commit b3fcb1d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/rust/src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -326,8 +326,8 @@ mod test {

#[test]
fn test_process_cc_data() {
let mut dtvcc_ctx = get_zero_allocated_obj::<dtvcc_ctx>();
let mut decoder = Dtvcc::new(&mut dtvcc_ctx);
let mut dtvcc_settings = get_zero_allocated_obj::<ccx_decoder_dtvcc_settings>();
let mut decoder = Dtvcc::new(&mut dtvcc_settings);

// Case 1: cc_type = 2
let mut dtvcc_report = ccx_decoder_dtvcc_report::default();
Expand Down Expand Up @@ -369,8 +369,8 @@ mod test {

#[test]
fn test_process_current_packet() {
let mut dtvcc_ctx = get_zero_allocated_obj::<dtvcc_ctx>();
let mut decoder = Dtvcc::new(&mut dtvcc_ctx);
let mut dtvcc_settings = get_zero_allocated_obj::<ccx_decoder_dtvcc_settings>();
let mut decoder = Dtvcc::new(&mut dtvcc_settings);

// Case 1: Without providing last_sequence
let mut dtvcc_report = ccx_decoder_dtvcc_report::default();
Expand Down
15 changes: 12 additions & 3 deletions src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -381,13 +385,18 @@ mod test {

#[test]
fn test_do_cb() {
let mut dtvcc_ctx = utils::get_zero_allocated_obj::<dtvcc_ctx>();
let mut dtvcc = Dtvcc::new(&mut dtvcc_ctx);
// Setting up `Dtvcc` & `lib_cc_decode`
let mut dtvcc_settings = get_zero_allocated_obj::<ccx_decoder_dtvcc_settings>();
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);
Expand Down

0 comments on commit b3fcb1d

Please sign in to comment.