@@ -27,7 +27,7 @@ use std::os::windows::io::{FromRawHandle, RawHandle};
27
27
28
28
use args:: Args ;
29
29
use bindings:: * ;
30
- use cfg_if:: cfg_if;
30
+ use cfg_if:: cfg_if;
31
31
use clap:: { error:: ErrorKind , Parser } ;
32
32
use common:: { copy_from_rust, CType , CType2 } ;
33
33
use decoder:: Dtvcc ;
@@ -43,62 +43,62 @@ use std::{
43
43
os:: raw:: { c_char, c_double, c_int, c_long, c_uint} ,
44
44
} ;
45
45
46
- // Mock data for rust unit tests
47
- cfg_if ! {
48
- if #[ cfg( test) ] {
49
- static mut cb_708: c_int = 0 ;
50
- static mut cb_field1: c_int = 0 ;
51
- static mut cb_field2: c_int = 0 ;
52
- static mut current_fps: c_double = 30.0 ;
53
- static mut usercolor_rgb: [ c_int; 8 ] = [ 0 ; 8 ] ;
54
- static mut FILEBUFFERSIZE : c_int = 0 ;
55
- static mut MPEG_CLOCK_FREQ : c_int = 90000 ;
56
-
57
- static mut frames_since_ref_time: c_int = 0 ;
58
- static mut total_frames_count: c_uint = 0 ;
59
- static mut fts_at_gop_start: c_long = 0 ;
60
- static mut gop_rollover: c_int = 0 ;
61
- static mut pts_big_change: c_uint = 0 ;
62
-
63
- static mut tlt_config: ccx_s_teletext_config = unsafe { std:: mem:: zeroed( ) } ;
64
- static mut ccx_options: ccx_s_options = unsafe { std:: mem:: zeroed( ) } ;
65
- static mut gop_time: gop_time_code = unsafe { std:: mem:: zeroed( ) } ;
66
- static mut first_gop_time: gop_time_code = unsafe { std:: mem:: zeroed( ) } ;
67
- static mut ccx_common_timing_settings: ccx_common_timing_settings_t = unsafe { std:: mem:: zeroed( ) } ;
68
- static mut capitalization_list: word_list = unsafe { std:: mem:: zeroed( ) } ;
69
- static mut profane: word_list = unsafe { std:: mem:: zeroed( ) } ;
70
-
71
- unsafe extern "C" fn version( _location: * const c_char) { }
72
- unsafe extern "C" fn set_binary_mode( ) { }
73
- }
74
- }
75
-
76
- // External C symbols (only when not testing)
77
- #[ cfg( not( test) ) ]
78
- extern "C" {
79
- static mut cb_708: c_int ;
80
- static mut cb_field1: c_int ;
81
- static mut cb_field2: c_int ;
82
- static mut current_fps: c_double ;
83
- static mut usercolor_rgb: [ c_int ; 8 ] ;
84
- static mut FILEBUFFERSIZE : c_int ;
85
- static mut MPEG_CLOCK_FREQ : c_int ;
86
- static mut tlt_config: ccx_s_teletext_config ;
87
- static mut ccx_options: ccx_s_options ;
88
- static mut frames_since_ref_time: c_int ;
89
- static mut total_frames_count: c_uint ;
90
- static mut gop_time: gop_time_code ;
91
- static mut first_gop_time: gop_time_code ;
92
- static mut fts_at_gop_start: c_long ;
93
- static mut gop_rollover: c_int ;
94
- static mut ccx_common_timing_settings: ccx_common_timing_settings_t ;
95
- static mut capitalization_list: word_list ;
96
- static mut profane: word_list ;
97
- static mut pts_big_change: c_uint ;
98
-
99
- fn version ( location : * const c_char ) ;
100
- fn set_binary_mode ( ) ;
101
- }
46
+ // Mock data for rust unit tests
47
+ cfg_if ! {
48
+ if #[ cfg( test) ] {
49
+ static mut cb_708: c_int = 0 ;
50
+ static mut cb_field1: c_int = 0 ;
51
+ static mut cb_field2: c_int = 0 ;
52
+ static mut current_fps: c_double = 30.0 ;
53
+ static mut usercolor_rgb: [ c_int; 8 ] = [ 0 ; 8 ] ;
54
+ static mut FILEBUFFERSIZE : c_int = 0 ;
55
+ static mut MPEG_CLOCK_FREQ : c_int = 90000 ;
56
+
57
+ static mut frames_since_ref_time: c_int = 0 ;
58
+ static mut total_frames_count: c_uint = 0 ;
59
+ static mut fts_at_gop_start: c_long = 0 ;
60
+ static mut gop_rollover: c_int = 0 ;
61
+ static mut pts_big_change: c_uint = 0 ;
62
+
63
+ static mut tlt_config: ccx_s_teletext_config = unsafe { std:: mem:: zeroed( ) } ;
64
+ static mut ccx_options: ccx_s_options = unsafe { std:: mem:: zeroed( ) } ;
65
+ static mut gop_time: gop_time_code = unsafe { std:: mem:: zeroed( ) } ;
66
+ static mut first_gop_time: gop_time_code = unsafe { std:: mem:: zeroed( ) } ;
67
+ static mut ccx_common_timing_settings: ccx_common_timing_settings_t = unsafe { std:: mem:: zeroed( ) } ;
68
+ static mut capitalization_list: word_list = unsafe { std:: mem:: zeroed( ) } ;
69
+ static mut profane: word_list = unsafe { std:: mem:: zeroed( ) } ;
70
+
71
+ unsafe extern "C" fn version( _location: * const c_char) { }
72
+ unsafe extern "C" fn set_binary_mode( ) { }
73
+ }
74
+ }
75
+
76
+ // External C symbols (only when not testing)
77
+ #[ cfg( not( test) ) ]
78
+ extern "C" {
79
+ static mut cb_708: c_int ;
80
+ static mut cb_field1: c_int ;
81
+ static mut cb_field2: c_int ;
82
+ static mut current_fps: c_double ;
83
+ static mut usercolor_rgb: [ c_int ; 8 ] ;
84
+ static mut FILEBUFFERSIZE : c_int ;
85
+ static mut MPEG_CLOCK_FREQ : c_int ;
86
+ static mut tlt_config: ccx_s_teletext_config ;
87
+ static mut ccx_options: ccx_s_options ;
88
+ static mut frames_since_ref_time: c_int ;
89
+ static mut total_frames_count: c_uint ;
90
+ static mut gop_time: gop_time_code ;
91
+ static mut first_gop_time: gop_time_code ;
92
+ static mut fts_at_gop_start: c_long ;
93
+ static mut gop_rollover: c_int ;
94
+ static mut ccx_common_timing_settings: ccx_common_timing_settings_t ;
95
+ static mut capitalization_list: word_list ;
96
+ static mut profane: word_list ;
97
+ static mut pts_big_change: c_uint ;
98
+
99
+ fn version ( location : * const c_char ) ;
100
+ fn set_binary_mode ( ) ;
101
+ }
102
102
103
103
/// Initialize env logger with custom format, using stdout as target
104
104
#[ no_mangle]
@@ -352,7 +352,8 @@ mod test {
352
352
353
353
#[ test]
354
354
fn test_do_cb ( ) {
355
- let mut dtvcc_ctx = utils:: get_zero_allocated_obj :: < dtvcc_ctx > ( ) ;
355
+ let mut dtvcc_ctx = crate :: decoder:: test:: initialize_dtvcc_ctx ( ) ;
356
+
356
357
let mut dtvcc = Dtvcc :: new ( & mut dtvcc_ctx) ;
357
358
358
359
let mut decoder_ctx = lib_cc_decode:: default ( ) ;
0 commit comments