1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-22 23:58:39 +02:00

Add Android.bp entries for googletest and mockall example tests (#2643)

This commit is contained in:
Nicole L 2025-02-26 09:11:48 -08:00 committed by GitHub
parent 4ee2337c63
commit 5f6b9333fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View File

@ -11,3 +11,19 @@ rust_test {
host_supported: true,
test_suites: ["general-tests"],
}
rust_test {
name: "libgoogletest_example",
crate_name: "googletest_example",
srcs: ["googletest.rs"],
rustlibs: ["libgoogletest_rust"],
host_supported: true,
}
rust_test {
name: "libmockall_example",
crate_name: "mockall_example",
srcs: ["mockall.rs"],
rustlibs: ["libmockall"],
host_supported: true,
}

View File

@ -10,7 +10,7 @@ pub trait Pet {
fn test_robot_dog() {
let mut mock_dog = MockPet::new();
mock_dog.expect_is_hungry().return_const(true);
assert_eq!(mock_dog.is_hungry(Duration::from_secs(10)), true);
assert!(mock_dog.is_hungry(Duration::from_secs(10)));
}
// ANCHOR_END: simple_example
@ -23,7 +23,7 @@ fn test_robot_cat() {
.with(mockall::predicate::gt(Duration::from_secs(3 * 3600)))
.return_const(true);
mock_cat.expect_is_hungry().return_const(false);
assert_eq!(mock_cat.is_hungry(Duration::from_secs(1 * 3600)), false);
assert_eq!(mock_cat.is_hungry(Duration::from_secs(5 * 3600)), true);
assert!(mock_cat.is_hungry(Duration::from_secs(5 * 3600)));
assert!(!mock_cat.is_hungry(Duration::from_secs(5)));
}
// ANCHOR_END: extended_example