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 11use binaryninja:: headless:: Session ;
22use binaryninja:: platform:: Platform ;
33use binaryninja:: type_archive:: TypeArchive ;
4+ use binaryninja:: types:: { Type , TypeClass } ;
45
56#[ test]
67fn test_create_archive ( ) {
@@ -9,8 +10,17 @@ fn test_create_archive() {
910
1011 let temp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
1112 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 ( ) ) ;
1315 println ! ( "{:?}" , type_archive) ;
1416 // TODO: It seems that type archives have to be closed.
1517 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 ) ;
1626}
You can’t perform that action at this time.
0 commit comments