|
|
|
@ -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("")); |
|
|
|
|