File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
use binaryninja:: headless:: Session ;
2
2
use binaryninja:: platform:: Platform ;
3
3
use binaryninja:: type_archive:: TypeArchive ;
4
+ use binaryninja:: types:: { Type , TypeClass } ;
4
5
5
6
#[ test]
6
7
fn test_create_archive ( ) {
@@ -9,8 +10,17 @@ fn test_create_archive() {
9
10
10
11
let temp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
11
12
let type_archive_path = temp_dir. path ( ) . with_file_name ( "type_archive_0" ) ;
12
- let type_archive = TypeArchive :: create ( type_archive_path, & placeholder_platform) . unwrap ( ) ;
13
+ let type_archive = TypeArchive :: create ( & type_archive_path, & placeholder_platform) . unwrap ( ) ;
14
+ type_archive. add_type ( ( "test" , Type :: int ( 7 , true ) ) . into ( ) ) ;
13
15
println ! ( "{:?}" , type_archive) ;
14
16
// TODO: It seems that type archives have to be closed.
15
17
type_archive. close ( ) ;
18
+
19
+ // Now open the type archive to check.
20
+ let type_archive = TypeArchive :: open ( & type_archive_path) . expect ( "Opened type archive" ) ;
21
+ let test_type = type_archive
22
+ . get_type_by_name ( "test" . into ( ) )
23
+ . expect ( "Found test type" ) ;
24
+ assert_eq ! ( test_type. width( ) , 7 ) ;
25
+ assert_eq ! ( test_type. type_class( ) , TypeClass :: IntegerTypeClass ) ;
16
26
}
You can’t perform that action at this time.
0 commit comments