summaryrefslogtreecommitdiff
path: root/rust/tests
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-17 08:57:43 +0200
committerMason Reed <mason@vector35.com>2025-05-17 08:58:53 +0200
commitc2f94700a0cc535860934fae01d7ecb81956bcec (patch)
treeadead20283c95f038338e394b5ae9399de8fdeb3 /rust/tests
parentf3dce0828c95e11af1f7d23ca56be6037b86de3c (diff)
[Rust] Re-open type archive in unit test to verify
Diffstat (limited to 'rust/tests')
-rw-r--r--rust/tests/type_archive.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/rust/tests/type_archive.rs b/rust/tests/type_archive.rs
index 38d0b758..7f0bd2f0 100644
--- a/rust/tests/type_archive.rs
+++ b/rust/tests/type_archive.rs
@@ -1,6 +1,7 @@
use binaryninja::headless::Session;
use binaryninja::platform::Platform;
use binaryninja::type_archive::TypeArchive;
+use binaryninja::types::{Type, TypeClass};
#[test]
fn test_create_archive() {
@@ -9,8 +10,17 @@ fn test_create_archive() {
let temp_dir = tempfile::tempdir().unwrap();
let type_archive_path = temp_dir.path().with_file_name("type_archive_0");
- let type_archive = TypeArchive::create(type_archive_path, &placeholder_platform).unwrap();
+ let type_archive = TypeArchive::create(&type_archive_path, &placeholder_platform).unwrap();
+ type_archive.add_type(("test", Type::int(7, true)).into());
println!("{:?}", type_archive);
// TODO: It seems that type archives have to be closed.
type_archive.close();
+
+ // Now open the type archive to check.
+ let type_archive = TypeArchive::open(&type_archive_path).expect("Opened type archive");
+ let test_type = type_archive
+ .get_type_by_name("test".into())
+ .expect("Found test type");
+ assert_eq!(test_type.width(), 7);
+ assert_eq!(test_type.type_class(), TypeClass::IntegerTypeClass);
}