Skip to content

Commit

Permalink
Use the latest googletest version number in our generated Cargo.toml …
Browse files Browse the repository at this point in the history
…for release.

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

PiperOrigin-RevId: 698801255
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Nov 21, 2024
1 parent 96dfcce commit 0325132
Show file tree
Hide file tree
Showing 38 changed files with 216 additions and 216 deletions.
2 changes: 1 addition & 1 deletion rust/cargo/Cargo-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions rust/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(""));
Expand Down
16 changes: 8 additions & 8 deletions rust/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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),*) => {
Expand All @@ -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\")"));
Expand Down
14 changes: 7 additions & 7 deletions rust/proxied.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() };

Expand All @@ -387,15 +387,15 @@ 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());
}

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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions rust/repeated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),* $(,)?]),* $(,)?) => {
Expand Down Expand Up @@ -626,7 +626,7 @@ mod tests {
);
}

#[gtest]
#[googletest::test]
fn test_repeated_extend() {
let mut r = Repeated::<i32>::new();

Expand All @@ -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)]);
Expand Down
12 changes: 6 additions & 6 deletions rust/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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!(
Expand All @@ -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"));
Expand All @@ -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!(
Expand All @@ -684,7 +684,7 @@ mod tests {
}
}

#[gtest]
#[googletest::test]
fn proto_str_utf8_chunks() {
macro_rules! assert_chunks {
($bytes:expr, $($chunks:expr),* $(,)?) => {
Expand Down Expand Up @@ -763,7 +763,7 @@ mod tests {
);
}

#[gtest]
#[googletest::test]
fn proto_str_chars() {
macro_rules! assert_chars {
($bytes:expr, $chars:expr) => {
Expand Down
6 changes: 3 additions & 3 deletions rust/test/cpp/debug_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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");
Expand Down
16 changes: 8 additions & 8 deletions rust/test/cpp/interop/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ extern "C" {
fn GetConstStaticInteropTestMessage() -> *const c_void;
}

#[gtest]
#[googletest::test]
fn send_to_cpp() {
let mut msg1 = InteropTestMessage::new();
msg1.set_i64(7);
let i = unsafe { TakeOwnershipAndGetOptionalInt64(msg1.__unstable_leak_raw_message()) };
assert_eq!(i, 7);
}

#[gtest]
#[googletest::test]
fn mutate_message_mut_in_cpp() {
let mut msg1 = InteropTestMessage::new();
unsafe {
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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()) };
Expand All @@ -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(
Expand Down
Loading

0 comments on commit 0325132

Please sign in to comment.