From 0a917b95f27bab71caa49f0ebe88931189260044 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko <dmitrig@google.com> Date: Mon, 22 Jul 2024 06:50:36 -0700 Subject: [PATCH] Use `#[googletest::test]` in Protobuf Rust PiperOrigin-RevId: 654726974 --- rust/cpp.rs | 4 +- rust/map.rs | 16 ++-- rust/proxied.rs | 14 +-- rust/repeated.rs | 6 +- rust/string.rs | 12 +-- rust/test/cpp/debug_test.rs | 6 +- rust/test/cpp/interop/main.rs | 14 +-- rust/test/shared/BUILD | 14 ++- rust/test/shared/accessors_map_test.rs | 14 +-- rust/test/shared/accessors_proto3_test.rs | 28 +++--- rust/test/shared/accessors_repeated_test.rs | 22 ++--- rust/test/shared/accessors_test.rs | 94 +++++++++---------- rust/test/shared/bad_names_test.rs | 6 +- rust/test/shared/child_parent_test.rs | 6 +- rust/test/shared/edition2023_test.rs | 6 +- rust/test/shared/enum_test.rs | 28 +++--- .../shared/fields_with_imported_types_test.rs | 6 +- rust/test/shared/import_public_test.rs | 2 +- rust/test/shared/merge_from_test.rs | 10 +- rust/test/shared/nested_types_test.rs | 4 +- rust/test/shared/package_test.rs | 4 +- rust/test/shared/proto_macro_test.rs | 14 +-- rust/test/shared/serialization_test.rs | 14 +-- rust/test/shared/simple_nested_test.rs | 14 +-- rust/test/shared/utf8/utf8_test.rs | 6 +- rust/test/upb/debug_string_test.rs | 2 +- rust/test/upb/string_ctypes_test.rs | 6 +- 27 files changed, 191 insertions(+), 181 deletions(-) diff --git a/rust/cpp.rs b/rust/cpp.rs index d8e4df041a..f852dfdfbc 100644 --- a/rust/cpp.rs +++ b/rust/cpp.rs @@ -899,14 +899,14 @@ mod tests { (content.as_mut_ptr(), content.len()) } - #[test] + #[googletest::test] fn test_serialized_data_roundtrip() { let (ptr, len) = allocate_byte_array(b"Hello world"); let serialized_data = SerializedData { data: NonNull::new(ptr).unwrap(), len }; assert_that!(&*serialized_data, eq(b"Hello world")); } - #[test] + #[googletest::test] fn test_empty_string() { let empty_str: String = RustStringRawParts { data: std::ptr::null(), len: 0 }.into(); assert_that!(empty_str, eq("")); diff --git a/rust/map.rs b/rust/map.rs index a0e0c9e449..170f50c97d 100644 --- a/rust/map.rs +++ b/rust/map.rs @@ -464,7 +464,7 @@ mod tests { use crate::{ProtoBytes, ProtoStr, ProtoString}; use googletest::prelude::*; - #[test] + #[googletest::test] fn test_proxied_scalar() { let mut map: Map<i32, i64> = Map::new(); let mut map_mut = map.as_mut(); @@ -490,7 +490,7 @@ mod tests { assert_that!(map_view_4.is_empty(), eq(false)); } - #[test] + #[googletest::test] fn test_proxied_str() { let mut map: Map<ProtoString, ProtoString> = Map::new(); let mut map_mut = map.as_mut(); @@ -515,7 +515,7 @@ mod tests { assert_that!(map_view_4.is_empty(), eq(false)); } - #[test] + #[googletest::test] fn test_proxied_iter() { let mut map: Map<i32, ProtoString> = Map::new(); let mut map_mut = map.as_mut(); @@ -562,7 +562,7 @@ mod tests { ); } - #[test] + #[googletest::test] fn test_overwrite_insert() { let mut map: Map<i32, ProtoString> = Map::new(); let mut map_mut = map.as_mut(); @@ -572,7 +572,7 @@ mod tests { assert_that!(map.as_mut(), unordered_elements_are![eq((0, ProtoStr::from_str("buzz"))),]); } - #[test] + #[googletest::test] fn test_extend() { let mut map: Map<i32, ProtoString> = Map::new(); let mut map_mut = map.as_mut(); @@ -609,7 +609,7 @@ mod tests { ); } - #[test] + #[googletest::test] fn test_copy_from() { let mut map: Map<i32, ProtoString> = Map::new(); let mut map_mut = map.as_mut(); @@ -640,7 +640,7 @@ mod tests { ); } - #[test] + #[googletest::test] fn test_all_maps_can_be_constructed() { macro_rules! gen_proto_values { ($key_t:ty, $($value_t:ty),*) => { @@ -662,7 +662,7 @@ mod tests { gen_proto_keys!(i32, u32, i64, u64, bool, ProtoString); } - #[test] + #[googletest::test] fn test_dbg() { let mut map = Map::<i32, f64>::new(); assert_that!(format!("{:?}", map.as_view()), eq("MapView(\"i32\", \"f64\")")); diff --git a/rust/proxied.rs b/rust/proxied.rs index e90dbe5805..5606824441 100644 --- a/rust/proxied.rs +++ b/rust/proxied.rs @@ -312,7 +312,7 @@ mod tests { } } - #[test] + #[googletest::test] fn test_as_view() { let my_proxied = MyProxied { val: "Hello World".to_string() }; @@ -327,7 +327,7 @@ mod tests { x.into_view() // OK: we return the same lifetime as we got in. } - #[test] + #[googletest::test] fn test_mut_into_view() { let mut my_proxied = MyProxied { val: "Hello World".to_string() }; reborrow_mut_into_view(my_proxied.as_mut()); @@ -335,7 +335,7 @@ mod tests { fn require_unified_lifetimes<'msg>(_x: Mut<'msg, MyProxied>, _y: View<'msg, MyProxied>) {} - #[test] + #[googletest::test] fn test_require_unified_lifetimes() { let mut my_proxied = MyProxied { val: "Hello1".to_string() }; let my_mut = my_proxied.as_mut(); @@ -360,7 +360,7 @@ mod tests { [x.as_view(), y.as_view()] } - #[test] + #[googletest::test] fn test_reborrow_generic_as_view() { let mut my_proxied = MyProxied { val: "Hello1".to_string() }; let mut my_mut = my_proxied.as_mut(); @@ -387,7 +387,7 @@ mod tests { [x.into_view(), y] } - #[test] + #[googletest::test] fn test_reborrow_generic_into_view() { let my_proxied = MyProxied { val: "Hello1".to_string() }; let my_view = my_proxied.as_view(); @@ -407,7 +407,7 @@ mod tests { [x.into_view(), y] } - #[test] + #[googletest::test] fn test_reborrow_generic_mut_into_view() { let mut my_proxied = MyProxied { val: "Hello1".to_string() }; let my_mut = my_proxied.as_mut(); @@ -430,7 +430,7 @@ mod tests { [x.into_mut(), y] } - #[test] + #[googletest::test] fn test_reborrow_generic_mut_into_mut() { let mut my_proxied = MyProxied { val: "Hello1".to_string() }; let my_mut = my_proxied.as_mut(); diff --git a/rust/repeated.rs b/rust/repeated.rs index 692a24971f..d7a02e4c5d 100644 --- a/rust/repeated.rs +++ b/rust/repeated.rs @@ -542,7 +542,7 @@ mod tests { use super::*; use googletest::prelude::*; - #[test] + #[googletest::test] fn test_primitive_repeated() { macro_rules! primitive_repeated_tests { ($($t:ty => [$($vals:expr),* $(,)?]),* $(,)?) => { @@ -583,7 +583,7 @@ mod tests { ); } - #[test] + #[googletest::test] fn test_repeated_extend() { let mut r = Repeated::<i32>::new(); @@ -600,7 +600,7 @@ mod tests { assert_that!(r.as_mut(), elements_are![eq(0), eq(1), eq(2), eq(3)]); } - #[test] + #[googletest::test] fn test_repeated_iter_into_proxied() { let r: Repeated<i32> = [0, 1, 2, 3].into_iter().into_proxied(Private); assert_that!(r.as_view(), elements_are![eq(0), eq(1), eq(2), eq(3)]); diff --git a/rust/string.rs b/rust/string.rs index 6ebdd37af1..e3b8365b40 100644 --- a/rust/string.rs +++ b/rust/string.rs @@ -545,7 +545,7 @@ mod tests { // UTF-8 test cases copied from: // https://github.com/rust-lang/rust/blob/e8ee0b7/library/core/tests/str_lossy.rs - #[test] + #[googletest::test] fn proto_str_debug() { assert_eq!(&format!("{:?}", test_proto_str(b"Hello There")), "\"Hello There\""); assert_eq!( @@ -557,7 +557,7 @@ mod tests { ); } - #[test] + #[googletest::test] fn proto_str_display() { assert_eq!(&test_proto_str(b"Hello There").to_string(), "Hello There"); assert_eq!( @@ -566,7 +566,7 @@ mod tests { ); } - #[test] + #[googletest::test] fn proto_str_to_rust_str() { assert_eq!(test_proto_str(b"hello").to_str(), Ok("hello")); assert_eq!(test_proto_str("ศไทย中华Việt Nam".as_bytes()).to_str(), Ok("ศไทย中华Việt Nam")); @@ -583,7 +583,7 @@ mod tests { } } - #[test] + #[googletest::test] fn proto_str_to_cow() { assert_eq!(test_proto_str(b"hello").to_cow_lossy(), Cow::Borrowed("hello")); assert_eq!( @@ -605,7 +605,7 @@ mod tests { } } - #[test] + #[googletest::test] fn proto_str_utf8_chunks() { macro_rules! assert_chunks { ($bytes:expr, $($chunks:expr),* $(,)?) => { @@ -684,7 +684,7 @@ mod tests { ); } - #[test] + #[googletest::test] fn proto_str_chars() { macro_rules! assert_chars { ($bytes:expr, $chars:expr) => { diff --git a/rust/test/cpp/debug_test.rs b/rust/test/cpp/debug_test.rs index 82b2d1b773..2b784a9a9b 100644 --- a/rust/test/cpp/debug_test.rs +++ b/rust/test/cpp/debug_test.rs @@ -3,7 +3,7 @@ use googletest::prelude::*; use optimize_for_lite_rust_proto::OptimizeForLiteTestMessage; #[cfg(not(lite_runtime))] -#[test] +#[googletest::test] fn test_debug() { let mut msg = DebugMsg::new(); msg.set_id(1); @@ -14,7 +14,7 @@ fn test_debug() { } #[cfg(lite_runtime)] -#[test] +#[googletest::test] fn test_debug_lite() { let mut msg = DebugMsg::new(); msg.set_id(1); @@ -27,7 +27,7 @@ fn test_debug_lite() { /// A message with the option set to optimize for lite will behave as a lite /// message regardless of the `lite_runtime` feature. Run this test not guarded /// by the cfg(lite_runtime) and ensure it functions as lite. -#[test] +#[googletest::test] fn test_optimize_for_lite_option() { let mut msg = OptimizeForLiteTestMessage::new(); msg.set_value("password"); diff --git a/rust/test/cpp/interop/main.rs b/rust/test/cpp/interop/main.rs index 812dab3a59..93ec9e9f0e 100644 --- a/rust/test/cpp/interop/main.rs +++ b/rust/test/cpp/interop/main.rs @@ -33,7 +33,7 @@ extern "C" { fn GetBytesExtension(msg: RawMessage) -> PtrAndLen; } -#[test] +#[googletest::test] fn send_to_cpp() { let mut msg1 = TestAllTypes::new(); msg1.set_optional_int32(7); @@ -43,7 +43,7 @@ fn send_to_cpp() { assert_eq!(i, 7); } -#[test] +#[googletest::test] fn mutate_message_mut_in_cpp() { let mut msg1 = TestAllTypes::new(); unsafe { @@ -58,7 +58,7 @@ fn mutate_message_mut_in_cpp() { proto_assert_eq!(msg1, msg2); } -#[test] +#[googletest::test] fn deserialize_in_rust() { let mut msg1 = TestAllTypes::new(); msg1.set_optional_int64(-1); @@ -71,7 +71,7 @@ fn deserialize_in_rust() { proto_assert_eq!(msg1, msg2); } -#[test] +#[googletest::test] fn deserialize_in_cpp() { let mut msg1 = TestAllTypes::new(); msg1.set_optional_int64(-1); @@ -88,7 +88,7 @@ fn deserialize_in_cpp() { proto_assert_eq!(msg1, msg2); } -#[test] +#[googletest::test] fn deserialize_in_cpp_into_mut() { let mut msg1 = TestAllTypes::new(); msg1.set_optional_int64(-1); @@ -106,7 +106,7 @@ fn deserialize_in_cpp_into_mut() { } } -#[test] +#[googletest::test] fn deserialize_in_cpp_into_view() { let mut msg1 = TestAllTypes::new(); msg1.set_optional_int64(-1); @@ -126,7 +126,7 @@ fn deserialize_in_cpp_into_view() { // This test ensures that random fields we (Rust) don't know about don't // accidentally get destroyed by Rust. -#[test] +#[googletest::test] fn smuggle_extension() { let msg1 = unsafe { TestAllExtensions::__unstable_wrap_cpp_grant_permission_to_break(NewWithExtension()) diff --git a/rust/test/shared/BUILD b/rust/test/shared/BUILD index af009e9c08..e39ee34976 100644 --- a/rust/test/shared/BUILD +++ b/rust/test/shared/BUILD @@ -87,6 +87,7 @@ rust_test( srcs = ["import_public_test.rs"], deps = [ "//rust/test:import_public_cpp_rust_proto", + "@crate_index//:googletest", ], ) @@ -95,6 +96,7 @@ rust_test( srcs = ["import_public_test.rs"], deps = [ "//rust/test:import_public_upb_rust_proto", + "@crate_index//:googletest", ], ) @@ -105,6 +107,7 @@ rust_test( "//rust/test:dots_in_package_cpp_rust_proto", "//rust/test:no_package_cpp_rust_proto", "//rust/test:package_cpp_rust_proto", + "@crate_index//:googletest", ], ) @@ -115,6 +118,7 @@ rust_test( "//rust/test:dots_in_package_upb_rust_proto", "//rust/test:no_package_upb_rust_proto", "//rust/test:package_upb_rust_proto", + "@crate_index//:googletest", ], ) @@ -155,13 +159,19 @@ rust_test( rust_test( name = "nested_types_cpp_test", srcs = ["nested_types_test.rs"], - deps = ["//rust/test:unittest_cpp_rust_proto"], + deps = [ + "//rust/test:unittest_cpp_rust_proto", + "@crate_index//:googletest", + ], ) rust_test( name = "nested_types_upb_test", srcs = ["nested_types_test.rs"], - deps = ["//rust/test:unittest_upb_rust_proto"], + deps = [ + "//rust/test:unittest_upb_rust_proto", + "@crate_index//:googletest", + ], ) rust_test( diff --git a/rust/test/shared/accessors_map_test.rs b/rust/test/shared/accessors_map_test.rs index 26a309de28..b284a24752 100644 --- a/rust/test/shared/accessors_map_test.rs +++ b/rust/test/shared/accessors_map_test.rs @@ -19,7 +19,7 @@ macro_rules! generate_map_primitives_tests { $(,)? ) => { paste! { $( - #[test] + #[googletest::test] fn [< test_map_ $k_field _ $v_field >]() { let mut msg = TestMap::new(); assert_that!(msg.[< map_ $k_field _ $v_field >]().len(), eq(0)); @@ -95,7 +95,7 @@ generate_map_primitives_tests!( (i32, MapEnum, int32, enum, 1, MapEnum::Baz), ); -#[test] +#[googletest::test] fn collect_as_hashmap() { // Highlights conversion from protobuf map to hashmap. let mut msg = TestMap::new(); @@ -114,7 +114,7 @@ fn collect_as_hashmap() { ); } -#[test] +#[googletest::test] fn test_string_maps() { let mut msg = TestMap::new(); msg.map_string_string_mut().insert("hello", "world"); @@ -126,7 +126,7 @@ fn test_string_maps() { assert_that!(msg.map_string_string().len(), eq(0)); } -#[test] +#[googletest::test] fn test_nested_enum_maps() { // Verify that C++ thunks are generated and are with the right name for strings TestMapWithNestedEnum::new() @@ -134,7 +134,7 @@ fn test_nested_enum_maps() { .insert("foo", test_map_with_nested_enum::inner_nested::NestedEnum::Foo); } -#[test] +#[googletest::test] fn test_bytes_and_string_copied() { let mut msg = TestMap::new(); @@ -154,7 +154,7 @@ fn test_bytes_and_string_copied() { assert_that!(msg.map_int32_bytes_mut().get(1).unwrap(), eq(b"world")); } -#[test] +#[googletest::test] fn test_map_setter() { let mut msg = TestMap::new(); msg.map_string_string_mut().insert("hello", "world"); @@ -177,7 +177,7 @@ macro_rules! generate_map_with_msg_values_tests { $(,)? ) => { paste! { $( - #[test] + #[googletest::test] fn [< test_map_ $k_field _all_types >]() { // We need to cover the following upb/c++ thunks: // TODO - b/323883851: Add test once Map::new is public. diff --git a/rust/test/shared/accessors_proto3_test.rs b/rust/test/shared/accessors_proto3_test.rs index f4096ea43a..63aaf1acf5 100644 --- a/rust/test/shared/accessors_proto3_test.rs +++ b/rust/test/shared/accessors_proto3_test.rs @@ -12,7 +12,7 @@ use protobuf::Optional; use unittest_proto3_optional_rust_proto::{test_proto3_optional, TestProto3Optional}; use unittest_proto3_rust_proto::{test_all_types, TestAllTypes}; -#[test] +#[googletest::test] fn test_fixed32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_fixed32(), eq(0)); @@ -27,7 +27,7 @@ fn test_fixed32_accessors() { assert_that!(msg.optional_fixed32(), eq(43)); } -#[test] +#[googletest::test] fn test_bool_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_bool(), eq(false)); @@ -39,7 +39,7 @@ fn test_bool_accessors() { assert_that!(msg.optional_bool(), eq(false)); } -#[test] +#[googletest::test] fn test_bytes_accessors() { let mut msg = TestAllTypes::new(); // Note: even though it's named 'optional_bytes', the field is actually not @@ -59,7 +59,7 @@ fn test_bytes_accessors() { assert_that!(*msg.optional_bytes(), empty()); } -#[test] +#[googletest::test] fn test_optional_bytes_accessors() { let mut msg = TestProto3Optional::new(); assert_that!(*msg.optional_bytes(), empty()); @@ -81,7 +81,7 @@ fn test_optional_bytes_accessors() { assert_that!(msg.optional_bytes_opt(), eq(Optional::Set(&b"\xffbinary\x85non-utf8"[..]))); } -#[test] +#[googletest::test] fn test_string_accessors() { let mut msg = TestAllTypes::new(); // Note: even though it's named 'optional_string', the field is actually not @@ -101,7 +101,7 @@ fn test_string_accessors() { assert_that!(*msg.optional_string().as_bytes(), empty()); } -#[test] +#[googletest::test] fn test_optional_string_accessors() { let mut msg = TestProto3Optional::new(); assert_that!(*msg.optional_string().as_bytes(), empty()); @@ -123,7 +123,7 @@ fn test_optional_string_accessors() { assert_that!(msg.optional_string_opt(), eq(Optional::Set("".into()))); } -#[test] +#[googletest::test] fn test_nested_enum_accessors() { use test_all_types::NestedEnum; @@ -137,7 +137,7 @@ fn test_nested_enum_accessors() { assert_that!(msg.optional_nested_enum(), eq(NestedEnum::Zero)); } -#[test] +#[googletest::test] fn test_optional_nested_enum_accessors() { use test_proto3_optional::NestedEnum; @@ -154,7 +154,7 @@ fn test_optional_nested_enum_accessors() { assert_that!(msg.optional_nested_enum_opt(), eq(Optional::Set(NestedEnum::Unspecified))); } -#[test] +#[googletest::test] fn test_foreign_enum_accessors() { use unittest_proto3_rust_proto::ForeignEnum; @@ -168,7 +168,7 @@ fn test_foreign_enum_accessors() { assert_that!(msg.optional_foreign_enum(), eq(ForeignEnum::ForeignZero)); } -#[test] +#[googletest::test] fn test_oneof_accessors() { use test_all_types::OneofField::*; @@ -197,7 +197,7 @@ fn test_oneof_accessors() { assert_that!(msg.oneof_field(), matches_pattern!(not_set(_))); } -#[test] +#[googletest::test] fn test_oneof_accessors_view_long_lifetime() { use test_all_types::OneofField::*; @@ -213,7 +213,7 @@ fn test_oneof_accessors_view_long_lifetime() { assert_that!(oneof, matches_pattern!(OneofUint32(eq(7)))); } -#[test] +#[googletest::test] fn test_oneof_enum_accessors() { use unittest_proto3_rust_proto::{ test_oneof2::{Foo, FooCase, NestedEnum}, @@ -231,7 +231,7 @@ fn test_oneof_enum_accessors() { assert_that!(msg.foo_case(), matches_pattern!(FooCase::FooEnum)); } -#[test] +#[googletest::test] fn test_submsg_setter() { use test_all_types::*; @@ -244,7 +244,7 @@ fn test_submsg_setter() { assert_that!(parent.optional_nested_message().bb(), eq(7)); } -#[test] +#[googletest::test] fn test_ctype_stringpiece() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_string_piece(), eq("")); diff --git a/rust/test/shared/accessors_repeated_test.rs b/rust/test/shared/accessors_repeated_test.rs index bfec487ce9..8898d9c096 100644 --- a/rust/test/shared/accessors_repeated_test.rs +++ b/rust/test/shared/accessors_repeated_test.rs @@ -13,7 +13,7 @@ use unittest_rust_proto::{test_all_types, test_all_types::NestedMessage, TestAll macro_rules! generate_repeated_numeric_test { ($(($t: ty, $field: ident)),*) => { paste! { $( - #[test] + #[googletest::test] fn [< test_repeated_ $field _accessors >]() { let mut msg = TestAllTypes::new(); assert_that!(msg.[< repeated_ $field >](), empty()); @@ -52,7 +52,7 @@ macro_rules! generate_repeated_numeric_test { ); } - #[test] + #[googletest::test] fn [< test_repeated_ $field _set >]() { let mut msg = TestAllTypes::new(); let mut msg2 = TestAllTypes::new(); @@ -70,7 +70,7 @@ macro_rules! generate_repeated_numeric_test { ); } - #[test] + #[googletest::test] fn [< test_repeated_ $field _exact_size_iterator >]() { let mut msg = TestAllTypes::new(); let mut mutator = msg.[<repeated_ $field _mut>](); @@ -104,7 +104,7 @@ generate_repeated_numeric_test!( (f64, double) ); -#[test] +#[googletest::test] fn test_repeated_bool_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.repeated_bool(), empty()); @@ -134,7 +134,7 @@ fn test_repeated_bool_accessors() { assert_that!(msg.repeated_bool(), each(eq(false))); } -#[test] +#[googletest::test] fn test_repeated_enum_accessors() { use test_all_types::NestedEnum; @@ -172,7 +172,7 @@ fn test_repeated_enum_accessors() { assert_that!(msg.repeated_nested_enum(), each(eq(NestedEnum::Foo))); } -#[test] +#[googletest::test] fn test_repeated_enum_set() { use test_all_types::NestedEnum; @@ -184,7 +184,7 @@ fn test_repeated_enum_set() { ); } -#[test] +#[googletest::test] fn test_repeated_bool_set() { let mut msg = TestAllTypes::new(); let mut msg2 = TestAllTypes::new(); @@ -199,7 +199,7 @@ fn test_repeated_bool_set() { assert_that!(&view.iter().collect::<Vec<_>>(), eq(&mutator2.iter().collect::<Vec<_>>())); } -#[test] +#[googletest::test] fn test_repeated_message() { let mut msg = TestAllTypes::new(); assert_that!(msg.repeated_nested_message().len(), eq(0)); @@ -230,7 +230,7 @@ fn test_repeated_message() { assert_that!(msg2.repeated_nested_message().len(), eq(0)); } -#[test] +#[googletest::test] fn test_repeated_message_setter() { let mut msg = TestAllTypes::new(); let mut nested = NestedMessage::new(); @@ -239,7 +239,7 @@ fn test_repeated_message_setter() { assert_that!(msg.repeated_nested_message().get(0).unwrap().bb(), eq(1)); } -#[test] +#[googletest::test] fn test_repeated_strings() { let mut older_msg = TestAllTypes::new(); { @@ -274,7 +274,7 @@ fn test_repeated_strings() { assert_that!(older_msg.repeated_string(), empty()); } -#[test] +#[googletest::test] fn test_repeated_bytes() { let mut older_msg = TestAllTypes::new(); { diff --git a/rust/test/shared/accessors_test.rs b/rust/test/shared/accessors_test.rs index c0365b1d9e..2a7795ec06 100644 --- a/rust/test/shared/accessors_test.rs +++ b/rust/test/shared/accessors_test.rs @@ -15,7 +15,7 @@ use std::rc::Rc; use std::sync::Arc; use unittest_rust_proto::{test_all_types, TestAllTypes}; -#[test] +#[googletest::test] fn test_default_accessors() { let msg: TestAllTypes = Default::default(); assert_that!( @@ -40,7 +40,7 @@ fn test_default_accessors() { assert_that!(msg.default_bytes(), eq("world".as_bytes())); } -#[test] +#[googletest::test] fn test_optional_fixed32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.has_optional_fixed32(), eq(false)); @@ -58,7 +58,7 @@ fn test_optional_fixed32_accessors() { assert_that!(msg.optional_fixed32(), eq(0)); } -#[test] +#[googletest::test] fn test_default_fixed32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_fixed32(), eq(47)); @@ -76,7 +76,7 @@ fn test_default_fixed32_accessors() { assert_that!(msg.default_fixed32_opt(), eq(Optional::Unset(47))); } -#[test] +#[googletest::test] fn test_optional_fixed64_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_fixed64_opt(), eq(Optional::Unset(0))); @@ -95,7 +95,7 @@ fn test_optional_fixed64_accessors() { assert_that!(msg.optional_fixed64(), eq(0)); } -#[test] +#[googletest::test] fn test_default_fixed64_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_fixed64(), eq(48)); @@ -114,7 +114,7 @@ fn test_default_fixed64_accessors() { assert_that!(msg.default_fixed64_opt(), eq(Optional::Unset(48))); } -#[test] +#[googletest::test] fn test_optional_int32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_int32_opt(), eq(Optional::Unset(0))); @@ -133,7 +133,7 @@ fn test_optional_int32_accessors() { assert_that!(msg.optional_int32(), eq(0)); } -#[test] +#[googletest::test] fn test_default_int32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_int32(), eq(41)); @@ -156,7 +156,7 @@ fn test_default_int32_accessors() { assert_that!(msg.default_int32_opt(), eq(Optional::Unset(41))); } -#[test] +#[googletest::test] fn test_optional_int64_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_int64_opt(), eq(Optional::Unset(0))); @@ -171,7 +171,7 @@ fn test_optional_int64_accessors() { assert_that!(msg.optional_int64(), eq(0)); } -#[test] +#[googletest::test] fn test_default_int64_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_int64(), eq(42)); @@ -186,7 +186,7 @@ fn test_default_int64_accessors() { assert_that!(msg.default_int64_opt(), eq(Optional::Unset(42))); } -#[test] +#[googletest::test] fn test_optional_sint32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_sint32_opt(), eq(Optional::Unset(0))); @@ -201,7 +201,7 @@ fn test_optional_sint32_accessors() { assert_that!(msg.optional_sint32(), eq(0)); } -#[test] +#[googletest::test] fn test_default_sint32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_sint32(), eq(-45)); @@ -216,7 +216,7 @@ fn test_default_sint32_accessors() { assert_that!(msg.default_sint32_opt(), eq(Optional::Unset(-45))); } -#[test] +#[googletest::test] fn test_optional_sint64_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_sint64_opt(), eq(Optional::Unset(0))); @@ -231,7 +231,7 @@ fn test_optional_sint64_accessors() { assert_that!(msg.optional_sint64(), eq(0)); } -#[test] +#[googletest::test] fn test_default_sint64_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_sint64(), eq(46)); @@ -246,7 +246,7 @@ fn test_default_sint64_accessors() { assert_that!(msg.default_sint64_opt(), eq(Optional::Unset(46))); } -#[test] +#[googletest::test] fn test_optional_uint32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_uint32_opt(), eq(Optional::Unset(0))); @@ -261,7 +261,7 @@ fn test_optional_uint32_accessors() { assert_that!(msg.optional_uint32(), eq(0)); } -#[test] +#[googletest::test] fn test_default_uint32_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_uint32(), eq(43)); @@ -276,7 +276,7 @@ fn test_default_uint32_accessors() { assert_that!(msg.default_uint32_opt(), eq(Optional::Unset(43))); } -#[test] +#[googletest::test] fn test_optional_uint64_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_uint64_opt(), eq(Optional::Unset(0))); @@ -291,7 +291,7 @@ fn test_optional_uint64_accessors() { assert_that!(msg.optional_uint64(), eq(0)); } -#[test] +#[googletest::test] fn test_default_uint64_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_uint64(), eq(44)); @@ -306,7 +306,7 @@ fn test_default_uint64_accessors() { assert_that!(msg.default_uint64_opt(), eq(Optional::Unset(44))); } -#[test] +#[googletest::test] fn test_optional_float_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_float_opt(), eq(Optional::Unset(0.0))); @@ -321,7 +321,7 @@ fn test_optional_float_accessors() { assert_that!(msg.optional_float(), eq(0.0)); } -#[test] +#[googletest::test] fn test_default_float_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_float(), eq(51.5)); @@ -336,7 +336,7 @@ fn test_default_float_accessors() { assert_that!(msg.default_float_opt(), eq(Optional::Unset(51.5))); } -#[test] +#[googletest::test] fn test_optional_double_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_double_opt(), eq(Optional::Unset(0.0))); @@ -351,7 +351,7 @@ fn test_optional_double_accessors() { assert_that!(msg.optional_double(), eq(0.0)); } -#[test] +#[googletest::test] fn test_default_double_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_double(), eq(52e3)); @@ -366,7 +366,7 @@ fn test_default_double_accessors() { assert_that!(msg.default_double_opt(), eq(Optional::Unset(52e3))); } -#[test] +#[googletest::test] fn test_optional_bool_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_bool_opt(), eq(Optional::Unset(false))); @@ -378,7 +378,7 @@ fn test_optional_bool_accessors() { assert_that!(msg.optional_bool_opt(), eq(Optional::Unset(false))); } -#[test] +#[googletest::test] fn test_default_bool_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_bool(), eq(true)); @@ -393,7 +393,7 @@ fn test_default_bool_accessors() { assert_that!(msg.default_bool_opt(), eq(Optional::Unset(true))); } -#[test] +#[googletest::test] fn test_optional_bytes_accessors() { let mut msg = TestAllTypes::new(); assert_that!(*msg.optional_bytes(), empty()); @@ -419,7 +419,7 @@ fn test_optional_bytes_accessors() { assert_that!(msg.optional_bytes_opt(), eq(Optional::Set(&b""[..]))); } -#[test] +#[googletest::test] fn test_into_proxied_for_bytes() { let mut msg = TestAllTypes::new(); @@ -461,7 +461,7 @@ fn test_into_proxied_for_bytes() { assert_that!(msg.optional_bytes(), eq(b"ninth")); } -#[test] +#[googletest::test] fn test_nonempty_default_bytes_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_bytes(), eq(b"world")); @@ -490,7 +490,7 @@ fn test_nonempty_default_bytes_accessors() { assert_that!(msg.default_bytes_opt(), eq(Optional::Unset(&b"world"[..]))); } -#[test] +#[googletest::test] fn test_optional_string_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_string(), eq("")); @@ -516,7 +516,7 @@ fn test_optional_string_accessors() { assert_that!(msg.optional_string_opt(), eq(Optional::Unset("".into()))); } -#[test] +#[googletest::test] fn test_into_proxied_for_string() { let mut msg = TestAllTypes::new(); @@ -565,7 +565,7 @@ fn test_into_proxied_for_string() { assert_that!(msg.optional_string(), eq("eleventh")); } -#[test] +#[googletest::test] fn test_nonempty_default_string_accessors() { let mut msg = TestAllTypes::new(); assert_that!(msg.default_string(), eq("hello")); @@ -591,7 +591,7 @@ fn test_nonempty_default_string_accessors() { assert_that!(msg.default_string_opt(), eq(Optional::Unset("hello".into()))); } -#[test] +#[googletest::test] fn test_singular_msg_field() { let mut msg = TestAllTypes::new(); let msg_view = msg.optional_nested_message(); @@ -606,7 +606,7 @@ fn test_singular_msg_field() { assert_that!(msg.has_optional_nested_message(), eq(true)); } -#[test] +#[googletest::test] fn test_message_opt() { let msg = TestAllTypes::new(); let opt: Optional<unittest_rust_proto::test_all_types::NestedMessageView<'_>> = @@ -615,7 +615,7 @@ fn test_message_opt() { assert_that!(opt.into_inner().bb(), eq(0)); } -#[test] +#[googletest::test] fn test_message_opt_set() { let mut msg = TestAllTypes::new(); let submsg = test_all_types::NestedMessage::new(); @@ -624,7 +624,7 @@ fn test_message_opt_set() { assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); } -#[test] +#[googletest::test] fn test_setting_submsg() { let mut msg = TestAllTypes::new(); let submsg = test_all_types::NestedMessage::new(); @@ -642,7 +642,7 @@ fn test_setting_submsg() { assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); } -#[test] +#[googletest::test] fn test_msg_mut_initializes() { let mut msg = TestAllTypes::new(); assert_that!(msg.has_optional_nested_message(), eq(false)); @@ -658,7 +658,7 @@ fn test_msg_mut_initializes() { assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); } -#[test] +#[googletest::test] fn test_optional_nested_enum_accessors() { use test_all_types::NestedEnum; @@ -678,7 +678,7 @@ fn test_optional_nested_enum_accessors() { assert_that!(msg.optional_nested_enum(), eq(NestedEnum::Foo)); } -#[test] +#[googletest::test] fn test_default_nested_enum_accessors() { use test_all_types::NestedEnum; @@ -695,7 +695,7 @@ fn test_default_nested_enum_accessors() { assert_that!(msg.default_nested_enum_opt(), eq(Optional::Unset(NestedEnum::Bar))); } -#[test] +#[googletest::test] fn test_optional_foreign_enum_accessors() { use unittest_rust_proto::ForeignEnum; @@ -712,7 +712,7 @@ fn test_optional_foreign_enum_accessors() { assert_that!(msg.optional_foreign_enum(), eq(ForeignEnum::ForeignFoo)); } -#[test] +#[googletest::test] fn test_default_foreign_enum_accessors() { use unittest_rust_proto::ForeignEnum; @@ -729,7 +729,7 @@ fn test_default_foreign_enum_accessors() { assert_that!(msg.default_foreign_enum_opt(), eq(Optional::Unset(ForeignEnum::ForeignBar))); } -#[test] +#[googletest::test] fn test_optional_import_enum_accessors() { use unittest_rust_proto::ImportEnum; @@ -746,7 +746,7 @@ fn test_optional_import_enum_accessors() { assert_that!(msg.optional_import_enum(), eq(ImportEnum::ImportFoo)); } -#[test] +#[googletest::test] fn test_default_import_enum_accessors() { use unittest_rust_proto::ImportEnum; @@ -763,7 +763,7 @@ fn test_default_import_enum_accessors() { assert_that!(msg.default_import_enum_opt(), eq(Optional::Unset(ImportEnum::ImportBar))); } -#[test] +#[googletest::test] fn test_oneof_accessors() { use unittest_rust_proto::test_oneof2::{Foo::*, FooCase, NestedEnum}; use unittest_rust_proto::TestOneof2; @@ -814,7 +814,7 @@ fn test_oneof_accessors() { // TODO: Add tests covering a message-type field in a oneof. } -#[test] +#[googletest::test] fn test_msg_oneof_default_accessors() { use unittest_rust_proto::test_oneof2::{Bar::*, BarCase, NestedEnum}; @@ -846,7 +846,7 @@ fn test_msg_oneof_default_accessors() { // TODO: Add tests covering a message-type field in a oneof. } -#[test] +#[googletest::test] fn test_group() { let mut m = TestAllTypes::new(); @@ -859,7 +859,7 @@ fn test_group() { assert_that!(m.optionalgroup().a(), eq(7)); } -#[test] +#[googletest::test] fn test_submsg_setter() { use test_all_types::*; @@ -872,7 +872,7 @@ fn test_submsg_setter() { assert_that!(parent.optional_nested_message().bb(), eq(7)); } -#[test] +#[googletest::test] fn test_clone() { let mut m = TestAllTypes::new(); m.set_optional_int32(42); @@ -884,7 +884,7 @@ fn test_clone() { assert_that!(clone.optional_int32(), eq(42)); } -#[test] +#[googletest::test] fn test_to_owned() { let mut m = TestAllTypes::new(); m.set_optional_int32(42); @@ -908,7 +908,7 @@ fn test_to_owned() { assert_that!(submsg_mut.bb(), eq(8)); } -#[test] +#[googletest::test] fn test_ctype_stringpiece() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_string_piece(), eq("")); diff --git a/rust/test/shared/bad_names_test.rs b/rust/test/shared/bad_names_test.rs index 19ba5076a7..a60bfb942b 100644 --- a/rust/test/shared/bad_names_test.rs +++ b/rust/test/shared/bad_names_test.rs @@ -8,20 +8,20 @@ use bad_names_rust_proto::*; use googletest::prelude::*; -#[test] +#[googletest::test] fn test_reserved_keyword_in_accessors() { let msg = Self__mangled_because_ident_isnt_a_legal_raw_identifier::new(); let res = msg.self__mangled_because_ident_isnt_a_legal_raw_identifier().r#for(); assert_that!(res, eq(0)); } -#[test] +#[googletest::test] fn test_reserved_keyword_in_messages() { let _ = r#enum::new(); let _ = Ref::new().r#const(); } -#[test] +#[googletest::test] fn test_collision_in_accessors() { let mut m = AccessorsCollide::new(); m.set_x_mut_5(false); diff --git a/rust/test/shared/child_parent_test.rs b/rust/test/shared/child_parent_test.rs index 1a269ec052..82763b5c5c 100644 --- a/rust/test/shared/child_parent_test.rs +++ b/rust/test/shared/child_parent_test.rs @@ -7,7 +7,7 @@ use googletest::prelude::*; -#[test] +#[googletest::test] fn test_canonical_types() { let _child = child_rust_proto::Child::new(); let _parent = parent_rust_proto::Parent::new(); @@ -16,12 +16,12 @@ fn test_canonical_types() { let _parent_from_child: child_rust_proto::Parent = parent_rust_proto::Parent::new(); } -#[test] +#[googletest::test] fn test_parent_serialization() { assert_that!(*parent_rust_proto::Parent::new().serialize().unwrap(), empty()); } -#[test] +#[googletest::test] fn test_child_serialization() { assert_that!(*child_rust_proto::Child::new().serialize().unwrap(), empty()); } diff --git a/rust/test/shared/edition2023_test.rs b/rust/test/shared/edition2023_test.rs index 824e33b0be..ba31299dcc 100644 --- a/rust/test/shared/edition2023_test.rs +++ b/rust/test/shared/edition2023_test.rs @@ -11,14 +11,14 @@ use googletest::prelude::*; // is _not_ a test for Rust Edition 2023 (which doesn't exist) but instead // Protobuf Edition 2023 (which exists). -#[test] +#[googletest::test] fn check_edition2023_works() { let msg = edition2023_rust_proto::EditionsMessage::new(); assert_that!(msg.plain_field_opt().into_inner(), eq(0)); assert_that!(msg.implicit_presence_field(), eq(0)); } -#[test] +#[googletest::test] fn string_view_works() { let mut msg = edition2023_rust_proto::EditionsMessage::new(); assert_that!(msg.str_view(), eq("")); @@ -28,7 +28,7 @@ fn string_view_works() { assert_that!(msg.has_str_view(), eq(true)); } -#[test] +#[googletest::test] fn repeated_string_view_works() { let mut msg = edition2023_rust_proto::EditionsMessage::new(); assert_that!(msg.repeated_str_view().len(), eq(0)); diff --git a/rust/test/shared/enum_test.rs b/rust/test/shared/enum_test.rs index a19bcb97eb..b4d0900495 100644 --- a/rust/test/shared/enum_test.rs +++ b/rust/test/shared/enum_test.rs @@ -12,7 +12,7 @@ use googletest::prelude::*; use protobuf::Enum; use unittest_rust_proto::*; -#[test] +#[googletest::test] fn test_nested_enum_values() { assert_that!(i32::from(test_all_types::NestedEnum::Foo), eq(1)); assert_that!(i32::from(test_all_types::NestedEnum::Bar), eq(2)); @@ -20,19 +20,19 @@ fn test_nested_enum_values() { assert_that!(i32::from(test_all_types::NestedEnum::Neg), eq(-1)); } -#[test] +#[googletest::test] fn test_isolated_nested_enum() { // Ensure that the enum is generated even when it's the only nested type for the // message. assert_that!(i32::from(test_required_enum_no_mask::NestedEnum::Foo), eq(2)); } -#[test] +#[googletest::test] fn test_enum_value_name_same_as_enum() { assert_that!(i32::from(TestEnumValueNameSameAsEnum::TestEnumValueNameSameAsEnum), eq(1)); } -#[test] +#[googletest::test] fn test_enum_defaults() { assert_that!(TestSparseEnum::default(), eq(TestSparseEnum::SparseA)); assert_that!(TestEnumWithDupValue::default(), eq(TestEnumWithDupValue::Foo1)); @@ -44,7 +44,7 @@ fn test_enum_defaults() { assert_that!(test_all_types::NestedEnum::default(), eq(test_all_types::NestedEnum::Foo)); } -#[test] +#[googletest::test] #[deny(unreachable_patterns)] #[allow(clippy::let_unit_value)] fn test_closed_enum_is_nonexhaustive() { @@ -58,7 +58,7 @@ fn test_closed_enum_is_nonexhaustive() { }; } -#[test] +#[googletest::test] fn test_closed_enum_conversion() { assert_that!(i32::from(TestSparseEnum::SparseA), eq(123)); assert_that!(TestSparseEnum::try_from(123), ok(eq(&TestSparseEnum::SparseA))); @@ -70,7 +70,7 @@ fn test_closed_enum_conversion() { assert_that!(TestSparseEnum::try_from(1), err(anything())); } -#[test] +#[googletest::test] fn test_closed_aliased_enum_conversion() { assert_that!(i32::from(TestEnumWithDupValue::Foo1), eq(1)); assert_that!(i32::from(TestEnumWithDupValue::Foo2), eq(1)); @@ -88,7 +88,7 @@ fn test_closed_aliased_enum_conversion() { assert_that!(TestEnumWithDupValue::Bar1, eq(TestEnumWithDupValue::Bar2)); } -#[test] +#[googletest::test] #[deny(unreachable_patterns)] #[allow(clippy::let_unit_value)] fn test_open_enum_is_nonexhaustive() { @@ -100,7 +100,7 @@ fn test_open_enum_is_nonexhaustive() { }; } -#[test] +#[googletest::test] fn test_open_enum_conversion() { assert_that!(i32::from(TestEnumWithNumericNames::Unknown), eq(0)); assert_that!(i32::from(TestEnumWithNumericNames::_2020), eq(1)); @@ -123,7 +123,7 @@ fn test_open_enum_conversion() { assert_that!(i32::from(TestEnumWithNumericNames::from(-1)), eq(-1)); } -#[test] +#[googletest::test] fn test_open_aliased_enum_conversion() { assert_that!(i32::from(TestEnumWithDuplicateStrippedPrefixNames::Unknown), eq(0)); assert_that!(i32::from(TestEnumWithDuplicateStrippedPrefixNames::Foo), eq(1)); @@ -157,19 +157,19 @@ fn test_open_aliased_enum_conversion() { assert_that!(i32::from(TestEnumWithDuplicateStrippedPrefixNames::from(5)), eq(5)); } -#[test] +#[googletest::test] fn test_enum_conversion_failure_display() { let err = TestSparseEnum::try_from(1).unwrap_err(); assert_that!(format!("{err}"), eq("1 is not a known value for TestSparseEnum")); } -#[test] +#[googletest::test] fn test_enum_conversion_failure_impls_std_error() { let err = TestSparseEnum::try_from(1).unwrap_err(); let _test_compiles: &dyn std::error::Error = &err; } -#[test] +#[googletest::test] fn test_is_known_for_closed_enum() { assert_that!(test_all_types::NestedEnum::is_known(-2), eq(false)); assert_that!(test_all_types::NestedEnum::is_known(-1), eq(true)); @@ -180,7 +180,7 @@ fn test_is_known_for_closed_enum() { assert_that!(test_all_types::NestedEnum::is_known(4), eq(false)); } -#[test] +#[googletest::test] fn test_is_known_for_open_enum() { assert_that!(TestEnumWithNumericNames::is_known(-1), eq(false)); assert_that!(TestEnumWithNumericNames::is_known(0), eq(true)); diff --git a/rust/test/shared/fields_with_imported_types_test.rs b/rust/test/shared/fields_with_imported_types_test.rs index 6b1b17c45b..9fa6563da1 100644 --- a/rust/test/shared/fields_with_imported_types_test.rs +++ b/rust/test/shared/fields_with_imported_types_test.rs @@ -10,7 +10,7 @@ /// a separate proto_library target. use googletest::prelude::*; -#[test] +#[googletest::test] fn test_message_field_generated() { use fields_with_imported_types_rust_proto::MsgWithFieldsWithImportedTypes; use imported_types_rust_proto::ImportedMessageView; @@ -19,7 +19,7 @@ fn test_message_field_generated() { assert_that!(msg.imported_message_field(), matches_pattern!(ImportedMessageView { .. })); } -#[test] +#[googletest::test] fn test_enum_field_generated() { use fields_with_imported_types_rust_proto::MsgWithFieldsWithImportedTypes; use imported_types_rust_proto::ImportedEnum; @@ -28,7 +28,7 @@ fn test_enum_field_generated() { assert_that!(msg.imported_enum_field(), eq(ImportedEnum::Unknown)); } -#[test] +#[googletest::test] fn test_oneof_message_field_generated() { use fields_with_imported_types_rust_proto::msg_with_fields_with_imported_types::ImportedTypesOneof::not_set; use fields_with_imported_types_rust_proto::MsgWithFieldsWithImportedTypes; diff --git a/rust/test/shared/import_public_test.rs b/rust/test/shared/import_public_test.rs index 4d05ad8f02..6299219151 100644 --- a/rust/test/shared/import_public_test.rs +++ b/rust/test/shared/import_public_test.rs @@ -7,7 +7,7 @@ //! Tests covering codegen of import public statements. -#[test] +#[googletest::test] fn test_import_public_types_are_reexported() { let _: import_public_rust_proto::PrimarySrcPubliclyImportedMsg; let _: import_public_rust_proto::PrimarySrcPubliclyImportedMsgView; diff --git a/rust/test/shared/merge_from_test.rs b/rust/test/shared/merge_from_test.rs index b07f528fd9..26eb3998ed 100644 --- a/rust/test/shared/merge_from_test.rs +++ b/rust/test/shared/merge_from_test.rs @@ -2,7 +2,7 @@ use googletest::prelude::*; use protobuf::proto; use unittest_rust_proto::{NestedTestAllTypes, TestAllTypes}; -#[test] +#[googletest::test] fn merge_from_empty() { let mut dst = TestAllTypes::new(); let src = TestAllTypes::new(); @@ -10,7 +10,7 @@ fn merge_from_empty() { assert_that!(dst.as_view().has_optional_int32(), eq(false)); } -#[test] +#[googletest::test] fn merge_from_non_empty() { let mut dst = TestAllTypes::new(); let src = proto!(TestAllTypes { optional_int32: 42 }); @@ -18,7 +18,7 @@ fn merge_from_non_empty() { assert_eq!(dst.as_view().optional_int32(), 42); } -#[test] +#[googletest::test] fn merge_repeated_empty() { let mut dst = TestAllTypes::new(); let mut src = TestAllTypes::new(); @@ -30,7 +30,7 @@ fn merge_repeated_empty() { ); } -#[test] +#[googletest::test] fn merge_repeated_non_empty() { let mut dst = TestAllTypes::new(); let mut src = TestAllTypes::new(); @@ -43,7 +43,7 @@ fn merge_repeated_non_empty() { ); } -#[test] +#[googletest::test] fn merge_from_sub_message() { let mut dst = NestedTestAllTypes::new(); let src = proto!(NestedTestAllTypes { diff --git a/rust/test/shared/nested_types_test.rs b/rust/test/shared/nested_types_test.rs index d47929efb4..8f04d9f38d 100644 --- a/rust/test/shared/nested_types_test.rs +++ b/rust/test/shared/nested_types_test.rs @@ -7,7 +7,7 @@ //! Tests covering nested types. -#[test] +#[googletest::test] fn test_nested_messages_accessible() { let _parent: unittest_rust_proto::TestAllTypes; let _child: unittest_rust_proto::test_all_types::NestedMessage; @@ -15,7 +15,7 @@ fn test_nested_messages_accessible() { nested_test_all_extensions_data::NestedDynamicExtensions::new(); } -#[test] +#[googletest::test] fn test_nested_enums_accessible() { let _parent: unittest_rust_proto::TestAllTypes; let _child: unittest_rust_proto::test_all_types::NestedEnum; diff --git a/rust/test/shared/package_test.rs b/rust/test/shared/package_test.rs index 04f5b84d5f..67a854d6d3 100644 --- a/rust/test/shared/package_test.rs +++ b/rust/test/shared/package_test.rs @@ -7,7 +7,7 @@ //! Tests covering proto packages. -#[test] +#[googletest::test] fn test_message_packages() { // empty package, message declared in the first .proto source let _: no_package_rust_proto::MsgWithoutPackage; @@ -26,7 +26,7 @@ fn test_message_packages() { let _: package_rust_proto::ImportedMsgWithPackage; } -#[test] +#[googletest::test] fn test_enum_packages() { // empty package, enum declared in the first .proto source let _: no_package_rust_proto::EnumWithoutPackage; diff --git a/rust/test/shared/proto_macro_test.rs b/rust/test/shared/proto_macro_test.rs index 876a5a47f4..5085cb73f5 100644 --- a/rust/test/shared/proto_macro_test.rs +++ b/rust/test/shared/proto_macro_test.rs @@ -18,7 +18,7 @@ struct TestValue { val: i64, } -#[test] +#[googletest::test] fn test_setting_literals() { let fixed64 = || 108; let test_ref = |x: &i64| *x; @@ -67,7 +67,7 @@ fn test_setting_literals() { assert_that!(msg.optional_nested_enum(), eq(test_all_types::NestedEnum::Baz)); } -#[test] +#[googletest::test] fn single_nested_message() { let msg = proto!(TestAllTypes { optional_nested_message: NestedMessage { bb: 42 } }); assert_that!(msg.optional_nested_message().bb(), eq(42)); @@ -122,7 +122,7 @@ fn single_nested_message() { assert_that!(msg.has_optional_nested_message(), eq(true)); } -#[test] +#[googletest::test] fn test_recursive_msg() { let msg = proto!(NestedTestAllTypes { child: NestedTestAllTypes { @@ -139,7 +139,7 @@ fn test_recursive_msg() { assert_that!(msg.child().child().child().payload().optional_int32(), eq(43)); } -#[test] +#[googletest::test] fn test_spread_msg() { let msg = proto!(TestAllTypes { optional_nested_message: NestedMessage { bb: 42 } }); let msg2 = proto!(TestAllTypes { ..msg.as_view() }); @@ -149,7 +149,7 @@ fn test_spread_msg() { assert_that!(msg3.optional_int32(), eq(1)); } -#[test] +#[googletest::test] fn test_spread_nested_msg() { let msg = proto!(NestedTestAllTypes { child: NestedTestAllTypes { @@ -168,7 +168,7 @@ fn test_spread_nested_msg() { assert_that!(msg2.child().child().child().payload().optional_int32(), eq(43)); } -#[test] +#[googletest::test] fn test_repeated_i32() { let msg = proto!(TestAllTypes { repeated_int32: [1, 1 + 1, 3] }); assert_that!(msg.repeated_int32().len(), eq(3)); @@ -177,7 +177,7 @@ fn test_repeated_i32() { assert_that!(msg.repeated_int32().get(2).unwrap(), eq(3)); } -#[test] +#[googletest::test] fn test_repeated_msg() { let msg2 = proto!(NestedTestAllTypes { payload: TestAllTypes { optional_int32: 1 } }); let msg = proto!(NestedTestAllTypes { diff --git a/rust/test/shared/serialization_test.rs b/rust/test/shared/serialization_test.rs index e5b614034f..bf3d67a0b5 100644 --- a/rust/test/shared/serialization_test.rs +++ b/rust/test/shared/serialization_test.rs @@ -15,7 +15,7 @@ use unittest_rust_proto::TestAllTypes as TestAllTypesProto2; macro_rules! generate_parameterized_serialization_test { ($(($type: ident, $name_ext: ident)),*) => { paste! { $( - #[test] + #[googletest::test] fn [< serialization_zero_length_ $name_ext >]() { let mut msg = [< $type >]::new(); @@ -29,7 +29,7 @@ macro_rules! generate_parameterized_serialization_test { assert_that!(serialized.len(), eq(0)); } - #[test] + #[googletest::test] fn [< serialize_deserialize_message_ $name_ext>]() { let mut msg = [< $type >]::new(); msg.set_optional_int64(42); @@ -44,17 +44,17 @@ macro_rules! generate_parameterized_serialization_test { assert_that!(msg.optional_bytes(), eq(msg2.optional_bytes())); } - #[test] + #[googletest::test] fn [< deserialize_empty_ $name_ext>]() { assert!([< $type >]::parse(&[]).is_ok()); } - #[test] + #[googletest::test] fn [< deserialize_error_ $name_ext>]() { assert!([< $type >]::parse(b"not a serialized proto").is_err()); } - #[test] + #[googletest::test] fn [< set_bytes_with_serialized_data_ $name_ext>]() { let mut msg = [< $type >]::new(); msg.set_optional_int64(42); @@ -64,7 +64,7 @@ macro_rules! generate_parameterized_serialization_test { assert_that!(msg2.optional_bytes(), eq(msg.serialize().unwrap())); } - #[test] + #[googletest::test] fn [< deserialize_on_previously_allocated_message_ $name_ext>]() { let mut msg = [< $type >]::new(); msg.set_optional_int64(42); @@ -95,7 +95,7 @@ macro_rules! generate_parameterized_int32_byte_size_test { ($(($type: ident, $name_ext: ident)),*) => { paste! { $( - #[test] + #[googletest::test] fn [< test_int32_byte_size_ $name_ext>]() { let args = vec![(0, 1), (127, 1), (128, 2), (-1, 10)]; for arg in args { diff --git a/rust/test/shared/simple_nested_test.rs b/rust/test/shared/simple_nested_test.rs index fe74786ec8..2fefc466de 100644 --- a/rust/test/shared/simple_nested_test.rs +++ b/rust/test/shared/simple_nested_test.rs @@ -10,7 +10,7 @@ use nested_rust_proto::outer::inner::InnerEnum; use nested_rust_proto::outer::InnerView; use nested_rust_proto::*; -#[test] +#[googletest::test] fn test_deeply_nested_message() { let deep = outer::inner::super_inner::duper_inner::even_more_inner::CantBelieveItsSoInner::new(); @@ -20,7 +20,7 @@ fn test_deeply_nested_message() { assert_that!(outermsg.deep().num(), eq(0)); } -#[test] +#[googletest::test] fn test_deeply_nested_enum() { use outer::inner::super_inner::duper_inner::even_more_inner::JustWayTooInner; let deep = JustWayTooInner::default(); @@ -30,7 +30,7 @@ fn test_deeply_nested_enum() { assert_that!(outermsg.deep_enum(), eq(JustWayTooInner::Unspecified)); } -#[test] +#[googletest::test] fn test_nested_views() { let outermsg = Outer::new(); let inner_msg: InnerView<'_> = outermsg.inner(); @@ -53,7 +53,7 @@ fn test_nested_views() { assert_that!(inner_msg.inner_enum(), eq(InnerEnum::Unspecified)); } -#[test] +#[googletest::test] fn test_nested_view_lifetimes() { // Ensure that views have the lifetime of the first layer of borrow, and don't // create intermediate borrows through nested accessors. @@ -79,7 +79,7 @@ fn test_nested_view_lifetimes() { assert_that!(string_map.len(), eq(0)); } -#[test] +#[googletest::test] fn test_msg_from_outside() { // let's make sure that we're not just working for messages nested inside // messages, messages from without and within should work @@ -87,7 +87,7 @@ fn test_msg_from_outside() { assert_that!(outer.notinside().num(), eq(0)); } -#[test] +#[googletest::test] fn test_recursive_view() { let rec = nested_rust_proto::Recursive::new(); assert_that!(rec.num(), eq(0)); @@ -100,7 +100,7 @@ fn test_recursive_view() { assert_that!(nested.num(), eq(0)); } -#[test] +#[googletest::test] fn test_recursive_mut() { let mut rec = nested_rust_proto::Recursive::new(); let mut one = rec.rec_mut(); diff --git a/rust/test/shared/utf8/utf8_test.rs b/rust/test/shared/utf8/utf8_test.rs index 8b46cf86dd..e4431efbe3 100644 --- a/rust/test/shared/utf8/utf8_test.rs +++ b/rust/test/shared/utf8/utf8_test.rs @@ -34,7 +34,7 @@ fn make_non_utf8_proto_str() -> &'static ProtoStr { } } -#[test] +#[googletest::test] fn test_proto2() { let non_utf8_str = make_non_utf8_proto_str(); @@ -52,7 +52,7 @@ fn test_proto2() { assert_that!(parsed_result, ok(anything())); } -#[test] +#[googletest::test] fn test_proto3() { let non_utf8_str = make_non_utf8_proto_str(); @@ -70,7 +70,7 @@ fn test_proto3() { assert_that!(parsed_result, err(matches_pattern!(&ParseError))); } -#[test] +#[googletest::test] fn test_verify() { let non_utf8_str = make_non_utf8_proto_str(); diff --git a/rust/test/upb/debug_string_test.rs b/rust/test/upb/debug_string_test.rs index fa2f429c1c..9cc3457f1e 100644 --- a/rust/test/upb/debug_string_test.rs +++ b/rust/test/upb/debug_string_test.rs @@ -13,7 +13,7 @@ use unittest_rust_proto::{ test_all_types::NestedMessage as NestedMessageProto2, TestAllTypes as TestAllTypesProto2, }; -#[test] +#[googletest::test] fn test_debug_string() { let mut msg = proto!(TestAllTypesProto2 { optional_int32: 42, diff --git a/rust/test/upb/string_ctypes_test.rs b/rust/test/upb/string_ctypes_test.rs index 6bbea67a21..8296592b0c 100644 --- a/rust/test/upb/string_ctypes_test.rs +++ b/rust/test/upb/string_ctypes_test.rs @@ -8,7 +8,7 @@ use googletest::prelude::*; use unittest_proto3_rust_proto::TestAllTypes; -#[test] +#[googletest::test] fn test_stringpiece_repeated() { let mut msg = TestAllTypes::new(); assert_that!(msg.repeated_string_piece().len(), eq(0)); @@ -17,7 +17,7 @@ fn test_stringpiece_repeated() { assert_that!(msg.repeated_string_piece().get(0), some(eq("hello"))); } -#[test] +#[googletest::test] fn test_cord() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_cord(), eq("")); @@ -25,7 +25,7 @@ fn test_cord() { assert_that!(msg.optional_cord(), eq("hello")); } -#[test] +#[googletest::test] fn test_cord_repeated() { let mut msg = TestAllTypes::new(); assert_that!(msg.repeated_cord().len(), eq(0));