From 0f4bfc4eacb46d061a3a6fd1faf0efee38d5b90e Mon Sep 17 00:00:00 2001 From: Derek Benson Date: Tue, 10 Sep 2024 08:26:29 -0700 Subject: [PATCH] Migrate upb/rust to gtest PiperOrigin-RevId: 672974055 --- rust/upb/BUILD | 3 +++ rust/upb/arena.rs | 7 ++++--- rust/upb/array.rs | 5 +++-- rust/upb/map.rs | 5 +++-- rust/upb/message.rs | 3 ++- rust/upb/mini_table.rs | 3 ++- rust/upb/owned_arena_box.rs | 7 ++++--- rust/upb/text.rs | 3 ++- rust/upb/wire.rs | 3 ++- 9 files changed, 25 insertions(+), 14 deletions(-) diff --git a/rust/upb/BUILD b/rust/upb/BUILD index f9b35ba3aa..0904bd668e 100644 --- a/rust/upb/BUILD +++ b/rust/upb/BUILD @@ -39,6 +39,9 @@ rust_library( rust_test( name = "upb_rs_crate_test", crate = ":upb", + deps = [ + "@crate_index//:googletest", + ], ) cc_library( diff --git a/rust/upb/arena.rs b/rust/upb/arena.rs index ebecac9dd8..bd103c5a2d 100644 --- a/rust/upb/arena.rs +++ b/rust/upb/arena.rs @@ -204,8 +204,9 @@ extern "C" { #[cfg(test)] mod tests { use super::*; + use googletest::gtest; - #[test] + #[gtest] fn assert_arena_linked() { use super::super::assert_linked; assert_linked!(upb_Arena_New); @@ -214,7 +215,7 @@ mod tests { assert_linked!(upb_Arena_Fuse); } - #[test] + #[gtest] fn raw_ffi_test() { // SAFETY: FFI unit test uses C API under expected patterns. unsafe { @@ -225,7 +226,7 @@ mod tests { } } - #[test] + #[gtest] fn test_arena_new_and_free() { let arena = Arena::new(); drop(arena); diff --git a/rust/upb/array.rs b/rust/upb/array.rs index 8c2962424d..b4b8e822b5 100644 --- a/rust/upb/array.rs +++ b/rust/upb/array.rs @@ -29,8 +29,9 @@ extern "C" { mod tests { use super::super::Arena; use super::*; + use googletest::gtest; - #[test] + #[gtest] fn assert_array_linked() { use super::super::assert_linked; assert_linked!(upb_Array_New); @@ -45,7 +46,7 @@ mod tests { assert_linked!(upb_Array_GetMutable); } - #[test] + #[gtest] fn array_ffi_test() { // SAFETY: FFI unit test uses C API under expected patterns. unsafe { diff --git a/rust/upb/map.rs b/rust/upb/map.rs index 7b04d7a8a4..db8e132b4e 100644 --- a/rust/upb/map.rs +++ b/rust/upb/map.rs @@ -51,8 +51,9 @@ extern "C" { mod tests { use super::super::Arena; use super::*; + use googletest::gtest; - #[test] + #[gtest] fn assert_map_linked() { use super::super::assert_linked; assert_linked!(upb_Map_New); @@ -64,7 +65,7 @@ mod tests { assert_linked!(upb_Map_Next); } - #[test] + #[gtest] fn map_ffi_test() { // SAFETY: FFI unit test uses C API under expected patterns. unsafe { diff --git a/rust/upb/message.rs b/rust/upb/message.rs index fa94955d6f..e3388b167e 100644 --- a/rust/upb/message.rs +++ b/rust/upb/message.rs @@ -306,8 +306,9 @@ extern "C" { #[cfg(test)] mod tests { use super::*; + use googletest::gtest; - #[test] + #[gtest] fn assert_message_linked() { use super::super::assert_linked; assert_linked!(upb_Message_New); diff --git a/rust/upb/mini_table.rs b/rust/upb/mini_table.rs index e505834c44..683936672c 100644 --- a/rust/upb/mini_table.rs +++ b/rust/upb/mini_table.rs @@ -50,8 +50,9 @@ extern "C" { #[cfg(test)] mod tests { use super::*; + use googletest::gtest; - #[test] + #[gtest] fn assert_mini_table_linked() { use super::super::assert_linked; assert_linked!(upb_MiniTable_FindFieldByNumber); diff --git a/rust/upb/owned_arena_box.rs b/rust/upb/owned_arena_box.rs index 6cfc8e76c6..956c76a52b 100644 --- a/rust/upb/owned_arena_box.rs +++ b/rust/upb/owned_arena_box.rs @@ -88,8 +88,9 @@ impl Debug for OwnedArenaBox { mod tests { use super::*; use core::str; + use googletest::gtest; - #[test] + #[gtest] fn test_byte_slice_pointer_roundtrip() { let arena = Arena::new(); let original_data: &'static [u8] = b"Hello world"; @@ -97,7 +98,7 @@ mod tests { assert_eq!(&*owned_data, b"Hello world"); } - #[test] + #[gtest] fn test_alloc_str_roundtrip() { let arena = Arena::new(); let s: &str = "Hello"; @@ -106,7 +107,7 @@ mod tests { assert_eq!(&*owned_data, s); } - #[test] + #[gtest] fn test_sized_type_roundtrip() { let arena = Arena::new(); let arena_alloc_u32: NonNull = arena.copy_in(&7u32).unwrap().into(); diff --git a/rust/upb/text.rs b/rust/upb/text.rs index 11ca752c57..96cbd6516d 100644 --- a/rust/upb/text.rs +++ b/rust/upb/text.rs @@ -68,8 +68,9 @@ pub unsafe fn debug_string(msg: RawMessage, mt: *const upb_MiniTable) -> String #[cfg(test)] mod tests { use super::*; + use googletest::gtest; - #[test] + #[gtest] fn assert_text_linked() { use super::super::assert_linked; assert_linked!(upb_DebugString); diff --git a/rust/upb/wire.rs b/rust/upb/wire.rs index ed3ce39934..439899270f 100644 --- a/rust/upb/wire.rs +++ b/rust/upb/wire.rs @@ -126,8 +126,9 @@ extern "C" { #[cfg(test)] mod tests { use super::*; + use googletest::gtest; - #[test] + #[gtest] fn assert_wire_linked() { use super::super::assert_linked; assert_linked!(upb_Encode);