Use the latest googletest version number in our generated Cargo.toml for release.

Crates.io does not allow publishing of Cargo.toml files which point to git.

PiperOrigin-RevId: 698801255
pull/19336/head
Protobuf Team Bot 1 week ago committed by Copybara-Service
parent 96dfcce517
commit 0325132bf4
  1. 2
      rust/cargo/Cargo-template.toml
  2. 4
      rust/cpp.rs
  3. 16
      rust/map.rs
  4. 14
      rust/proxied.rs
  5. 6
      rust/repeated.rs
  6. 12
      rust/string.rs
  7. 6
      rust/test/cpp/debug_test.rs
  8. 16
      rust/test/cpp/interop/main.rs
  9. 14
      rust/test/shared/accessors_map_test.rs
  10. 32
      rust/test/shared/accessors_proto3_test.rs
  11. 24
      rust/test/shared/accessors_repeated_test.rs
  12. 98
      rust/test/shared/accessors_test.rs
  13. 6
      rust/test/shared/bad_names_test.rs
  14. 6
      rust/test/shared/child_parent_test.rs
  15. 2
      rust/test/shared/ctype_cord_test.rs
  16. 6
      rust/test/shared/edition2023_test.rs
  17. 28
      rust/test/shared/enum_test.rs
  18. 6
      rust/test/shared/fields_with_imported_types_test.rs
  19. 6
      rust/test/shared/gtest_matchers_test.rs
  20. 2
      rust/test/shared/import_public_test.rs
  21. 10
      rust/test/shared/merge_from_test.rs
  22. 4
      rust/test/shared/nested_types_test.rs
  23. 4
      rust/test/shared/no_internal_access_test.rs
  24. 4
      rust/test/shared/package_test.rs
  25. 18
      rust/test/shared/proto_macro_test.rs
  26. 16
      rust/test/shared/serialization_test.rs
  27. 14
      rust/test/shared/simple_nested_test.rs
  28. 6
      rust/test/shared/utf8/utf8_test.rs
  29. 2
      rust/test/upb/debug_string_test.rs
  30. 4
      rust/test/upb/string_ctypes_test.rs
  31. 8
      rust/upb/arena.rs
  32. 6
      rust/upb/array.rs
  33. 6
      rust/upb/map.rs
  34. 4
      rust/upb/message.rs
  35. 4
      rust/upb/mini_table.rs
  36. 8
      rust/upb/owned_arena_box.rs
  37. 4
      rust/upb/text.rs
  38. 4
      rust/upb/wire.rs

@ -21,7 +21,7 @@ path = "src/shared.rs"
paste = "1.0.15"
[dev-dependencies]
googletest = {git = "https://github.com/google/googletest-rust.git" }
googletest = "0.12.0"
[build-dependencies]
cc = "1.1.6"

