Skip to content

Commit c2f9470

Browse files
committed
[Rust] Re-open type archive in unit test to verify
1 parent f3dce08 commit c2f9470

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

rust/tests/type_archive.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use binaryninja::headless::Session;
22
use binaryninja::platform::Platform;
33
use binaryninja::type_archive::TypeArchive;
4+
use binaryninja::types::{Type, TypeClass};
45

56
#[test]
67
fn 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
}

0 commit comments

Comments
 (0)