Pin the rev of googletest to the GitHub main branch
PiperOrigin-RevId: 630417312pull/16731/head
parent
353b4e0031
commit
7b3682fcf2
|
@ -23,7 +23,7 @@ jobs:
|
|||
- name: Run tests
|
||||
uses: protocolbuffers/protobuf-ci/bazel-docker@v3
|
||||
with:
|
||||
image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:7.1.1-75f2a85ece6526cc3d54087018c0f1097d78d42b"
|
||||
image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:7.1.1-97f82260fd504923d8af642d567afb2d83a1959d"
|
||||
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
|
||||
bazel-cache: rust_linux
|
||||
bazel: >-
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"checksum": "f93f5d1848bc00c6384273f9fb5273cc1b7fc0cb4dbc2afd776d2feb7b37f3ae",
|
||||
"checksum": "8863e5b8f3da7cf4502f68bea0d455dec4834bf25ff070caaa58a8e1c5ea1a3d",
|
||||
"crates": {
|
||||
"aho-corasick 1.1.2": {
|
||||
"name": "aho-corasick",
|
||||
"version": "1.1.2",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/aho-corasick/1.1.2/download",
|
||||
"url": "https://static.crates.io/crates/aho-corasick/1.1.2/download",
|
||||
"sha256": "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
|
||||
}
|
||||
},
|
||||
|
@ -53,7 +53,7 @@
|
|||
"version": "1.1.0",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/autocfg/1.1.0/download",
|
||||
"url": "https://static.crates.io/crates/autocfg/1.1.0/download",
|
||||
"sha256": "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
}
|
||||
},
|
||||
|
@ -101,7 +101,7 @@
|
|||
"deps": {
|
||||
"common": [
|
||||
{
|
||||
"id": "googletest 0.10.0",
|
||||
"id": "googletest 0.11.0",
|
||||
"target": "googletest"
|
||||
}
|
||||
],
|
||||
|
@ -121,13 +121,16 @@
|
|||
},
|
||||
"license": null
|
||||
},
|
||||
"googletest 0.10.0": {
|
||||
"googletest 0.11.0": {
|
||||
"name": "googletest",
|
||||
"version": "0.10.0",
|
||||
"version": "0.11.0",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/googletest/0.10.0/download",
|
||||
"sha256": "09213705c85aa0e4b4fff44a3a826a556979a34a266df6bcda703a49c69fb61e"
|
||||
"Git": {
|
||||
"remote": "https://github.com/google/googletest-rust",
|
||||
"commitish": {
|
||||
"Rev": "471d4a2a8e8bc74f6d7d9c8eecb4d4e3157b2a9f"
|
||||
},
|
||||
"strip_prefix": "googletest"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
|
@ -163,7 +166,7 @@
|
|||
"proc_macro_deps": {
|
||||
"common": [
|
||||
{
|
||||
"id": "googletest_macro 0.10.0",
|
||||
"id": "googletest_macro 0.11.0",
|
||||
"target": "googletest_macro"
|
||||
},
|
||||
{
|
||||
|
@ -173,17 +176,20 @@
|
|||
],
|
||||
"selects": {}
|
||||
},
|
||||
"version": "0.10.0"
|
||||
"version": "0.11.0"
|
||||
},
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"googletest_macro 0.10.0": {
|
||||
"googletest_macro 0.11.0": {
|
||||
"name": "googletest_macro",
|
||||
"version": "0.10.0",
|
||||
"version": "0.11.0",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/googletest_macro/0.10.0/download",
|
||||
"sha256": "005e4cb962c56efd249bdeeb4ac232b11e1c45a2e49793bba2b2982dcc3f2e9d"
|
||||
"Git": {
|
||||
"remote": "https://github.com/google/googletest-rust",
|
||||
"commitish": {
|
||||
"Rev": "471d4a2a8e8bc74f6d7d9c8eecb4d4e3157b2a9f"
|
||||
},
|
||||
"strip_prefix": "googletest_macro"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
|
@ -209,14 +215,14 @@
|
|||
"target": "quote"
|
||||
},
|
||||
{
|
||||
"id": "syn 2.0.38",
|
||||
"id": "syn 2.0.43",
|
||||
"target": "syn"
|
||||
}
|
||||
],
|
||||
"selects": {}
|
||||
},
|
||||
"edition": "2021",
|
||||
"version": "0.10.0"
|
||||
"version": "0.11.0"
|
||||
},
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
|
@ -225,7 +231,7 @@
|
|||
"version": "2.6.4",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/memchr/2.6.4/download",
|
||||
"url": "https://static.crates.io/crates/memchr/2.6.4/download",
|
||||
"sha256": "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||
}
|
||||
},
|
||||
|
@ -263,7 +269,7 @@
|
|||
"version": "0.2.17",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/num-traits/0.2.17/download",
|
||||
"url": "https://static.crates.io/crates/num-traits/0.2.17/download",
|
||||
"sha256": "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
|
||||
}
|
||||
},
|
||||
|
@ -332,7 +338,7 @@
|
|||
"version": "1.0.14",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/paste/1.0.14/download",
|
||||
"url": "https://static.crates.io/crates/paste/1.0.14/download",
|
||||
"sha256": "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
|
||||
}
|
||||
},
|
||||
|
@ -385,7 +391,7 @@
|
|||
"version": "1.0.69",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/proc-macro2/1.0.69/download",
|
||||
"url": "https://static.crates.io/crates/proc-macro2/1.0.69/download",
|
||||
"sha256": "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
|
||||
}
|
||||
},
|
||||
|
@ -448,7 +454,7 @@
|
|||
"version": "1.0.33",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/quote/1.0.33/download",
|
||||
"url": "https://static.crates.io/crates/quote/1.0.33/download",
|
||||
"sha256": "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
}
|
||||
},
|
||||
|
@ -494,7 +500,7 @@
|
|||
"version": "1.10.0",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/regex/1.10.0/download",
|
||||
"url": "https://static.crates.io/crates/regex/1.10.0/download",
|
||||
"sha256": "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87"
|
||||
}
|
||||
},
|
||||
|
@ -567,7 +573,7 @@
|
|||
"version": "0.4.1",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/regex-automata/0.4.1/download",
|
||||
"url": "https://static.crates.io/crates/regex-automata/0.4.1/download",
|
||||
"sha256": "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b"
|
||||
}
|
||||
},
|
||||
|
@ -641,7 +647,7 @@
|
|||
"version": "0.8.1",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/regex-syntax/0.8.1/download",
|
||||
"url": "https://static.crates.io/crates/regex-syntax/0.8.1/download",
|
||||
"sha256": "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33"
|
||||
}
|
||||
},
|
||||
|
@ -686,7 +692,7 @@
|
|||
"version": "1.0.14",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/rustversion/1.0.14/download",
|
||||
"url": "https://static.crates.io/crates/rustversion/1.0.14/download",
|
||||
"sha256": "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
||||
}
|
||||
},
|
||||
|
@ -734,13 +740,13 @@
|
|||
},
|
||||
"license": "MIT OR Apache-2.0"
|
||||
},
|
||||
"syn 2.0.38": {
|
||||
"syn 2.0.43": {
|
||||
"name": "syn",
|
||||
"version": "2.0.38",
|
||||
"version": "2.0.43",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/syn/2.0.38/download",
|
||||
"sha256": "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
|
||||
"url": "https://static.crates.io/crates/syn/2.0.43/download",
|
||||
"sha256": "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
|
@ -790,7 +796,7 @@
|
|||
"selects": {}
|
||||
},
|
||||
"edition": "2021",
|
||||
"version": "2.0.38"
|
||||
"version": "2.0.43"
|
||||
},
|
||||
"license": "MIT OR Apache-2.0"
|
||||
},
|
||||
|
@ -799,7 +805,7 @@
|
|||
"version": "1.0.12",
|
||||
"repository": {
|
||||
"Http": {
|
||||
"url": "https://crates.io/api/v1/crates/unicode-ident/1.0.12/download",
|
||||
"url": "https://static.crates.io/crates/unicode-ident/1.0.12/download",
|
||||
"sha256": "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -27,9 +27,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "googletest"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09213705c85aa0e4b4fff44a3a826a556979a34a266df6bcda703a49c69fb61e"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/google/googletest-rust?rev=471d4a2a8e8bc74f6d7d9c8eecb4d4e3157b2a9f#471d4a2a8e8bc74f6d7d9c8eecb4d4e3157b2a9f"
|
||||
dependencies = [
|
||||
"googletest_macro",
|
||||
"num-traits",
|
||||
|
@ -39,9 +38,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "googletest_macro"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "005e4cb962c56efd249bdeeb4ac232b11e1c45a2e49793bba2b2982dcc3f2e9d"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/google/googletest-rust?rev=471d4a2a8e8bc74f6d7d9c8eecb4d4e3157b2a9f#471d4a2a8e8bc74f6d7d9c8eecb4d4e3157b2a9f"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
|
@ -123,9 +121,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.38"
|
||||
version = "2.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
|
||||
checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -215,7 +215,8 @@ crates_repository(
|
|||
lockfile = "//:Cargo.bazel.lock",
|
||||
packages = {
|
||||
"googletest": crate.spec(
|
||||
version = ">0.0.0",
|
||||
git = "https://github.com/google/googletest-rust",
|
||||
rev = "471d4a2a8e8bc74f6d7d9c8eecb4d4e3157b2a9f",
|
||||
),
|
||||
"paste": crate.spec(
|
||||
version = ">=1",
|
||||
|
|
31
rust/map.rs
31
rust/map.rs
|
@ -521,13 +521,13 @@ mod tests {
|
|||
assert_that!(
|
||||
map.as_view().iter().collect::<Vec<_>>(),
|
||||
unordered_elements_are![
|
||||
eq((3, ProtoStr::from_str("fizz"))),
|
||||
eq((5, ProtoStr::from_str("buzz"))),
|
||||
eq((15, ProtoStr::from_str("fizzbuzz")))
|
||||
eq(&(3, ProtoStr::from_str("fizz"))),
|
||||
eq(&(5, ProtoStr::from_str("buzz"))),
|
||||
eq(&(15, ProtoStr::from_str("fizzbuzz")))
|
||||
]
|
||||
);
|
||||
assert_that!(
|
||||
map.as_view().into_iter().collect::<Vec<_>>(),
|
||||
map.as_view(),
|
||||
unordered_elements_are![
|
||||
eq((3, ProtoStr::from_str("fizz"))),
|
||||
eq((5, ProtoStr::from_str("buzz"))),
|
||||
|
@ -535,7 +535,15 @@ mod tests {
|
|||
]
|
||||
);
|
||||
assert_that!(
|
||||
map.as_view().into_iter().collect::<Vec<_>>(),
|
||||
map.as_mut().iter().collect::<Vec<_>>(),
|
||||
unordered_elements_are![
|
||||
eq(&(3, ProtoStr::from_str("fizz"))),
|
||||
eq(&(5, ProtoStr::from_str("buzz"))),
|
||||
eq(&(15, ProtoStr::from_str("fizzbuzz")))
|
||||
]
|
||||
);
|
||||
assert_that!(
|
||||
map.as_mut(),
|
||||
unordered_elements_are![
|
||||
eq((3, ProtoStr::from_str("fizz"))),
|
||||
eq((5, ProtoStr::from_str("buzz"))),
|
||||
|
@ -551,10 +559,7 @@ mod tests {
|
|||
assert!(map_mut.insert(0, "fizz"));
|
||||
// insert should return false when the key is already present
|
||||
assert!(!map_mut.insert(0, "buzz"));
|
||||
assert_that!(
|
||||
map.as_mut().iter().collect::<Vec<_>>(),
|
||||
unordered_elements_are![eq((0, ProtoStr::from_str("buzz"))),]
|
||||
);
|
||||
assert_that!(map.as_mut(), unordered_elements_are![eq((0, ProtoStr::from_str("buzz"))),]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -568,7 +573,7 @@ mod tests {
|
|||
map_mut.extend([(0, "fizz"), (1, "buzz"), (2, "fizzbuzz")]);
|
||||
|
||||
assert_that!(
|
||||
map.as_view().into_iter().collect::<Vec<_>>(),
|
||||
map.as_view(),
|
||||
unordered_elements_are![
|
||||
eq((0, ProtoStr::from_str("fizz"))),
|
||||
eq((1, ProtoStr::from_str("buzz"))),
|
||||
|
@ -584,7 +589,7 @@ mod tests {
|
|||
map_mut.extend(&map_2);
|
||||
|
||||
assert_that!(
|
||||
map.as_view().into_iter().collect::<Vec<_>>(),
|
||||
map.as_view(),
|
||||
unordered_elements_are![
|
||||
eq((0, ProtoStr::from_str("fizz"))),
|
||||
eq((1, ProtoStr::from_str("buzz"))),
|
||||
|
@ -601,7 +606,7 @@ mod tests {
|
|||
map_mut.copy_from([(0, "fizz"), (1, "buzz"), (2, "fizzbuzz")]);
|
||||
|
||||
assert_that!(
|
||||
map.as_view().into_iter().collect::<Vec<_>>(),
|
||||
map.as_view(),
|
||||
unordered_elements_are![
|
||||
eq((0, ProtoStr::from_str("fizz"))),
|
||||
eq((1, ProtoStr::from_str("buzz"))),
|
||||
|
@ -617,7 +622,7 @@ mod tests {
|
|||
map_mut.copy_from(&map_2);
|
||||
|
||||
assert_that!(
|
||||
map.as_view().into_iter().collect::<Vec<_>>(),
|
||||
map.as_view(),
|
||||
unordered_elements_are![
|
||||
eq((2, ProtoStr::from_str("bing"))),
|
||||
eq((3, ProtoStr::from_str("bong")))
|
||||
|
|
|
@ -479,8 +479,7 @@ mod tests {
|
|||
assert_that!(r.len(), eq(expected_len));
|
||||
|
||||
)*
|
||||
assert_that!(
|
||||
r.iter().collect::<Vec<$t>>(), elements_are![$(eq($vals)),*]);
|
||||
assert_that!(r, elements_are![$(eq($vals)),*]);
|
||||
r.set(0, <$t as Default>::default());
|
||||
assert_that!(r.get(0).expect("elem 0"), eq(<$t as Default>::default()));
|
||||
|
||||
|
@ -507,15 +506,12 @@ mod tests {
|
|||
assert_that!(r.as_mut().len(), eq(0));
|
||||
|
||||
r.as_mut().extend([0, 1]);
|
||||
assert_that!(r.as_mut().iter().collect::<Vec<_>>(), elements_are![eq(0), eq(1)]);
|
||||
assert_that!(r.as_mut(), elements_are![eq(0), eq(1)]);
|
||||
let mut x = Repeated::<i32>::new();
|
||||
x.as_mut().extend([2, 3]);
|
||||
|
||||
r.as_mut().extend(&x.as_mut());
|
||||
|
||||
assert_that!(
|
||||
r.as_mut().iter().collect::<Vec<_>>(),
|
||||
elements_are![eq(0), eq(1), eq(2), eq(3)]
|
||||
);
|
||||
assert_that!(r.as_mut(), elements_are![eq(0), eq(1), eq(2), eq(3)]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ macro_rules! generate_map_primitives_tests {
|
|||
let mut msg = TestMap::new();
|
||||
assert_that!(msg.[< map_ $k_field _ $v_field >]().len(), eq(0));
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _ $v_field >]().iter().collect::<Vec<_>>(),
|
||||
msg.[< map_ $k_field _ $v_field >](),
|
||||
elements_are![]
|
||||
);
|
||||
assert_that!(
|
||||
|
@ -41,24 +41,24 @@ macro_rules! generate_map_primitives_tests {
|
|||
assert_that!(msg.[< map_ $k_field _ $v_field _mut>]().insert(k, v), eq(false));
|
||||
assert_that!(msg.[< map_ $k_field _ $v_field >]().len(), eq(1));
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _ $v_field >]().iter().collect::<Vec<_>>(),
|
||||
msg.[< map_ $k_field _ $v_field >](),
|
||||
elements_are![eq((k, v))]
|
||||
);
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _ $v_field >]().keys().collect::<Vec<_>>(),
|
||||
elements_are![eq(k)]
|
||||
elements_are![eq(&k)]
|
||||
);
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _ $v_field >]().values().collect::<Vec<_>>(),
|
||||
elements_are![eq(v)]
|
||||
elements_are![eq(&v)]
|
||||
);
|
||||
|
||||
let k2: $k_type = $k_nonzero;
|
||||
let v2: $v_type = $v_nonzero;
|
||||
assert_that!(msg.[< map_ $k_field _ $v_field _mut>]().insert(k2, v2), eq(true));
|
||||
assert_that!(msg.[< map_ $k_field _ $v_field >]().len(), eq(2));
|
||||
assert_that!(msg.[< map_ $k_field _ $v_field >](), len(eq(2)));
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _ $v_field >]().iter().collect::<Vec<_>>(),
|
||||
msg.[< map_ $k_field _ $v_field >](),
|
||||
unordered_elements_are![
|
||||
eq((k, v)),
|
||||
eq((k2, v2)),
|
||||
|
@ -66,11 +66,11 @@ macro_rules! generate_map_primitives_tests {
|
|||
);
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _ $v_field >]().keys().collect::<Vec<_>>(),
|
||||
unordered_elements_are![eq(k), eq(k2)]
|
||||
unordered_elements_are![eq(&k), eq(&k2)]
|
||||
);
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _ $v_field >]().values().collect::<Vec<_>>(),
|
||||
unordered_elements_are![eq(v), eq(v2)]
|
||||
unordered_elements_are![eq(&v), eq(&v2)]
|
||||
);
|
||||
}
|
||||
)* }
|
||||
|
@ -105,11 +105,11 @@ fn collect_as_hashmap() {
|
|||
let hashmap: HashMap<String, String> =
|
||||
msg.map_string_string().iter().map(|(k, v)| (k.to_string(), v.to_string())).collect();
|
||||
assert_that!(
|
||||
hashmap.into_iter().collect::<Vec<_>>(),
|
||||
hashmap,
|
||||
unordered_elements_are![
|
||||
eq(("hello".to_owned(), "world".to_owned())),
|
||||
eq(("fizz".to_owned(), "buzz".to_owned())),
|
||||
eq(("boo".to_owned(), "blah".to_owned())),
|
||||
(eq("hello"), eq("world")),
|
||||
(eq("fizz"), eq("buzz")),
|
||||
(eq("boo"), eq("blah")),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -150,10 +150,7 @@ fn test_bytes_and_string_copied() {
|
|||
}
|
||||
|
||||
assert_that!(msg.map_string_string_mut().get("hello").unwrap(), eq("world"));
|
||||
assert_that!(
|
||||
msg.map_string_string().iter().collect::<Vec<_>>(),
|
||||
unordered_elements_are![eq(("hello".into(), "world".into()))]
|
||||
);
|
||||
assert_that!(msg.map_string_string(), unordered_elements_are![(eq("hello"), eq("world"))]);
|
||||
assert_that!(msg.map_int32_bytes_mut().get(1).unwrap(), eq(b"world"));
|
||||
}
|
||||
|
||||
|
@ -166,7 +163,7 @@ fn test_map_setter() {
|
|||
let mut msg2 = TestMap::new();
|
||||
msg2.set_map_string_string(msg.map_string_string());
|
||||
assert_that!(
|
||||
msg2.map_string_string().iter().collect::<Vec<_>>(),
|
||||
msg2.map_string_string(),
|
||||
unordered_elements_are![
|
||||
eq(("hello".into(), "world".into())),
|
||||
eq(("fizz".into(), "buzz".into()))
|
||||
|
@ -242,7 +239,7 @@ macro_rules! generate_map_with_msg_values_tests {
|
|||
msg.[< map_ $k_field _all_types_mut >]().remove($k_nonzero),
|
||||
eq(true),
|
||||
"`remove` should return true when key was present.");
|
||||
assert_that!(msg.[< map_ $k_field _all_types >]().len(), eq(0));
|
||||
assert_that!(msg.[< map_ $k_field _all_types >](), empty());
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _all_types_mut >]().remove($k_nonzero),
|
||||
eq(false),
|
||||
|
@ -255,13 +252,13 @@ macro_rules! generate_map_with_msg_values_tests {
|
|||
// "`iter` should work when empty."
|
||||
// );
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _all_types_mut >]().keys().collect::<Vec<_>>(),
|
||||
elements_are![],
|
||||
msg.[< map_ $k_field _all_types_mut >]().keys().count(),
|
||||
eq(0),
|
||||
"`iter` should work when empty."
|
||||
);
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _all_types_mut >]().values().collect::<Vec<_>>(),
|
||||
elements_are![],
|
||||
msg.[< map_ $k_field _all_types_mut >]().values().count(),
|
||||
eq(0),
|
||||
"`iter` should work when empty."
|
||||
);
|
||||
|
||||
|
@ -277,10 +274,10 @@ macro_rules! generate_map_with_msg_values_tests {
|
|||
// );
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _all_types >]().keys().collect::<Vec<_>>(),
|
||||
unordered_elements_are![eq($k_nonzero)]
|
||||
unordered_elements_are![eq(&$k_nonzero)]
|
||||
);
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _all_types >]().values().collect::<Vec<_>>().len(),
|
||||
msg.[< map_ $k_field _all_types >]().values().count(),
|
||||
eq(1));
|
||||
|
||||
|
||||
|
@ -292,15 +289,15 @@ macro_rules! generate_map_with_msg_values_tests {
|
|||
eq(true));
|
||||
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _all_types >]().iter().collect::<Vec<_>>().len(),
|
||||
eq(2)
|
||||
msg.[< map_ $k_field _all_types >](),
|
||||
len(eq(2))
|
||||
);
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _all_types >]().keys().collect::<Vec<_>>(),
|
||||
unordered_elements_are![eq($k_nonzero), eq($k_other)]
|
||||
unordered_elements_are![eq(&$k_nonzero), eq(&$k_other)]
|
||||
);
|
||||
assert_that!(
|
||||
msg.[< map_ $k_field _all_types >]().values().collect::<Vec<_>>().len(),
|
||||
msg.[< map_ $k_field _all_types >]().values().count(),
|
||||
eq(2)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -35,20 +35,20 @@ macro_rules! generate_repeated_numeric_test {
|
|||
mutator.set(2, 0 as $t);
|
||||
|
||||
assert_that!(
|
||||
mutator.iter().collect::<Vec<_>>(),
|
||||
elements_are![eq(2 as $t), eq(1 as $t), eq(0 as $t)]
|
||||
mutator,
|
||||
elements_are![eq(2 as $t), eq(1 as $t), eq(0 as $t)]
|
||||
);
|
||||
assert_that!(
|
||||
mutator.as_view().into_iter().collect::<Vec<_>>(),
|
||||
elements_are![eq(2 as $t), eq(1 as $t), eq(0 as $t)]
|
||||
mutator.as_view(),
|
||||
elements_are![eq(2 as $t), eq(1 as $t), eq(0 as $t)]
|
||||
);
|
||||
|
||||
for i in 0..mutator.len() {
|
||||
mutator.set(i, 0 as $t);
|
||||
}
|
||||
assert_that!(
|
||||
msg.[<repeated_ $field _mut >]().iter().collect::<Vec<_>>(),
|
||||
each(eq(0 as $t))
|
||||
msg.[<repeated_ $field _mut >](),
|
||||
each(eq(0 as $t))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ macro_rules! generate_repeated_numeric_test {
|
|||
let view = msg.[<repeated_ $field>]();
|
||||
assert_that!(
|
||||
view.iter().collect::<Vec<_>>(),
|
||||
eq(mutator2.iter().collect::<Vec<_>>())
|
||||
eq(&mutator2.iter().collect::<Vec<_>>())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -125,16 +125,13 @@ fn test_repeated_bool_accessors() {
|
|||
mutator.set(2, false);
|
||||
assert_that!(mutator.get(2), some(eq(false)));
|
||||
|
||||
assert_that!(mutator.iter().collect::<Vec<_>>(), elements_are![eq(false), eq(true), eq(false)]);
|
||||
assert_that!(
|
||||
mutator.as_view().into_iter().collect::<Vec<_>>(),
|
||||
elements_are![eq(false), eq(true), eq(false)]
|
||||
);
|
||||
assert_that!(mutator, elements_are![eq(false), eq(true), eq(false)]);
|
||||
assert_that!(mutator.as_view(), elements_are![eq(false), eq(true), eq(false)]);
|
||||
|
||||
for i in 0..mutator.len() {
|
||||
mutator.set(i, false);
|
||||
}
|
||||
assert_that!(msg.repeated_bool().iter().collect::<Vec<_>>(), each(eq(false)));
|
||||
assert_that!(msg.repeated_bool(), each(eq(false)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -161,18 +158,18 @@ fn test_repeated_enum_accessors() {
|
|||
assert_that!(mutator.get(2), some(eq(NestedEnum::Foo)));
|
||||
|
||||
assert_that!(
|
||||
mutator.iter().collect::<Vec<_>>(),
|
||||
mutator,
|
||||
elements_are![eq(NestedEnum::Bar), eq(NestedEnum::Baz), eq(NestedEnum::Foo)]
|
||||
);
|
||||
assert_that!(
|
||||
mutator.as_view().into_iter().collect::<Vec<_>>(),
|
||||
mutator.as_view(),
|
||||
elements_are![eq(NestedEnum::Bar), eq(NestedEnum::Baz), eq(NestedEnum::Foo)]
|
||||
);
|
||||
|
||||
for i in 0..mutator.len() {
|
||||
mutator.set(i, NestedEnum::Foo);
|
||||
}
|
||||
assert_that!(msg.repeated_nested_enum().iter().collect::<Vec<_>>(), each(eq(NestedEnum::Foo)));
|
||||
assert_that!(msg.repeated_nested_enum(), each(eq(NestedEnum::Foo)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -187,7 +184,7 @@ fn test_repeated_bool_set() {
|
|||
msg.set_repeated_bool(mutator2.as_view());
|
||||
|
||||
let view = msg.repeated_bool();
|
||||
assert_that!(view.iter().collect::<Vec<_>>(), eq(mutator2.iter().collect::<Vec<_>>()));
|
||||
assert_that!(&view.iter().collect::<Vec<_>>(), eq(&mutator2.iter().collect::<Vec<_>>()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -211,8 +208,8 @@ fn test_repeated_message() {
|
|||
assert_that!(msg.repeated_nested_message().get(0).unwrap().bb(), eq(2));
|
||||
|
||||
assert_that!(
|
||||
msg.repeated_nested_message().iter().map(|m| m.bb()).collect::<Vec<_>>(),
|
||||
eq(vec![2]),
|
||||
msg.repeated_nested_message(),
|
||||
elements_are![predicate(|m: protobuf::View<NestedMessage>| m.bb() == 2)],
|
||||
);
|
||||
|
||||
drop(msg);
|
||||
|
@ -243,7 +240,7 @@ fn test_repeated_strings() {
|
|||
assert_that!(msg.repeated_string().get(0).unwrap(), eq("set from Mut"));
|
||||
assert_that!(msg.repeated_string().get(1).unwrap(), eq("set second str"));
|
||||
assert_that!(
|
||||
msg.repeated_string().iter().collect::<Vec<_>>(),
|
||||
msg.repeated_string(),
|
||||
elements_are![eq("set from Mut"), eq("set second str")]
|
||||
);
|
||||
older_msg.repeated_string_mut().copy_from(msg.repeated_string());
|
||||
|
@ -251,7 +248,7 @@ fn test_repeated_strings() {
|
|||
|
||||
assert_that!(older_msg.repeated_string().len(), eq(2));
|
||||
assert_that!(
|
||||
older_msg.repeated_string().iter().collect::<Vec<_>>(),
|
||||
older_msg.repeated_string(),
|
||||
elements_are![eq("set from Mut"), eq("set second str")]
|
||||
);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ fn test_default_accessors() {
|
|||
let msg: TestAllTypes = Default::default();
|
||||
assert_that!(
|
||||
msg,
|
||||
matches_pattern!(TestAllTypes{
|
||||
matches_pattern!(&TestAllTypes{
|
||||
default_int32(): eq(41),
|
||||
default_int64(): eq(42),
|
||||
default_uint32(): eq(43),
|
||||
|
|
|
@ -61,12 +61,12 @@ fn test_closed_enum_is_nonexhaustive() {
|
|||
#[test]
|
||||
fn test_closed_enum_conversion() {
|
||||
assert_that!(i32::from(TestSparseEnum::SparseA), eq(123));
|
||||
assert_that!(TestSparseEnum::try_from(123), ok(eq(TestSparseEnum::SparseA)));
|
||||
assert_that!(TestSparseEnum::try_from(123), ok(eq(&TestSparseEnum::SparseA)));
|
||||
|
||||
assert_that!(i32::from(TestSparseEnum::SparseD), eq(-15));
|
||||
assert_that!(TestSparseEnum::try_from(-15), ok(eq(TestSparseEnum::SparseD)));
|
||||
assert_that!(TestSparseEnum::try_from(-15), ok(eq(&TestSparseEnum::SparseD)));
|
||||
|
||||
assert_that!(TestSparseEnum::try_from(0), ok(eq(TestSparseEnum::SparseF)));
|
||||
assert_that!(TestSparseEnum::try_from(0), ok(eq(&TestSparseEnum::SparseF)));
|
||||
assert_that!(TestSparseEnum::try_from(1), err(anything()));
|
||||
}
|
||||
|
||||
|
@ -78,9 +78,9 @@ fn test_closed_aliased_enum_conversion() {
|
|||
assert_that!(i32::from(TestEnumWithDupValue::Bar2), eq(2));
|
||||
assert_that!(i32::from(TestEnumWithDupValue::Baz), eq(3));
|
||||
|
||||
assert_that!(TestEnumWithDupValue::try_from(1), ok(eq(TestEnumWithDupValue::Foo1)));
|
||||
assert_that!(TestEnumWithDupValue::try_from(2), ok(eq(TestEnumWithDupValue::Bar1)));
|
||||
assert_that!(TestEnumWithDupValue::try_from(3), ok(eq(TestEnumWithDupValue::Baz)));
|
||||
assert_that!(TestEnumWithDupValue::try_from(1), ok(eq(&TestEnumWithDupValue::Foo1)));
|
||||
assert_that!(TestEnumWithDupValue::try_from(2), ok(eq(&TestEnumWithDupValue::Bar1)));
|
||||
assert_that!(TestEnumWithDupValue::try_from(3), ok(eq(&TestEnumWithDupValue::Baz)));
|
||||
assert_that!(TestEnumWithDupValue::try_from(0), err(anything()));
|
||||
assert_that!(TestEnumWithDupValue::try_from(4), err(anything()));
|
||||
|
||||
|
|
Loading…
Reference in New Issue