File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed
ios/CobraAppTest/CobraAppTestUITests Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -72,4 +72,20 @@ class CobraAppTestUITests: XCTestCase {
72
72
XCTAssert ( " \( error. localizedDescription) " . count == first_error. count)
73
73
}
74
74
}
75
+
76
+
77
+ func testProcessMessageStack( ) throws {
78
+ let cobra : Cobra = try Cobra ( accessKey: accessKey)
79
+ cobra. delete ( )
80
+
81
+ var testPcm : [ Int16 ] = [ ]
82
+ testPcm. reserveCapacity ( Int ( Cobra . frameLength) )
83
+
84
+ do {
85
+ let res = try cobra. process ( pcm: testPcm)
86
+ XCTAssert ( res != true )
87
+ } catch {
88
+ XCTAssert ( " \( error. localizedDescription) " . count > 0 )
89
+ }
90
+ }
75
91
}
Original file line number Diff line number Diff line change @@ -67,6 +67,24 @@ def test_message_stack(self):
67
67
self .assertEqual (len (error ), len (e .message_stack ))
68
68
self .assertListEqual (list (error ), list (e .message_stack ))
69
69
70
+ def test_process_message_stack (self ):
71
+ relative_path = '../..'
72
+
73
+ c = Cobra (access_key = sys .argv [1 ], library_path = pv_library_path (relative_path ))
74
+ test_pcm = [0 ] * c .frame_length
75
+
76
+ address = c ._handle
77
+ c ._handle = None
78
+
79
+ try :
80
+ res = c .process (test_pcm )
81
+ self .assertTrue (res == - 1 )
82
+ except CobraError as e :
83
+ self .assertGreater (len (e .message_stack ), 0 )
84
+ self .assertLess (len (e .message_stack ), 8 )
85
+
86
+ c ._handle = address
87
+
70
88
71
89
if __name__ == '__main__' :
72
90
if len (sys .argv ) != 2 :
Original file line number Diff line number Diff line change @@ -363,3 +363,36 @@ impl Drop for CobraInner {
363
363
}
364
364
}
365
365
}
366
+
367
+ #[ cfg( test) ]
368
+ mod tests {
369
+ use std:: env;
370
+
371
+ use crate :: util:: { pv_library_path} ;
372
+ use crate :: cobra:: { CobraInner } ;
373
+
374
+ #[ test]
375
+ fn test_process_error_stack ( ) {
376
+ let access_key = env:: var ( "PV_ACCESS_KEY" )
377
+ . expect ( "Pass the AccessKey in using the PV_ACCESS_KEY env variable" ) ;
378
+
379
+ let mut inner = CobraInner :: init (
380
+ & access_key. as_str ( ) ,
381
+ pv_library_path ( )
382
+ ) . expect ( "Unable to create Cobra" ) ;
383
+
384
+ let test_pcm = vec ! [ 0 ; inner. frame_length as usize ] ;
385
+ let address = inner. ccobra ;
386
+ inner. ccobra = std:: ptr:: null_mut ( ) ;
387
+
388
+ let res = inner. process ( & test_pcm) ;
389
+
390
+ inner. ccobra = address;
391
+ if let Err ( err) = res {
392
+ assert ! ( err. message_stack. len( ) > 0 ) ;
393
+ assert ! ( err. message_stack. len( ) < 8 ) ;
394
+ } else {
395
+ assert ! ( res. unwrap( ) == true ) ;
396
+ }
397
+ }
398
+ }
You can’t perform that action at this time.
0 commit comments