diff options
Diffstat (limited to 'rust/tests')
| -rw-r--r-- | rust/tests/collaboration.rs | 16 | ||||
| -rw-r--r-- | rust/tests/debug_info.rs | 2 | ||||
| -rw-r--r-- | rust/tests/initialization.rs | 2 | ||||
| -rw-r--r-- | rust/tests/project.rs | 6 | ||||
| -rw-r--r-- | rust/tests/repository.rs | 4 | ||||
| -rw-r--r-- | rust/tests/type_container.rs | 2 | ||||
| -rw-r--r-- | rust/tests/types.rs | 2 | ||||
| -rw-r--r-- | rust/tests/websocket.rs | 19 |
8 files changed, 29 insertions, 24 deletions
diff --git a/rust/tests/collaboration.rs b/rust/tests/collaboration.rs index 210492e4..3526a6f8 100644 --- a/rust/tests/collaboration.rs +++ b/rust/tests/collaboration.rs @@ -109,7 +109,7 @@ fn test_project_creation() { .expect("Failed to delete file"); assert!( !project - .get_file_by_id(created_file_id) + .get_file_by_id(&created_file_id) .is_ok_and(|f| f.is_some()), "File was not deleted" ); @@ -136,7 +136,7 @@ fn test_project_creation() { let created_folder_file_id = created_folder_file.id(); // Verify the file exists in the folder. let check_folder_file = project - .get_file_by_id(created_folder_file_id) + .get_file_by_id(&created_folder_file_id) .expect("Failed to get folder file by id") .unwrap(); assert_eq!(check_folder_file.name().as_str(), "test_folder_file"); @@ -155,7 +155,7 @@ fn test_project_creation() { .expect("Failed to delete folder"); assert!( !project - .get_folder_by_id(created_folder_id) + .get_folder_by_id(&created_folder_id) .is_ok_and(|f| f.is_some()), "Folder was not deleted" ); @@ -190,7 +190,7 @@ fn test_project_sync() { SymbolBuilder::new(SymbolType::Function, "test", entry_function.start()).create(); view.define_user_symbol(&new_entry_func_symbol); // Verify that we modified the binary - assert_eq!(entry_function.symbol().raw_name().as_str(), "test"); + assert_eq!(entry_function.symbol().raw_name(), "test".into()); // Make new snapshot. assert!(view.file().save_auto_snapshot()); // We should have two snapshots. @@ -210,20 +210,20 @@ fn test_project_sync() { drop(view); // Verify that the remote file exists. project - .get_file_by_id(remote_file.id()) + .get_file_by_id(&remote_file.id()) .expect("Failed to get remote file by id"); // Download the remote database with our changes. let downloaded_file = remote_file - .download_database(out_dir.join("downloaded_atox.obj.bndb")) + .download_database(&out_dir.join("downloaded_atox.obj.bndb")) .expect("Failed to download database"); let downloaded_view = downloaded_file - .view_of_type(view_type) + .view_of_type(&view_type) .expect("Failed to open downloaded view"); // Verify the changes in the entry function. let entry_function = downloaded_view .entry_point_function() .expect("Failed to get entry point function"); - assert_eq!(entry_function.symbol().raw_name().as_str(), "test"); + assert_eq!(entry_function.symbol().raw_name(), "test".into()); project .delete_file(&remote_file) .expect("Failed to delete file"); diff --git a/rust/tests/debug_info.rs b/rust/tests/debug_info.rs index 8b83363b..407b41d5 100644 --- a/rust/tests/debug_info.rs +++ b/rust/tests/debug_info.rs @@ -69,7 +69,7 @@ fn test_debug_info() { let func = view .function_at(&view.default_platform().unwrap(), 0x3b440) .expect("Debug info test function exists"); - assert_eq!(func.symbol().raw_name().to_string(), "test_func"); + assert_eq!(func.symbol().raw_name().to_string_lossy(), "test_func"); view.file().close(); } diff --git a/rust/tests/initialization.rs b/rust/tests/initialization.rs index 7ec52598..00063215 100644 --- a/rust/tests/initialization.rs +++ b/rust/tests/initialization.rs @@ -23,7 +23,7 @@ fn test_license_validation() { Err(e) => panic!("Unexpected error: {:?}", e), } // Reset the license so that it actually can validate license. - set_license::<String>(None); + set_license(None); // Actually make sure we can initialize. init().expect("Failed to initialize, make sure you have a license before trying to run tests!"); // Open an empty binary and make sure it succeeds. diff --git a/rust/tests/project.rs b/rust/tests/project.rs index f7d49bad..0b03e647 100644 --- a/rust/tests/project.rs +++ b/rust/tests/project.rs @@ -152,7 +152,7 @@ fn modify_project() { .unwrap(); assert_eq!(project.folders().unwrap().len(), 5); - let last_folder = project.folder_by_id(folder_5.id()).unwrap(); + let last_folder = project.folder_by_id(&folder_5.id()).unwrap(); project.delete_folder(&last_folder).unwrap(); assert_eq!(project.folders().unwrap().len(), 4); drop(folder_5); @@ -245,8 +245,8 @@ fn modify_project() { .unwrap(); assert_eq!(project.files().len(), 10); - let file_a = project.file_by_id(file_8.id()).unwrap(); - let file_b = project.file_by_path(file_7.path_on_disk()).unwrap(); + let file_a = project.file_by_id(&file_8.id()).unwrap(); + let file_b = project.file_by_path(&file_7.path_on_disk()).unwrap(); project.delete_file(&file_a); project.delete_file(&file_b); assert_eq!(project.files().len(), 8); diff --git a/rust/tests/repository.rs b/rust/tests/repository.rs index b1efee11..ac861b2c 100644 --- a/rust/tests/repository.rs +++ b/rust/tests/repository.rs @@ -8,7 +8,7 @@ fn test_list() { let repositories = manager.repositories(); for repository in &repositories { let repo_path = repository.path(); - let repository_by_path = manager.repository_by_path(repo_path).unwrap(); + let repository_by_path = manager.repository_by_path(&repo_path).unwrap(); assert_eq!(repository.url(), repository_by_path.url()); } @@ -19,7 +19,7 @@ fn test_list() { let plugins = repository.plugins(); for plugin in &plugins { let plugin_path = plugin.path(); - let plugin_by_path = repository.plugin_by_path(plugin_path).unwrap(); + let plugin_by_path = repository.plugin_by_path(&plugin_path).unwrap(); assert_eq!(plugin.package_url(), plugin_by_path.package_url()); } } diff --git a/rust/tests/type_container.rs b/rust/tests/type_container.rs index 4a017541..96f3bc4a 100644 --- a/rust/tests/type_container.rs +++ b/rust/tests/type_container.rs @@ -49,7 +49,7 @@ fn test_add_delete_type() { .type_id("mytype") .expect("mytype not found"); assert!( - view_type_container.delete_type(my_type_id), + view_type_container.delete_type(&my_type_id), "Type was deleted!" ); // There should be no type ids if the type was actually deleted diff --git a/rust/tests/types.rs b/rust/tests/types.rs index 4ed4caf7..17682777 100644 --- a/rust/tests/types.rs +++ b/rust/tests/types.rs @@ -65,7 +65,7 @@ fn add_type_to_view() { empty_view.define_auto_type("test", "me", &test_type); assert!(empty_view.type_by_name("test").is_some()); empty_view.undefine_auto_type( - empty_view + &empty_view .type_id_by_name("test") .expect("Failed to get type id"), ); diff --git a/rust/tests/websocket.rs b/rust/tests/websocket.rs index c5cf6be4..2c25a810 100644 --- a/rust/tests/websocket.rs +++ b/rust/tests/websocket.rs @@ -1,6 +1,5 @@ use binaryninja::headless::Session; use binaryninja::rc::Ref; -use binaryninja::string::IntoCStr; use binaryninja::websocket::{ register_websocket_provider, CoreWebsocketClient, CoreWebsocketProvider, WebsocketClient, WebsocketClientCallback, WebsocketProvider, @@ -31,11 +30,9 @@ impl WebsocketClient for MyWebsocketClient { Self { core } } - fn connect<I, K, V>(&self, host: &str, _headers: I) -> bool + fn connect<I>(&self, host: &str, _headers: I) -> bool where - I: IntoIterator<Item = (K, V)>, - K: IntoCStr, - V: IntoCStr, + I: IntoIterator<Item = (String, String)>, { assert_eq!(host, "url"); true @@ -89,7 +86,11 @@ fn reg_websocket_provider() { let provider = register_websocket_provider::<MyWebsocketProvider>("RustWebsocketProvider"); let client = provider.create_client().unwrap(); let mut callback = MyClientCallbacks::default(); - let success = client.initialize_connection("url", [("header", "value")], &mut callback); + let success = client.initialize_connection( + "url", + [("header".to_string(), "value".to_string())], + &mut callback, + ); assert!(success, "Failed to initialize connection!"); } @@ -100,7 +101,11 @@ fn listen_websocket_provider() { let client = provider.create_client().unwrap(); let mut callback = MyClientCallbacks::default(); - client.initialize_connection("url", [("header", "value")], &mut callback); + client.initialize_connection( + "url", + [("header".to_string(), "value".to_string())], + &mut callback, + ); assert!(client.write("test1".as_bytes())); assert!(client.write("test2".as_bytes())); |