@ -1301,14 +1301,14 @@ mod tests {
(content.as_mut_ptr(), content.len())
}
#[gtest]
#[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"));
}
#[gtest]
#[googletest::test]
fn test_empty_string() {
let empty_str: String = RustStringRawParts { data: std::ptr::null(), len: 0 }.into();
assert_that!(empty_str, eq(""));

@ -527,7 +527,7 @@ mod tests {
use crate::{ProtoBytes, ProtoStr, ProtoString};
use googletest::prelude::*;
#[gtest]
#[googletest::test]
fn test_proxied_scalar() {
let mut map: Map<i32, i64> = Map::new();
let mut map_mut = map.as_mut();
@ -553,7 +553,7 @@ mod tests {
assert_that!(map_view_4.is_empty(), eq(false));
}
#[gtest]
#[googletest::test]
fn test_proxied_str() {
let mut map: Map<ProtoString, ProtoString> = Map::new();
let mut map_mut = map.as_mut();
@ -578,7 +578,7 @@ mod tests {
assert_that!(map_view_4.is_empty(), eq(false));
}
#[gtest]
#[googletest::test]
fn test_proxied_iter() {
let mut map: Map<i32, ProtoString> = Map::new();
let mut map_mut = map.as_mut();
@ -625,7 +625,7 @@ mod tests {
);
}
#[gtest]
#[googletest::test]
fn test_overwrite_insert() {
let mut map: Map<i32, ProtoString> = Map::new();
let mut map_mut = map.as_mut();
@ -635,7 +635,7 @@ mod tests {
assert_that!(map.as_mut(), unordered_elements_are![eq((0, ProtoStr::from_str("buzz"))),]);
}
#[gtest]
#[googletest::test]
fn test_extend() {
let mut map: Map<i32, ProtoString> = Map::new();
let mut map_mut = map.as_mut();
@ -672,7 +672,7 @@ mod tests {
);
}
#[gtest]
#[googletest::test]
fn test_copy_from() {
let mut map: Map<i32, ProtoString> = Map::new();
let mut map_mut = map.as_mut();
@ -703,7 +703,7 @@ mod tests {
);
}
#[gtest]
#[googletest::test]
fn test_all_maps_can_be_constructed() {
macro_rules! gen_proto_values {
($key_t:ty, $($value_t:ty),*) => {
@ -725,7 +725,7 @@ mod tests {
gen_proto_keys!(i32, u32, i64, u64, bool, ProtoString);
}
#[gtest]
#[googletest::test]
fn test_dbg() {
let mut map = Map::<i32, f64>::new();
assert_that!(format!("{:?}", map.as_view()), eq("MapView(\"i32\", \"f64\")"));

@ -372,7 +372,7 @@ mod tests {
impl<'msg> MutProxy<'msg> for MyProxiedMut<'msg> {}
#[gtest]
#[googletest::test]
fn test_as_view() {
let my_proxied = MyProxied { val: "Hello World".to_string() };
@ -387,7 +387,7 @@ mod tests {
x.into_view() // OK: we return the same lifetime as we got in.
}
#[gtest]
#[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());
@ -395,7 +395,7 @@ mod tests {
fn require_unified_lifetimes<'msg>(_x: Mut<'msg, MyProxied>, _y: View<'msg, MyProxied>) {}
#[gtest]
#[googletest::test]
fn test_require_unified_lifetimes() {
let mut my_proxied = MyProxied { val: "Hello1".to_string() };
let my_mut = my_proxied.as_mut();
@ -420,7 +420,7 @@ mod tests {
[x.as_view(), y.as_view()]
}
#[gtest]
#[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();
@ -447,7 +447,7 @@ mod tests {
[x.into_view(), y]
}
#[gtest]
#[googletest::test]
fn test_reborrow_generic_into_view() {
let my_proxied = MyProxied { val: "Hello1".to_string() };
let my_view = my_proxied.as_view();
@ -467,7 +467,7 @@ mod tests {
[x.into_view(), y]
}
#[gtest]
#[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();
@ -491,7 +491,7 @@ mod tests {
[tmp, y]
}
#[gtest]
#[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();

@ -585,7 +585,7 @@ mod tests {
use super::*;
use googletest::prelude::*;
#[gtest]
#[googletest::test]
fn test_primitive_repeated() {
macro_rules! primitive_repeated_tests {
($($t:ty => [$($vals:expr),* $(,)?]),* $(,)?) => {
@ -626,7 +626,7 @@ mod tests {
);
}
#[gtest]
#[googletest::test]
fn test_repeated_extend() {
let mut r = Repeated::<i32>::new();
@ -643,7 +643,7 @@ mod tests {
assert_that!(r.as_mut(), elements_are![eq(0), eq(1), eq(2), eq(3)]);
}
#[gtest]
#[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)]);

@ -621,7 +621,7 @@ mod tests {
// UTF-8 test cases copied from:
// https://github.com/rust-lang/rust/blob/e8ee0b7/library/core/tests/str_lossy.rs
#[gtest]
#[googletest::test]
fn proto_str_debug() {
assert_eq!(&format!("{:?}", test_proto_str(b"Hello There")), "\"Hello There\"");
assert_eq!(
@ -633,7 +633,7 @@ mod tests {
);
}
#[gtest]
#[googletest::test]
fn proto_str_display() {
assert_eq!(&test_proto_str(b"Hello There").to_string(), "Hello There");
assert_eq!(
@ -642,7 +642,7 @@ mod tests {
);
}
#[gtest]
#[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"));
@ -662,7 +662,7 @@ mod tests {
}
}
#[gtest]
#[googletest::test]
fn proto_str_to_cow() {
assert_eq!(test_proto_str(b"hello").to_cow_lossy(), Cow::Borrowed("hello"));
assert_eq!(
@ -684,7 +684,7 @@ mod tests {
}
}
#[gtest]
#[googletest::test]
fn proto_str_utf8_chunks() {
macro_rules! assert_chunks {
($bytes:expr, $($chunks:expr),* $(,)?) => {
@ -763,7 +763,7 @@ mod tests {
);
}
#[gtest]
#[googletest::test]
fn proto_str_chars() {
macro_rules! assert_chars {
($bytes:expr, $chars:expr) => {

@ -3,7 +3,7 @@ use googletest::prelude::*;
use optimize_for_lite_rust_proto::OptimizeForLiteTestMessage;
#[cfg(not(lite_runtime))]
#[gtest]
#[googletest::test]
fn test_debug() {
let mut msg = DebugMsg::new();
msg.set_id(1);
@ -13,7 +13,7 @@ fn test_debug() {
}
#[cfg(lite_runtime)]
#[gtest]
#[googletest::test]
fn test_debug_lite() {
let mut msg = DebugMsg::new();
msg.set_id(1);
@ -25,7 +25,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.
#[gtest]
#[googletest::test]
fn test_optimize_for_lite_option() {
let mut msg = OptimizeForLiteTestMessage::new();
msg.set_value("password");

@ -40,7 +40,7 @@ extern "C" {
fn GetConstStaticInteropTestMessage() -> *const c_void;
}
#[gtest]
#[googletest::test]
fn send_to_cpp() {
let mut msg1 = InteropTestMessage::new();
msg1.set_i64(7);
@ -48,7 +48,7 @@ fn send_to_cpp() {
assert_eq!(i, 7);
}
#[gtest]
#[googletest::test]
fn mutate_message_mut_in_cpp() {
let mut msg1 = InteropTestMessage::new();
unsafe {
@ -63,7 +63,7 @@ fn mutate_message_mut_in_cpp() {
proto_assert_eq!(msg1, msg2);
}
#[gtest]
#[googletest::test]
fn deserialize_in_rust() {
let mut msg1 = InteropTestMessage::new();
msg1.set_i64(-1);
@ -75,7 +75,7 @@ fn deserialize_in_rust() {
proto_assert_eq!(msg1, msg2);
}
#[gtest]
#[googletest::test]
fn deserialize_in_cpp() {
let mut msg1 = InteropTestMessage::new();
msg1.set_i64(-1);
@ -92,7 +92,7 @@ fn deserialize_in_cpp() {
proto_assert_eq!(msg1, msg2);
}
#[gtest]
#[googletest::test]
fn deserialize_in_cpp_into_mut() {
let mut msg1 = InteropTestMessage::new();
msg1.set_i64(-1);
@ -110,7 +110,7 @@ fn deserialize_in_cpp_into_mut() {
}
}
#[gtest]
#[googletest::test]
fn deserialize_in_cpp_into_view() {
let mut msg1 = InteropTestMessage::new();
msg1.set_i64(-1);
@ -131,7 +131,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.
#[gtest]
#[googletest::test]
fn smuggle_extension() {
let msg1 =
unsafe { InteropTestMessage::__unstable_take_ownership_of_raw_message(NewWithExtension()) };
@ -143,7 +143,7 @@ fn smuggle_extension() {
assert_eq!(bytes, b"smuggled");
}
#[gtest]
#[googletest::test]
fn view_of_const_static() {
let view: InteropTestMessageView<'static> = unsafe {
InteropTestMessageView::__unstable_wrap_raw_message_unchecked_lifetime(

@ -20,7 +20,7 @@ macro_rules! generate_map_primitives_tests {
$(,)?
) => {
paste! { $(
#[gtest]
#[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));
@ -96,7 +96,7 @@ generate_map_primitives_tests!(
(i32, MapEnum, int32, enum, 1, MapEnum::Baz),
);
#[gtest]
#[googletest::test]
fn collect_as_hashmap() {
// Highlights conversion from protobuf map to hashmap.
let mut msg = TestMap::new();
@ -115,7 +115,7 @@ fn collect_as_hashmap() {
);
}
#[gtest]
#[googletest::test]
fn test_string_maps() {
let mut msg = TestMap::new();
msg.map_string_string_mut().insert("hello", "world");
@ -127,7 +127,7 @@ fn test_string_maps() {
assert_that!(msg.map_string_string().len(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_nested_enum_maps() {
// Verify that C++ thunks are generated and are with the right name for strings
TestMapWithNestedEnum::new()
@ -135,7 +135,7 @@ fn test_nested_enum_maps() {
.insert("foo", test_map_with_nested_enum::inner_nested::NestedEnum::Foo);
}
#[gtest]
#[googletest::test]
fn test_bytes_and_string_copied() {
let mut msg = TestMap::new();
@ -155,7 +155,7 @@ fn test_bytes_and_string_copied() {
assert_that!(msg.map_int32_bytes_mut().get(1).unwrap(), eq(b"world"));
}
#[gtest]
#[googletest::test]
fn test_map_setter() {
// Set Map
{
@ -268,7 +268,7 @@ macro_rules! generate_map_with_msg_values_tests {
$(,)?
) => {
paste! { $(
#[gtest]
#[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.

@ -15,7 +15,7 @@ use protobuf::Optional;
use unittest_proto3_optional_rust_proto::{test_proto3_optional, TestProto3Optional};
use unittest_proto3_rust_proto::{test_all_types, TestAllTypes};
#[gtest]
#[googletest::test]
fn test_fixed32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_fixed32(), eq(0));
@ -30,7 +30,7 @@ fn test_fixed32_accessors() {
assert_that!(msg.optional_fixed32(), eq(43));
}
#[gtest]
#[googletest::test]
fn test_bool_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_bool(), eq(false));
@ -42,7 +42,7 @@ fn test_bool_accessors() {
assert_that!(msg.optional_bool(), eq(false));
}
#[gtest]
#[googletest::test]
fn test_bytes_accessors() {
let mut msg = TestAllTypes::new();
// Note: even though it's named 'optional_bytes', the field is actually not
@ -62,7 +62,7 @@ fn test_bytes_accessors() {
assert_that!(*msg.optional_bytes(), empty());
}
#[gtest]
#[googletest::test]
fn test_optional_bytes_accessors() {
let mut msg = TestProto3Optional::new();
assert_that!(*msg.optional_bytes(), empty());
@ -84,7 +84,7 @@ fn test_optional_bytes_accessors() {
assert_that!(msg.optional_bytes_opt(), eq(Optional::Set(&b"\xffbinary\x85non-utf8"[..])));
}
#[gtest]
#[googletest::test]
fn test_string_accessors() {
let mut msg = TestAllTypes::new();
// Note: even though it's named 'optional_string', the field is actually not
@ -104,7 +104,7 @@ fn test_string_accessors() {
assert_that!(*msg.optional_string().as_bytes(), empty());
}
#[gtest]
#[googletest::test]
fn test_optional_string_accessors() {
let mut msg = TestProto3Optional::new();
assert_that!(*msg.optional_string().as_bytes(), empty());
@ -126,7 +126,7 @@ fn test_optional_string_accessors() {
assert_that!(msg.optional_string_opt(), eq(Optional::Set("".into())));
}
#[gtest]
#[googletest::test]
fn test_nested_enum_accessors() {
use test_all_types::NestedEnum;
@ -140,7 +140,7 @@ fn test_nested_enum_accessors() {
assert_that!(msg.optional_nested_enum(), eq(NestedEnum::Zero));
}
#[gtest]
#[googletest::test]
fn test_optional_nested_enum_accessors() {
use test_proto3_optional::NestedEnum;
@ -157,7 +157,7 @@ fn test_optional_nested_enum_accessors() {
assert_that!(msg.optional_nested_enum_opt(), eq(Optional::Set(NestedEnum::Unspecified)));
}
#[gtest]
#[googletest::test]
fn test_foreign_enum_accessors() {
use unittest_proto3_rust_proto::ForeignEnum;
@ -171,7 +171,7 @@ fn test_foreign_enum_accessors() {
assert_that!(msg.optional_foreign_enum(), eq(ForeignEnum::ForeignZero));
}
#[gtest]
#[googletest::test]
fn test_oneof_accessors() {
use test_all_types::OneofField::*;
@ -200,7 +200,7 @@ fn test_oneof_accessors() {
assert_that!(msg.oneof_field(), matches_pattern!(not_set(_)));
}
#[gtest]
#[googletest::test]
fn test_oneof_accessors_view_long_lifetime() {
use test_all_types::OneofField::*;
@ -216,7 +216,7 @@ fn test_oneof_accessors_view_long_lifetime() {
assert_that!(oneof, matches_pattern!(OneofUint32(eq(7))));
}
#[gtest]
#[googletest::test]
fn test_oneof_enum_accessors() {
use unittest_proto3_rust_proto::{
test_oneof2::{Foo, FooCase, NestedEnum},
@ -234,7 +234,7 @@ fn test_oneof_enum_accessors() {
assert_that!(msg.foo_case(), matches_pattern!(FooCase::FooEnum));
}
#[gtest]
#[googletest::test]
fn test_submsg_setter() {
use test_all_types::*;
@ -247,7 +247,7 @@ fn test_submsg_setter() {
assert_that!(parent.optional_nested_message().bb(), eq(7));
}
#[gtest]
#[googletest::test]
fn test_ctype_stringpiece() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_string_piece(), eq(""));
@ -255,7 +255,7 @@ fn test_ctype_stringpiece() {
assert_that!(msg.optional_string_piece(), eq("hello"));
}
#[gtest]
#[googletest::test]
fn test_msg_clear() {
let mut m = TestAllTypes::new();
m.set_optional_int32(42);
@ -264,7 +264,7 @@ fn test_msg_clear() {
assert_that!(m.optional_int32(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_submsg_clear() {
let mut m = TestAllTypes::new();
let mut sub = m.optional_nested_message_mut();

@ -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! { $(
#[gtest]
#[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 {
);
}
#[gtest]
#[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 {
);
}
#[gtest]
#[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)
);
#[gtest]
#[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)));
}
#[gtest]
#[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)));
}
#[gtest]
#[googletest::test]
fn test_repeated_enum_set() {
use test_all_types::NestedEnum;
@ -184,7 +184,7 @@ fn test_repeated_enum_set() {
);
}
#[gtest]
#[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<_>>()));
}
#[gtest]
#[googletest::test]
fn test_repeated_message() {
let mut msg = TestAllTypes::new();
assert_that!(msg.repeated_nested_message().len(), eq(0));
@ -236,7 +236,7 @@ fn test_repeated_message() {
assert_that!(msg2.repeated_nested_message().len(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_repeated_message_setter() {
let mut msg = TestAllTypes::new();
let mut nested = NestedMessage::new();
@ -245,13 +245,13 @@ fn test_repeated_message_setter() {
assert_that!(msg.repeated_nested_message().get(0).unwrap().bb(), eq(1));
}
#[gtest]
#[googletest::test]
fn test_repeated_message_drop() {
let mut repeated = Repeated::<TestAllTypes>::new();
repeated.as_mut().push(TestAllTypes::new());
}
#[gtest]
#[googletest::test]
fn test_repeated_strings() {
let mut older_msg = TestAllTypes::new();
{
@ -286,7 +286,7 @@ fn test_repeated_strings() {
assert_that!(older_msg.repeated_string(), empty());
}
#[gtest]
#[googletest::test]
fn test_repeated_bytes() {
let mut older_msg = TestAllTypes::new();
{

@ -17,7 +17,7 @@ use std::rc::Rc;
use std::sync::Arc;
use unittest_rust_proto::{test_all_types, TestAllTypes};
#[gtest]
#[googletest::test]
fn test_default_accessors() {
let msg: TestAllTypes = Default::default();
assert_that!(
@ -42,7 +42,7 @@ fn test_default_accessors() {
assert_that!(msg.default_bytes(), eq("world".as_bytes()));
}
#[gtest]
#[googletest::test]
fn test_optional_fixed32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.has_optional_fixed32(), eq(false));
@ -60,7 +60,7 @@ fn test_optional_fixed32_accessors() {
assert_that!(msg.optional_fixed32(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_default_fixed32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_fixed32(), eq(47));
@ -78,7 +78,7 @@ fn test_default_fixed32_accessors() {
assert_that!(msg.default_fixed32_opt(), eq(Optional::Unset(47)));
}
#[gtest]
#[googletest::test]
fn test_optional_fixed64_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_fixed64_opt(), eq(Optional::Unset(0)));
@ -97,7 +97,7 @@ fn test_optional_fixed64_accessors() {
assert_that!(msg.optional_fixed64(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_default_fixed64_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_fixed64(), eq(48));
@ -116,7 +116,7 @@ fn test_default_fixed64_accessors() {
assert_that!(msg.default_fixed64_opt(), eq(Optional::Unset(48)));
}
#[gtest]
#[googletest::test]
fn test_optional_int32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_int32_opt(), eq(Optional::Unset(0)));
@ -135,7 +135,7 @@ fn test_optional_int32_accessors() {
assert_that!(msg.optional_int32(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_default_int32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_int32(), eq(41));
@ -158,7 +158,7 @@ fn test_default_int32_accessors() {
assert_that!(msg.default_int32_opt(), eq(Optional::Unset(41)));
}
#[gtest]
#[googletest::test]
fn test_optional_int64_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_int64_opt(), eq(Optional::Unset(0)));
@ -173,7 +173,7 @@ fn test_optional_int64_accessors() {
assert_that!(msg.optional_int64(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_default_int64_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_int64(), eq(42));
@ -188,7 +188,7 @@ fn test_default_int64_accessors() {
assert_that!(msg.default_int64_opt(), eq(Optional::Unset(42)));
}
#[gtest]
#[googletest::test]
fn test_optional_sint32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_sint32_opt(), eq(Optional::Unset(0)));
@ -203,7 +203,7 @@ fn test_optional_sint32_accessors() {
assert_that!(msg.optional_sint32(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_default_sint32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_sint32(), eq(-45));
@ -218,7 +218,7 @@ fn test_default_sint32_accessors() {
assert_that!(msg.default_sint32_opt(), eq(Optional::Unset(-45)));
}
#[gtest]
#[googletest::test]
fn test_optional_sint64_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_sint64_opt(), eq(Optional::Unset(0)));
@ -233,7 +233,7 @@ fn test_optional_sint64_accessors() {
assert_that!(msg.optional_sint64(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_default_sint64_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_sint64(), eq(46));
@ -248,7 +248,7 @@ fn test_default_sint64_accessors() {
assert_that!(msg.default_sint64_opt(), eq(Optional::Unset(46)));
}
#[gtest]
#[googletest::test]
fn test_optional_uint32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_uint32_opt(), eq(Optional::Unset(0)));
@ -263,7 +263,7 @@ fn test_optional_uint32_accessors() {
assert_that!(msg.optional_uint32(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_default_uint32_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_uint32(), eq(43));
@ -278,7 +278,7 @@ fn test_default_uint32_accessors() {
assert_that!(msg.default_uint32_opt(), eq(Optional::Unset(43)));
}
#[gtest]
#[googletest::test]
fn test_optional_uint64_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_uint64_opt(), eq(Optional::Unset(0)));
@ -293,7 +293,7 @@ fn test_optional_uint64_accessors() {
assert_that!(msg.optional_uint64(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_default_uint64_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_uint64(), eq(44));
@ -308,7 +308,7 @@ fn test_default_uint64_accessors() {
assert_that!(msg.default_uint64_opt(), eq(Optional::Unset(44)));
}
#[gtest]
#[googletest::test]
fn test_optional_float_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_float_opt(), eq(Optional::Unset(0.0)));
@ -323,7 +323,7 @@ fn test_optional_float_accessors() {
assert_that!(msg.optional_float(), eq(0.0));
}
#[gtest]
#[googletest::test]
fn test_default_float_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_float(), eq(51.5));
@ -338,7 +338,7 @@ fn test_default_float_accessors() {
assert_that!(msg.default_float_opt(), eq(Optional::Unset(51.5)));
}
#[gtest]
#[googletest::test]
fn test_optional_double_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_double_opt(), eq(Optional::Unset(0.0)));
@ -353,7 +353,7 @@ fn test_optional_double_accessors() {
assert_that!(msg.optional_double(), eq(0.0));
}
#[gtest]
#[googletest::test]
fn test_default_double_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_double(), eq(52e3));
@ -368,7 +368,7 @@ fn test_default_double_accessors() {
assert_that!(msg.default_double_opt(), eq(Optional::Unset(52e3)));
}
#[gtest]
#[googletest::test]
fn test_optional_bool_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_bool_opt(), eq(Optional::Unset(false)));
@ -380,7 +380,7 @@ fn test_optional_bool_accessors() {
assert_that!(msg.optional_bool_opt(), eq(Optional::Unset(false)));
}
#[gtest]
#[googletest::test]
fn test_default_bool_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_bool(), eq(true));
@ -395,7 +395,7 @@ fn test_default_bool_accessors() {
assert_that!(msg.default_bool_opt(), eq(Optional::Unset(true)));
}
#[gtest]
#[googletest::test]
fn test_optional_bytes_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(*msg.optional_bytes(), empty());
@ -421,7 +421,7 @@ fn test_optional_bytes_accessors() {
assert_that!(msg.optional_bytes_opt(), eq(Optional::Set(&b""[..])));
}
#[gtest]
#[googletest::test]
fn test_into_proxied_for_bytes() {
let mut msg = TestAllTypes::new();
@ -463,7 +463,7 @@ fn test_into_proxied_for_bytes() {
assert_that!(msg.optional_bytes(), eq(b"ninth"));
}
#[gtest]
#[googletest::test]
fn test_nonempty_default_bytes_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_bytes(), eq(b"world"));
@ -492,7 +492,7 @@ fn test_nonempty_default_bytes_accessors() {
assert_that!(msg.default_bytes_opt(), eq(Optional::Unset(&b"world"[..])));
}
#[gtest]
#[googletest::test]
fn test_optional_string_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_string(), eq(""));
@ -518,7 +518,7 @@ fn test_optional_string_accessors() {
assert_that!(msg.optional_string_opt(), eq(Optional::Unset("".into())));
}
#[gtest]
#[googletest::test]
fn test_into_proxied_for_string() {
let mut msg = TestAllTypes::new();
@ -567,7 +567,7 @@ fn test_into_proxied_for_string() {
assert_that!(msg.optional_string(), eq("eleventh"));
}
#[gtest]
#[googletest::test]
fn test_nonempty_default_string_accessors() {
let mut msg = TestAllTypes::new();
assert_that!(msg.default_string(), eq("hello"));
@ -593,7 +593,7 @@ fn test_nonempty_default_string_accessors() {
assert_that!(msg.default_string_opt(), eq(Optional::Unset("hello".into())));
}
#[gtest]
#[googletest::test]
fn test_singular_msg_field() {
let mut msg = TestAllTypes::new();
let msg_view = msg.optional_nested_message();
@ -608,7 +608,7 @@ fn test_singular_msg_field() {
assert_that!(msg.has_optional_nested_message(), eq(true));
}
#[gtest]
#[googletest::test]
fn test_message_opt() {
let msg = TestAllTypes::new();
let opt: Optional<unittest_rust_proto::test_all_types::NestedMessageView<'_>> =
@ -617,7 +617,7 @@ fn test_message_opt() {
assert_that!(opt.into_inner().bb(), eq(0));
}
#[gtest]
#[googletest::test]
fn test_message_opt_set() {
let mut msg = TestAllTypes::new();
let submsg = test_all_types::NestedMessage::new();
@ -626,7 +626,7 @@ fn test_message_opt_set() {
assert_that!(msg.optional_nested_message_opt().is_set(), eq(false));
}
#[gtest]
#[googletest::test]
fn test_setting_submsg() {
let mut msg = TestAllTypes::new();
let submsg = test_all_types::NestedMessage::new();
@ -644,7 +644,7 @@ fn test_setting_submsg() {
assert_that!(msg.optional_nested_message_opt().is_set(), eq(false));
}
#[gtest]
#[googletest::test]
fn test_msg_mut_initializes() {
let mut msg = TestAllTypes::new();
assert_that!(msg.has_optional_nested_message(), eq(false));
@ -660,7 +660,7 @@ fn test_msg_mut_initializes() {
assert_that!(msg.optional_nested_message_opt().is_set(), eq(false));
}
#[gtest]
#[googletest::test]
fn test_optional_nested_enum_accessors() {
use test_all_types::NestedEnum;
@ -680,7 +680,7 @@ fn test_optional_nested_enum_accessors() {
assert_that!(msg.optional_nested_enum(), eq(NestedEnum::Foo));
}
#[gtest]
#[googletest::test]
fn test_default_nested_enum_accessors() {
use test_all_types::NestedEnum;
@ -697,7 +697,7 @@ fn test_default_nested_enum_accessors() {
assert_that!(msg.default_nested_enum_opt(), eq(Optional::Unset(NestedEnum::Bar)));
}
#[gtest]
#[googletest::test]
fn test_optional_foreign_enum_accessors() {
use unittest_rust_proto::ForeignEnum;
@ -714,7 +714,7 @@ fn test_optional_foreign_enum_accessors() {
assert_that!(msg.optional_foreign_enum(), eq(ForeignEnum::ForeignFoo));
}
#[gtest]
#[googletest::test]
fn test_default_foreign_enum_accessors() {
use unittest_rust_proto::ForeignEnum;
@ -731,7 +731,7 @@ fn test_default_foreign_enum_accessors() {
assert_that!(msg.default_foreign_enum_opt(), eq(Optional::Unset(ForeignEnum::ForeignBar)));
}
#[gtest]
#[googletest::test]
fn test_optional_import_enum_accessors() {
use unittest_import_rust_proto::ImportEnum;
@ -748,7 +748,7 @@ fn test_optional_import_enum_accessors() {
assert_that!(msg.optional_import_enum(), eq(ImportEnum::ImportFoo));
}
#[gtest]
#[googletest::test]
fn test_default_import_enum_accessors() {
use unittest_import_rust_proto::ImportEnum;
@ -765,7 +765,7 @@ fn test_default_import_enum_accessors() {
assert_that!(msg.default_import_enum_opt(), eq(Optional::Unset(ImportEnum::ImportBar)));
}
#[gtest]
#[googletest::test]
fn test_oneof_accessors() {
use unittest_rust_proto::test_oneof2::{Foo::*, FooCase, NestedEnum};
use unittest_rust_proto::TestOneof2;
@ -816,7 +816,7 @@ fn test_oneof_accessors() {
// TODO: Add tests covering a message-type field in a oneof.
}
#[gtest]
#[googletest::test]
fn test_msg_oneof_default_accessors() {
use unittest_rust_proto::test_oneof2::{Bar::*, BarCase, NestedEnum};
@ -848,7 +848,7 @@ fn test_msg_oneof_default_accessors() {
// TODO: Add tests covering a message-type field in a oneof.
}
#[gtest]
#[googletest::test]
fn test_group() {
let mut m = TestAllTypes::new();
@ -861,7 +861,7 @@ fn test_group() {
assert_that!(m.optionalgroup().a(), eq(7));
}
#[gtest]
#[googletest::test]
fn test_submsg_setter() {
use test_all_types::*;
@ -874,7 +874,7 @@ fn test_submsg_setter() {
assert_that!(parent.optional_nested_message().bb(), eq(7));
}
#[gtest]
#[googletest::test]
fn test_clone() {
let mut m = TestAllTypes::new();
m.set_optional_int32(42);
@ -886,7 +886,7 @@ fn test_clone() {
assert_that!(clone.optional_int32(), eq(42));
}
#[gtest]
#[googletest::test]
fn test_to_owned() {
let mut m = TestAllTypes::new();
m.set_optional_int32(42);
@ -910,7 +910,7 @@ fn test_to_owned() {
assert_that!(submsg_mut.bb(), eq(8));
}
#[gtest]
#[googletest::test]
fn test_ctype_stringpiece() {
let mut msg = TestAllTypes::new();
assert_that!(msg.optional_string_piece(), eq(""));
@ -920,7 +920,7 @@ fn test_ctype_stringpiece() {
assert_that!(msg.has_optional_string_piece(), eq(true));
}
#[gtest]
#[googletest::test]
fn test_msg_clear() {
let mut m = TestAllTypes::new();
m.set_optional_int32(42);
@ -929,7 +929,7 @@ fn test_msg_clear() {
assert_that!(m.has_optional_int32(), eq(false));
}
#[gtest]
#[googletest::test]
fn test_submsg_clear() {
let mut m = TestAllTypes::new();
let mut sub = m.optional_nested_message_mut();

@ -8,20 +8,20 @@
use bad_names_rust_proto::*;
use googletest::prelude::*;
#[gtest]
#[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));
}
#[gtest]
#[googletest::test]
fn test_reserved_keyword_in_messages() {
let _ = r#enum::new();
let _ = Ref::new().r#const();
}
#[gtest]
#[googletest::test]
fn test_collision_in_accessors() {
let mut m = AccessorsCollide::new();
m.set_x_mut_5(false);

@ -8,7 +8,7 @@
use googletest::prelude::*;
use protobuf::prelude::*;
#[gtest]
#[googletest::test]
fn test_canonical_types() {
let _child = child_rust_proto::Child::new();
let _parent = parent_rust_proto::Parent::new();
@ -17,12 +17,12 @@ fn test_canonical_types() {
let _parent_from_child: child_rust_proto::Parent = parent_rust_proto::Parent::new();
}
#[gtest]
#[googletest::test]
fn test_parent_serialization() {
assert_that!(*parent_rust_proto::Parent::new().serialize().unwrap(), empty());
}
#[gtest]
#[googletest::test]
fn test_child_serialization() {
assert_that!(*child_rust_proto::Child::new().serialize().unwrap(), empty());
}

@ -9,7 +9,7 @@ use googletest::prelude::*;
use unittest_rust_proto::{TestAllTypes, TestCord};
#[gtest]
#[googletest::test]
fn test_bytes_cord() {
let mut msg = TestCord::new();
assert_that!(msg.has_optional_bytes_cord(), eq(false));

@ -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).
#[gtest]
#[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));
}
#[gtest]
#[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));
}
#[gtest]
#[googletest::test]
fn repeated_string_view_works() {
let mut msg = edition2023_rust_proto::EditionsMessage::new();
assert_that!(msg.repeated_str_view().len(), eq(0));

@ -12,7 +12,7 @@ use googletest::prelude::*;
use protobuf::Enum;
use unittest_rust_proto::*;
#[gtest]
#[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));
}
#[gtest]
#[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));
}
#[gtest]
#[googletest::test]
fn test_enum_value_name_same_as_enum() {
assert_that!(i32::from(TestEnumValueNameSameAsEnum::TestEnumValueNameSameAsEnum), eq(1));
}
#[gtest]
#[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));
}
#[gtest]
#[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() {
};
}
#[gtest]
#[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()));
}
#[gtest]
#[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));
}
#[gtest]
#[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() {
};
}
#[gtest]
#[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));
}
#[gtest]
#[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));
}
#[gtest]
#[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"));
}
#[gtest]
#[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;
}
#[gtest]
#[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));
}
#[gtest]
#[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));

@ -10,7 +10,7 @@
/// a separate proto_library target.
use googletest::prelude::*;
#[gtest]
#[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 { .. }));
}
#[gtest]
#[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));
}
#[gtest]
#[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;

@ -16,7 +16,7 @@ use unittest_rust_proto::TestAllTypes;
macro_rules! generate_eq_msgs_tests {
($(($type: ident, $name_ext: ident)),*) => {
paste! {$(
#[gtest]
#[googletest::test]
fn [<expect_eq_msgs_ $name_ext>]() {
let mut msg = [< $type >]::new();
let mut msg2 = [< $type >]::new();
@ -33,7 +33,7 @@ macro_rules! generate_eq_msgs_tests {
macro_rules! generate_not_eq_msgs_tests {
($(($type: ident, $name_ext: ident)),*) => {
paste! {$(
#[gtest]
#[googletest::test]
fn [<expect_not_eq_msgs_ $name_ext>]() {
let mut msg = [< $type >]::new();
let mut msg2 = [< $type >]::new();
@ -51,7 +51,7 @@ generate_eq_msgs_tests!((TestAllTypes, editions), (TestAllTypesProto3, proto3));
generate_not_eq_msgs_tests!((TestAllTypes, editions), (TestAllTypesProto3, proto3));
#[gtest]
#[googletest::test]
fn proto_eq_works_on_view() {
// This exercises the `impl<T> Matcher<T> for MessageMatcher<T>
// where T: MatcherEq + Copy` implementation.

@ -9,7 +9,7 @@
use googletest::prelude::*;
#[gtest]
#[googletest::test]
fn test_import_public_types_are_reexported() {
let _: import_public_rust_proto::PrimarySrcPubliclyImportedMsg;
let _: import_public_rust_proto::PrimarySrcPubliclyImportedMsgView;

@ -2,7 +2,7 @@ use googletest::prelude::*;
use protobuf::prelude::*;
use unittest_rust_proto::{NestedTestAllTypes, TestAllTypes};
#[gtest]
#[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));
}
#[gtest]
#[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);
}
#[gtest]
#[googletest::test]
fn merge_repeated_empty() {
let mut dst = TestAllTypes::new();
let mut src = TestAllTypes::new();
@ -30,7 +30,7 @@ fn merge_repeated_empty() {
);
}
#[gtest]
#[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() {
);
}
#[gtest]
#[googletest::test]
fn merge_from_sub_message() {
let mut dst = NestedTestAllTypes::new();
let src = proto!(NestedTestAllTypes {

@ -9,7 +9,7 @@
use googletest::prelude::*;
#[gtest]
#[googletest::test]
fn test_nested_messages_accessible() {
let _parent: unittest_rust_proto::TestAllTypes;
let _child: unittest_rust_proto::test_all_types::NestedMessage;
@ -17,7 +17,7 @@ fn test_nested_messages_accessible() {
nested_test_all_extensions_data::NestedDynamicExtensions::new();
}
#[gtest]
#[googletest::test]
fn test_nested_enums_accessible() {
let _parent: unittest_rust_proto::TestAllTypes;
let _child: unittest_rust_proto::test_all_types::NestedEnum;

@ -1,7 +1,7 @@
use googletest::gtest;
use protobuf::{__internal, __runtime};
#[gtest]
#[googletest::test]
#[allow(clippy::unit_cmp)]
fn test_no_internal_access() {
// This test is to ensure that the `__internal` and `__runtime` mods are

@ -9,7 +9,7 @@
use googletest::prelude::*;
#[gtest]
#[googletest::test]
fn test_message_packages() {
// empty package, message declared in the first .proto source
let _: no_package_rust_proto::MsgWithoutPackage;
@ -28,7 +28,7 @@ fn test_message_packages() {
let _: package_rust_proto::ImportedMsgWithPackage;
}
#[gtest]
#[googletest::test]
fn test_enum_packages() {
// empty package, enum declared in the first .proto source
let _: no_package_rust_proto::EnumWithoutPackage;

@ -20,7 +20,7 @@ struct TestValue {
val: i64,
}
#[gtest]
#[googletest::test]
fn test_setting_literals() {
let fixed64 = || 108;
let test_ref = |x: &i64| *x;
@ -69,7 +69,7 @@ fn test_setting_literals() {
assert_that!(msg.optional_nested_enum(), eq(test_all_types::NestedEnum::Baz));
}
#[gtest]
#[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));
@ -124,7 +124,7 @@ fn single_nested_message() {
assert_that!(msg.has_optional_nested_message(), eq(true));
}
#[gtest]
#[googletest::test]
fn test_recursive_msg() {
let msg = proto!(NestedTestAllTypes {
child: NestedTestAllTypes {
@ -141,7 +141,7 @@ fn test_recursive_msg() {
assert_that!(msg.child().child().child().payload().optional_int32(), eq(43));
}
#[gtest]
#[googletest::test]
fn test_spread_msg() {
let msg = proto!(TestAllTypes { optional_nested_message: NestedMessage { bb: 42 } });
let msg2 = proto!(TestAllTypes { ..msg.as_view() });
@ -151,7 +151,7 @@ fn test_spread_msg() {
assert_that!(msg3.optional_int32(), eq(1));
}
#[gtest]
#[googletest::test]
fn test_spread_nested_msg() {
let msg = proto!(NestedTestAllTypes {
child: NestedTestAllTypes {
@ -170,7 +170,7 @@ fn test_spread_nested_msg() {
assert_that!(msg2.child().child().child().payload().optional_int32(), eq(43));
}
#[gtest]
#[googletest::test]
fn test_repeated_i32() {
let msg = proto!(TestAllTypes { repeated_int32: [1, 1 + 1, 3] });
assert_that!(msg.repeated_int32().len(), eq(3));
@ -179,7 +179,7 @@ fn test_repeated_i32() {
assert_that!(msg.repeated_int32().get(2).unwrap(), eq(3));
}
#[gtest]
#[googletest::test]
fn test_repeated_msg() {
let msg2 = proto!(NestedTestAllTypes { payload: TestAllTypes { optional_int32: 1 } });
let msg = proto!(NestedTestAllTypes {
@ -205,7 +205,7 @@ fn test_repeated_msg() {
assert_that!(msg.repeated_child().get(1).unwrap().payload().optional_int32(), eq(2));
}
#[gtest]
#[googletest::test]
fn test_string_maps() {
let msg =
proto!(TestMap { map_string_string: [("foo", "bar"), ("baz", "qux"), ("quux", "quuz")] });
@ -215,7 +215,7 @@ fn test_string_maps() {
assert_that!(msg.map_string_string().get("quux").unwrap(), eq("quuz"));
}
#[gtest]
#[googletest::test]
fn test_message_maps() {
let msg3 = proto!(TestAllTypes { optional_int32: 3 });
let kv3 = ("quux", msg3);

@ -17,7 +17,7 @@ use unittest_rust_proto::TestAllTypes;
macro_rules! generate_parameterized_serialization_test {
($(($type: ident, $name_ext: ident)),*) => {
paste! { $(
#[gtest]
#[googletest::test]
fn [< serialization_zero_length_ $name_ext >]() {
let mut msg = [< $type >]::new();
@ -31,13 +31,13 @@ macro_rules! generate_parameterized_serialization_test {
assert_that!(serialized.len(), eq(0));
}
#[gtest]
#[googletest::test]
fn [< serialize_default_view $name_ext>]() {
let default = View::<[< $type >]>::default();
assert_that!(default.serialize().unwrap().len(), eq(0));
}
#[gtest]
#[googletest::test]
fn [< serialize_deserialize_message_ $name_ext>]() {
let mut msg = [< $type >]::new();
msg.set_optional_int64(42);
@ -52,17 +52,17 @@ macro_rules! generate_parameterized_serialization_test {
assert_that!(msg.optional_bytes(), eq(msg2.optional_bytes()));
}
#[gtest]
#[googletest::test]
fn [< deserialize_empty_ $name_ext>]() {
assert!([< $type >]::parse(&[]).is_ok());
}
#[gtest]
#[googletest::test]
fn [< deserialize_error_ $name_ext>]() {
assert!([< $type >]::parse(b"not a serialized proto").is_err());
}
#[gtest]
#[googletest::test]
fn [< set_bytes_with_serialized_data_ $name_ext>]() {
let mut msg = [< $type >]::new();
msg.set_optional_int64(42);
@ -72,7 +72,7 @@ macro_rules! generate_parameterized_serialization_test {
assert_that!(msg2.optional_bytes(), eq(msg.serialize().unwrap()));
}
#[gtest]
#[googletest::test]
fn [< deserialize_on_previously_allocated_message_ $name_ext>]() {
let mut msg = [< $type >]::new();
msg.set_optional_int64(42);
@ -102,7 +102,7 @@ macro_rules! generate_parameterized_int32_byte_size_test {
($(($type: ident, $name_ext: ident)),*) => {
paste! { $(
#[gtest]
#[googletest::test]
fn [< test_int32_byte_size_ $name_ext>]() {
let args = vec![(0, 1), (127, 1), (128, 2), (-1, 10)];
for arg in args {

@ -10,7 +10,7 @@ use nested_rust_proto::outer::inner::InnerEnum;
use nested_rust_proto::outer::InnerView;
use nested_rust_proto::*;
#[gtest]
#[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));
}
#[gtest]
#[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));
}
#[gtest]
#[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));
}
#[gtest]
#[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));
}
#[gtest]
#[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));
}
#[gtest]
#[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));
}
#[gtest]
#[googletest::test]
fn test_recursive_mut() {
let mut rec = nested_rust_proto::Recursive::new();
let mut one = rec.rec_mut();

@ -36,7 +36,7 @@ fn make_non_utf8_proto_str() -> &'static ProtoStr {
}
}
#[gtest]
#[googletest::test]
fn test_proto2() {
let non_utf8_str = make_non_utf8_proto_str();
@ -54,7 +54,7 @@ fn test_proto2() {
assert_that!(parsed_result, ok(anything()));
}
#[gtest]
#[googletest::test]
fn test_proto3() {
let non_utf8_str = make_non_utf8_proto_str();
@ -72,7 +72,7 @@ fn test_proto3() {
assert_that!(parsed_result, err(matches_pattern!(&ParseError)));
}
#[gtest]
#[googletest::test]
fn test_verify() {
let non_utf8_str = make_non_utf8_proto_str();

@ -13,7 +13,7 @@ use unittest_rust_proto::{
test_all_types::NestedMessage as NestedMessageProto2, TestAllTypes as TestAllTypesProto2,
};
#[gtest]
#[googletest::test]
fn test_debug_string() {
let mut msg = proto!(TestAllTypesProto2 {
optional_int32: 42,

@ -8,7 +8,7 @@
use googletest::prelude::*;
use unittest_proto3_rust_proto::TestAllTypes;
#[gtest]
#[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")));
}
#[gtest]
#[googletest::test]
fn test_cord_repeated() {
let mut msg = TestAllTypes::new();
assert_that!(msg.repeated_cord().len(), eq(0));

@ -204,9 +204,9 @@ extern "C" {
#[cfg(test)]
mod tests {
use super::*;
use googletest::gtest;
#[gtest]
#[googletest::test]
fn assert_arena_linked() {
use crate::assert_linked;
assert_linked!(upb_Arena_New);
@ -215,7 +215,7 @@ mod tests {
assert_linked!(upb_Arena_Fuse);
}
#[gtest]
#[googletest::test]
fn raw_ffi_test() {
// SAFETY: FFI unit test uses C API under expected patterns.
unsafe {
@ -226,7 +226,7 @@ mod tests {
}
}
#[gtest]
#[googletest::test]
fn test_arena_new_and_free() {
let arena = Arena::new();
drop(arena);

@ -29,9 +29,9 @@ extern "C" {
mod tests {
use super::super::Arena;
use super::*;
use googletest::gtest;
#[gtest]
#[googletest::test]
fn assert_array_linked() {
use crate::assert_linked;
assert_linked!(upb_Array_New);
@ -46,7 +46,7 @@ mod tests {
assert_linked!(upb_Array_GetMutable);
}
#[gtest]
#[googletest::test]
fn array_ffi_test() {
// SAFETY: FFI unit test uses C API under expected patterns.
unsafe {

@ -51,9 +51,9 @@ extern "C" {
mod tests {
use super::super::Arena;
use super::*;
use googletest::gtest;
#[gtest]
#[googletest::test]
fn assert_map_linked() {
use crate::assert_linked;
assert_linked!(upb_Map_New);
@ -65,7 +65,7 @@ mod tests {
assert_linked!(upb_Map_Next);
}
#[gtest]
#[googletest::test]
fn map_ffi_test() {
// SAFETY: FFI unit test uses C API under expected patterns.
unsafe {

@ -306,9 +306,9 @@ extern "C" {
#[cfg(test)]
mod tests {
use super::*;
use googletest::gtest;
#[gtest]
#[googletest::test]
fn assert_message_linked() {
use crate::assert_linked;
assert_linked!(upb_Message_New);

@ -50,9 +50,9 @@ extern "C" {
#[cfg(test)]
mod tests {
use super::*;
use googletest::gtest;
#[gtest]
#[googletest::test]
fn assert_mini_table_linked() {
use crate::assert_linked;
assert_linked!(upb_MiniTable_FindFieldByNumber);

@ -88,9 +88,9 @@ impl<T: Debug + 'static> Debug for OwnedArenaBox<T> {
mod tests {
use super::*;
use core::str;
use googletest::gtest;
#[gtest]
#[googletest::test]
fn test_byte_slice_pointer_roundtrip() {
let arena = Arena::new();
let original_data: &'static [u8] = b"Hello world";
@ -98,7 +98,7 @@ mod tests {
assert_eq!(&*owned_data, b"Hello world");
}
#[gtest]
#[googletest::test]
fn test_alloc_str_roundtrip() {
let arena = Arena::new();
let s: &str = "Hello";
@ -107,7 +107,7 @@ mod tests {
assert_eq!(&*owned_data, s);
}
#[gtest]
#[googletest::test]
fn test_sized_type_roundtrip() {
let arena = Arena::new();
let arena_alloc_u32: NonNull<u32> = arena.copy_in(&7u32).unwrap().into();

@ -68,9 +68,9 @@ pub unsafe fn debug_string(msg: RawMessage, mt: *const upb_MiniTable) -> String
#[cfg(test)]
mod tests {
use super::*;
use googletest::gtest;
#[gtest]
#[googletest::test]
fn assert_text_linked() {
use crate::assert_linked;
assert_linked!(upb_DebugString);

@ -126,9 +126,9 @@ extern "C" {
#[cfg(test)]
mod tests {
use super::*;
use googletest::gtest;
#[gtest]
#[googletest::test]
fn assert_wire_linked() {
use crate::assert_linked;
assert_linked!(upb_Encode);

Loading…
Cancel
Save