Adopt Googletest where possible PiperOrigin-RevId: 664953726 Change-Id: I68be602da84e066f224478d694bbd11ab9265963
diff --git a/common/BUILD b/common/BUILD index fe26cda..09360f5 100644 --- a/common/BUILD +++ b/common/BUILD
@@ -38,6 +38,9 @@ crubit_rust_test( name = "arc_anyhow_test", crate = ":arc_anyhow", + deps = [ + "//third_party/gtest_rust/googletest", + ], ) rust_library( @@ -63,6 +66,7 @@ deps = [ ":token_stream_matchers", ":token_stream_printer", + "//third_party/gtest_rust/googletest", ], ) @@ -97,6 +101,9 @@ crubit_rust_test( name = "memoized_test", crate = ":memoized", + deps = [ + "//third_party/gtest_rust/googletest", + ], ) bzl_library( @@ -128,6 +135,9 @@ crubit_rust_test( name = "ffi_types_test", crate = ":ffi_types", + deps = [ + "//third_party/gtest_rust/googletest", + ], ) rust_proc_macro( @@ -150,6 +160,9 @@ proc_macro_deps = [ ":item_exists", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) cc_library( @@ -197,7 +210,10 @@ tags = [ "not_run:arm", # We don't need to run Crubit itself on aarch64. ], - deps = ["@crate_index//:quote"], + deps = [ + "//third_party/gtest_rust/googletest", + "@crate_index//:quote", + ], ) rust_library( @@ -219,6 +235,7 @@ "not_run:arm", # We don't need to run Crubit itself on aarch64. ], deps = [ + "//third_party/gtest_rust/googletest", "@crate_index//:quote", "@crate_index//:tempfile", ], @@ -271,6 +288,7 @@ name = "error_report_test", crate = ":error_report", deps = [ + "//third_party/gtest_rust/googletest", "@crate_index//:serde_json", ], )
diff --git a/common/arc_anyhow.rs b/common/arc_anyhow.rs index 656f7b7..0090c1b 100644 --- a/common/arc_anyhow.rs +++ b/common/arc_anyhow.rs
@@ -260,9 +260,13 @@ #[cfg(test)] mod tests { use super::*; - #[test] + use googletest::prelude::*; + + use super::Result as AAResult; + + #[gtest] fn test_result_context() { - let result: Result<()> = Result::Err(anyhow!("Something went wrong!")) + let result: AAResult<()> = AAResult::Err(anyhow!("Something went wrong!")) .with_context(|| "context 1") .context("context 2"); let err = result.unwrap_err(); @@ -294,7 +298,7 @@ // ); // ``` } - #[test] + #[gtest] fn test_error_context() { let err = anyhow!("Something went wrong!").context("context 1").context("context 2"); assert_eq!(&format!("{err}"), "context 2",); @@ -309,18 +313,18 @@ ); } - #[test] + #[gtest] fn test_macro_anyhow() { assert_eq!(&format!("{}", anyhow!("message")), "message"); } - #[test] + #[gtest] fn test_macro_bail() { - let err = (|| -> Result<()> { bail!("message") })().unwrap_err(); + let err = (|| -> AAResult<()> { bail!("message") })().unwrap_err(); assert_eq!(&format!("{err}"), "message"); } - #[test] + #[gtest] fn test_macro_ensure() { let err = (|| { ensure!(false, "message");
diff --git a/common/code_gen_utils.rs b/common/code_gen_utils.rs index cc0fdb6..ef287ad 100644 --- a/common/code_gen_utils.rs +++ b/common/code_gen_utils.rs
@@ -3,7 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception use arc_anyhow::{anyhow, ensure, Result}; -use itertools::Itertools; use once_cell::sync::Lazy; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote, ToTokens}; @@ -362,31 +361,33 @@ #[cfg(test)] pub mod tests { use super::*; + use googletest::prelude::*; + use itertools::Itertools; use quote::quote; use token_stream_matchers::{assert_cc_matches, assert_rs_matches}; use token_stream_printer::cc_tokens_to_formatted_string_for_tests; - #[test] + #[gtest] fn test_format_cc_ident_basic() { assert_cc_matches!(format_cc_ident("foo").unwrap(), quote! { foo }); } - #[test] + #[gtest] fn test_format_cc_ident_exotic_xid_start() { assert_cc_matches!(format_cc_ident("Łukasz").unwrap(), quote! { Łukasz }); } - #[test] + #[gtest] fn test_format_cc_ident_underscore() { assert_cc_matches!(format_cc_ident("_").unwrap(), quote! { _ }); } - #[test] + #[gtest] fn test_format_cc_ident_reserved_rust_keyword() { assert_cc_matches!(format_cc_ident("impl").unwrap(), quote! { impl }); } - #[test] + #[gtest] fn test_format_cc_ident_reserved_cc_keyword() { let err = format_cc_ident("reinterpret_cast").unwrap_err(); let msg = err.to_string(); @@ -394,7 +395,7 @@ assert!(msg.contains("C++ reserved keyword")); } - #[test] + #[gtest] fn test_format_cc_ident_unparseable_identifier() { let err = format_cc_ident("foo)").unwrap_err(); let msg = err.to_string(); @@ -402,7 +403,7 @@ assert!(msg.contains("cannot parse")); } - #[test] + #[gtest] fn test_format_cc_ident_unqualified_identifiers() { // https://en.cppreference.com/w/cpp/language/identifiers#Unqualified_identifiers @@ -419,7 +420,7 @@ /// /// This may appear in `IR::Record::cc_name`, or in /// `__crubit::annotate(cpp_type=...)`. - #[test] + #[gtest] fn test_format_cc_ident_qualified_identifiers() { assert_cc_matches!( format_cc_ident("std::vector<int>").unwrap(), @@ -427,14 +428,14 @@ ); } - #[test] + #[gtest] fn test_format_cc_ident_empty() { let err = format_cc_ident("").unwrap_err(); let msg = err.to_string(); assert_eq!(msg, "Empty string is not a valid C++ identifier"); } - #[test] + #[gtest] fn test_format_cc_ident_invalid_first_char() { let tests = vec![ // `0` and `1 are field names in `struct RustStruct(i32, u16)`. @@ -462,37 +463,37 @@ } } - #[test] + #[gtest] fn test_make_rs_ident_basic() { let id = make_rs_ident("foo"); assert_rs_matches!(quote! { #id }, quote! { foo }); } - #[test] + #[gtest] fn test_make_rs_ident_reserved_cc_keyword() { let id = make_rs_ident("reinterpret_cast"); assert_rs_matches!(quote! { #id }, quote! { reinterpret_cast }); } - #[test] + #[gtest] fn test_make_rs_ident_reserved_rust_keyword() { let id = make_rs_ident("impl"); assert_rs_matches!(quote! { #id }, quote! { r#impl }); } - #[test] + #[gtest] #[should_panic] fn test_make_rs_ident_unfinished_group() { make_rs_ident("(foo"); // No closing `)`. } - #[test] + #[gtest] #[should_panic] fn test_make_rs_ident_empty() { make_rs_ident(""); } - #[test] + #[gtest] fn test_cc_include_to_tokens_for_system_header() { let include = CcInclude::cstddef(); assert_cc_matches!( @@ -503,7 +504,7 @@ ); } - #[test] + #[gtest] fn test_cc_include_to_tokens_for_user_header() { let include = CcInclude::user_header("some/path/to/header.h".into()); assert_cc_matches!( @@ -514,7 +515,7 @@ ); } - #[test] + #[gtest] fn test_cc_include_ord() { let cstddef = CcInclude::cstddef(); let memory = CcInclude::memory(); @@ -528,7 +529,7 @@ assert!(a < b); } - #[test] + #[gtest] fn test_format_cc_includes() { let includes = [ CcInclude::cstddef(), @@ -554,7 +555,7 @@ ); } - #[test] + #[gtest] fn test_namespace_qualifier_empty() { let ns = NamespaceQualifier::new::<&str>([]); let actual_rs = ns.format_for_rs(); @@ -563,7 +564,7 @@ assert!(actual_cc.is_empty()); } - #[test] + #[gtest] fn test_namespace_qualifier_basic() { let ns = NamespaceQualifier::new(["foo", "bar"]); let actual_rs = ns.format_for_rs(); @@ -572,7 +573,7 @@ assert_cc_matches!(actual_cc, quote! { foo::bar:: }); } - #[test] + #[gtest] fn test_namespace_qualifier_reserved_cc_keyword() { let ns = NamespaceQualifier::new(["foo", "impl", "bar"]); let actual_rs = ns.format_for_rs(); @@ -581,7 +582,7 @@ assert_cc_matches!(actual_cc, quote! { foo::impl::bar:: }); } - #[test] + #[gtest] fn test_namespace_qualifier_reserved_rust_keyword() { let ns = NamespaceQualifier::new(["foo", "reinterpret_cast", "bar"]); let actual_rs = ns.format_for_rs(); @@ -592,7 +593,7 @@ assert!(msg.contains("C++ reserved keyword")); } - #[test] + #[gtest] fn test_namespace_qualifier_format_with_cc_body_top_level_namespace() { let ns = NamespaceQualifier::new::<&str>([]); assert_cc_matches!( @@ -601,7 +602,7 @@ ); } - #[test] + #[gtest] fn test_namespace_qualifier_format_with_cc_body_nested_namespace() { let ns = NamespaceQualifier::new(["foo", "bar", "baz"]); assert_cc_matches!( @@ -614,7 +615,7 @@ ); } - #[test] + #[gtest] fn test_format_cc_include_support_lib_header() { let tests = vec![ ( @@ -655,7 +656,7 @@ } } - #[test] + #[gtest] fn test_escape_non_identifier_chars() { let tests = vec![ ("", ""),
diff --git a/common/error_report.rs b/common/error_report.rs index 198c99b..1eda154 100644 --- a/common/error_report.rs +++ b/common/error_report.rs
@@ -195,8 +195,11 @@ #[cfg(test)] mod tests { use super::*; + use googletest::prelude::*; - #[test] + use arc_anyhow::Result; + + #[gtest] fn anyhow_1arg_static_plain() { let arc_err = anyhow!("abc"); let err: &FormattedError = arc_err.downcast_ref().unwrap(); @@ -206,7 +209,7 @@ assert_eq!(err.message, "abc"); } - #[test] + #[gtest] fn anyhow_1arg_static_fmt() { let some_var = "def"; let arc_err = anyhow!("abc{some_var}"); @@ -217,7 +220,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn anyhow_1arg_dynamic() { let arc_err = anyhow!(format!("abc{}", "def")); let err: &FormattedError = arc_err.downcast_ref().unwrap(); @@ -227,7 +230,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn anyhow_2arg() { let arc_err = anyhow!("abc{}", "def"); let err: &FormattedError = arc_err.downcast_ref().unwrap(); @@ -237,7 +240,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn bail_1arg_static_plain() { let arc_err = (|| -> arc_anyhow::Result<()> { bail!("abc") })().unwrap_err(); let err: &FormattedError = arc_err.downcast_ref().unwrap(); @@ -247,7 +250,7 @@ assert_eq!(err.message, "abc"); } - #[test] + #[gtest] fn bail_1arg_static_fmt() { let some_var = "def"; let arc_err = (|| -> arc_anyhow::Result<()> { bail!("abc{some_var}") })().unwrap_err(); @@ -258,7 +261,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn bail_1arg_dynamic() { let arc_err = (|| -> arc_anyhow::Result<()> { bail!(format!("abc{}", "def")) })().unwrap_err(); @@ -269,7 +272,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn bail_2arg() { let arc_err = (|| -> arc_anyhow::Result<()> { bail!("abc{}", "def") })().unwrap_err(); let err: &FormattedError = arc_err.downcast_ref().unwrap(); @@ -279,7 +282,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn ensure_pass() { let f = || { ensure!(true, "unused message"); @@ -288,7 +291,7 @@ f().unwrap(); } - #[test] + #[gtest] fn ensure_fail_1arg_static_plain() { let arc_err = (|| { ensure!(false, "abc"); @@ -302,7 +305,7 @@ assert_eq!(err.message, "abc"); } - #[test] + #[gtest] fn ensure_fail_1arg_static_fmt() { let some_var = "def"; let arc_err = (|| { @@ -317,7 +320,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn ensure_fail_1arg_dynamic() { let arc_err = (|| { ensure!(false, format!("abc{}", "def")); @@ -331,7 +334,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn ensure_fail_2arg() { let arc_err = (|| { ensure!(false, "abc{}", "def"); @@ -345,7 +348,7 @@ assert_eq!(err.message, "abcdef"); } - #[test] + #[gtest] fn error_report() { let report = ErrorReport::new(); report.insert(&anyhow!("abc{}", "def"));
diff --git a/common/ffi_types.rs b/common/ffi_types.rs index ee75fdf..341e958 100644 --- a/common/ffi_types.rs +++ b/common/ffi_types.rs
@@ -103,8 +103,9 @@ #[cfg(test)] mod tests { use super::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_from_into_ffi_u8_slice_box() { let slice = Box::<[u8]>::from(*b"Hello World!"); let ffi_slice = FfiU8SliceBox::from_boxed_slice(slice.clone());
diff --git a/common/memoized.rs b/common/memoized.rs index a8f41a2..da6d776 100644 --- a/common/memoized.rs +++ b/common/memoized.rs
@@ -294,10 +294,11 @@ #[cfg(test)] pub mod tests { + use googletest::prelude::*; use std::cell::Cell; use std::rc::Rc; - #[test] + #[gtest] fn test_basic_memoization() { crate::query_group! { pub trait Add10 { @@ -331,7 +332,7 @@ /// /// This test is similar to test_basic_memoization, except that it accepts /// and returns references. - #[test] + #[gtest] fn test_nonstatic_memoization() { crate::query_group! { pub trait Add10<'a> { @@ -370,7 +371,7 @@ assert_eq!(count.get(), 3); } - #[test] + #[gtest] #[should_panic( expected = "Cycle detected: a memoized function depends on its own return value" )] @@ -388,7 +389,7 @@ db.add10(1); } - #[test] + #[gtest] fn test_finite_recursion() { crate::query_group! { pub trait Add10 { @@ -427,7 +428,7 @@ /// /// [^1]: Since it has no inputs at all, we could store it as a bare `Option<ReturnType>`, but /// instead we use `HashMap<(), ReturnType>`. Well, good enough. - #[test] + #[gtest] fn test_argless() { crate::query_group! { pub trait Argless {
diff --git a/common/test/bidirectional_deps/BUILD b/common/test/bidirectional_deps/BUILD index 07810aa..3c15299 100644 --- a/common/test/bidirectional_deps/BUILD +++ b/common/test/bidirectional_deps/BUILD
@@ -32,6 +32,7 @@ ], deps = [ ":leaf_rs_lib", + "//third_party/gtest_rust/googletest", ], )
diff --git a/common/test/bidirectional_deps/rs_test.rs b/common/test/bidirectional_deps/rs_test.rs index e0557b3..34ae250 100644 --- a/common/test/bidirectional_deps/rs_test.rs +++ b/common/test/bidirectional_deps/rs_test.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_round_trip() { let value = leaf_rs_lib::wrap(4); assert_eq!(middle_cc_lib::crubit::Unwrap(value), 4); @@ -11,7 +13,7 @@ assert_eq!(leaf_rs_lib::unwrap(value), 2); } -#[test] +#[gtest] fn test_enum_round_trip() { let value = leaf_rs_lib::wrap_enum(2); assert_eq!(middle_cc_lib::crubit::UnwrapEnum(value), 2);
diff --git a/common/token_stream_matchers.rs b/common/token_stream_matchers.rs index 39f2f90..ec5ca0d 100644 --- a/common/token_stream_matchers.rs +++ b/common/token_stream_matchers.rs
@@ -408,6 +408,7 @@ mod tests { use super::internal::*; use super::*; + use googletest::prelude::*; use quote::quote; macro_rules! assert_rs_cc_matches { @@ -417,7 +418,7 @@ }; } - #[test] + #[gtest] fn test_optional_trailing_comma() { assert_rs_matches!(quote! {x}, quote! {x}); assert_rs_matches!(quote! {x}, quote! {x},); @@ -432,13 +433,13 @@ assert_cc_not_matches!(quote! {x}, quote! {y},); } - #[test] + #[gtest] fn test_assert_not_matches_accepts_not_matching_pattern() { assert_cc_not_matches!(quote! { fn foo() {} }, quote! { fn bar() {} }); assert_rs_not_matches!(quote! { fn foo() {} }, quote! { fn bar() {} }); } - #[test] + #[gtest] #[should_panic(expected = r#"input unexpectedly matched the pattern. input: ``` @@ -448,30 +449,30 @@ assert_cc_not_matches!(quote! { fn foo() {} }, quote! { fn foo() {} }); } - #[test] + #[gtest] #[should_panic(expected = "input:\n\n```\nfn foo() {}\n\n```")] fn test_assert_rs_not_matches_panics_on_match() { assert_rs_not_matches!(quote! { fn foo() {} }, quote! { fn foo() {} }); } - #[test] + #[gtest] fn test_assert_cc_matches_accepts_matching_pattern() { assert_rs_cc_matches!(quote! { fn foo() {} }, quote! { fn foo() {} }); } - #[test] + #[gtest] #[should_panic] fn test_assert_cc_matches_panics_on_mismatch() { assert_cc_matches!(quote! { fn foo() {} }, quote! { fn bar() {} }); } - #[test] + #[gtest] #[should_panic] fn test_assert_rs_matches_panics_on_mismatch() { assert_rs_matches!(quote! { fn foo() {} }, quote! { fn bar() {} }); } - #[test] + #[gtest] fn test_accept_siblings() { assert_rs_cc_matches!(quote! {a b c d}, quote! {a b c d}); assert_rs_cc_matches!(quote! {a b c d}, quote! {a b}); @@ -479,24 +480,24 @@ assert_rs_cc_matches!(quote! {a b c d}, quote! {c d}); } - #[test] + #[gtest] fn test_accept_subtrees() { assert_rs_cc_matches!(quote! {impl SomeStruct { fn foo() {} }}, quote! {fn foo() {}}); } - #[test] + #[gtest] #[should_panic] fn test_cc_reject_partial_subtree() { assert_cc_matches!(quote! {fn foo() {a(); b();}}, quote! {fn foo() { a(); }}); } - #[test] + #[gtest] #[should_panic] fn test_rs_reject_partial_subtree() { assert_rs_matches!(quote! {fn foo() {a(); b();}}, quote! {fn foo() { a(); }}); } - #[test] + #[gtest] fn test_cc_error_message() { assert_eq!( format!( @@ -523,7 +524,7 @@ ); } - #[test] + #[gtest] fn test_rustfmt_in_rs_error_message() { assert_eq!( format!( @@ -547,7 +548,7 @@ ); } - #[test] + #[gtest] fn test_reject_unfinished_pattern() { assert_eq!( format!( @@ -568,7 +569,7 @@ ); } - #[test] + #[gtest] fn test_reject_different_delimiters() { assert_eq!( format!( @@ -589,7 +590,7 @@ ); } - #[test] + #[gtest] fn test_reject_mismatch_inside_group() { assert_eq!( format!( @@ -609,7 +610,7 @@ ); } - #[test] + #[gtest] fn test_accept_wildcard_in_group() { assert_rs_cc_matches!( quote! {fn foo() -> bool { return false; }}, @@ -617,7 +618,7 @@ ); } - #[test] + #[gtest] fn test_ignore_newlines() { assert_rs_cc_matches!( quote! {__NEWLINE__ fn __NEWLINE__ foo __NEWLINE__ ( @@ -626,7 +627,7 @@ ); } - #[test] + #[gtest] fn test_ignore_space() { assert_rs_cc_matches!( quote! {__SPACE__ fn __SPACE__ foo __SPACE__ ( @@ -635,7 +636,7 @@ ); } - #[test] + #[gtest] fn test_reject_unfinished_input_inside_group() { assert_eq!( format!( @@ -682,28 +683,28 @@ ); } - #[test] + #[gtest] fn test_accept_unfinished_input_with_only_newlines() { assert_rs_cc_matches!(quote! {fn foo() { __NEWLINE__ }}, quote! {fn foo() {}}); assert_rs_cc_matches!(quote! {fn foo() { a(); __NEWLINE__ }}, quote! {fn foo() { a(); }}); } - #[test] + #[gtest] fn test_wildcard_in_the_beginning_of_the_group() { assert_rs_cc_matches!(quote! { [ a b c ] }, quote! { [ ... c ] }); assert_rs_cc_matches!(quote! { [ a a b b c c ] }, quote! { [ ... c c ] }); } - #[test] + #[gtest] fn test_wildcard_in_the_middle_of_the_group() { assert_rs_cc_matches!(quote! { [ a b c ] }, quote! { [ a ... c ] }); assert_rs_cc_matches!(quote! { [ a a b b c c ] }, quote! { [ a a ... c c ] }); } - #[test] + #[gtest] fn test_wildcard_in_the_end_of_the_group() { assert_rs_cc_matches!(quote! { [ a b c ] }, quote! { [ a ... ] }); assert_rs_cc_matches!(quote! { [ a a b b c c ] }, quote! { [ a a ... ] }); } - #[test] + #[gtest] fn test_pattern_with_wildcards_must_cover_entire_group() { // pattern `[]` would not match the input assert_rs_cc_matches!(quote! { [ a a b b c c ] }, quote! { [ ... ] }); @@ -713,7 +714,7 @@ assert_rs_cc_matches!(quote! { [ a a b b c c ] }, quote! { [ a ... ] }); } - #[test] + #[gtest] fn test_wildcard_not_consuming_anything_in_group() { assert_rs_cc_matches!(quote! { [ a b c ] }, quote! { [ ... a b c ] }); assert_rs_cc_matches!(quote! { [ a b c ] }, quote! { [ a ... b c ] }); @@ -721,13 +722,13 @@ assert_rs_cc_matches!(quote! { [ a b c ] }, quote! { [ a b c ... ] }); } - #[test] + #[gtest] fn test_multiple_wildcards() { assert_rs_cc_matches!(quote! { [ a b c d e f g ] }, quote! { [ a ... b ... c ... f ... ] }); assert_rs_cc_matches!(quote! { [ a b c d e f g ] }, quote! { [ a ... b ... f ... g ] }); } - #[test] + #[gtest] fn test_error_message_shows_the_longest_match_with_wildcards() { assert_eq!( format!( @@ -763,7 +764,7 @@ ); } - #[test] + #[gtest] #[should_panic(expected = "Empty `pattern` is unexpected, because it always matches. \ (Maybe you used `// comment text` instead of `__COMMENT__ \"comment text\"? \ Or maybe you want to use `TokenStream::is_empty`?)")] @@ -777,7 +778,7 @@ ); } - #[test] + #[gtest] #[should_panic(expected = "Empty `pattern` is unexpected, because it always matches. \ (Maybe you used `// comment text` instead of `__COMMENT__ \"comment text\"? \ Or maybe you want to use `TokenStream::is_empty`?)")] @@ -791,7 +792,7 @@ ); } - #[test] + #[gtest] fn test_assert_rs_matches_does_not_need_trailing_wildcard() { assert_rs_matches!( quote! { @@ -804,7 +805,7 @@ ); } - #[test] + #[gtest] #[should_panic] fn test_assert_rs_matches_no_trailing_wildcard_inside_group() { assert_rs_matches!(
diff --git a/common/token_stream_printer.rs b/common/token_stream_printer.rs index 38fb9e3..1f6f96f 100644 --- a/common/token_stream_printer.rs +++ b/common/token_stream_printer.rs
@@ -282,12 +282,13 @@ #[cfg(test)] mod tests { use super::*; + use googletest::prelude::*; use super::Result; use quote::quote; use tempfile::tempdir; - #[test] + #[gtest] fn test_simple_token_stream() -> Result<()> { let token_stream = quote! { struct Foo {} @@ -303,14 +304,14 @@ Ok(()) } - #[test] + #[gtest] fn test_space_idents_and_literals() -> Result<()> { let token_stream = quote! { foo 42 bar 23 }; assert_eq!(tokens_to_string(token_stream)?, "foo 42 bar 23"); Ok(()) } - #[test] + #[gtest] fn test_dont_space_punctuation() -> Result<()> { let token_stream = quote! { foo+42+bar+23 }; assert_eq!(tokens_to_string(token_stream)?, "foo+42+bar+23"); @@ -318,7 +319,7 @@ } /// `foo : ::bar` is valid syntax, but `foo:::bar` is not. - #[test] + #[gtest] fn test_paamayim_nekudotayim() -> Result<()> { assert_eq!(tokens_to_string(quote! { x : :: y })?, "x: ::y"); // The following variants are not syntactically valid, but good to have working @@ -329,56 +330,56 @@ Ok(()) } - #[test] + #[gtest] fn test_newline_token() -> Result<()> { let token_stream = quote! { a __NEWLINE__ b }; assert_eq!(tokens_to_string(token_stream)?, "a\nb"); Ok(()) } - #[test] + #[gtest] fn test_space_token() -> Result<()> { let token_stream = quote! { a __SPACE__ = __SPACE__ b }; assert_eq!(tokens_to_string(token_stream)?, "a = b"); Ok(()) } - #[test] + #[gtest] fn test_redundant_space_token() -> Result<()> { let token_stream = quote! { a __SPACE__ b }; assert_eq!(tokens_to_string(token_stream)?, "a b"); Ok(()) } - #[test] + #[gtest] fn test_hash_token() -> Result<()> { let token_stream = quote! { a __HASH_TOKEN__ b }; assert_eq!(tokens_to_string(token_stream)?, "a #b"); Ok(()) } - #[test] + #[gtest] fn test_include_standard_header() -> Result<()> { let token_stream = quote! { __HASH_TOKEN__ include <cstddef> }; assert_eq!(tokens_to_string(token_stream)?, "#include<cstddef>"); Ok(()) } - #[test] + #[gtest] fn test_comments() -> Result<()> { let token_stream = quote! { __COMMENT__ "line1\nline2" }; assert_eq!(tokens_to_string(token_stream)?, "// line1\n// line2\n"); Ok(()) } - #[test] + #[gtest] fn test_invalid_comment() -> Result<()> { assert!(tokens_to_string(quote! { __COMMENT__ }).is_err()); assert!(tokens_to_string(quote! { __COMMENT__ ident }).is_err()); Ok(()) } - #[test] + #[gtest] fn test_doc_comment() -> Result<()> { // token_stream_printer (and rustfmt) don't put a space between /// and the doc // comment, if the space is desired, it has to appear in the annotation. @@ -395,7 +396,7 @@ Ok(()) } - #[test] + #[gtest] fn test_doc_comment_leading_spaces() -> Result<()> { assert_eq!( rs_tokens_to_formatted_string_for_tests(quote! { #[doc = " hello"] struct X {} })?, @@ -410,7 +411,7 @@ Ok(()) } - #[test] + #[gtest] fn test_special_tokens_in_groups() -> Result<()> { assert_eq!(tokens_to_string(quote! {{ a __NEWLINE__ b }})?, "{ a\nb }"); assert_eq!(tokens_to_string(quote! {{ a __SPACE__ b }})?, "{ a b }"); @@ -419,7 +420,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rs_tokens_to_formatted_string_for_tests() { let input = quote! { fn foo() {} @@ -434,7 +435,7 @@ ); } - #[test] + #[gtest] fn test_rs_tokens_to_formatted_string() { let cfg = RustfmtConfig::new(Path::new(RUSTFMT_EXE_PATH_FOR_TESTING), None); let input = quote! { @@ -452,7 +453,7 @@ ); } - #[test] + #[gtest] fn test_rs_tokens_to_formatted_string_with_custom_rustfmt_toml() -> Result<()> { let tmpdir = tempdir()?; let rustfmt_toml_path = tmpdir.path().join("rustfmt-for-tests.toml"); @@ -484,7 +485,7 @@ Ok(()) } - #[test] + #[gtest] fn test_cc_tokens_to_formatted_string_for_tests() { let input = quote! { namespace ns {
diff --git a/rs_bindings_from_cc/BUILD b/rs_bindings_from_cc/BUILD index 11c293b..fcc5c32 100644 --- a/rs_bindings_from_cc/BUILD +++ b/rs_bindings_from_cc/BUILD
@@ -360,6 +360,9 @@ crubit_rust_test( name = "rs_ir_test", crate = ":ir", + deps = [ + "//third_party/gtest_rust/googletest", + ], ) rust_library( @@ -388,6 +391,7 @@ deps = [ ":ir_matchers", ":ir_testing", + "//third_party/gtest_rust/googletest", "@crate_index//:quote", ], ) @@ -438,6 +442,7 @@ ":ir_testing", "//common:arc_anyhow", "//common:multiplatform_testing", + "//third_party/gtest_rust/googletest", "@crate_index//:itertools", "@crate_index//:proc-macro2", "@crate_index//:quote", @@ -515,6 +520,7 @@ deps = [ "//common:arc_anyhow", "//common:multiplatform_testing", + "//third_party/gtest_rust/googletest", ], ) @@ -574,6 +580,7 @@ ], crate = ":collect_instantiations", deps = [ + "//third_party/gtest_rust/googletest", "@crate_index//:quote", ], )
diff --git a/rs_bindings_from_cc/collect_instantiations.rs b/rs_bindings_from_cc/collect_instantiations.rs index 8e3d685..d4677d6 100644 --- a/rs_bindings_from_cc/collect_instantiations.rs +++ b/rs_bindings_from_cc/collect_instantiations.rs
@@ -94,14 +94,16 @@ #[cfg(test)] mod tests { use super::*; + use arc_anyhow::Result; + use googletest::prelude::*; use quote::quote; - #[test] + #[gtest] fn test_noop() { assert!(collect_instantiations_impl(vec![]).unwrap().is_empty()); } - #[test] + #[gtest] fn test_file_does_not_exist() { let err = collect_instantiations_impl(vec!["does/not/exist".into()]).unwrap_err(); assert_eq!( @@ -122,7 +124,7 @@ collect_instantiations_impl(vec![file]) } - #[test] + #[gtest] fn test_file_doesnt_parse() { let input = make_tmp_input_file("does_not_parse", "This is not (Rust>!"); let err = collect_instantiations_impl(vec![input.clone()]).unwrap_err(); @@ -132,7 +134,7 @@ ); } - #[test] + #[gtest] fn test_single_template_parens() { let result = write_file_and_collect_instantiations(quote! { cc_template!(MyTemplate<int>) }) @@ -140,7 +142,7 @@ assert_eq!(result, vec!["MyTemplate<int>".to_string()]); } - #[test] + #[gtest] fn test_single_template_brackets() { let result = write_file_and_collect_instantiations(quote! { cc_template![MyTemplate<int>] }) @@ -148,7 +150,7 @@ assert_eq!(result, vec!["MyTemplate<int>".to_string()]); } - #[test] + #[gtest] fn test_single_template_curlies() { let result = write_file_and_collect_instantiations(quote! { cc_template!{MyTemplate<int>} }) @@ -156,7 +158,7 @@ assert_eq!(result, vec!["MyTemplate<int>".to_string()]); } - #[test] + #[gtest] fn test_multiple_instantiations() { let result = write_file_and_collect_instantiations(quote! { cc_template!(MyTemplate<short>); @@ -174,7 +176,7 @@ ); } - #[test] + #[gtest] fn test_instantiations_in_subgroups() { let result = write_file_and_collect_instantiations(quote! { fn my_rust_func(input: cc_template!(std::vector<Foo>)) -> @@ -193,7 +195,7 @@ ); } - #[test] + #[gtest] fn test_identical_instantiations() { let result = write_file_and_collect_instantiations(quote! { fn my_rust_func(input: cc_template!(std::vector<Foo>)) -> @@ -212,7 +214,7 @@ std::str::from_utf8(&u8_slice).unwrap().to_string() } - #[test] + #[gtest] fn test_collect_instantiations_json() { let filename = make_tmp_input_file( "json",
diff --git a/rs_bindings_from_cc/generate_bindings/BUILD b/rs_bindings_from_cc/generate_bindings/BUILD index 2ac7833..c78a1dc 100644 --- a/rs_bindings_from_cc/generate_bindings/BUILD +++ b/rs_bindings_from_cc/generate_bindings/BUILD
@@ -43,6 +43,7 @@ "//common:token_stream_matchers", "//rs_bindings_from_cc:ir_matchers", "//rs_bindings_from_cc:ir_testing", + "//third_party/gtest_rust/googletest", "@crate_index//:static_assertions", ], )
diff --git a/rs_bindings_from_cc/generate_bindings/generate_func.rs b/rs_bindings_from_cc/generate_bindings/generate_func.rs index 622da47..cdd2846 100644 --- a/rs_bindings_from_cc/generate_bindings/generate_func.rs +++ b/rs_bindings_from_cc/generate_bindings/generate_func.rs
@@ -1995,13 +1995,15 @@ use super::*; use crate::tests::*; use crate::BindingsTokens; + use arc_anyhow::Result; + use googletest::prelude::*; use ir_testing::{retrieve_func, with_lifetime_macros}; use token_stream_matchers::{ assert_cc_matches, assert_cc_not_matches, assert_rs_matches, assert_rs_not_matches, }; use token_stream_printer::rs_tokens_to_formatted_string_for_tests; - #[test] + #[gtest] fn test_simple_function() -> Result<()> { let ir = ir_from_cc("int Add(int a, int b);")?; let BindingsTokens { rs_api, rs_api_impl } = generate_bindings_tokens(ir)?; @@ -2033,7 +2035,7 @@ Ok(()) } - #[test] + #[gtest] fn test_inline_function() -> Result<()> { let ir = ir_from_cc("inline int Add(int a, int b);")?; let BindingsTokens { rs_api, rs_api_impl } = generate_bindings_tokens(ir)?; @@ -2070,7 +2072,7 @@ Ok(()) } - #[test] + #[gtest] fn test_simple_function_with_types_from_other_target() -> Result<()> { let ir = ir_from_cc_dependency( "inline ReturnStruct DoSomething(ParamStruct param);", @@ -2121,7 +2123,7 @@ Ok(()) } - #[test] + #[gtest] fn test_ref_to_struct_in_thunk_impls() -> Result<()> { let ir = ir_from_cc("struct S{}; inline void foo(S& s) {} ")?; let rs_api_impl = generate_bindings_tokens(ir)?.rs_api_impl; @@ -2136,7 +2138,7 @@ Ok(()) } - #[test] + #[gtest] fn test_const_ref_to_struct_in_thunk_impls() -> Result<()> { let ir = ir_from_cc("struct S{}; inline void foo(const S& s) {} ")?; let rs_api_impl = generate_bindings_tokens(ir)?.rs_api_impl; @@ -2151,7 +2153,7 @@ Ok(()) } - #[test] + #[gtest] fn test_unsigned_int_in_thunk_impls() -> Result<()> { let ir = ir_from_cc("inline void foo(unsigned int i) {} ")?; let rs_api_impl = generate_bindings_tokens(ir)?.rs_api_impl; @@ -2166,7 +2168,7 @@ Ok(()) } - #[test] + #[gtest] fn test_record_static_methods_qualify_call_in_thunk() -> Result<()> { let ir = ir_from_cc( r#" @@ -2186,7 +2188,7 @@ Ok(()) } - #[test] + #[gtest] fn test_record_instance_methods_deref_this_in_thunk() -> Result<()> { let ir = ir_from_cc( r#" @@ -2207,7 +2209,7 @@ Ok(()) } - #[test] + #[gtest] fn test_ptr_func() -> Result<()> { let ir = ir_from_cc(r#" inline int* Deref(int*const* p); "#)?; @@ -2245,7 +2247,7 @@ Ok(()) } - #[test] + #[gtest] fn test_const_char_ptr_func() -> Result<()> { // This is a regression test: We used to include the "const" in the name // of the CcType, which caused a panic in the code generator @@ -2282,7 +2284,7 @@ Ok(()) } - #[test] + #[gtest] fn test_func_ptr_thunk() -> Result<()> { // Using an `inline` keyword forces generation of a C++ thunk in // `rs_api_impl` (i.e. exercises `format_cpp_type` and similar code). @@ -2307,7 +2309,7 @@ Ok(()) } - #[test] + #[gtest] fn test_doc_comment_func() -> Result<()> { let ir = ir_from_cc( " @@ -2332,7 +2334,7 @@ /// Trivial types (at least those that are mapped to Copy rust types) do not /// get a Drop impl. - #[test] + #[gtest] fn test_impl_drop_trivial() -> Result<()> { let ir = ir_from_cc( r#"struct Trivial final { @@ -2348,7 +2350,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_default_explicitly_defaulted_constructor() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2384,7 +2386,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_clone_that_propagates_lifetime() -> Result<()> { // This test covers the case where a single lifetime applies to 1) // the `__this` parameter and 2) other constructor parameters. For @@ -2439,7 +2441,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_default_non_trivial_struct() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2453,7 +2455,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_from_for_1_arg_constructor() -> Result<()> { for explicit_qualifier in ["", "explicit"] { let ir = ir_from_cc(&format!( @@ -2482,7 +2484,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_from_for_implicit_conversion_from_reference() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2516,7 +2518,7 @@ /// Methods with missing lifetimes for `self` should give a useful error /// message. - #[test] + #[gtest] fn test_eq_nolifetime() -> Result<()> { // Missing lifetimes currently only causes hard errors for trait impls, // not For inherent methods. @@ -2531,7 +2533,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_eq_for_member_function() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2566,7 +2568,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_eq_for_free_function() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2590,7 +2592,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_eq_for_free_function_different_types() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2615,7 +2617,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_eq_for_free_function_by_value() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2640,7 +2642,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_lt_for_member_function() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2691,7 +2693,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_lt_for_free_function() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2733,7 +2735,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_lt_for_free_function_by_value() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2774,7 +2776,7 @@ Ok(()) } - #[test] + #[gtest] fn test_assign() -> Result<()> { let ir = ir_from_cc( r#" @@ -2801,7 +2803,7 @@ Ok(()) } - #[test] + #[gtest] fn test_assign_nonreference_other() -> Result<()> { let ir = ir_from_cc( r#" @@ -2828,7 +2830,7 @@ Ok(()) } - #[test] + #[gtest] fn test_assign_nonreference_return() -> Result<()> { let ir = ir_from_cc( r#" @@ -2855,7 +2857,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_eq_non_const_member_function() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2868,7 +2870,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_lt_different_operands() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2890,7 +2892,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_lt_non_const_member_function() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2907,7 +2909,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_lt_rhs_by_value() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2924,7 +2926,7 @@ Ok(()) } - #[test] + #[gtest] fn test_impl_lt_missing_eq_impl() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2940,7 +2942,7 @@ Ok(()) } - #[test] + #[gtest] fn test_thunk_ident_function() -> Result<()> { let ir = ir_from_cc("inline int foo() {}")?; let func = retrieve_func(&ir, "foo"); @@ -2948,7 +2950,7 @@ Ok(()) } - #[test] + #[gtest] fn test_thunk_ident_special_names() { let ir = ir_from_cc("struct Class {};").unwrap(); @@ -2963,7 +2965,7 @@ assert_eq!(thunk_ident(default_constructor), make_rs_ident("__rust_thunk___ZN5ClassC1Ev")); } - #[test] + #[gtest] fn test_elided_lifetimes() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2988,7 +2990,7 @@ Ok(()) } - #[test] + #[gtest] fn test_annotated_lifetimes() -> Result<()> { let ir = ir_from_cc(&with_lifetime_macros( r#" @@ -3012,7 +3014,7 @@ Ok(()) } - #[test] + #[gtest] fn test_format_generic_params() -> Result<()> { assert!( format_generic_params(/* lifetimes= */ &[], std::iter::empty::<syn::Ident>()) @@ -3034,7 +3036,7 @@ Ok(()) } - #[test] + #[gtest] fn test_format_tuple_except_singleton() { fn format(xs: &[TokenStream]) -> TokenStream { format_tuple_except_singleton(xs) @@ -3044,7 +3046,7 @@ assert_rs_matches!(format(&[quote! {a}, quote! {b}]), quote! {(a, b)}); } - #[test] + #[gtest] fn test_overloaded_functions() -> Result<()> { // TODO(b/213280424): We don't support creating bindings for overloaded // functions yet, except in the case of overloaded constructors with a @@ -3107,7 +3109,7 @@ } /// !Unpin references should not be pinned. - #[test] + #[gtest] fn test_nonunpin_ref_param() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -3127,7 +3129,7 @@ } /// !Unpin mut references must be pinned. - #[test] + #[gtest] fn test_nonunpin_mut_param() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -3147,7 +3149,7 @@ } /// !Unpin &self should not be pinned. - #[test] + #[gtest] fn test_nonunpin_ref_self() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -3169,7 +3171,7 @@ } /// !Unpin &mut self must be pinned. - #[test] + #[gtest] fn test_nonunpin_mut_self() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -3191,7 +3193,7 @@ } /// Drop::drop must not use self : Pin<...>. - #[test] + #[gtest] fn test_nonunpin_drop() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -3208,7 +3210,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nonunpin_0_arg_constructor() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3241,7 +3243,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nonunpin_1_arg_constructor() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3274,7 +3276,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nonunpin_2_arg_constructor() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3310,7 +3312,7 @@ /// Traits which monomorphize the `Ctor` parameter into the caller must /// synthesize an RvalueReference parameter, with an appropriate /// lifetime parameter. - #[test] + #[gtest] fn test_nonunpin_by_value_params() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3361,7 +3363,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nonunpin_return() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3401,7 +3403,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nonunpin_const_return() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3441,7 +3443,7 @@ Ok(()) } - #[test] + #[gtest] fn test_unpin_by_value_param() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3479,7 +3481,7 @@ Ok(()) } - #[test] + #[gtest] fn test_unpin_by_value_return() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3523,7 +3525,7 @@ Ok(()) } - #[test] + #[gtest] fn test_unpin_rvalue_ref_qualified_method() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3555,7 +3557,7 @@ Ok(()) } - #[test] + #[gtest] fn test_unpin_rvalue_ref_const_qualified_method() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3589,7 +3591,7 @@ /// Assignment is special in that it discards the return type. /// So if the return type is !Unpin, it needs to emplace!() it. - #[test] + #[gtest] fn test_nonunpin_return_assign() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3637,7 +3639,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nonunpin_param() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3673,7 +3675,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nonunpin_trait_param() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3711,7 +3713,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nonmovable_param() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3730,7 +3732,7 @@ Ok(()) } - #[test] + #[gtest] fn test_function_returning_rvalue_reference() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision
diff --git a/rs_bindings_from_cc/generate_bindings/generate_record.rs b/rs_bindings_from_cc/generate_bindings/generate_record.rs index e1e8654..41ab668 100644 --- a/rs_bindings_from_cc/generate_bindings/generate_record.rs +++ b/rs_bindings_from_cc/generate_bindings/generate_record.rs
@@ -875,10 +875,12 @@ use super::*; use crate::tests::*; use crate::BindingsTokens; + use arc_anyhow::Result; + use googletest::prelude::*; use ir_testing::with_lifetime_macros; use token_stream_matchers::{assert_cc_matches, assert_rs_matches, assert_rs_not_matches}; - #[test] + #[gtest] fn test_template_in_dependency_and_alias_in_current_target() -> Result<()> { // See also the test with the same name in `ir_from_cc_test.rs`. let ir = { @@ -951,7 +953,7 @@ Ok(()) } - #[test] + #[gtest] fn test_template_with_out_of_line_definition() -> Result<()> { // See also an end-to-end test in the `test/templates/out_of_line_definition` // directory. @@ -1007,7 +1009,7 @@ Ok(()) } - #[test] + #[gtest] fn test_simple_struct() -> Result<()> { let ir = ir_from_cc( r#" @@ -1075,7 +1077,7 @@ Ok(()) } - #[test] + #[gtest] fn test_struct_vs_class() -> Result<()> { let ir = ir_from_cc( r#" @@ -1112,7 +1114,7 @@ Ok(()) } - #[test] + #[gtest] fn test_struct_vs_typedefed_struct() -> Result<()> { let ir = ir_from_cc( r#" @@ -1171,7 +1173,7 @@ Ok(()) } - #[test] + #[gtest] fn test_record_with_unsupported_field_type() -> Result<()> { // Using a nested struct because it's currently not supported. // But... any other unsupported type would also work for this test. @@ -1211,7 +1213,7 @@ /// This is a regression test for b/283835873 where the alignment of the /// generated struct was wrong/missing. - #[test] + #[gtest] fn test_struct_with_only_bitfields() -> Result<()> { let ir = ir_from_cc( r#" @@ -1249,7 +1251,7 @@ Ok(()) } - #[test] + #[gtest] fn test_struct_with_unnamed_bitfield_member() -> Result<()> { // This test input causes `field_decl->getName()` to return an empty string. // This example is based on `struct timex` from @@ -1287,7 +1289,7 @@ /// Classes with a non-public destructor shouldn't be constructible, not /// even via Copy/Clone. - #[test] + #[gtest] fn test_trivial_nonpublic_destructor() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -1320,7 +1322,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nontrivial_nonpublic_destructor() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -1355,7 +1357,7 @@ /// /// Right now, a struct can only be Copy/Clone if it's final, but that /// restriction will likely be lifted later. - #[test] + #[gtest] fn test_trivial_abstract_by_value() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -1383,7 +1385,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nontrivial_abstract_by_value() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -1407,7 +1409,7 @@ Ok(()) } - #[test] + #[gtest] fn test_struct_with_unnamed_struct_and_union_members() -> Result<()> { // This test input causes `field_decl->getName()` to return an empty string. // See also: @@ -1467,34 +1469,34 @@ Ok(()) } - #[test] + #[gtest] fn test_copy_derives() { let record = ir_record("S"); assert_eq!(generate_derives(&record), &["Clone", "Copy"]); } - #[test] + #[gtest] fn test_copy_derives_not_is_trivial_abi() { let mut record = ir_record("S"); record.is_trivial_abi = false; assert_eq!(generate_derives(&record), &[""; 0]); } - #[test] + #[gtest] fn test_copy_derives_ctor_deleted() { let mut record = ir_record("S"); record.copy_constructor = ir::SpecialMemberFunc::Unavailable; assert_eq!(generate_derives(&record), &[""; 0]); } - #[test] + #[gtest] fn test_copy_derives_ctor_nontrivial_members() { let mut record = ir_record("S"); record.copy_constructor = ir::SpecialMemberFunc::NontrivialMembers; assert_eq!(generate_derives(&record), &[""; 0]); } - #[test] + #[gtest] fn test_copy_derives_ctor_nontrivial_self() { let mut record = ir_record("S"); record.copy_constructor = ir::SpecialMemberFunc::NontrivialUserDefined; @@ -1502,7 +1504,7 @@ } /// In Rust, a Drop type cannot be Copy. - #[test] + #[gtest] fn test_copy_derives_dtor_nontrivial_self() { let mut record = ir_record("S"); for definition in @@ -1513,7 +1515,7 @@ } } - #[test] + #[gtest] fn test_base_class_subobject_layout() -> Result<()> { let ir = ir_from_cc( r#" @@ -1540,7 +1542,7 @@ /// The same as test_base_class_subobject_layout, but with multiple /// inheritance. - #[test] + #[gtest] fn test_base_class_multiple_inheritance_subobject_layout() -> Result<()> { let ir = ir_from_cc( r#" @@ -1566,7 +1568,7 @@ /// The same as test_base_class_subobject_layout, but with a chain of /// inheritance. - #[test] + #[gtest] fn test_base_class_deep_inheritance_subobject_layout() -> Result<()> { let ir = ir_from_cc( r#" @@ -1592,7 +1594,7 @@ /// For derived classes with no data members, we can't use the offset of the /// first member to determine the size of the base class subobjects. - #[test] + #[gtest] fn test_base_class_subobject_fieldless_layout() -> Result<()> { let ir = ir_from_cc( r#" @@ -1614,7 +1616,7 @@ Ok(()) } - #[test] + #[gtest] fn test_base_class_subobject_empty_fieldless() -> Result<()> { let ir = ir_from_cc( r#" @@ -1637,7 +1639,7 @@ Ok(()) } - #[test] + #[gtest] fn test_base_class_subobject_empty() -> Result<()> { let ir = ir_from_cc( r#" @@ -1662,7 +1664,7 @@ /// Non-aggregate structs can't be directly initialized, because we add /// a zero-sized private field to the bindings. - #[test] + #[gtest] fn test_non_aggregate_struct_private_field() -> Result<()> { let ir = ir_from_cc( r#" @@ -1688,7 +1690,7 @@ /// When a field is [[no_unique_address]], it occupies the space up to the /// next field. - #[test] + #[gtest] fn test_no_unique_address() -> Result<()> { let ir = ir_from_cc( r#" @@ -1740,7 +1742,7 @@ /// When a [[no_unique_address]] field is the last one, it occupies the rest /// of the object. - #[test] + #[gtest] fn test_no_unique_address_last_field() -> Result<()> { let ir = ir_from_cc( r#" @@ -1769,7 +1771,7 @@ Ok(()) } - #[test] + #[gtest] fn test_no_unique_address_empty() -> Result<()> { let ir = ir_from_cc( r#" @@ -1806,7 +1808,7 @@ Ok(()) } - #[test] + #[gtest] fn test_base_class_subobject_empty_last_field() -> Result<()> { let ir = ir_from_cc( r#" @@ -1840,7 +1842,7 @@ Ok(()) } - #[test] + #[gtest] fn test_doc_comment_record() -> Result<()> { let ir = ir_from_cc( "// Doc Comment\n\ @@ -1868,7 +1870,7 @@ Ok(()) } - #[test] + #[gtest] fn test_basic_union() -> Result<()> { let ir = ir_from_cc( r#" @@ -1915,7 +1917,7 @@ Ok(()) } - #[test] + #[gtest] fn test_union_with_opaque_field() -> Result<()> { let ir = ir_from_cc( r#" @@ -1953,7 +1955,7 @@ Ok(()) } - #[test] + #[gtest] fn test_currently_no_offset_assertions_for_unions() -> Result<()> { let ir = ir_from_cc( r#" @@ -1981,7 +1983,7 @@ Ok(()) } - #[test] + #[gtest] fn test_union_with_private_fields() -> Result<()> { let ir = ir_from_cc( r#" @@ -2026,7 +2028,7 @@ Ok(()) } - #[test] + #[gtest] fn test_nontrivial_unions() -> Result<()> { let ir = ir_from_cc_dependency( r#" @@ -2056,7 +2058,7 @@ Ok(()) } - #[test] + #[gtest] fn test_empty_struct() -> Result<()> { let ir = ir_from_cc( r#" @@ -2093,7 +2095,7 @@ Ok(()) } - #[test] + #[gtest] fn test_empty_union() -> Result<()> { let ir = ir_from_cc( r#" @@ -2130,7 +2132,7 @@ Ok(()) } - #[test] + #[gtest] fn test_union_field_with_nontrivial_destructor() -> Result<()> { let ir = ir_from_cc( r#" @@ -2169,7 +2171,7 @@ Ok(()) } - #[test] + #[gtest] fn test_union_with_constructors() -> Result<()> { let ir = ir_from_cc( r#" @@ -2228,7 +2230,7 @@ Ok(()) } - #[test] + #[gtest] fn test_unambiguous_public_bases() -> Result<()> { let ir = ir_from_cc_dependency( " @@ -2288,7 +2290,7 @@ /// /// So, we need to be sure to not allow casting to privately-ambiguous /// bases. - #[test] + #[gtest] fn test_unambiguous_public_bases_private_ambiguity() -> Result<()> { let ir = ir_from_cc_dependency( " @@ -2306,7 +2308,7 @@ Ok(()) } - #[test] + #[gtest] fn test_virtual_thunk() -> Result<()> { let ir = ir_from_cc("struct Polymorphic { virtual void Foo(); };")?; @@ -2321,7 +2323,7 @@ /// A trivially relocatable final struct is safe to use in Rust as normal, /// and is Unpin. - #[test] + #[gtest] fn test_no_negative_impl_unpin() -> Result<()> { let ir = ir_from_cc("struct Trivial final {};")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -2329,7 +2331,7 @@ Ok(()) } - #[test] + #[gtest] fn test_no_aligned_attr() { let ir = ir_from_cc("struct SomeStruct {};").unwrap(); let rs_api = generate_bindings_tokens(ir).unwrap().rs_api; @@ -2341,7 +2343,7 @@ }}; } - #[test] + #[gtest] fn test_aligned_attr() { let ir = ir_from_cc("struct SomeStruct {} __attribute__((aligned(64)));").unwrap(); let rs_api = generate_bindings_tokens(ir).unwrap().rs_api; @@ -2354,7 +2356,7 @@ }; } - #[test] + #[gtest] fn test_forward_declared() -> Result<()> { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -2371,7 +2373,7 @@ Ok(()) } - #[test] + #[gtest] fn test_private_struct_not_present() -> Result<()> { let ir = ir_from_cc(&with_lifetime_macros( r#"#pragma clang lifetime_elision @@ -2395,7 +2397,7 @@ Ok(()) } - #[test] + #[gtest] fn test_implicit_template_specializations_are_sorted_by_mangled_name() -> Result<()> { let bindings = generate_bindings_tokens(ir_from_cc( r#" @@ -2461,7 +2463,7 @@ Ok(()) } - #[test] + #[gtest] fn test_implicit_template_specialization_namespace_qualifier() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" #pragma clang lifetime_elision @@ -2495,7 +2497,7 @@ Ok(()) } - #[test] + #[gtest] fn test_derived_class_inherits_unambiguous_public_functions_bases() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2537,7 +2539,7 @@ Ok(()) } - #[test] + #[gtest] fn test_member_in_derived_class_overwrites_inherited_ones() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2573,7 +2575,7 @@ Ok(()) } - #[test] + #[gtest] fn test_forward_declared_class_template_specialization_symbol() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2606,7 +2608,7 @@ /// Unsupported fields on supported structs are replaced with opaque blobs. /// /// This is hard to test any other way than token comparison! - #[test] + #[gtest] fn test_supported_suppressed_field_types() -> Result<()> { // Ideally we'd use a cross-platform test, but it's hard to craft an unsupported // type that is still returned successfully by db.rs_type_kind(), and so @@ -2649,7 +2651,7 @@ /// Nontrivial fields are replaced with opaque blobs, even if they're /// supported! - #[test] + #[gtest] fn test_supported_nontrivial_field() -> Result<()> { let mut ir = ir_from_cc( r#" @@ -2675,7 +2677,7 @@ Ok(()) } - #[test] + #[gtest] fn test_supported_no_unique_address_field() -> Result<()> { let mut ir = ir_from_cc( r#"
diff --git a/rs_bindings_from_cc/generate_bindings/lib.rs b/rs_bindings_from_cc/generate_bindings/lib.rs index 5b6a21c..88bcaee 100644 --- a/rs_bindings_from_cc/generate_bindings/lib.rs +++ b/rs_bindings_from_cc/generate_bindings/lib.rs
@@ -1446,6 +1446,8 @@ #[cfg(test)] pub(crate) mod tests { use super::*; + use arc_anyhow::Result; + use googletest::prelude::*; use ir_testing::{make_ir_from_items, retrieve_func, with_lifetime_macros}; use static_assertions::{assert_impl_all, assert_not_impl_any}; use token_stream_matchers::{ @@ -1484,7 +1486,7 @@ )) } - #[test] + #[gtest] fn test_disable_thread_safety_warnings() -> Result<()> { let ir = ir_from_cc("inline void foo() {}")?; let rs_api_impl = generate_bindings_tokens(ir)?.rs_api_impl; @@ -1504,7 +1506,7 @@ } // TODO(b/200067824): These should generate nested types. - #[test] + #[gtest] fn test_nested_type_definitions() -> Result<()> { for nested_type in ["enum NotPresent {};", "struct NotPresent {};", "struct NotPresent;"] { let ir = ir_from_cc(&format!( @@ -1524,7 +1526,7 @@ /// Unlike other nested type definitions, typedefs can use the aliased type /// instead. - #[test] + #[gtest] fn test_typedef_member() -> Result<()> { let ir = ir_from_cc( r#" @@ -1547,7 +1549,7 @@ Ok(()) } - #[test] + #[gtest] fn test_struct_from_other_target() -> Result<()> { let ir = ir_from_cc_dependency("// intentionally empty", "struct SomeStruct {};")?; let BindingsTokens { rs_api, rs_api_impl } = generate_bindings_tokens(ir)?; @@ -1556,7 +1558,7 @@ Ok(()) } - #[test] + #[gtest] fn test_func_ptr_where_params_are_primitive_types() -> Result<()> { let ir = ir_from_cc(r#" int (*get_ptr_to_func())(float, double); "#)?; let BindingsTokens { rs_api, rs_api_impl } = generate_bindings_tokens(ir)?; @@ -1596,7 +1598,7 @@ Ok(()) } - #[test] + #[gtest] fn test_func_ref() -> Result<()> { let ir = ir_from_cc(r#" int (&get_ref_to_func())(float, double); "#)?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -1612,7 +1614,7 @@ Ok(()) } - #[test] + #[gtest] fn test_func_ptr_with_non_static_lifetime() -> Result<()> { let ir = ir_from_cc(&with_lifetime_macros( r#" @@ -1628,7 +1630,7 @@ Ok(()) } - #[test] + #[gtest] fn test_func_ptr_where_params_are_raw_ptrs() -> Result<()> { let ir = ir_from_cc(r#" const int* (*get_ptr_to_func())(const int*); "#)?; let BindingsTokens { rs_api, rs_api_impl } = generate_bindings_tokens(ir)?; @@ -1682,7 +1684,7 @@ mod custom_abi_tests { use super::*; use ir_matchers::assert_ir_matches; - #[test] + #[gtest] fn test_func_ptr_with_custom_abi() -> Result<()> { if multiplatform_testing::test_platform() != multiplatform_testing::Platform::X86Linux { return Ok(()); @@ -1747,7 +1749,7 @@ Ok(()) } - #[test] + #[gtest] fn test_func_ptr_with_custom_abi_thunk() -> Result<()> { if multiplatform_testing::test_platform() != multiplatform_testing::Platform::X86Linux { return Ok(()); @@ -1801,7 +1803,7 @@ Ok(()) } - #[test] + #[gtest] fn test_custom_abi_thunk() -> Result<()> { if multiplatform_testing::test_platform() != multiplatform_testing::Platform::X86Linux { return Ok(()); @@ -1868,7 +1870,7 @@ } } - #[test] + #[gtest] fn test_item_order() -> Result<()> { let ir = ir_from_cc( "int first_func(); @@ -1897,7 +1899,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_enum_basic() -> Result<()> { let ir = ir_from_cc("enum Color { kRed = 5, kBlue };")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -1927,7 +1929,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_opaque_enum() -> Result<()> { let ir = ir_from_cc("enum Color : int;")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -1935,7 +1937,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_scoped_enum_basic() -> Result<()> { let ir = ir_from_cc("enum class Color { kRed = -5, kBlue };")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -1965,7 +1967,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_enum_with_64_bit_signed_vals() -> Result<()> { let ir = ir_from_cc( r#"enum Color : long { @@ -2006,7 +2008,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_enum_with_64_bit_unsigned_vals() -> Result<()> { let ir = ir_from_cc( r#" enum Color: unsigned long { @@ -2043,7 +2045,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_enum_with_32_bit_signed_vals() -> Result<()> { let ir = ir_from_cc( "enum Color { kViolet = -2147483647 - 1, kRed = -5, kBlue, kGreen = 3, kMagenta = 2147483647 };", @@ -2078,7 +2080,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_enum_with_32_bit_unsigned_vals() -> Result<()> { let ir = ir_from_cc("enum Color: unsigned int { kRed, kBlue, kLimeGreen = 4294967295 };")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -2109,7 +2111,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_enum_bool() -> Result<()> { let ir = ir_from_cc("enum Bool : bool { kFalse, kTrue };")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -2139,7 +2141,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_enum_bool_alias() -> Result<()> { let ir = ir_from_cc("using MyBool = bool; enum Bool : MyBool { kFalse, kTrue };")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -2171,7 +2173,7 @@ /// At the least, a trivial type should have no drop impl if or until we add /// empty drop impls. - #[test] + #[gtest] fn test_no_impl_drop() -> Result<()> { let ir = ir_from_cc("struct Trivial {};")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -2182,7 +2184,7 @@ /// User-defined destructors *must* become Drop impls with ManuallyDrop /// fields - #[test] + #[gtest] fn test_impl_drop_user_defined_destructor() -> Result<()> { let ir = ir_from_cc( r#" struct NontrivialStruct { ~NontrivialStruct(); }; @@ -2214,7 +2216,7 @@ /// nontrivial types without user-defined destructors should invoke /// the C++ destructor to preserve the order of field destructions. - #[test] + #[gtest] fn test_impl_drop_nontrivial_member_destructor() -> Result<()> { // TODO(jeanpierreda): This would be cleaner if the UserDefinedDestructor code were // omitted. For example, we simulate it so that UserDefinedDestructor @@ -2251,7 +2253,7 @@ Ok(()) } - #[test] + #[gtest] fn test_type_alias() -> Result<()> { let ir = ir_from_cc( r#" @@ -2293,7 +2295,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rs_type_kind_implements_copy() -> Result<()> { let template = r#" LIFETIMES struct [[clang::trivial_abi]] TrivialStruct final { int i; }; @@ -2426,7 +2428,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rs_type_kind_is_shared_ref_to_with_lifetimes() -> Result<()> { let db = db_from_cc( "#pragma clang lifetime_elision @@ -2458,7 +2460,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rs_type_kind_is_shared_ref_to_without_lifetimes() -> Result<()> { let db = db_from_cc( "struct SomeStruct {}; @@ -2479,7 +2481,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rs_type_kind_lifetimes() -> Result<()> { let db = db_from_cc( r#" @@ -2510,7 +2512,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rs_type_kind_lifetimes_raw_ptr() -> Result<()> { let db = db_from_cc("void foo(int* a);")?; let ir = db.ir(); @@ -2520,7 +2522,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rs_type_kind_rejects_func_ptr_that_returns_struct_by_value() -> Result<()> { let db = db_from_cc( r#" @@ -2545,7 +2547,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rs_type_kind_rejects_func_ptr_that_takes_struct_by_value() -> Result<()> { let db = db_from_cc( r#" @@ -2570,7 +2572,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rust_keywords_are_escaped_in_rs_api_file() -> Result<()> { let ir = ir_from_cc("struct type { int dyn; };")?; let rs_api = generate_bindings_tokens(ir)?.rs_api; @@ -2578,7 +2580,7 @@ Ok(()) } - #[test] + #[gtest] fn test_rust_keywords_are_not_escaped_in_rs_api_impl_file() -> Result<()> { let ir = ir_from_cc("struct type { int dyn; };")?; let rs_api_impl = generate_bindings_tokens(ir)?.rs_api_impl; @@ -2589,7 +2591,7 @@ Ok(()) } - #[test] + #[gtest] fn test_namespace_module_items() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2627,7 +2629,7 @@ Ok(()) } - #[test] + #[gtest] fn test_detail_outside_of_namespace_module() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2658,7 +2660,7 @@ Ok(()) } - #[test] + #[gtest] fn test_assertions_outside_of_namespace_module() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2690,7 +2692,7 @@ Ok(()) } - #[test] + #[gtest] fn test_reopened_namespaces() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2728,7 +2730,7 @@ Ok(()) } - #[test] + #[gtest] fn test_qualified_identifiers_in_impl_file() -> Result<()> { let rs_api_impl = generate_bindings_tokens(ir_from_cc( r#" @@ -2757,7 +2759,7 @@ Ok(()) } - #[test] + #[gtest] fn test_inline_namespace() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2802,7 +2804,7 @@ Ok(()) } - #[test] + #[gtest] fn test_inline_namespace_not_marked_inline() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" @@ -2836,13 +2838,13 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_doc_comment_with_no_comment_with_no_source_loc_with_source_loc_enabled() { let actual = generate_doc_comment(None, None, SourceLocationDocComment::Enabled); assert!(actual.is_empty()); } - #[test] + #[gtest] fn test_generate_doc_comment_with_no_comment_with_source_loc_with_source_loc_enabled() { let actual = generate_doc_comment( None, @@ -2852,7 +2854,7 @@ assert_rs_matches!(actual, quote! {#[doc = " google3/some/header;l=11"]}); } - #[test] + #[gtest] fn test_generate_doc_comment_with_comment_with_source_loc_with_source_loc_enabled() { let actual = generate_doc_comment( Some("Some doc comment"), @@ -2865,20 +2867,20 @@ ); } - #[test] + #[gtest] fn test_generate_doc_comment_with_comment_with_no_source_loc_with_source_loc_enabled() { let actual = generate_doc_comment(Some("Some doc comment"), None, SourceLocationDocComment::Enabled); assert_rs_matches!(actual, quote! {#[doc = " Some doc comment"]}); } - #[test] + #[gtest] fn test_no_generate_doc_comment_with_no_comment_with_no_source_loc_with_source_loc_disabled() { let actual = generate_doc_comment(None, None, SourceLocationDocComment::Disabled); assert!(actual.is_empty()); } - #[test] + #[gtest] fn test_no_generate_doc_comment_with_no_comment_with_source_loc_with_source_loc_disabled() { let actual = generate_doc_comment( None, @@ -2888,7 +2890,7 @@ assert!(actual.is_empty()); } - #[test] + #[gtest] fn test_no_generate_doc_comment_with_comment_with_source_loc_with_source_loc_disabled() { let actual = generate_doc_comment( Some("Some doc comment"), @@ -2898,7 +2900,7 @@ assert_rs_matches!(actual, quote! {#[doc = " Some doc comment"]}); } - #[test] + #[gtest] fn test_no_generate_doc_comment_with_comment_with_no_source_loc_with_source_loc_disabled() { let actual = generate_doc_comment( Some("Some doc comment"), @@ -2926,7 +2928,7 @@ } } - #[test] + #[gtest] fn test_generate_unsupported_item_with_source_loc_enabled() -> Result<()> { let db = Database::new( Rc::new(make_ir_from_items([])), @@ -2949,7 +2951,7 @@ /// Not all items currently have source_loc(), e.g. comments. /// /// For these, we omit the mention of the location. - #[test] + #[gtest] fn test_generate_unsupported_item_with_missing_source_loc() -> Result<()> { let db = Database::new( Rc::new(make_ir_from_items([])), @@ -2969,7 +2971,7 @@ Ok(()) } - #[test] + #[gtest] fn test_generate_unsupported_item_with_source_loc_disabled() -> Result<()> { let db = Database::new( Rc::new(make_ir_from_items([])), @@ -2992,7 +2994,7 @@ /// Enumerators with unknown attributes on otherwise-ok enums are omitted. /// /// This is hard to test any other way than token comparison! - #[test] + #[gtest] fn test_supported_unknown_attr_enumerator() -> Result<()> { let mut ir = ir_from_cc( r#" @@ -3013,7 +3015,7 @@ /// /// This is hard to test any other way than token comparison, because it's /// hard to test for the nonexistence of a module. - #[test] + #[gtest] fn test_supported_unknown_attr_namespace() -> Result<()> { for nested_notpresent in ["struct NotPresent {};", "struct NotPresent;", "enum NotPresent {};"] @@ -3043,7 +3045,7 @@ /// Namespaces with an unknown attribute are still merged with the same /// namespace with no unknown attribute. - #[test] + #[gtest] fn test_supported_unknown_attr_namespace_merge() -> Result<()> { let mut ir = ir_from_cc( r#" @@ -3072,7 +3074,7 @@ /// Namespaces with an unknown attribute are not present in supported, but /// their typedefs are. - #[test] + #[gtest] fn test_supported_unknown_attr_namespace_typedef() -> Result<()> { let mut ir = ir_from_cc( r#" @@ -3097,7 +3099,7 @@ } /// The default crubit feature set currently doesn't include supported. - #[test] + #[gtest] fn test_default_crubit_features_disabled_supported() -> Result<()> { for item in [ "extern \"C\" void NotPresent() {}", @@ -3123,7 +3125,7 @@ } /// The default crubit feature set currently doesn't include experimetnal. - #[test] + #[gtest] fn test_default_crubit_features_disabled_experimental() -> Result<()> { let mut ir = ir_from_cc("struct NotPresent {~NotPresent();};")?; ir.target_crubit_features_mut(&ir.current_target().clone()).clear(); @@ -3139,7 +3141,7 @@ Ok(()) } - #[test] + #[gtest] fn test_default_crubit_features_disabled_dependency_supported_function_parameter() -> Result<()> { for dependency in ["struct NotPresent {};"] { @@ -3158,7 +3160,7 @@ Ok(()) } - #[test] + #[gtest] fn test_default_crubit_features_disabled_dependency_experimental_function_parameter() -> Result<()> { let mut ir = @@ -3176,7 +3178,7 @@ Ok(()) } - #[test] + #[gtest] fn test_default_crubit_features_disabled_dependency_supported_function_return_type() -> Result<()> { let mut ir = ir_from_cc_dependency("NotPresent Func();", "struct NotPresent {};")?; @@ -3193,7 +3195,7 @@ Ok(()) } - #[test] + #[gtest] fn test_default_crubit_features_disabled_dependency_experimental_function_return_type() -> Result<()> { let mut ir = @@ -3211,7 +3213,7 @@ Ok(()) } - #[test] + #[gtest] fn test_default_crubit_features_disabled_dependency_struct() -> Result<()> { for dependency in ["struct NotPresent {signed char x;};", "using NotPresent = signed char;"] { @@ -3231,7 +3233,7 @@ Ok(()) } - #[test] + #[gtest] fn test_type_map_override_assert() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" #pragma clang lifetime_elision @@ -3257,7 +3259,7 @@ Ok(()) } - #[test] + #[gtest] fn test_type_map_override_c_abi_incompatible() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" #pragma clang lifetime_elision @@ -3284,7 +3286,7 @@ Ok(()) } - #[test] + #[gtest] fn test_type_map_override_c_abi_compatible() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" #pragma clang lifetime_elision @@ -3313,7 +3315,7 @@ } /// We cannot generate size/align assertions for incomplete types. - #[test] + #[gtest] fn test_type_map_override_assert_incomplete() -> Result<()> { let rs_api = generate_bindings_tokens(ir_from_cc( r#" #pragma clang lifetime_elision
diff --git a/rs_bindings_from_cc/generate_bindings/rs_snippet.rs b/rs_bindings_from_cc/generate_bindings/rs_snippet.rs index 3f5ad7a..05eaec2 100644 --- a/rs_bindings_from_cc/generate_bindings/rs_snippet.rs +++ b/rs_bindings_from_cc/generate_bindings/rs_snippet.rs
@@ -941,9 +941,11 @@ #[cfg(test)] mod tests { use super::*; + use arc_anyhow::Result; + use googletest::prelude::*; use token_stream_matchers::assert_rs_matches; - #[test] + #[gtest] fn test_dfs_iter_ordering() { // Set up a test input representing: A<B<C>, D<E>>. let a = { @@ -975,7 +977,7 @@ assert_eq!(vec!["A", "B", "C", "D", "E"], dfs_names); } - #[test] + #[gtest] fn test_dfs_iter_ordering_for_func_ptr() { // Set up a test input representing: fn(A, B) -> C let f = { @@ -1011,7 +1013,7 @@ assert_eq!(vec!["fn", "A", "B", "C"], dfs_names); } - #[test] + #[gtest] fn test_lifetime_elision_for_references() { let type_args: &[RsTypeKind] = &[]; let referent = Rc::new(RsTypeKind::Other { @@ -1027,7 +1029,7 @@ assert_rs_matches!(quote! {#reference}, quote! {&T}); } - #[test] + #[gtest] fn test_lifetime_elision_for_rvalue_references() { let type_args: &[RsTypeKind] = &[]; let referent = Rc::new(RsTypeKind::Other { @@ -1043,7 +1045,7 @@ assert_rs_matches!(quote! {#reference}, quote! {RvalueReference<'_, T>}); } - #[test] + #[gtest] fn test_format_as_self_param_rvalue_reference() -> Result<()> { let type_args: &[RsTypeKind] = &[]; let referent = Rc::new(RsTypeKind::Other { @@ -1062,7 +1064,7 @@ Ok(()) } - #[test] + #[gtest] fn test_format_as_self_param_const_rvalue_reference() -> Result<()> { let type_args: &[RsTypeKind] = &[]; let referent = Rc::new(RsTypeKind::Other { @@ -1085,7 +1087,7 @@ /// /// If a nested type within it requires a feature, then the whole feature /// does. This is done automatically via dfs_iter(). - #[test] + #[gtest] fn test_required_crubit_features() { let no_types: &[RsTypeKind] = &[]; let int = RsTypeKind::Primitive(PrimitiveType::i32);
diff --git a/rs_bindings_from_cc/ir.rs b/rs_bindings_from_cc/ir.rs index 9dab3fd..028cc13 100644 --- a/rs_bindings_from_cc/ir.rs +++ b/rs_bindings_from_cc/ir.rs
@@ -1504,13 +1504,14 @@ #[cfg(test)] mod tests { use super::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_identifier_debug_print() { assert_eq!(format!("{:?}", Identifier { identifier: "hello".into() }), "\"hello\""); } - #[test] + #[gtest] fn test_unqualified_identifier_debug_print() { assert_eq!( format!( @@ -1523,7 +1524,7 @@ assert_eq!(format!("{:?}", UnqualifiedIdentifier::Destructor), "Destructor"); } - #[test] + #[gtest] fn test_used_headers() { let input = r#" { @@ -1543,14 +1544,14 @@ assert_eq!(ir.flat_ir, expected); } - #[test] + #[gtest] fn test_empty_crate_root_path() { let input = "{ \"current_target\": \"//foo:bar\" }"; let ir = deserialize_ir(input.as_bytes()).unwrap(); assert_eq!(ir.crate_root_path(), None); } - #[test] + #[gtest] fn test_crate_root_path() { let input = r#" { @@ -1562,19 +1563,19 @@ assert_eq!(ir.crate_root_path().as_deref(), Some("__cc_template_instantiations_rs_api")); } - #[test] + #[gtest] fn test_bazel_label_target() { let label: BazelLabel = "//foo:bar".into(); assert_eq!(label.target_name(), "bar"); } - #[test] + #[gtest] fn test_bazel_label_target_dotless() { let label: BazelLabel = "//foo".into(); assert_eq!(label.target_name(), "foo"); } - #[test] + #[gtest] fn test_bazel_label_dotless_slashless() { let label: BazelLabel = "foo".into(); assert_eq!(label.target_name(), "foo"); @@ -1582,7 +1583,7 @@ /// These are not labels, but there is an unambiguous interpretation of /// what their target should be that lets us keep going. - #[test] + #[gtest] fn test_bazel_label_empty_target() { for s in ["foo:", "foo/", ""] { let label: BazelLabel = s.into(); @@ -1590,61 +1591,61 @@ } } - #[test] + #[gtest] fn test_bazel_label_escape_target_name_with_relative_label() { let label: BazelLabel = "foo".into(); assert_eq!(label.target_name_escaped(), "foo"); } - #[test] + #[gtest] fn test_bazel_label_escape_target_name_with_invalid_characters() { let label: BazelLabel = "//:!./%-@^#$&()*-+,;<=>?[]{|}~".into(); assert_eq!(label.target_name_escaped(), "___________________________"); } - #[test] + #[gtest] fn test_bazel_label_escape_target_name_core() { let label: BazelLabel = "//foo~:core".into(); assert_eq!(label.target_name_escaped(), "core_foo_"); } - #[test] + #[gtest] fn test_bazel_label_escape_target_name_with_no_target_name() { let label: BazelLabel = "//foo/bar~".into(); assert_eq!(label.target_name_escaped(), "bar_"); } - #[test] + #[gtest] fn test_bazel_label_escape_target_name_with_no_package_name() { let label: BazelLabel = "//:foo~".into(); assert_eq!(label.target_name_escaped(), "foo_"); } - #[test] + #[gtest] fn test_bazel_label_escape_target_name_core_with_no_package_name_with_no_target_name() { let label: BazelLabel = "core".into(); assert_eq!(label.target_name_escaped(), "core_"); } - #[test] + #[gtest] fn test_bazel_label_escape_target_name_starting_with_digit() { let label: BazelLabel = "12345".into(); assert_eq!(label.target_name_escaped(), "n12345"); } - #[test] + #[gtest] fn test_bazel_to_cc_identifier_empty() { assert_eq!(BazelLabel::from("").convert_to_cc_identifier(), "_"); } - #[test] + #[gtest] fn test_bazel_to_cc_identifier_alphanumeric_not_transformed() { assert_eq!(BazelLabel::from("abc").convert_to_cc_identifier(), "_abc"); assert_eq!(BazelLabel::from("foo123").convert_to_cc_identifier(), "_foo123"); assert_eq!(BazelLabel::from("123foo").convert_to_cc_identifier(), "_123foo"); } - #[test] + #[gtest] fn test_bazel_to_cc_identifier_simple_targets() { assert_eq!( BazelLabel::from("//foo/bar:baz_abc").convert_to_cc_identifier(), @@ -1652,7 +1653,7 @@ ); } - #[test] + #[gtest] fn test_bazel_to_cc_identifier_conflict() { assert_ne!( BazelLabel::from("//foo_bar:baz").convert_to_cc_identifier(),
diff --git a/rs_bindings_from_cc/ir_from_cc_test.rs b/rs_bindings_from_cc/ir_from_cc_test.rs index 763d57c..71c34ab 100644 --- a/rs_bindings_from_cc/ir_from_cc_test.rs +++ b/rs_bindings_from_cc/ir_from_cc_test.rs
@@ -4,6 +4,7 @@ #![cfg(test)] use arc_anyhow::Result; +use googletest::prelude::*; use ir::*; use ir_matchers::{assert_ir_matches, assert_ir_not_matches, assert_items_match}; use ir_testing::{ir_id, retrieve_func, retrieve_record}; @@ -21,7 +22,7 @@ ir_testing::ir_from_cc_dependency(multiplatform_testing::test_platform(), header, dep_header) } -#[test] +#[gtest] fn test_function() { let ir = ir_from_cc("int f(int a, int b);").unwrap(); assert_ir_matches!( @@ -106,7 +107,7 @@ ); } -#[test] +#[gtest] fn test_function_with_asm_label() { let ir = ir_from_cc("int f(int a, int b) asm(\"foo\");").unwrap(); assert_ir_matches!( @@ -120,7 +121,7 @@ ); } -#[test] +#[gtest] fn test_function_with_unnamed_parameters() { let ir = ir_from_cc("int f(int, int);").unwrap(); assert_ir_matches!( @@ -142,7 +143,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_function_parameters() { let ir = ir_from_cc("int f(int self, int crate, int super);").unwrap(); assert_ir_matches!( @@ -166,7 +167,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_struct_name() { let ir = ir_from_cc("struct Self{ int field; };").unwrap(); assert_ir_matches!( @@ -180,7 +181,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_enum_name() { let ir = ir_from_cc("enum Self{ kFoo = 1 };").unwrap(); assert_ir_matches!( @@ -194,7 +195,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_enumerator_name() { let ir = ir_from_cc("enum SomeEnum { self = 1 };").unwrap(); assert_ir_matches!( @@ -208,7 +209,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_anonymous_struct_type_alias() { let ir = ir_from_cc("typedef struct { int field; } Self;").unwrap(); assert_ir_matches!( @@ -222,7 +223,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_field_name() { let ir = ir_from_cc("struct SomeStruct { int self; };").unwrap(); assert_ir_matches!( @@ -241,7 +242,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_namespace_name() { let ir = ir_from_cc("namespace self { void foo(); }").unwrap(); assert_ir_matches!( @@ -255,7 +256,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_function_name() { let ir = ir_from_cc("void self();").unwrap(); assert_ir_matches!( @@ -269,7 +270,7 @@ ); } -#[test] +#[gtest] fn test_unescapable_rust_keywords_in_type_alias_name() { let ir = ir_from_cc("using Self = int;").unwrap(); assert_ir_matches!( @@ -283,7 +284,7 @@ ); } -#[test] +#[gtest] fn test_function_with_custom_calling_convention() { if multiplatform_testing::test_platform() != multiplatform_testing::Platform::X86Linux { return; // vectorcall only exists on x86_64, not e.g. aarch64 @@ -301,7 +302,7 @@ ); } -#[test] +#[gtest] fn test_functions_from_dependency_are_not_emitted() -> Result<()> { let ir = ir_from_cc_dependency("int Add(int a, int b);", "int Multiply(int a, int b);")?; assert_ir_matches!(ir, quote! { Func { name: "Add" ... } }); @@ -309,13 +310,13 @@ Ok(()) } -#[test] +#[gtest] fn test_dont_import_record_nested_in_func() { let ir = ir_from_cc("inline void f() { struct S{}; }").unwrap(); assert_ir_not_matches!(ir, quote! { Record { ... "S" ... } }); } -#[test] +#[gtest] fn test_explicit_class_template_instantiation_declaration_not_supported_yet() { let ir = ir_from_cc( " @@ -336,7 +337,7 @@ ); } -#[test] +#[gtest] fn test_function_template_not_supported_yet() { let ir = ir_from_cc("template<typename SomeParam> void SomeFunctionTemplate() {};").unwrap(); assert_ir_matches!( @@ -350,7 +351,7 @@ ); } -#[test] +#[gtest] fn test_record_member_variable_access_specifiers() { let ir = ir_from_cc( " @@ -413,7 +414,7 @@ ); } -#[test] +#[gtest] fn test_bitfields() { let ir = ir_from_cc( r#" @@ -479,7 +480,7 @@ } /// This is a regression test for b/270748945. -#[test] +#[gtest] fn test_struct_with_packed_attribute() { let ir = ir_from_cc( r#" @@ -502,7 +503,7 @@ } /// This is a regression test for b/270748945. -#[test] +#[gtest] fn test_struct_with_packed_field() { let ir = ir_from_cc( r#" @@ -524,7 +525,7 @@ ); } -#[test] +#[gtest] fn test_struct_with_unnamed_bitfield_member() { // This test input causes `field_decl->getName()` to return an empty string. // This example is based on `struct timex` from @@ -552,7 +553,7 @@ ); } -#[test] +#[gtest] fn test_struct_with_bridging_type_annotation() { let ir = ir_from_cc( r#" @@ -580,7 +581,7 @@ ); } -#[test] +#[gtest] fn test_struct_with_unnamed_struct_and_union_members() { // This test input causes `field_decl->getName()` to return an empty string. // See also: @@ -632,7 +633,7 @@ ); } -#[test] +#[gtest] fn test_record_private_member_functions_not_present() { let ir = ir_from_cc( " @@ -653,7 +654,7 @@ assert_ir_not_matches!(ir, quote! { Func { name: "private_method" ... } }); } -#[test] +#[gtest] fn test_record_private_static_member_functions_not_present() { let ir = ir_from_cc( " @@ -674,7 +675,7 @@ assert_ir_not_matches!(ir, quote! { Func { name: "private_method" ... } }); } -#[test] +#[gtest] fn test_record_special_member_access_specifiers() { let ir = ir_from_cc( " @@ -703,7 +704,7 @@ ); } -#[test] +#[gtest] fn test_record_special_member_definition() { let ir = ir_from_cc( " @@ -730,7 +731,7 @@ ); } -#[test] +#[gtest] fn test_pointer_member_variable() { let ir = ir_from_cc( "struct SomeStruct { @@ -770,7 +771,7 @@ ); } -#[test] +#[gtest] fn test_doc_comment() -> Result<()> { let ir = ir_from_cc( r#" @@ -822,7 +823,7 @@ Ok(()) } -#[test] +#[gtest] fn test_doc_comment_vs_tooling_directives() -> Result<()> { let ir = ir_from_cc( r#" // Doc comment for `f1` @@ -872,7 +873,7 @@ Ok(()) } -#[test] +#[gtest] fn test_type_conversion() -> Result<()> { // TODO(mboehme): Add tests for the corresponding versions of the types in // the `std` namespace. We currently can't do this because we can't include @@ -1035,7 +1036,7 @@ Ok(()) } -#[test] +#[gtest] fn test_typedef() -> Result<()> { let ir = ir_from_cc( r#" @@ -1098,7 +1099,7 @@ Ok(()) } -#[test] +#[gtest] fn test_typedef_duplicate() -> Result<()> { let ir = ir_from_cc( r#" @@ -1147,7 +1148,7 @@ Ok(()) } -#[test] +#[gtest] fn test_typedef_of_full_template_specialization() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1254,7 +1255,7 @@ Ok(()) } -#[test] +#[gtest] fn test_typedef_for_explicit_template_specialization() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1328,7 +1329,7 @@ Ok(()) } -#[test] +#[gtest] fn test_multiple_typedefs_to_same_specialization() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1359,7 +1360,7 @@ Ok(()) } -#[test] +#[gtest] fn test_implicit_specialization_items_are_deterministically_ordered() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1424,7 +1425,7 @@ Ok(()) } -#[test] +#[gtest] fn test_templates_inheritance() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1470,7 +1471,7 @@ Ok(()) } -#[test] +#[gtest] fn test_aliased_class_template_instantiated_in_header() -> Result<()> { // This aliased class template specialization is instantiated due to the code // that is present in the header. We should not corrupt the AST by @@ -1505,7 +1506,7 @@ Ok(()) } -#[test] +#[gtest] fn test_aliased_class_template_partially_instantiated_in_header() -> Result<()> { // Similar to `test_aliased_class_template_instantiated_in_header`, but doesn't // instantiate all members. @@ -1538,7 +1539,7 @@ Ok(()) } -#[test] +#[gtest] fn test_subst_template_type_parm_pack_type() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1587,7 +1588,7 @@ Ok(()) } -#[test] +#[gtest] fn test_fully_instantiated_template_in_function_return_type() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1642,7 +1643,7 @@ Ok(()) } -#[test] +#[gtest] fn test_fully_instantiated_template_in_function_param_type() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1711,7 +1712,7 @@ Ok(()) } -#[test] +#[gtest] fn test_fully_instantiated_template_in_public_field() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1774,7 +1775,7 @@ Ok(()) } -#[test] +#[gtest] fn test_fully_instantiated_template_in_private_field() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1815,7 +1816,7 @@ Ok(()) } -#[test] +#[gtest] fn test_template_with_decltype_and_with_auto() -> Result<()> { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -1840,7 +1841,7 @@ Ok(()) } -#[test] +#[gtest] fn test_subst_template_type_parm_type_vs_const_when_non_const_template_param() -> Result<()> { // This test (and // `test_subst_template_type_parm_type_vs_const_when_const_template_param`) @@ -1909,7 +1910,7 @@ Ok(()) } -#[test] +#[gtest] fn test_subst_template_type_parm_type_vs_const_when_const_template_param() -> Result<()> { // This test (and // `test_subst_template_type_parm_type_vs_const_when_non_const_template_param`) @@ -1978,7 +1979,7 @@ Ok(()) } -#[test] +#[gtest] fn test_template_and_alias_are_both_in_dependency() -> Result<()> { // See also the `test_template_in_dependency_and_alias_in_current_target` test. let ir = { @@ -2089,7 +2090,7 @@ Ok(()) } -#[test] +#[gtest] fn test_template_in_dependency_and_alias_in_current_target() -> Result<()> { // See also the `test_template_and_alias_are_both_in_dependency` test. let ir = { @@ -2196,7 +2197,7 @@ Ok(()) } -#[test] +#[gtest] fn test_well_known_types_check_namespaces() -> Result<()> { let ir = ir_from_cc( r#" @@ -2232,34 +2233,34 @@ Ok(()) } -#[test] +#[gtest] fn test_dont_import_typedef_nested_in_func() { let ir = ir_from_cc("inline void f() { typedef int MyTypedefDecl; }").unwrap(); assert_ir_not_matches!(ir, quote! { TypeAlias { identifier: "MyTypedefDecl" ... } }); } -#[test] +#[gtest] fn test_dont_import_typedef_for_structs_from_c() { let ir = ir_from_cc("struct MyStruct {}; typedef struct MyStruct MyStruct;").unwrap(); assert_ir_matches!(ir, quote! { Record { ... cc_name: "MyStruct" ...}}); assert_ir_not_matches!(ir, quote! { TypeAlias { identifier: "MyStruct" ... } }); } -#[test] +#[gtest] fn test_ignore_typedef_but_import_struct_from_c() { let ir = ir_from_cc("typedef struct {} MyStruct;").unwrap(); assert_ir_matches!(ir, quote! { Record { ... cc_name: "MyStruct" ...}}); assert_ir_not_matches!(ir, quote! { TypeAlias { identifier: "MyStruct" ... } }); } -#[test] +#[gtest] fn test_typedef_and_import_struct_from_c() { let ir = ir_from_cc("typedef struct MyStruct {} MyTypedef;").unwrap(); assert_ir_matches!(ir, quote! { Record { ... cc_name: "MyStruct" ...}}); assert_ir_matches!(ir, quote! { TypeAlias { identifier: "MyTypedef" ... } }); } -#[test] +#[gtest] fn test_import_struct_typedef_from_different_decl_context() { let ir = ir_from_cc( "struct MyStruct {}; namespace test_namespace_bindings { typedef MyStruct MyStruct; }", @@ -2271,7 +2272,7 @@ // TODO(b/214901011): This only worked because we didn't generate bindings for // the second reopened namespace. -// #[test] +// #[gtest] #[allow(dead_code)] fn test_ignore_struct_typedef_from_decl_context_redecl() { let ir = ir_from_cc( @@ -2287,7 +2288,7 @@ // TODO(b/214901011): This only worked because we didn't generate IR for the // namespace coming from the dependency. -// #[test] +// #[gtest] #[allow(dead_code)] fn test_ignore_struct_typedef_from_decl_context_redecl_from_multiple_targets() { let ir = ir_from_cc_dependency( @@ -2298,28 +2299,28 @@ assert_ir_not_matches!(ir, quote! { TypeAlias { identifier: "MyStruct" ... } }); } -#[test] +#[gtest] fn test_dont_import_typedef_for_unions_from_c() { let ir = ir_from_cc("union MyUnion {}; typedef union MyUnion MyUnion;").unwrap(); assert_ir_matches!(ir, quote! { Record { ... cc_name: "MyUnion" ...}}); assert_ir_not_matches!(ir, quote! { TypeAlias { identifier: "MyUnion" ... } }); } -#[test] +#[gtest] fn test_ignore_typedef_but_import_union_from_c() { let ir = ir_from_cc("typedef union {} MyUnion;").unwrap(); assert_ir_matches!(ir, quote! { Record { ... cc_name: "MyUnion" ...}}); assert_ir_not_matches!(ir, quote! { TypeAlias { identifier: "MyUnion" ... } }); } -#[test] +#[gtest] fn test_typedef_and_import_union_from_c() { let ir = ir_from_cc("typedef union MyUnion {} MyTypedef;").unwrap(); assert_ir_matches!(ir, quote! { Record { ... cc_name: "MyUnion" ...}}); assert_ir_matches!(ir, quote! { TypeAlias { identifier: "MyTypedef" ... } }); } -#[test] +#[gtest] fn test_import_union_typedef_from_different_decl_context() { let ir = ir_from_cc( "union MyUnion {}; namespace test_namespace_bindings { typedef MyUnion MyUnion; }", @@ -2331,7 +2332,7 @@ // TODO(b/214901011): This only worked because we didn't generate bindings for // the second reopened namespace. -// #[test] +// #[gtest] #[allow(dead_code)] fn test_ignore_union_typedef_from_decl_context_redecl() { let ir = ir_from_cc( @@ -2347,7 +2348,7 @@ // TODO(b/214901011): This only worked because we didn't generate IR for the // namespace coming from the dependency. -// #[test] +// #[gtest] #[allow(dead_code)] fn test_ignore_union_typedef_from_decl_context_redecl_from_multiple_targets() { let ir = ir_from_cc_dependency( @@ -2358,7 +2359,7 @@ assert_ir_not_matches!(ir, quote! { TypeAlias { identifier: "MyUnion" ... } }); } -#[test] +#[gtest] fn test_records_nested_in_records_not_supported_yet() { let ir = ir_from_cc("struct SomeStruct { struct NestedStruct {}; };").unwrap(); assert_ir_matches!( @@ -2372,7 +2373,7 @@ ); } -#[test] +#[gtest] fn test_record_with_unsupported_field_type() -> Result<()> { // Using a nested struct because it's currently not supported. // But... any other unsupported type would also work for this test. @@ -2430,7 +2431,7 @@ Ok(()) } -#[test] +#[gtest] fn test_record_with_unsupported_base() -> Result<()> { let ir = ir_from_cc( r#" struct OuterStruct { @@ -2498,7 +2499,7 @@ Ok(()) } -#[test] +#[gtest] fn test_do_not_import_static_member_functions_when_record_not_supported_yet() { // only using nested struct as an example of a record we cannot import yet. let ir = ir_from_cc( @@ -2518,7 +2519,7 @@ ); } -#[test] +#[gtest] fn test_do_not_import_nonstatic_member_functions_when_record_not_supported_yet() { // only using nested struct as an example of a record we cannot import yet. let ir = ir_from_cc( @@ -2538,7 +2539,7 @@ ); } -#[test] +#[gtest] fn test_dont_import_injected_class_name() { let ir = ir_from_cc("struct SomeStruct {};").unwrap(); let names = ir.records().map(|r| r.rs_name.as_ref()).filter(|n| n.contains("SomeStruct")); @@ -2558,7 +2559,7 @@ ); } -#[test] +#[gtest] fn test_integer_typedef_usage() -> Result<()> { // This is a regression test. We used to incorrectly desugar typedefs of // builtin types and treat them as if they were the underlying builtin type. @@ -2597,7 +2598,7 @@ Ok(()) } -#[test] +#[gtest] fn test_struct() { let ir = ir_from_cc("struct SomeStruct { int first_field; int second_field; };").unwrap(); assert_ir_matches!( @@ -2639,7 +2640,7 @@ ); } -#[test] +#[gtest] fn test_class() { // This test verifies that `record_type` correectly captures whether the C++ // RecordDecl was for a `struct` VS for a `class`. @@ -2656,13 +2657,13 @@ ); } -#[test] +#[gtest] fn test_struct_forward_declaration() { let ir = ir_from_cc("struct Struct;").unwrap(); assert!(!ir.records().any(|r| r.rs_name.as_ref() == "Struct")); } -#[test] +#[gtest] fn test_struct_forward_declaration_in_namespace() -> Result<()> { let ir = ir_from_cc( r#" @@ -2701,7 +2702,7 @@ Ok(()) } -#[test] +#[gtest] fn test_union() { let ir = ir_from_cc("union SomeUnion { int first_field; int second_field; };").unwrap(); assert_ir_matches!( @@ -2742,7 +2743,7 @@ ); } -#[test] +#[gtest] fn test_union_with_data_members_with_different_sizes() { let ir = ir_from_cc( r#" @@ -2775,7 +2776,7 @@ ); } -#[test] +#[gtest] fn test_member_function_params() { let ir = ir_from_cc( r#" @@ -2829,7 +2830,7 @@ ); } -#[test] +#[gtest] fn test_member_function_static() { assert_member_function_has_instance_method_metadata( "Function", @@ -2838,7 +2839,7 @@ ); } -#[test] +#[gtest] fn test_member_function() { assert_member_function_has_instance_method_metadata( "Function", @@ -2851,7 +2852,7 @@ ); } -#[test] +#[gtest] fn test_member_function_const() { assert_member_function_has_instance_method_metadata( "Function", @@ -2864,7 +2865,7 @@ ); } -#[test] +#[gtest] fn test_member_function_virtual() { assert_member_function_has_instance_method_metadata( "Function", @@ -2877,7 +2878,7 @@ ); } -#[test] +#[gtest] fn test_member_function_lvalue() { assert_member_function_has_instance_method_metadata( "Function", @@ -2890,7 +2891,7 @@ ); } -#[test] +#[gtest] fn test_member_function_rvalue() { assert_member_function_has_instance_method_metadata( "Function", @@ -2903,7 +2904,7 @@ ); } -#[test] +#[gtest] fn test_member_function_rvalue_ref_qualified_this_param_type() { let ir = ir_from_cc( r#" #pragma clang lifetime_elision @@ -2935,7 +2936,7 @@ ); } -#[test] +#[gtest] fn test_member_function_explicit_constructor() { let ir = ir_from_cc( r#" @@ -2958,7 +2959,7 @@ ); } -#[test] +#[gtest] fn test_member_function_constructor() { for explicit_prefix in ["", "explicit"] { let ir = ir_from_cc(&format!( @@ -2986,7 +2987,7 @@ ir.functions().map(|f| f.name.clone()).collect() } -#[test] +#[gtest] fn test_identifier_function_name() { assert_eq!( get_func_names("void Function();"), @@ -2996,7 +2997,7 @@ ); } -#[test] +#[gtest] fn test_constructor_function_name() { assert!( get_func_names("struct Struct {Struct();};") @@ -3004,7 +3005,7 @@ ); } -#[test] +#[gtest] fn test_destructor_function_name() { assert!( get_func_names("struct Struct {~Struct();};") @@ -3012,7 +3013,7 @@ ); } -#[test] +#[gtest] fn test_unsupported_items_are_emitted() -> Result<()> { // We will have to rewrite this test to use something else that is unsupported // once we start importing nested structs. @@ -3024,7 +3025,7 @@ Ok(()) } -#[test] +#[gtest] fn test_unsupported_items_from_dependency_are_not_emitted() -> Result<()> { // We will have to rewrite this test to use something else that is unsupported // once we start importing nested structs. @@ -3038,7 +3039,7 @@ Ok(()) } -#[test] +#[gtest] fn test_user_of_unsupported_type_is_unsupported() -> Result<()> { // We will have to rewrite this test to use something else that is unsupported // once we start importing nested structs. @@ -3071,7 +3072,7 @@ ); } -#[test] +#[gtest] fn test_elided_lifetimes() { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3116,7 +3117,7 @@ assert_eq!(t.name.as_deref(), Some("&mut")); } -#[test] +#[gtest] fn test_operator_names() { let ir = ir_from_cc( r#" @@ -3152,7 +3153,7 @@ assert!(operator_names.contains("==")); } -#[test] +#[gtest] fn test_elided_lifetimes_in_default_constructor_with_implicit_default() { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3164,7 +3165,7 @@ verify_elided_lifetimes_in_default_constructor(&ir); } -#[test] +#[gtest] fn test_elided_lifetimes_in_default_constructor_with_explicit_default() { let ir = ir_from_cc( r#"#pragma clang lifetime_elision @@ -3177,7 +3178,7 @@ verify_elided_lifetimes_in_default_constructor(&ir); } -#[test] +#[gtest] fn test_no_aligned_attr() { let ir = ir_from_cc("struct SomeStruct {};").unwrap(); @@ -3193,7 +3194,7 @@ }; } -#[test] +#[gtest] fn test_aligned_attr() { let ir = ir_from_cc("struct SomeStruct {} __attribute__((aligned(64)));").unwrap(); assert_ir_matches! {ir, quote! { @@ -3208,7 +3209,7 @@ }; } -#[test] +#[gtest] fn test_c_style_struct_with_typedef_and_aligned_attr() { let ir = ir_from_cc("typedef struct {} SomeStruct __attribute__((aligned(64)));").unwrap(); @@ -3224,7 +3225,7 @@ }; } -#[test] +#[gtest] fn test_volatile_is_unsupported() { let ir = ir_from_cc("volatile int* foo();").unwrap(); let f = ir @@ -3234,7 +3235,7 @@ assert_eq!("foo", f.name.as_ref()); } -#[test] +#[gtest] fn test_unnamed_enum_unsupported() { let ir = ir_from_cc("enum { kFoo = 1, kBar = 2 };").unwrap(); assert_ir_matches!( @@ -3250,7 +3251,7 @@ ); } -#[test] +#[gtest] fn test_literal_operator_unsupported() { let ir = ir_from_cc( r#" @@ -3272,7 +3273,7 @@ ); } -#[test] +#[gtest] fn test_unsupported_item_has_item_id() { let ir = ir_from_cc("struct SomeStruct { struct NestedStruct {}; };").unwrap(); let unsupported = @@ -3280,14 +3281,14 @@ assert_ne!(unsupported.id, ItemId::new_for_testing(0)); } -#[test] +#[gtest] fn test_comment_has_item_id() { let ir = ir_from_cc("// Comment").unwrap(); let comment = ir.comments().find(|i| i.text.as_ref() == "Comment").unwrap(); assert_ne!(comment.id, ItemId::new_for_testing(0)); } -#[test] +#[gtest] fn test_function_has_item_id() { let ir = ir_from_cc("int foo();").unwrap(); let function = @@ -3295,7 +3296,7 @@ assert_ne!(function.id, ItemId::new_for_testing(0)); } -#[test] +#[gtest] fn test_top_level_items() { let ir = ir_from_cc( r#" @@ -3352,7 +3353,7 @@ ); } -#[test] +#[gtest] fn test_record_items() { let ir = ir_from_cc( r#" @@ -3428,7 +3429,7 @@ ); } -#[test] +#[gtest] fn test_namespaces() { let ir = ir_from_cc( r#" @@ -3493,7 +3494,7 @@ ); } -#[test] +#[gtest] fn test_nested_namespace_definition() { let ir = ir_from_cc( r#" @@ -3526,7 +3527,7 @@ ); } -#[test] +#[gtest] fn test_enclosing_item_ids() { let ir = ir_from_cc( r#" @@ -3581,7 +3582,7 @@ } } -#[test] +#[gtest] fn test_namespace_canonical_id() { let ir = ir_from_cc( r#" @@ -3614,7 +3615,7 @@ assert_eq!(namespaces[0].canonical_namespace_id, namespaces[1].canonical_namespace_id); } -#[test] +#[gtest] fn test_reopened_namespaces() { let ir = ir_from_cc( r#" @@ -3652,7 +3653,7 @@ ); } -#[test] +#[gtest] fn test_namespace_stored_data_in_ir() { let ir = ir_from_cc( r#" @@ -3718,7 +3719,7 @@ ); } -#[test] +#[gtest] fn test_items_inside_linkage_spec_decl_are_imported() { let ir = ir_from_cc( r#" @@ -3731,7 +3732,7 @@ assert_ir_matches!(ir, quote! { Record { ... cc_name: "MyStruct" ... } }) } -#[test] +#[gtest] fn test_items_inside_linkage_spec_decl_are_considered_toplevel() { // The test below assumes the first top_level_item_ids element is the one added // by the the source code under test. Let's double check that assumption here. @@ -3759,7 +3760,7 @@ ); } -#[test] +#[gtest] fn test_inline_namespace() { let ir = ir_from_cc( r#" @@ -3785,7 +3786,7 @@ ); } -#[test] +#[gtest] fn test_function_redeclared_as_friend() { let ir = ir_from_cc( r#" @@ -3848,7 +3849,7 @@ ); } -#[test] +#[gtest] fn test_function_redeclared_in_separate_namespace_chunk() { let ir = ir_from_cc( r#" @@ -3894,7 +3895,7 @@ ); } -#[test] +#[gtest] fn test_forward_declared_specialization_has_rs_name() { let ir = ir_from_cc( r#" @@ -3926,7 +3927,7 @@ ); } -#[test] +#[gtest] fn test_friend() { let ir = ir_from_cc( r#" @@ -3965,7 +3966,7 @@ ) } -#[test] +#[gtest] fn test_private_method() { let ir_with_function = quote! { ... @@ -3995,7 +3996,7 @@ } } -#[test] +#[gtest] fn test_source_location_with_macro() { let assert_matches = |cc_snippet: &str, expected: proc_macro2::TokenStream| { let ir = ir_from_cc(cc_snippet).unwrap(); @@ -4051,7 +4052,7 @@ ); } -#[test] +#[gtest] fn test_source_location() { let assert_matches = |cc_snippet: &str, expected: proc_macro2::TokenStream| { let ir = ir_from_cc(cc_snippet).unwrap(); @@ -4079,7 +4080,7 @@ ); } -#[test] +#[gtest] fn test_source_location_with_macro_defined_in_another_file() { let dependency_header = r#" #define MyIntTypeAliasToTestSourceLocation(type_alias_name) using type_alias_name = int;"#; @@ -4101,7 +4102,7 @@ ); } -#[test] +#[gtest] fn test_source_location_class_template_specialization() { let cc_snippet = "template <typename T> class MyClassTemplateToTestSourceLocation { T t_; }; using MyClassTemplateSpecializationToTestSourceLocation = MyClassTemplateToTestSourceLocation<bool>;";
diff --git a/rs_bindings_from_cc/ir_matchers.rs b/rs_bindings_from_cc/ir_matchers.rs index f0cd616..d80fb4c 100644 --- a/rs_bindings_from_cc/ir_matchers.rs +++ b/rs_bindings_from_cc/ir_matchers.rs
@@ -130,6 +130,7 @@ #[cfg(test)] mod tests { use super::*; + use googletest::prelude::*; use quote::quote; /// We aren't testing platform-specific details, just the matchers. @@ -137,7 +138,7 @@ ir_testing::ir_from_cc(multiplatform_testing::Platform::X86Linux, header) } - #[test] + #[gtest] fn test_optional_trailing_comma() { assert_ir_matches!(ir_from_cc("").unwrap(), quote! { FlatIR { ... }}); assert_ir_matches!(ir_from_cc("").unwrap(), quote! { FlatIR { ... }},); @@ -146,23 +147,23 @@ assert_ir_not_matches!(ir_from_cc("").unwrap(), quote! {this pattern is not in the ir},); } - #[test] + #[gtest] fn test_assert_ir_matches_assumes_trailing_commas_in_groups() { assert_ir_matches!(ir_from_cc("").unwrap(), quote! {{... , }}); } - #[test] + #[gtest] fn test_assert_not_matches_accepts_not_matching_pattern() { assert_ir_not_matches!(ir_from_cc("").unwrap(), quote! {this pattern is not in the ir}); } - #[test] + #[gtest] #[should_panic(expected = "input:\n\n```\nFlatIR {")] fn test_assert_ir_not_matches_panics_on_match() { assert_ir_not_matches!(ir_from_cc("").unwrap(), quote! {items}); } - #[test] + #[gtest] #[should_panic] fn test_assert_ir_matches_panics_on_mismatch() { assert_ir_matches!(ir_from_cc("").unwrap(), quote! {this pattern is not in the ir});
diff --git a/rs_bindings_from_cc/ir_testing.rs b/rs_bindings_from_cc/ir_testing.rs index 33d85df..1f1244f 100644 --- a/rs_bindings_from_cc/ir_testing.rs +++ b/rs_bindings_from_cc/ir_testing.rs
@@ -146,12 +146,14 @@ #[cfg(test)] mod tests { use super::*; + use arc_anyhow::Result; + use googletest::prelude::*; use ir::ItemId; use ir_matchers::assert_ir_matches; use multiplatform_testing::Platform; use quote::quote; - #[test] + #[gtest] fn test_features_ir_from_cc() -> Result<()> { assert_ir_matches!( ir_from_cc(multiplatform_testing::Platform::X86Linux, "")?, @@ -165,7 +167,7 @@ ); Ok(()) } - #[test] + #[gtest] fn test_features_ir_from_items() -> Result<()> { assert_ir_matches!( make_ir_from_items([]), @@ -180,7 +182,7 @@ Ok(()) } - #[test] + #[gtest] #[should_panic(expected = "Duplicate decl_id found in")] fn test_duplicate_decl_ids_err() { let mut r1 = ir_record(Platform::X86Linux, "R1");
diff --git a/rs_bindings_from_cc/test/bazel_unit_tests/additional_rust_srcs_for_crubit_bindings_aspect_hint_test/BUILD b/rs_bindings_from_cc/test/bazel_unit_tests/additional_rust_srcs_for_crubit_bindings_aspect_hint_test/BUILD index 5a277ed..d58e350 100644 --- a/rs_bindings_from_cc/test/bazel_unit_tests/additional_rust_srcs_for_crubit_bindings_aspect_hint_test/BUILD +++ b/rs_bindings_from_cc/test/bazel_unit_tests/additional_rust_srcs_for_crubit_bindings_aspect_hint_test/BUILD
@@ -27,6 +27,9 @@ cc_deps = [ ":empty_cc_lib_with_additional_rust_srcs", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) additional_rust_srcs_for_crubit_bindings_aspect_hint_test_suite(
diff --git a/rs_bindings_from_cc/test/bazel_unit_tests/additional_rust_srcs_for_crubit_bindings_aspect_hint_test/test.rs b/rs_bindings_from_cc/test/bazel_unit_tests/additional_rust_srcs_for_crubit_bindings_aspect_hint_test/test.rs index bf061e8..2a8f136 100644 --- a/rs_bindings_from_cc/test/bazel_unit_tests/additional_rust_srcs_for_crubit_bindings_aspect_hint_test/test.rs +++ b/rs_bindings_from_cc/test/bazel_unit_tests/additional_rust_srcs_for_crubit_bindings_aspect_hint_test/test.rs
@@ -3,8 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception use empty_cc_lib_with_additional_rust_srcs::additional_rust_srcs_test_stub::*; +use googletest::prelude::*; -#[test] +#[gtest] fn test_additional_rust_srcs() { assert_eq!(func_that_returns_1(), 1); }
diff --git a/rs_bindings_from_cc/test/cc_import/BUILD b/rs_bindings_from_cc/test/cc_import/BUILD index a86d9a6..df84f43 100644 --- a/rs_bindings_from_cc/test/cc_import/BUILD +++ b/rs_bindings_from_cc/test/cc_import/BUILD
@@ -32,4 +32,7 @@ crubit_rust_test( name = "math_test", crate = ":math", + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/cc_import/math.rs b/rs_bindings_from_cc/test/cc_import/math.rs index c071b76..2e86f90 100644 --- a/rs_bindings_from_cc/test/cc_import/math.rs +++ b/rs_bindings_from_cc/test/cc_import/math.rs
@@ -15,13 +15,14 @@ #[cfg(test)] mod tests { use super::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_math() { assert_eq!(add_two_and_three(), 5); } - #[test] + #[gtest] fn test_not_reopened_namespaces() { assert_eq!(complex_math::two_only::get_square(), 4); assert_eq!(complex_math::three_only::get_square(), 9);
diff --git a/rs_bindings_from_cc/test/cc_std/BUILD b/rs_bindings_from_cc/test/cc_std/BUILD index 2b0bf6b..d17d7ca 100644 --- a/rs_bindings_from_cc/test/cc_std/BUILD +++ b/rs_bindings_from_cc/test/cc_std/BUILD
@@ -9,7 +9,10 @@ cc_deps = [ "//support/cc_std", ], - deps = ["//support:ctor"], + deps = [ + "//support:ctor", + "//third_party/gtest_rust/googletest", + ], ) crubit_rust_test( @@ -18,7 +21,10 @@ cc_deps = [ "//support/cc_std", ], - deps = ["//support:ctor"], + deps = [ + "//support:ctor", + "//third_party/gtest_rust/googletest", + ], ) crubit_test_cc_library(
diff --git a/rs_bindings_from_cc/test/consume_absl/test.rs b/rs_bindings_from_cc/test/consume_absl/test.rs index 750d5e7..f0a8e9d 100644 --- a/rs_bindings_from_cc/test/consume_absl/test.rs +++ b/rs_bindings_from_cc/test/consume_absl/test.rs
@@ -6,7 +6,7 @@ mod tests { // TODO(mboehme): Disabled because absl::Duration cannot yet be imported. /* - #[test] + #[gtest] fn test_seconds() { use time::Seconds; use time::ToInt64Seconds;
diff --git a/rs_bindings_from_cc/test/cpp_duplicate_target_name/test.rs b/rs_bindings_from_cc/test/cpp_duplicate_target_name/test.rs index 4cb2be6..4132018 100644 --- a/rs_bindings_from_cc/test/cpp_duplicate_target_name/test.rs +++ b/rs_bindings_from_cc/test/cpp_duplicate_target_name/test.rs
@@ -4,6 +4,6 @@ #[cfg(test)] mod tests { - #[test] + #[gtest] fn test_build() {} }
diff --git a/rs_bindings_from_cc/test/cpp_reserved_target_name/BUILD b/rs_bindings_from_cc/test/cpp_reserved_target_name/BUILD index f0d9b4f..024e1dd 100644 --- a/rs_bindings_from_cc/test/cpp_reserved_target_name/BUILD +++ b/rs_bindings_from_cc/test/cpp_reserved_target_name/BUILD
@@ -10,6 +10,9 @@ cc_deps = [ "//rs_bindings_from_cc/test/cpp_reserved_target_name/subdir2", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) # Tests that the name of a Crubit-enabled cc_library named 'core'. @@ -27,6 +30,9 @@ proc_macro_deps = [ "//common:item_exists", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) # Test that it's OK to include a Crubit-enabled cc_library named 'core' in transitive deps, i.e., @@ -45,4 +51,7 @@ cc_deps = [ ":core_user", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/cpp_reserved_target_name/test_crubit_disabled_cc_library_named_core_in_transitive_deps.rs b/rs_bindings_from_cc/test/cpp_reserved_target_name/test_crubit_disabled_cc_library_named_core_in_transitive_deps.rs index 107e420..bd667fb 100644 --- a/rs_bindings_from_cc/test/cpp_reserved_target_name/test_crubit_disabled_cc_library_named_core_in_transitive_deps.rs +++ b/rs_bindings_from_cc/test/cpp_reserved_target_name/test_crubit_disabled_cc_library_named_core_in_transitive_deps.rs
@@ -2,5 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_build() {}
diff --git a/rs_bindings_from_cc/test/cpp_reserved_target_name/test_crubit_enabled_cc_library_named_core_in_transitive_deps.rs b/rs_bindings_from_cc/test/cpp_reserved_target_name/test_crubit_enabled_cc_library_named_core_in_transitive_deps.rs index 8d331f6..f473227 100644 --- a/rs_bindings_from_cc/test/cpp_reserved_target_name/test_crubit_enabled_cc_library_named_core_in_transitive_deps.rs +++ b/rs_bindings_from_cc/test/cpp_reserved_target_name/test_crubit_enabled_cc_library_named_core_in_transitive_deps.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_crubit_enabled_cc_library_named_core_in_transitive_deps() { let s = core_user::StructInHeaderThatIncludeCoreHeader::default(); let _ = s.struct_in_core;
diff --git a/rs_bindings_from_cc/test/cpp_reserved_target_name/test_map_crubit_enabled_cc_library_named_core.rs b/rs_bindings_from_cc/test/cpp_reserved_target_name/test_map_crubit_enabled_cc_library_named_core.rs index bf8d292..5b2c08e 100644 --- a/rs_bindings_from_cc/test/cpp_reserved_target_name/test_map_crubit_enabled_cc_library_named_core.rs +++ b/rs_bindings_from_cc/test/cpp_reserved_target_name/test_map_crubit_enabled_cc_library_named_core.rs
@@ -2,9 +2,10 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +use googletest::prelude::*; use item_exists::type_exists; -#[test] +#[gtest] fn test_map_cc_library_named_core() { assert!(type_exists!(core_cpp_reserved_target_name::StructInCore)); }
diff --git a/rs_bindings_from_cc/test/cpp_target_name/BUILD b/rs_bindings_from_cc/test/cpp_target_name/BUILD index 2e813d1..cf0f399 100644 --- a/rs_bindings_from_cc/test/cpp_target_name/BUILD +++ b/rs_bindings_from_cc/test/cpp_target_name/BUILD
@@ -39,6 +39,9 @@ cc_deps = [ ":crubit_disabled_cc_library_with_invalid_character_in_transitive_deps", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_test_cc_library( @@ -54,6 +57,9 @@ cc_deps = [ ":crubit_enabled_cc_library_with_invalid_character_in_transitive_deps", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_test_cc_library( @@ -67,4 +73,7 @@ cc_deps = [ ":crubit_enabled_cc_library_with_!./%-@^#$&()*-+,;<=>?[]{|}~", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/cpp_target_name/test_with_cc_library_with_invalid_character_in_transitive_deps.rs b/rs_bindings_from_cc/test/cpp_target_name/test_with_cc_library_with_invalid_character_in_transitive_deps.rs index 7bfb3f6..fbc0f25 100644 --- a/rs_bindings_from_cc/test/cpp_target_name/test_with_cc_library_with_invalid_character_in_transitive_deps.rs +++ b/rs_bindings_from_cc/test/cpp_target_name/test_with_cc_library_with_invalid_character_in_transitive_deps.rs
@@ -4,6 +4,8 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_build_with_cc_library_with_invalid_character_in_transitive_deps() {} }
diff --git a/rs_bindings_from_cc/test/cpp_target_name/test_with_crubit_enabled_cc_library_with_invalid_character.rs b/rs_bindings_from_cc/test/cpp_target_name/test_with_crubit_enabled_cc_library_with_invalid_character.rs index 3214c71..8819a4e 100644 --- a/rs_bindings_from_cc/test/cpp_target_name/test_with_crubit_enabled_cc_library_with_invalid_character.rs +++ b/rs_bindings_from_cc/test/cpp_target_name/test_with_crubit_enabled_cc_library_with_invalid_character.rs
@@ -5,8 +5,9 @@ mod tests { use crubit_enabled_cc_library_with____________________________::func; + use googletest::prelude::*; - #[test] + #[gtest] fn test_build_with_crubit_enabled_cc_library_with_invalid_character() { func(); }
diff --git a/rs_bindings_from_cc/test/cpp_target_name/test_with_crubit_enabled_cc_library_with_invalid_character_in_transitive_deps.rs b/rs_bindings_from_cc/test/cpp_target_name/test_with_crubit_enabled_cc_library_with_invalid_character_in_transitive_deps.rs index d77fc3c..99715d7 100644 --- a/rs_bindings_from_cc/test/cpp_target_name/test_with_crubit_enabled_cc_library_with_invalid_character_in_transitive_deps.rs +++ b/rs_bindings_from_cc/test/cpp_target_name/test_with_crubit_enabled_cc_library_with_invalid_character_in_transitive_deps.rs
@@ -4,6 +4,8 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_build_with_crubit_enabled_cc_library_with_invalid_character_in_transitive_deps() {} }
diff --git a/rs_bindings_from_cc/test/crubit_features/BUILD b/rs_bindings_from_cc/test/crubit_features/BUILD index 3ff4e6d..9b9d524 100644 --- a/rs_bindings_from_cc/test/crubit_features/BUILD +++ b/rs_bindings_from_cc/test/crubit_features/BUILD
@@ -53,4 +53,7 @@ proc_macro_deps = [ "//common:item_exists", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/crubit_features/test.rs b/rs_bindings_from_cc/test/crubit_features/test.rs index a983bb2..7a15b9e 100644 --- a/rs_bindings_from_cc/test/crubit_features/test.rs +++ b/rs_bindings_from_cc/test/crubit_features/test.rs
@@ -5,14 +5,16 @@ mod definitions { use super::*; - #[test] + use googletest::prelude::*; + + #[gtest] fn disabled_struct_has_no_bindings() { assert!( !type_exists!(definition_disabled::DisabledStruct), "definition_disabled::DisabledStruct was exposed through bindings." ); } - #[test] + #[gtest] fn enabled_struct_has_bindings() { assert!( type_exists!(definition_enabled::EnabledStruct), @@ -23,9 +25,11 @@ mod aliases { use super::*; + use googletest::prelude::*; + /// This test will fail if aliases expose a struct whose bindings were /// disabled. - #[test] + #[gtest] fn aliases_dont_expose_disabled_structs() { assert!( !type_exists!(alias_enabled::AliasedDisabledStruct), @@ -40,7 +44,7 @@ /// _instantiation_ actually occurs in this crate. Template _instantiation_ /// in other headers should respect the template _definition_ and its /// API promises. - #[test] + #[gtest] fn aliases_dont_expose_disabled_templates() { assert!( !type_exists!(alias_enabled::AliasedDisabledTemplate), @@ -54,7 +58,7 @@ /// While Crubit _was_ enabled for the definition, the usage site also needs /// to consent to people depending on the type _via_ the using library, /// since that implies a maintenance burden. - #[test] + #[gtest] fn disabled_struct_aliases_arent_exposed() { assert!( !type_exists!(alias_disabled::AliasedEnabledStruct), @@ -62,7 +66,7 @@ ); } - #[test] + #[gtest] fn disabled_template_aliases_arent_exposed() { assert!( !type_exists!(alias_disabled::AliasedEnabledTemplate), @@ -73,12 +77,15 @@ mod functions { use super::*; - #[test] + use googletest::prelude::*; + + #[gtest] fn test_functions_disabled_when_parameter_types_are() { assert!(!value_exists!(func_enabled::FuncTakesDisabledStruct)); assert!(!value_exists!(func_enabled::FuncTakesDisabledTemplate)); } - #[test] + + #[gtest] fn test_functions_disabled_when_return_type_is() { assert!(!value_exists!(func_enabled::FuncReturnsDisabledStruct)); assert!(!value_exists!(func_enabled::FuncReturnsDisabledTemplate)); @@ -87,7 +94,9 @@ mod structs { use super::*; - #[test] + use googletest::prelude::*; + + #[gtest] fn test_struct_enabled() { // The generated field assertions will handle the rest. assert!(type_exists!(wrapper_struct_enabled::EnabledStructWithDisabledField));
diff --git a/rs_bindings_from_cc/test/disabled_layering_check/BUILD b/rs_bindings_from_cc/test/disabled_layering_check/BUILD index 6bc0931..aebefea 100644 --- a/rs_bindings_from_cc/test/disabled_layering_check/BUILD +++ b/rs_bindings_from_cc/test/disabled_layering_check/BUILD
@@ -18,6 +18,9 @@ # doesn't get compiled with :my_lib as direct. ":top_lib", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_test_cc_library(
diff --git a/rs_bindings_from_cc/test/disabled_layering_check/disabled_layering_check_test.rs b/rs_bindings_from_cc/test/disabled_layering_check/disabled_layering_check_test.rs index 20bbf5f..2856968 100644 --- a/rs_bindings_from_cc/test/disabled_layering_check/disabled_layering_check_test.rs +++ b/rs_bindings_from_cc/test/disabled_layering_check/disabled_layering_check_test.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_disabled_layering_check() { assert_eq!(top_lib::GetValFromMyStruct(my_lib::MyStruct { val: 42 }), 42); }
diff --git a/rs_bindings_from_cc/test/empty_public_header/BUILD b/rs_bindings_from_cc/test/empty_public_header/BUILD index cbe3792..3348d8a 100644 --- a/rs_bindings_from_cc/test/empty_public_header/BUILD +++ b/rs_bindings_from_cc/test/empty_public_header/BUILD
@@ -28,4 +28,7 @@ cc_deps = [ ":cc_library_with_rust_deps", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/empty_public_header/test.rs b/rs_bindings_from_cc/test/empty_public_header/test.rs index 4cb2be6..d34fb3c 100644 --- a/rs_bindings_from_cc/test/empty_public_header/test.rs +++ b/rs_bindings_from_cc/test/empty_public_header/test.rs
@@ -4,6 +4,8 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_build() {} }
diff --git a/rs_bindings_from_cc/test/extern_c/BUILD b/rs_bindings_from_cc/test/extern_c/BUILD index d0c0235..7122ef1 100644 --- a/rs_bindings_from_cc/test/extern_c/BUILD +++ b/rs_bindings_from_cc/test/extern_c/BUILD
@@ -28,6 +28,7 @@ ], deps = [ "//support:oops", + "//third_party/gtest_rust/googletest", "@crate_index//:static_assertions", ], ) @@ -41,4 +42,7 @@ proc_macro_deps = [ "//common:item_exists", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/extern_c/has_bindings_test.rs b/rs_bindings_from_cc/test/extern_c/has_bindings_test.rs index fd533d8..ec868c2 100644 --- a/rs_bindings_from_cc/test/extern_c/has_bindings_test.rs +++ b/rs_bindings_from_cc/test/extern_c/has_bindings_test.rs
@@ -2,30 +2,31 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +use googletest::prelude::*; use has_bindings::crubit::has_bindings; use static_assertions::assert_not_impl_any; -#[test] +#[gtest] fn test_void_function_non_extern_c() { has_bindings::crubit_void_function_non_extern_c(); } -#[test] +#[gtest] fn test_void_function() { has_bindings::crubit_void_function(); } -#[test] +#[gtest] fn test_non_inline_function() { has_bindings::crubit_non_inline_function(); } -#[test] +#[gtest] fn test_extern_c_directly_function() { has_bindings::crubit_extern_c_directly_function(); } -#[test] +#[gtest] fn test_void_ptr_function() { let value = 1; let ptr = &value as *const _ as *const std::ffi::c_void; @@ -34,7 +35,7 @@ assert_eq!(ptr, result_ptr); } -#[test] +#[gtest] fn test_user_struct() { let mut i: core::ffi::c_int = 123; let s = has_bindings::Struct { x: &mut i, y: 123, z: 0 as *mut _ }; @@ -47,7 +48,7 @@ assert_eq!(s.z.type_id(), std::any::TypeId::of::<*mut has_bindings::Struct>()); } -#[test] +#[gtest] fn test_nontrivial_struct() { let mut i = 0; { @@ -58,7 +59,7 @@ assert_eq!(i, 42); } -#[test] +#[gtest] fn test_user_enum() { let _: has_bindings::Enum = has_bindings::Enum::kEnumerator; // Can't really assert this due to how value_exists works, sadly. @@ -66,14 +67,14 @@ // (has_bindings::Enum::kUnkownAttrEnumerator)); } -#[test] +#[gtest] fn test_user_union() { // as close as one gets to verifying that it's a union. It is indeed a union! let _: has_bindings::Union = has_bindings::Union { x: 1 }; let _: has_bindings::Union = has_bindings::Union { y: 3 }; } -#[test] +#[gtest] fn test_alias() { assert_eq!( std::any::TypeId::of::<has_bindings::Struct>(), @@ -81,12 +82,12 @@ ) } -#[test] +#[gtest] fn test_crubit_add() { assert_eq!(has_bindings::crubit_add(1, 2), 3); } -#[test] +#[gtest] fn test_crubit_enum_function() { assert_eq!( has_bindings::crubit_enum_function(has_bindings::Enum::kEnumerator), @@ -94,7 +95,7 @@ ); } -#[test] +#[gtest] fn test_crubit_union_function() { let u = has_bindings::crubit_union_function(has_bindings::Union { x: 42 }); assert_eq!( @@ -104,7 +105,7 @@ ); } -#[test] +#[gtest] fn test_function_pointer() { extern "C" fn my_callback(a: *mut std::ffi::c_int) { // SAFETY: we're going to pass it a valid pointer to an integer, it's OK! @@ -123,7 +124,7 @@ assert_eq!(state, 42); } -#[test] +#[gtest] fn test_nullable_function_pointer() { extern "C" fn my_callback(a: *mut std::ffi::c_int) { // SAFETY: we're going to pass it a valid pointer to an integer, it's OK! @@ -145,7 +146,7 @@ /// You can use a class that uses inheritance, but to Rust, it looks like /// private inheritance: the struct is only available as an opaque thunk within /// the derived class. -#[test] +#[gtest] fn test_oop() { assert_not_impl_any!(has_bindings::MyDerivedStruct : oops::Inherits<has_bindings::Struct>); }
diff --git a/rs_bindings_from_cc/test/extern_c/no_bindings_test.rs b/rs_bindings_from_cc/test/extern_c/no_bindings_test.rs index 9a720b3..8431dca 100644 --- a/rs_bindings_from_cc/test/extern_c/no_bindings_test.rs +++ b/rs_bindings_from_cc/test/extern_c/no_bindings_test.rs
@@ -2,40 +2,41 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +use googletest::prelude::*; use item_exists::{type_exists, value_exists}; use no_bindings::crubit::no_bindings; -#[test] +#[gtest] fn test_nontrivial_type() { assert!(!type_exists!(no_bindings::Nontrivial)); } -#[test] +#[gtest] fn test_nontrivial_alias() { assert!(!type_exists!(no_bindings::NontrivialAlias)); } -#[test] +#[gtest] fn test_deprecated_alias() { assert!(!type_exists!(no_bindings::DeprecatedAlias)); } -#[test] +#[gtest] fn test_accepts_nontrivial_ptr() { assert!(!value_exists!(no_bindings::crubit_accepts_nontrivial_ptr)); } -#[test] +#[gtest] fn test_accepts_nontrivial_value() { assert!(!value_exists!(no_bindings::crubit_accepts_nontrivial_value)); } -#[test] +#[gtest] fn test_returns_nontrivial_ptr() { assert!(!value_exists!(no_bindings::crubit_returns_nontrivial_ptr)); } -#[test] +#[gtest] fn test_returns_nontrivial_value() { assert!(!value_exists!(no_bindings::crubit_returns_nontrivial_value)); } @@ -44,47 +45,47 @@ // this isn't actually a different calling convention, and we'd expect bindings // to exist after all. #[cfg(target_arch = "x86_64")] -#[test] +#[gtest] fn test_vectorcall() { assert!(!value_exists!(no_bindings::crubit_vectorcall)); } -#[test] +#[gtest] fn test_parameter_lifetimebound() { assert!(!value_exists!(no_bindings::crubit_parameter_lifetimebound)); } -#[test] +#[gtest] fn test_noreturn() { assert!(!value_exists!(no_bindings::crubit_noreturn)); } -#[test] +#[gtest] fn test_nodiscard() { assert!(!value_exists!(no_bindings::crubit_nodiscard)); } -#[test] +#[gtest] fn test_deprecated() { assert!(!value_exists!(no_bindings::crubit_deprecated)); } -#[test] +#[gtest] fn test_enable_if() { assert!(!value_exists!(no_bindings::crubit_enable_if)); } -#[test] +#[gtest] fn test_unknown_attr_struct() { assert!(!type_exists!(no_bindings::UnknownAttrStruct)); } -#[test] +#[gtest] fn test_unknown_attr_enum() { assert!(!type_exists!(no_bindings::UnknownAttrEnum)); } -#[test] +#[gtest] fn test_templates() { assert!(!type_exists!(no_bindings::TemplatedStruct)); assert!(!type_exists!(no_bindings::InstantiatedTemplatedStruct)); @@ -92,19 +93,19 @@ /// Function pointers, like most supported types, are only supported if their /// type dependencies are. -#[test] +#[gtest] fn test_function_pointers() { assert!(!type_exists!(no_bindings::Callback)); assert!(!value_exists!(no_bindings::crubit_invoke_callback)); } -#[test] +#[gtest] fn test_type_attributes() { assert!(!type_exists!(no_bindings::UnknownTypeAttribute)); assert!(!value_exists!(no_bindings::crubit_unknown_type_attribute)); } -#[test] +#[gtest] fn test_incomplete_type() { assert!(!value_exists!(no_bindings::crubit_incomplete_type)); }
diff --git a/rs_bindings_from_cc/test/forward_declaration/basic/BUILD b/rs_bindings_from_cc/test/forward_declaration/basic/BUILD index 5480106..dc8d7a3 100644 --- a/rs_bindings_from_cc/test/forward_declaration/basic/BUILD +++ b/rs_bindings_from_cc/test/forward_declaration/basic/BUILD
@@ -20,4 +20,7 @@ cc_deps = [ ":forward_declaration", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/forward_declaration/basic/test.rs b/rs_bindings_from_cc/test/forward_declaration/basic/test.rs index 91eea51..e5286c6 100644 --- a/rs_bindings_from_cc/test/forward_declaration/basic/test.rs +++ b/rs_bindings_from_cc/test/forward_declaration/basic/test.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_build() { use forward_declaration::*; Func(A::default());
diff --git a/rs_bindings_from_cc/test/forward_declaration/included_before_definition/BUILD b/rs_bindings_from_cc/test/forward_declaration/included_before_definition/BUILD index ddb2845..0fb29a3 100644 --- a/rs_bindings_from_cc/test/forward_declaration/included_before_definition/BUILD +++ b/rs_bindings_from_cc/test/forward_declaration/included_before_definition/BUILD
@@ -35,4 +35,7 @@ proc_macro_deps = [ "//common:item_exists", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/forward_declaration/included_before_definition/test.rs b/rs_bindings_from_cc/test/forward_declaration/included_before_definition/test.rs index 8d1b9d2..b6fec16 100644 --- a/rs_bindings_from_cc/test/forward_declaration/included_before_definition/test.rs +++ b/rs_bindings_from_cc/test/forward_declaration/included_before_definition/test.rs
@@ -2,9 +2,10 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +use googletest::prelude::*; use item_exists::type_exists; -#[test] +#[gtest] fn test_forward_declarations_included_before_definition() { assert!(type_exists!(definition::A)); assert!(type_exists!(definition::my_namespace::B));
diff --git a/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_dependent/BUILD b/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_dependent/BUILD index a17d0a6..0102440 100644 --- a/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_dependent/BUILD +++ b/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_dependent/BUILD
@@ -33,5 +33,6 @@ ], deps = [ "//support:forward_declare", + "//third_party/gtest_rust/googletest", ], )
diff --git a/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_dependent/test.rs b/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_dependent/test.rs index 9cfc64b..2274706 100644 --- a/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_dependent/test.rs +++ b/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_dependent/test.rs
@@ -1,10 +1,12 @@ // Part of the Crubit project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + use core::any::TypeId; use forward_declare::CcCast; +use googletest::prelude::*; -#[test] +#[gtest] fn test_complete_to_incomplete_ptr_conversion_crossing_crate_boundaries() { let mut a = definition::A::default(); let a_ptr: *mut definition::A = &mut a; @@ -20,7 +22,7 @@ } } -#[test] +#[gtest] fn test_complete_to_incomplete_ref_conversion_crossing_crate_boundaries() { let mut a = definition::A::default(); let a_ptr: *mut definition::A = &mut a; @@ -36,7 +38,7 @@ } } -#[test] +#[gtest] fn test_each_crate_has_distinct_type_for_a() { assert_ne!(TypeId::of::<forward_declaration1::A>(), TypeId::of::<forward_declaration2::A>()); assert_ne!(TypeId::of::<forward_declaration1::A>(), TypeId::of::<definition::A>());
diff --git a/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_independent/BUILD b/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_independent/BUILD index 62fc190..e5740b1 100644 --- a/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_independent/BUILD +++ b/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_independent/BUILD
@@ -30,5 +30,6 @@ ], deps = [ "//support:forward_declare", + "//third_party/gtest_rust/googletest", ], )
diff --git a/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_independent/test.rs b/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_independent/test.rs index db36ce7..2274706 100644 --- a/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_independent/test.rs +++ b/rs_bindings_from_cc/test/forward_declaration/multiple_forward_declarations_independent/test.rs
@@ -4,8 +4,9 @@ use core::any::TypeId; use forward_declare::CcCast; +use googletest::prelude::*; -#[test] +#[gtest] fn test_complete_to_incomplete_ptr_conversion_crossing_crate_boundaries() { let mut a = definition::A::default(); let a_ptr: *mut definition::A = &mut a; @@ -21,7 +22,7 @@ } } -#[test] +#[gtest] fn test_complete_to_incomplete_ref_conversion_crossing_crate_boundaries() { let mut a = definition::A::default(); let a_ptr: *mut definition::A = &mut a; @@ -37,7 +38,7 @@ } } -#[test] +#[gtest] fn test_each_crate_has_distinct_type_for_a() { assert_ne!(TypeId::of::<forward_declaration1::A>(), TypeId::of::<forward_declaration2::A>()); assert_ne!(TypeId::of::<forward_declaration1::A>(), TypeId::of::<definition::A>());
diff --git a/rs_bindings_from_cc/test/forward_declaration/type_ownership/BUILD b/rs_bindings_from_cc/test/forward_declaration/type_ownership/BUILD index f9a767b..c353292 100644 --- a/rs_bindings_from_cc/test/forward_declaration/type_ownership/BUILD +++ b/rs_bindings_from_cc/test/forward_declaration/type_ownership/BUILD
@@ -65,6 +65,9 @@ cc_deps = [ ":definition_with_crubit_disabled", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_test_cc_library( @@ -90,4 +93,7 @@ cc_deps = [ ":definition_with_crubit_disabled_in_deps", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/forward_declaration/type_ownership/test.rs b/rs_bindings_from_cc/test/forward_declaration/type_ownership/test.rs index 3ba7dea..75ae83d 100644 --- a/rs_bindings_from_cc/test/forward_declaration/type_ownership/test.rs +++ b/rs_bindings_from_cc/test/forward_declaration/type_ownership/test.rs
@@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +#[gtest] fn test_build() { // TODO(b/318690257): Currently, the build fails with: // error: "the size for values of type `forward_declare::Unsized` cannot be
diff --git a/rs_bindings_from_cc/test/forward_declaration/type_ownership/test_with_crubit_disabled.rs b/rs_bindings_from_cc/test/forward_declaration/type_ownership/test_with_crubit_disabled.rs index 8840c57..1b7da06 100644 --- a/rs_bindings_from_cc/test/forward_declaration/type_ownership/test_with_crubit_disabled.rs +++ b/rs_bindings_from_cc/test/forward_declaration/type_ownership/test_with_crubit_disabled.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_build() { // Crubit is disabled for `definition.h`, no `definition.h` API to test. }
diff --git a/rs_bindings_from_cc/test/forward_declaration/type_ownership/test_with_crubit_disabled_in_deps.rs b/rs_bindings_from_cc/test/forward_declaration/type_ownership/test_with_crubit_disabled_in_deps.rs index 4a4c955..08b4361 100644 --- a/rs_bindings_from_cc/test/forward_declaration/type_ownership/test_with_crubit_disabled_in_deps.rs +++ b/rs_bindings_from_cc/test/forward_declaration/type_ownership/test_with_crubit_disabled_in_deps.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_build() { // Crubit is disabled for `definition.h` and `forward_declaration.h`, so no // API to test.
diff --git a/rs_bindings_from_cc/test/function/calling_conventions/BUILD b/rs_bindings_from_cc/test/function/calling_conventions/BUILD index 91f8af1..60a7f59 100644 --- a/rs_bindings_from_cc/test/function/calling_conventions/BUILD +++ b/rs_bindings_from_cc/test/function/calling_conventions/BUILD
@@ -15,4 +15,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":calling_conventions"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/function/calling_conventions/test.rs b/rs_bindings_from_cc/test/function/calling_conventions/test.rs index ab0ac58..3776a5e 100644 --- a/rs_bindings_from_cc/test/function/calling_conventions/test.rs +++ b/rs_bindings_from_cc/test/function/calling_conventions/test.rs
@@ -5,15 +5,16 @@ #[cfg(test)] mod tests { use calling_conventions::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_default_cc() { let s = UnusualSwiftcallStruct { x0: 0x1111_1111, x1: 0x2222_2222, x2: 0x4444_4444 }; let func_differentiator = 0xffff_0000; assert_eq!(function_with_default_cc(s), 0x7777_7777 + func_differentiator); } - #[test] + #[gtest] fn test_swiftcall_cc() { let s = UnusualSwiftcallStruct { x0: 0x1111_1111, x1: 0x2222_2222, x2: 0x4444_4444 }; let func_differentiator = 0x0000_ffff;
diff --git a/rs_bindings_from_cc/test/function/inline/BUILD b/rs_bindings_from_cc/test/function/inline/BUILD index bc8147b..cd92158 100644 --- a/rs_bindings_from_cc/test/function/inline/BUILD +++ b/rs_bindings_from_cc/test/function/inline/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":hello_world"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/function/inline/test.rs b/rs_bindings_from_cc/test/function/inline/test.rs index cb8175a..f81f8d3 100644 --- a/rs_bindings_from_cc/test/function/inline/test.rs +++ b/rs_bindings_from_cc/test/function/inline/test.rs
@@ -4,25 +4,26 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; use hello_world::*; - #[test] + #[gtest] fn test_hello_world() { assert_eq!(hello_world_inline(), 42); } - #[test] + #[gtest] fn test_take_struct_by_const_ref() { let s = SomeStruct { int_field: 789 }; assert_eq!(789, take_struct_by_const_ref(&s)); } - #[test] + #[gtest] fn test_double_unsigned_int() { assert_eq!(double_unsigned_int(123), 246); } - #[test] + #[gtest] fn test_forward_declared_doubler() { assert_eq!(foo::forward_declared_doubler(124), 248); }
diff --git a/rs_bindings_from_cc/test/function/no_elided_lifetimes/BUILD b/rs_bindings_from_cc/test/function/no_elided_lifetimes/BUILD index a8b958a..b2f5d97 100644 --- a/rs_bindings_from_cc/test/function/no_elided_lifetimes/BUILD +++ b/rs_bindings_from_cc/test/function/no_elided_lifetimes/BUILD
@@ -15,4 +15,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":no_elided_lifetimes"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/function/no_elided_lifetimes/test.rs b/rs_bindings_from_cc/test/function/no_elided_lifetimes/test.rs index ad41db5..016995a 100644 --- a/rs_bindings_from_cc/test/function/no_elided_lifetimes/test.rs +++ b/rs_bindings_from_cc/test/function/no_elided_lifetimes/test.rs
@@ -4,9 +4,10 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; use no_elided_lifetimes::*; - #[test] + #[gtest] fn test_store_pointer() { let mut boxed_int = Box::new(123);
diff --git a/rs_bindings_from_cc/test/function/non_extern_c/BUILD b/rs_bindings_from_cc/test/function/non_extern_c/BUILD index 0f1d9f1..eaff07b 100644 --- a/rs_bindings_from_cc/test/function/non_extern_c/BUILD +++ b/rs_bindings_from_cc/test/function/non_extern_c/BUILD
@@ -16,4 +16,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":simple_functions"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/function/non_extern_c/test.rs b/rs_bindings_from_cc/test/function/non_extern_c/test.rs index 8f1aebf..2b640f1 100644 --- a/rs_bindings_from_cc/test/function/non_extern_c/test.rs +++ b/rs_bindings_from_cc/test/function/non_extern_c/test.rs
@@ -4,13 +4,15 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_return_value() { use simple_functions::return_value; assert_eq!(return_value(), 42); } - #[test] + #[gtest] fn test_return_pointer() { use simple_functions::return_pointer; unsafe { @@ -18,7 +20,7 @@ } } - #[test] + #[gtest] fn test_return_reference() { use simple_functions::return_reference; unsafe { @@ -26,7 +28,7 @@ } } - #[test] + #[gtest] fn test_take_pointer() { use simple_functions::take_pointer; unsafe { @@ -39,7 +41,7 @@ assert_eq!(i, 42); } - #[test] + #[gtest] fn test_take_reference() { use simple_functions::take_reference; let mut i: i32 = 0; @@ -49,7 +51,7 @@ assert_eq!(i, 42); } - #[test] + #[gtest] fn test_forward_pointer() { use simple_functions::forward_pointer; assert_eq!(unsafe { forward_pointer(std::ptr::null()) }, std::ptr::null()); @@ -57,24 +59,24 @@ assert_eq!(unsafe { *forward_pointer(&i) }, 42); } - #[test] + #[gtest] fn test_forward_reference() { use simple_functions::forward_reference; let i: i32 = 42; assert_eq!(unsafe { *forward_reference(&i) }, 42); } - #[test] + #[gtest] fn test_multiply() { assert_eq!(simple_functions::multiply(42, 123), 42 * 123); } - #[test] + #[gtest] fn test_multiply_with_unnamed_parameters() { assert_eq!(simple_functions::multiply_with_unnamed_parameters(42, 456), 42 * 456); } - #[test] + #[gtest] fn test_multiply_with_keyword_named_parameters() { assert_eq!( 42 * 123 * 456, @@ -82,21 +84,21 @@ ); } - #[test] + #[gtest] fn test_function_pointer() { let maybe_mul_fn = simple_functions::get_pointer_to_multiply_function(); let mul_fn = maybe_mul_fn.expect("Expecting non-null / non-None function pointer"); assert_eq!(mul_fn(123, 456), 123 * 456); } - #[test] + #[gtest] fn test_function_reference() { // TODO(b/217419782): Replicate `test_function_pointer`, but for C++ // references. (e.g. no `expect` / `Option` unwrapping should be // needed). } - #[test] + #[gtest] fn test_function_pointer_returned_from_inline_function() { let maybe_mul_fn = simple_functions::inline_get_pointer_to_multiply_function(); let mul_fn = maybe_mul_fn.expect("Expecting non-null / non-None function pointer"); @@ -104,7 +106,7 @@ } /// Test that function pointers can be accepted as function parameters. - #[test] + #[gtest] fn test_apply_binary_op() { extern "C" fn multiply(x: i32, y: i32) -> i32 { x * y
diff --git a/rs_bindings_from_cc/test/function/simple/BUILD b/rs_bindings_from_cc/test/function/simple/BUILD index e707490..5602622 100644 --- a/rs_bindings_from_cc/test/function/simple/BUILD +++ b/rs_bindings_from_cc/test/function/simple/BUILD
@@ -15,4 +15,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":simple_functions"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/function/simple/test.rs b/rs_bindings_from_cc/test/function/simple/test.rs index b9cbd96..fd66132 100644 --- a/rs_bindings_from_cc/test/function/simple/test.rs +++ b/rs_bindings_from_cc/test/function/simple/test.rs
@@ -4,13 +4,15 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_return_value() { use simple_functions::return_value; assert_eq!(return_value(), 42); } - #[test] + #[gtest] fn test_return_pointer() { use simple_functions::return_pointer; unsafe { @@ -18,7 +20,7 @@ } } - #[test] + #[gtest] fn test_return_reference() { use simple_functions::return_reference; unsafe { @@ -26,7 +28,7 @@ } } - #[test] + #[gtest] fn test_take_pointer() { use simple_functions::take_pointer; take_pointer(None); @@ -35,7 +37,7 @@ assert_eq!(i, 42); } - #[test] + #[gtest] fn test_take_reference() { use simple_functions::take_reference; let mut i: i32 = 0; @@ -43,7 +45,7 @@ assert_eq!(i, 42); } - #[test] + #[gtest] fn test_forward_pointer() { use simple_functions::forward_pointer; assert_eq!(forward_pointer(None), None); @@ -51,24 +53,24 @@ assert_eq!(*forward_pointer(Some(&i)).unwrap(), 42); } - #[test] + #[gtest] fn test_forward_reference() { use simple_functions::forward_reference; let i: i32 = 42; assert_eq!(*forward_reference(&i), 42); } - #[test] + #[gtest] fn test_multiply() { assert_eq!(simple_functions::multiply(42, 123), 42 * 123); } - #[test] + #[gtest] fn test_multiply_with_unnamed_parameters() { assert_eq!(simple_functions::multiply_with_unnamed_parameters(42, 456), 42 * 456); } - #[test] + #[gtest] fn test_multiply_with_keyword_named_parameters() { assert_eq!( 42 * 123 * 456, @@ -76,21 +78,21 @@ ); } - #[test] + #[gtest] fn test_function_pointer() { let maybe_mul_fn = simple_functions::get_pointer_to_multiply_function(); let mul_fn = maybe_mul_fn.expect("Expecting non-null / non-None function pointer"); assert_eq!(mul_fn(123, 456), 123 * 456); } - #[test] + #[gtest] fn test_function_reference() { // TODO(b/217419782): Replicate `test_function_pointer`, but for C++ // references. (e.g. no `expect` / `Option` unwrapping should be // needed). } - #[test] + #[gtest] fn test_function_pointer_returned_from_inline_function() { let maybe_mul_fn = simple_functions::inline_get_pointer_to_multiply_function(); let mul_fn = maybe_mul_fn.expect("Expecting non-null / non-None function pointer"); @@ -98,7 +100,7 @@ } /// Test that function pointers can be accepted as function parameters. - #[test] + #[gtest] fn test_apply_binary_op() { extern "C" fn multiply(x: i32, y: i32) -> i32 { x * y
diff --git a/rs_bindings_from_cc/test/generated_headers/BUILD b/rs_bindings_from_cc/test/generated_headers/BUILD index 2bee4ca..a273e00 100644 --- a/rs_bindings_from_cc/test/generated_headers/BUILD +++ b/rs_bindings_from_cc/test/generated_headers/BUILD
@@ -21,4 +21,7 @@ name = "generated_header_test", srcs = ["generated_header_test.rs"], cc_deps = [":generated_header"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/generated_headers/generated_header_test.rs b/rs_bindings_from_cc/test/generated_headers/generated_header_test.rs index 039f92f..7b1b960 100644 --- a/rs_bindings_from_cc/test/generated_headers/generated_header_test.rs +++ b/rs_bindings_from_cc/test/generated_headers/generated_header_test.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_bindings_from_generated_header() { assert_eq!(generated_header::ReturnsFortyTwo(), 42); }
diff --git a/rs_bindings_from_cc/test/includes/BUILD b/rs_bindings_from_cc/test/includes/BUILD index 2b80f86..3255479 100644 --- a/rs_bindings_from_cc/test/includes/BUILD +++ b/rs_bindings_from_cc/test/includes/BUILD
@@ -19,4 +19,7 @@ name = "includes_test", srcs = ["includes_test.rs"], cc_deps = [":using_includes"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/includes/includes_test.rs b/rs_bindings_from_cc/test/includes/includes_test.rs index 79c447d..b2342fb 100644 --- a/rs_bindings_from_cc/test/includes/includes_test.rs +++ b/rs_bindings_from_cc/test/includes/includes_test.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_access_to_declaration_from_header_using_system_include_directory() { assert_eq!(using_includes::ReturnsFortyTwo(), 42); }
diff --git a/rs_bindings_from_cc/test/macro_locations/BUILD b/rs_bindings_from_cc/test/macro_locations/BUILD index 6089816..5065beb 100644 --- a/rs_bindings_from_cc/test/macro_locations/BUILD +++ b/rs_bindings_from_cc/test/macro_locations/BUILD
@@ -26,4 +26,7 @@ cc_deps = [ ":uses_macro", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/macro_locations/uses_struct_and_function_from_macro.rs b/rs_bindings_from_cc/test/macro_locations/uses_struct_and_function_from_macro.rs index bdf3d7a..b3747a7 100644 --- a/rs_bindings_from_cc/test/macro_locations/uses_struct_and_function_from_macro.rs +++ b/rs_bindings_from_cc/test/macro_locations/uses_struct_and_function_from_macro.rs
@@ -4,8 +4,9 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; - #[test] + #[gtest] fn test_uses_struct_and_function_from_macro() { let my_struct = uses_macro::StructFromMacro { val: 3 }; assert_eq!(my_struct.val, uses_macro::functionFromMacro(3));
diff --git a/rs_bindings_from_cc/test/namespace/inline/BUILD b/rs_bindings_from_cc/test/namespace/inline/BUILD index 9b17c03..65320b4 100644 --- a/rs_bindings_from_cc/test/namespace/inline/BUILD +++ b/rs_bindings_from_cc/test/namespace/inline/BUILD
@@ -12,4 +12,7 @@ name = "test", srcs = ["test.rs"], cc_deps = [":inline"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/namespace/inline/test.rs b/rs_bindings_from_cc/test/namespace/inline/test.rs index 5e3711d..ff0eb15 100644 --- a/rs_bindings_from_cc/test/namespace/inline/test.rs +++ b/rs_bindings_from_cc/test/namespace/inline/test.rs
@@ -4,9 +4,10 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; use inline::*; - #[test] + #[gtest] fn test_inline_namespaces() { let s = foo::inline1::MyStruct { value: 123 }; assert_eq!(123, foo::inline1::GetStructValue1(&s));
diff --git a/rs_bindings_from_cc/test/namespace/reopened/BUILD b/rs_bindings_from_cc/test/namespace/reopened/BUILD index a530287..3f4ae06 100644 --- a/rs_bindings_from_cc/test/namespace/reopened/BUILD +++ b/rs_bindings_from_cc/test/namespace/reopened/BUILD
@@ -23,4 +23,7 @@ proc_macro_deps = [ "//common:item_exists", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/namespace/reopened/test.rs b/rs_bindings_from_cc/test/namespace/reopened/test.rs index 2b23d66..f389077 100644 --- a/rs_bindings_from_cc/test/namespace/reopened/test.rs +++ b/rs_bindings_from_cc/test/namespace/reopened/test.rs
@@ -2,15 +2,16 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +use googletest::prelude::*; use item_exists::value_exists; use reopened_namespace::foo; -#[test] +#[gtest] fn test_not_present() { assert!(!value_exists!(foo::FunctionUsesNamespaceType)); } -#[test] +#[gtest] fn test_reopened_namespace() { assert_eq!(42, foo::Returns42()); }
diff --git a/rs_bindings_from_cc/test/roundtrip/BUILD b/rs_bindings_from_cc/test/roundtrip/BUILD index 508bc96..dd3083d 100644 --- a/rs_bindings_from_cc/test/roundtrip/BUILD +++ b/rs_bindings_from_cc/test/roundtrip/BUILD
@@ -17,4 +17,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":roundtrip"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/roundtrip/test.rs b/rs_bindings_from_cc/test/roundtrip/test.rs index 3b33959..d5ac293 100644 --- a/rs_bindings_from_cc/test/roundtrip/test.rs +++ b/rs_bindings_from_cc/test/roundtrip/test.rs
@@ -4,28 +4,30 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_rs_char_parameter_type_and_return_type() { use roundtrip::rs_char_test::*; let roundtrip = NextChar('a'); assert_eq!(roundtrip, 'b'); } - #[test] + #[gtest] fn test_rs_char_field_type() { use roundtrip::rs_char_test::*; let s = SomeStruct { c: 'x' }; assert_eq!('x', s.GetChar()); } - #[test] + #[gtest] fn test_rs_char_via_type_alias() { use roundtrip::rs_char_test::*; let roundtrip = NextCharViaTypeAlias('a'); assert_eq!(roundtrip, 'b'); } - #[test] + #[gtest] fn test_rs_char_via_import() { use roundtrip::rs_char_test::*; let roundtrip = NextCharViaImport('a');
diff --git a/rs_bindings_from_cc/test/struct/abi_class/BUILD b/rs_bindings_from_cc/test/struct/abi_class/BUILD index cfdfdcf..9023d5e 100644 --- a/rs_bindings_from_cc/test/struct/abi_class/BUILD +++ b/rs_bindings_from_cc/test/struct/abi_class/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":abi_class"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/struct/abi_class/test.rs b/rs_bindings_from_cc/test/struct/abi_class/test.rs index ad5d149..7bd80f5 100644 --- a/rs_bindings_from_cc/test/struct/abi_class/test.rs +++ b/rs_bindings_from_cc/test/struct/abi_class/test.rs
@@ -5,8 +5,9 @@ #[cfg(test)] mod tests { use abi_class::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_struct_float() { let x = StructFloat::Create(123.0); let y = StructFloat::Create(456.0); @@ -14,7 +15,7 @@ assert_eq!(123.0 + 456.0, StructFloat::Inspect(sum)); } - #[test] + #[gtest] fn test_struct_memory() { let x = StructMemory::Create(456); let y = StructMemory::Create(321); @@ -22,7 +23,7 @@ assert_eq!(456 + 321, StructMemory::Inspect(sum)); } - #[test] + #[gtest] fn test_struct_integer() { let x = StructInteger::Create(456); let y = StructInteger::Create(789);
diff --git a/rs_bindings_from_cc/test/struct/constructors/BUILD b/rs_bindings_from_cc/test/struct/constructors/BUILD index 5987dd0..765f398 100644 --- a/rs_bindings_from_cc/test/struct/constructors/BUILD +++ b/rs_bindings_from_cc/test/struct/constructors/BUILD
@@ -26,6 +26,7 @@ ], deps = [ "//support:ctor", + "//third_party/gtest_rust/googletest", "@crate_index//:static_assertions", ], )
diff --git a/rs_bindings_from_cc/test/struct/constructors/test.rs b/rs_bindings_from_cc/test/struct/constructors/test.rs index eb5e8ee..82c1166 100644 --- a/rs_bindings_from_cc/test/struct/constructors/test.rs +++ b/rs_bindings_from_cc/test/struct/constructors/test.rs
@@ -6,10 +6,11 @@ mod tests { use constructors::*; use ctor::CtorNew as _; + use googletest::prelude::*; use no_elided_lifetimes::*; use static_assertions::{assert_impl_all, assert_not_impl_any}; - #[test] + #[gtest] #[allow(clippy::redundant_clone)] fn test_user_provided_constructors() { assert_impl_all!(StructWithUserProvidedConstructors: Default); @@ -25,28 +26,28 @@ assert_not_impl_any!(StructWithUserProvidedConstructors: Copy); } - #[test] + #[gtest] fn test_explicit_conversion_constructor() { assert_impl_all!(StructWithExplicitConversionConstructor: From<i32>); let i: StructWithExplicitConversionConstructor = 125.into(); assert_eq!(125, i.int_field); } - #[test] + #[gtest] fn test_implicit_conversion_constructor() { assert_impl_all!(StructWithImplicitConversionConstructor: From<i32>); let i: StructWithImplicitConversionConstructor = 125.into(); assert_eq!(125, i.int_field); } - #[test] + #[gtest] fn test_implicit_conversion_from_reference() { let other = OtherSimpleStruct { int_field: 126 }; let i: StructWithImplicitConversionFromReference = (&other).into(); assert_eq!(126, i.int_field); } - #[test] + #[gtest] #[allow(clippy::redundant_clone)] fn test_inline_constructors() { assert_impl_all!(StructWithInlineConstructors: Default); @@ -66,17 +67,17 @@ assert_eq!(456, i.int_field); } - #[test] + #[gtest] fn test_deleted_constructors() { assert_not_impl_any!(StructWithDeletedConstructors: Clone, Copy, Default, From<i32>); } - #[test] + #[gtest] fn test_private_constructors() { assert_not_impl_any!(StructWithPrivateConstructors: Clone, Copy, Default, From<i32>); } - #[test] + #[gtest] #[allow(clippy::clone_on_copy)] fn test_explicitly_defaulted_constructors() { assert_impl_all!(StructWithExplicitlyDefaultedConstructors: Default); @@ -98,7 +99,7 @@ assert_impl_all!(StructWithExplicitlyDefaultedConstructors: Copy); } - #[test] + #[gtest] fn test_nontrivial_struct() { // Non-trivial types cannot be copied. assert_not_impl_any!(NonTrivialStructWithConstructors: Copy); @@ -118,7 +119,7 @@ assert_eq!(s_clone.int_field, 123); } - #[test] + #[gtest] fn test_no_elided_lifetimes() { // b/214244223: No bindings should be generated for any of the // constructors if no lifetimes are present on `this` parameter in C++.
diff --git a/rs_bindings_from_cc/test/struct/destructors/BUILD b/rs_bindings_from_cc/test/struct/destructors/BUILD index 7a663de..44f73dd 100644 --- a/rs_bindings_from_cc/test/struct/destructors/BUILD +++ b/rs_bindings_from_cc/test/struct/destructors/BUILD
@@ -15,4 +15,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":field_destruction_order"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/struct/destructors/test.rs b/rs_bindings_from_cc/test/struct/destructors/test.rs index 5b817a1..3bdacdd 100644 --- a/rs_bindings_from_cc/test/struct/destructors/test.rs +++ b/rs_bindings_from_cc/test/struct/destructors/test.rs
@@ -5,9 +5,10 @@ #[cfg(test)] mod tests { use field_destruction_order::*; + use googletest::prelude::*; use std::mem::ManuallyDrop; - #[test] + #[gtest] fn test_field_destruction_order() { let field1_value = 1; let field2_value = 2;
diff --git a/rs_bindings_from_cc/test/struct/fields/BUILD b/rs_bindings_from_cc/test/struct/fields/BUILD index 9e14616..6a74e39 100644 --- a/rs_bindings_from_cc/test/struct/fields/BUILD +++ b/rs_bindings_from_cc/test/struct/fields/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":fields"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/struct/fields/test.rs b/rs_bindings_from_cc/test/struct/fields/test.rs index 085efae..e09586d 100644 --- a/rs_bindings_from_cc/test/struct/fields/test.rs +++ b/rs_bindings_from_cc/test/struct/fields/test.rs
@@ -5,8 +5,9 @@ #[cfg(test)] mod tests { use fields::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_simple_struct() { // This test doesn't really do a whole lot beyond verifying that the // struct and its fields are imported correctly and that the generated
diff --git a/rs_bindings_from_cc/test/struct/forward_declarations/BUILD b/rs_bindings_from_cc/test/struct/forward_declarations/BUILD index 0953495..50659a1 100644 --- a/rs_bindings_from_cc/test/struct/forward_declarations/BUILD +++ b/rs_bindings_from_cc/test/struct/forward_declarations/BUILD
@@ -50,6 +50,7 @@ deps = [ "//support:ctor", "//support:forward_declare", + "//third_party/gtest_rust/googletest", "@crate_index//:static_assertions", ], )
diff --git a/rs_bindings_from_cc/test/struct/forward_declarations/forward_declarations_test.rs b/rs_bindings_from_cc/test/struct/forward_declarations/forward_declarations_test.rs index 0032390..1e11daa 100644 --- a/rs_bindings_from_cc/test/struct/forward_declarations/forward_declarations_test.rs +++ b/rs_bindings_from_cc/test/struct/forward_declarations/forward_declarations_test.rs
@@ -1,13 +1,15 @@ // Part of the Crubit project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + use forward_declare::CcCast; +use googletest::prelude::*; use static_assertions::{assert_impl_all, assert_not_impl_any}; use std::pin::Pin; /// Given a complete UnpinStruct, all APIs accepting a (possibly incomplete) /// UnpinStruct work (with an cc_cast()). -#[test] +#[gtest] fn test_read_complete_unpin() { let s = definition::ns::UnpinStruct { field: 42 }; let s = &s; @@ -26,7 +28,7 @@ /// Given a complete UnpinStruct, all APIs accepting a (possibly incomplete) /// mut UnpinStruct work (with an cc_cast()). -#[test] +#[gtest] fn test_write_complete_unpin() { let mut s = definition::ns::UnpinStruct { field: 42 }; let s = &mut s; @@ -49,7 +51,7 @@ /// Given an incomplete UnpinStruct, all APIs accepting a (possibly /// incomplete) UnpinStruct work (with an cc_cast()). -#[test] +#[gtest] fn test_read_incomplete_unpin() { let s = definition::ns::UnpinStruct { field: 42 }; let decl1_s: &declaration_1::ns::UnpinStruct = (&s).cc_cast(); @@ -68,7 +70,7 @@ /// Given an incomplete UnpinStruct, all APIs accepting a (possibly /// incomplete) mut UnpinStruct work (with an cc_cast()). -#[test] +#[gtest] fn test_write_incomplete_unpin() { let mut s = definition::ns::UnpinStruct { field: 42 }; let mut decl1_s: Pin<&mut declaration_1::ns::UnpinStruct> = (&mut s).cc_cast(); @@ -91,7 +93,7 @@ /// Given a complete NonunpinStruct, all APIs accepting a (possibly incomplete) /// NonunpinStruct work (with an cc_cast()). -#[test] +#[gtest] fn test_read_complete_nonunpin() { ctor::emplace! { let mut s = ctor::ctor!(definition::ns::NonunpinStruct {field: 42}); @@ -111,7 +113,7 @@ /// Given a complete NonunpinStruct, all APIs accepting a (possibly incomplete) /// mut NonunpinStruct work (with an cc_cast()). -#[test] +#[gtest] fn test_write_complete_nonunpin() { ctor::emplace! { let mut s = ctor::ctor!(definition::ns::NonunpinStruct {field: 42}); @@ -135,7 +137,7 @@ /// Given an incomplete NonunpinStruct, all APIs accepting a (possibly /// incomplete) NonunpinStruct work (with an cc_cast()). -#[test] +#[gtest] fn test_read_incomplete_nonunpin() { ctor::emplace! { let mut s = ctor::ctor!(definition::ns::NonunpinStruct {field: 42}); @@ -156,7 +158,7 @@ /// Given an incomplete NonunpinStruct, all APIs accepting a (possibly /// incomplete) mut NonunpinStruct work (with an cc_cast()). -#[test] +#[gtest] fn test_write_incomplete_nonunpin() { ctor::emplace! { let mut s = ctor::ctor!(definition::ns::NonunpinStruct {field: 42}); @@ -179,7 +181,7 @@ assert_eq!(declaration_1::ns::ReadNonunpinStruct(&*decl1_s), 3); } -#[test] +#[gtest] fn test_inline_functions_with_incomplete_parameters() { let unpin = definition::ns::UnpinStruct { field: 42 }; let unpin_ref = &unpin; @@ -194,7 +196,7 @@ /// Classes in different forward-declared namespaces should not be castable to /// one another. -#[test] +#[gtest] fn test_namespaced_forward_declarations() { type Declaration = *const declaration_1::ns::UnpinStruct; type Definition = *const definition::ns::UnpinStruct; @@ -209,7 +211,7 @@ assert_not_impl_any!(Other: CcCast<Declaration>); } -#[test] +#[gtest] fn test_forward_declared_used_as_field_type() { // This is a regression test for b/246962427. This mostly verifies that the // generated bindings compile (and are usable at a very basic level).
diff --git a/rs_bindings_from_cc/test/struct/incomplete_record/BUILD b/rs_bindings_from_cc/test/struct/incomplete_record/BUILD index 0befd91..cd4ac2c 100644 --- a/rs_bindings_from_cc/test/struct/incomplete_record/BUILD +++ b/rs_bindings_from_cc/test/struct/incomplete_record/BUILD
@@ -18,4 +18,7 @@ cc_deps = [ ":reference_incomplete_record_by_value", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/struct/incomplete_record/test.rs b/rs_bindings_from_cc/test/struct/incomplete_record/test.rs index f6aee5f..b90683b 100644 --- a/rs_bindings_from_cc/test/struct/incomplete_record/test.rs +++ b/rs_bindings_from_cc/test/struct/incomplete_record/test.rs
@@ -5,7 +5,8 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; - #[test] + #[gtest] fn test_build() {} }
diff --git a/rs_bindings_from_cc/test/struct/inheritance/BUILD b/rs_bindings_from_cc/test/struct/inheritance/BUILD index 370a2f2..0294d7d 100644 --- a/rs_bindings_from_cc/test/struct/inheritance/BUILD +++ b/rs_bindings_from_cc/test/struct/inheritance/BUILD
@@ -17,5 +17,6 @@ deps = [ "//support:ctor", "//support:oops", + "//third_party/gtest_rust/googletest", ], )
diff --git a/rs_bindings_from_cc/test/struct/inheritance/upcast_test.rs b/rs_bindings_from_cc/test/struct/inheritance/upcast_test.rs index c3f9eae..d21748e 100644 --- a/rs_bindings_from_cc/test/struct/inheritance/upcast_test.rs +++ b/rs_bindings_from_cc/test/struct/inheritance/upcast_test.rs
@@ -4,10 +4,11 @@ #[cfg(test)] mod tests { use ctor::CtorNew as _; + use googletest::prelude::*; use oops::Upcast as _; use upcast::*; - #[test] + #[gtest] fn test_upcast() { let derived = Derived::default(); let derived = &derived; @@ -24,7 +25,7 @@ assert_eq!(base4 as *const _ as usize, derived.base4_address()); } - #[test] + #[gtest] fn test_virtual_upcast() { use upcast::virtual_inheritance::*; ctor::emplace! { @@ -46,7 +47,7 @@ assert_eq!(base1 as *const _ as usize, base1_address); } - #[test] + #[gtest] fn test_upcast_thunk_name_uniqueness() { ctor::emplace! { let derived = another_namespace::VirtualBase2::ctor_new(());
diff --git a/rs_bindings_from_cc/test/struct/methods/BUILD b/rs_bindings_from_cc/test/struct/methods/BUILD index 0a5c453..43f4d89 100644 --- a/rs_bindings_from_cc/test/struct/methods/BUILD +++ b/rs_bindings_from_cc/test/struct/methods/BUILD
@@ -15,4 +15,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":methods"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/struct/methods/test.rs b/rs_bindings_from_cc/test/struct/methods/test.rs index a244f27..55369cd 100644 --- a/rs_bindings_from_cc/test/struct/methods/test.rs +++ b/rs_bindings_from_cc/test/struct/methods/test.rs
@@ -4,46 +4,47 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; use methods::*; - #[test] + #[gtest] fn test_instance_const_method() { let s = InstanceMethods { int_field: 124 }; assert_eq!(124, s.get_int_field()); } - #[test] + #[gtest] fn test_instance_nonconst_method() { let mut s = InstanceMethods { int_field: 123 }; s.set_int_field(457); assert_eq!(457, s.int_field); } - #[test] + #[gtest] fn test_inline_instance_const_method() { let s = InstanceMethods { int_field: 124 }; assert_eq!(124, s.inline_get_int_field()); } - #[test] + #[gtest] fn test_inline_instance_nonconst_method() { let mut s = InstanceMethods { int_field: 123 }; s.inline_set_int_field(457); assert_eq!(457, s.int_field); } - #[test] + #[gtest] fn test_static_factory_method() { let s: SomeClass = SomeClass::static_factory_method(123); assert_eq!(123, s.int_var); } - #[test] + #[gtest] fn test_static_method_that_multiplies_its_args() { assert_eq!(42 * 789, SomeClass::static_method_that_multiplies_its_args(42, 789)); } - #[test] + #[gtest] fn test_static_inline_method() { assert_eq!(42 * 456, SomeClass::static_inline_method(456)); }
diff --git a/rs_bindings_from_cc/test/struct/methods_qualifiers/BUILD b/rs_bindings_from_cc/test/struct/methods_qualifiers/BUILD index 1cf68c2..ce0963b 100644 --- a/rs_bindings_from_cc/test/struct/methods_qualifiers/BUILD +++ b/rs_bindings_from_cc/test/struct/methods_qualifiers/BUILD
@@ -15,5 +15,6 @@ cc_deps = [":methods_qualifiers"], deps = [ "//support:ctor", + "//third_party/gtest_rust/googletest", ], )
diff --git a/rs_bindings_from_cc/test/struct/methods_qualifiers/test.rs b/rs_bindings_from_cc/test/struct/methods_qualifiers/test.rs index 13d6dde..51aac2c 100644 --- a/rs_bindings_from_cc/test/struct/methods_qualifiers/test.rs +++ b/rs_bindings_from_cc/test/struct/methods_qualifiers/test.rs
@@ -3,17 +3,18 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception use ctor::emplace; +use googletest::prelude::*; use methods_qualifiers::*; use std::pin::Pin; -#[test] +#[gtest] fn test_methods_on_mov_pinned_box_to_plain_unpin_struct() { let c = UnpinStructWithRefQualifiedMethods { i: 0 }; assert_eq!(ctor::mov!(Box::pin(c)).0.const_qualified_get_i(), 0); assert_eq!(ctor::mov!(Box::pin(c)).0.const_lvalue_ref_qualified_get_i(), 0); assert_eq!(ctor::mov!(Box::pin(c)).as_const().const_rvalue_ref_qualified_get_i(), 0); } -#[test] +#[gtest] fn test_methods_on_mov_pinned_box_to_mut_unpin_struct() { let mut c_mut = UnpinStructWithRefQualifiedMethods { i: 0 }; c_mut.increment_i(); // Slience the warning on unused `mut`. @@ -24,7 +25,7 @@ assert_eq!(ctor::mov!(Box::pin(c_mut)).rvalue_ref_qualified_get_i(), 1); assert_eq!(ctor::mov!(Box::pin(c_mut)).as_const().const_rvalue_ref_qualified_get_i(), 1); } -#[test] +#[gtest] fn test_methods_on_mov_pinned_mut_unpin_struct_ref() { emplace! {let c : Pin<&mut _> = UnpinStructWithRefQualifiedMethods{i:0};} assert_eq!(ctor::mov!(c).0.unqualified_get_i(), 0);
diff --git a/rs_bindings_from_cc/test/struct/multiple_targets/BUILD b/rs_bindings_from_cc/test/struct/multiple_targets/BUILD index 45e5ff5..b553f32 100644 --- a/rs_bindings_from_cc/test/struct/multiple_targets/BUILD +++ b/rs_bindings_from_cc/test/struct/multiple_targets/BUILD
@@ -23,4 +23,7 @@ ":dependency", ":uses_dependency", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/struct/multiple_targets/test.rs b/rs_bindings_from_cc/test/struct/multiple_targets/test.rs index 5834bfb..97a40ff 100644 --- a/rs_bindings_from_cc/test/struct/multiple_targets/test.rs +++ b/rs_bindings_from_cc/test/struct/multiple_targets/test.rs
@@ -4,7 +4,9 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_has_dependency() { let dependency = dependency::Dependency { magic: 42 }; assert_eq!(uses_dependency::UseDependency(dependency).magic, dependency.magic);
diff --git a/rs_bindings_from_cc/test/struct/no_unique_address/BUILD b/rs_bindings_from_cc/test/struct/no_unique_address/BUILD index 68d03a4..9a6e213 100644 --- a/rs_bindings_from_cc/test/struct/no_unique_address/BUILD +++ b/rs_bindings_from_cc/test/struct/no_unique_address/BUILD
@@ -14,5 +14,8 @@ name = "no_unique_address_test", srcs = ["no_unique_address_test.rs"], cc_deps = [":no_unique_address"], - deps = ["//support:ctor"], + deps = [ + "//support:ctor", + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/struct/no_unique_address/no_unique_address_test.rs b/rs_bindings_from_cc/test/struct/no_unique_address/no_unique_address_test.rs index 9b6e805..2b85917 100644 --- a/rs_bindings_from_cc/test/struct/no_unique_address/no_unique_address_test.rs +++ b/rs_bindings_from_cc/test/struct/no_unique_address/no_unique_address_test.rs
@@ -4,25 +4,26 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; use no_unique_address::*; use ctor::CtorNew as _; - #[test] + #[gtest] fn test_get() { let s = Struct::Make(1, 2); assert_eq!(s.field1(), &1); assert_eq!(s.field2(), &2); } - #[test] + #[gtest] fn test_padding_between_fields() { let s = PaddingBetweenFields::Make(1, 2); assert_eq!(s.field1, 1); assert_eq!(s.field2(), &2); } - #[test] + #[gtest] fn test_field_in_tail_padding() { ctor::emplace! { let s = FieldInTailPadding::ctor_new((1, 2, 3)); @@ -32,7 +33,7 @@ assert_eq!(s.char_in_tail_padding_of_prev_field, 3); } - #[test] + #[gtest] fn test_struct_with_fields_written_before_empty_no_unique_address_field() { ctor::emplace! { let mut s = StructWithFieldsWrittenBeforeEmptyNoUniqueAddressField::Make(1); @@ -41,12 +42,12 @@ assert_eq!(s.no_unique_address_empty_field().method(), 12345); } - #[test] + #[gtest] fn test_class_with_fields_written_before_empty_no_unique_address_field_compile() { let _ = ClassWithFieldsWrittenBeforeEmptyNoUniqueAddressField::default(); } - #[test] + #[gtest] fn test_struct_with_bit_fields_and_no_unique_address_fields() { let s = StructWithBitFieldsAndNoUniqueAddressField::default(); assert_eq!(s.field2, 54321);
diff --git a/rs_bindings_from_cc/test/struct/nonunpin/BUILD b/rs_bindings_from_cc/test/struct/nonunpin/BUILD index ab2098c..aab3276 100644 --- a/rs_bindings_from_cc/test/struct/nonunpin/BUILD +++ b/rs_bindings_from_cc/test/struct/nonunpin/BUILD
@@ -16,5 +16,8 @@ srcs = ["nonunpin_test.rs"], cc_deps = [":nonunpin"], rustc_flags = ["-Zallow-features=negative_impls"], - deps = ["//support:ctor"], + deps = [ + "//support:ctor", + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/struct/nonunpin/nonunpin_test.rs b/rs_bindings_from_cc/test/struct/nonunpin/nonunpin_test.rs index 8c9db0b..a54156d 100644 --- a/rs_bindings_from_cc/test/struct/nonunpin/nonunpin_test.rs +++ b/rs_bindings_from_cc/test/struct/nonunpin/nonunpin_test.rs
@@ -7,12 +7,13 @@ mod tests { use ctor::{ctor, emplace, mov, ConstRvalueReference, Ctor, Emplace, RvalueReference}; use ctor::{Assign as _, CtorNew as _, ReconstructUnchecked as _}; + use googletest::prelude::*; use nonunpin::{Nonmovable, Nonunpin, NonunpinStruct, ReturnsNonmovable}; use std::pin::Pin; /// When a value is constructed in-place, it is initialized, has the correct /// address. - #[test] + #[gtest] fn test_onearg_ctor() { ctor::emplace! { let mut x = Nonunpin::ctor_new(42); @@ -21,7 +22,7 @@ assert_eq!(x.addr(), &*x as *const _ as usize); } - #[test] + #[gtest] fn test_default_ctor() { ctor::emplace! { let mut x = Nonunpin::ctor_new(()); @@ -30,7 +31,7 @@ assert_eq!(x.addr(), &*x as *const _ as usize); } - #[test] + #[gtest] fn test_move_construct() { ctor::emplace! { let mut x = Nonunpin::ctor_new(42); @@ -44,7 +45,7 @@ assert_eq!(y.addr(), &*y as *const _ as usize); } - #[test] + #[gtest] fn test_move_assign() { ctor::emplace! { let mut x = Nonunpin::ctor_new(42); @@ -60,7 +61,7 @@ assert_eq!(y.addr(), &*y as *const _ as usize); } - #[test] + #[gtest] fn test_copy_construct() { ctor::emplace! { let x = Nonunpin::ctor_new(42); @@ -74,7 +75,7 @@ assert_eq!(y.addr(), &*y as *const _ as usize); } - #[test] + #[gtest] fn test_copy_assign() { ctor::emplace! { let x = Nonunpin::ctor_new(42); @@ -89,7 +90,7 @@ assert_eq!(y.addr(), &*y as *const _ as usize); } - #[test] + #[gtest] fn test_methods() { ctor::emplace! { let mut x = Nonunpin::ctor_new(42); @@ -100,7 +101,7 @@ /// Test that the struct can be returned and passed as all the reference /// types, and passed by value. - #[test] + #[gtest] fn test_ref() { ctor::emplace! { let mut x = Nonunpin::ctor_new(42); @@ -132,7 +133,7 @@ } } - #[test] + #[gtest] fn test_aggregate() { ctor::emplace! { let mut x = ctor!(NonunpinStruct {value: 42}); @@ -148,7 +149,7 @@ assert_eq!(x.value, 0); } - #[test] + #[gtest] fn test_return_by_value() { ctor::emplace! { let x = Nonunpin::ctor_new(42); @@ -162,7 +163,7 @@ assert_eq!(y.addr(), &*y as *const _ as usize); } - #[test] + #[gtest] fn test_nonmovable_ctor() { ctor::emplace! { let x = Nonmovable::ctor_new(()); @@ -172,7 +173,7 @@ /// Thanks to C++17 prvalue semantics, we can in fact return a non-movable /// type by value. - #[test] + #[gtest] fn test_nonmovable_return_value() { ctor::emplace! { let x = ReturnsNonmovable(); @@ -191,7 +192,7 @@ /// In that case, the struct containing it must *also* become /// non-trivially-relocatable, and it becomes ~exactly as difficult to deal /// with as the C++ class it contains. - #[test] + #[gtest] fn test_struct_field() { #[ctor::recursively_pinned] struct MyStruct { @@ -220,7 +221,7 @@ /// Rust union. This mirrors the struct case, storing by value. /// /// It is also quite ugly, but, fortunately, these unions are not common. - #[test] + #[gtest] fn test_union_field() { union MyUnion { int: u32, @@ -247,7 +248,7 @@ } /// The example from the ctor.rs docs; copy-pasted. - #[test] + #[gtest] fn test_swap() { fn swap(mut x: Pin<&mut Nonunpin>, mut y: Pin<&mut Nonunpin>) { emplace! { let mut tmp = mov!(x.as_mut()); }
diff --git a/rs_bindings_from_cc/test/struct/operators/BUILD b/rs_bindings_from_cc/test/struct/operators/BUILD index 66f2847..feb35c8 100644 --- a/rs_bindings_from_cc/test/struct/operators/BUILD +++ b/rs_bindings_from_cc/test/struct/operators/BUILD
@@ -17,6 +17,7 @@ cc_deps = [":add"], deps = [ "//support:ctor", + "//third_party/gtest_rust/googletest", ], ) @@ -32,6 +33,7 @@ cc_deps = [":add_assign"], deps = [ "//support:ctor", + "//third_party/gtest_rust/googletest", "@crate_index//:static_assertions", ], ) @@ -48,6 +50,7 @@ cc_deps = [":operators"], deps = [ "//support:ctor", + "//third_party/gtest_rust/googletest", "@crate_index//:static_assertions", ], )
diff --git a/rs_bindings_from_cc/test/struct/operators/add_assign_test.rs b/rs_bindings_from_cc/test/struct/operators/add_assign_test.rs index bc6949c..5abd986 100644 --- a/rs_bindings_from_cc/test/struct/operators/add_assign_test.rs +++ b/rs_bindings_from_cc/test/struct/operators/add_assign_test.rs
@@ -5,15 +5,16 @@ #[cfg(test)] mod tests { use add_assign::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_add_assign_member_int() { let mut s = AddAssignMemberInt { i: 11 }; s += 22; assert_eq!(33, s.i); } - #[test] + #[gtest] fn test_add_assign_member_by_value() { let mut s1 = AddAssignMemberByValue { i: 11 }; let s2 = AddAssignMemberByValue { i: 22 }; @@ -21,7 +22,7 @@ assert_eq!(33, s1.i); } - #[test] + #[gtest] fn test_add_assign_member_by_ref() { let mut s1 = AddAssignMemberByRef { i: 11 }; let mut s2 = AddAssignMemberByRef { i: 22 }; @@ -29,7 +30,7 @@ assert_eq!(33, s1.i); } - #[test] + #[gtest] fn test_add_assign_member_by_const_ref() { let mut s1 = AddAssignMemberByConstRef { i: 11 }; let s2 = AddAssignMemberByConstRef { i: 22 }; @@ -37,7 +38,7 @@ assert_eq!(33, s1.i); } - #[test] + #[gtest] fn test_add_assign_free_by_value() { let mut s1 = AddAssignFreeByValue { i: 11 }; let s2 = AddAssignFreeByValue { i: 22 }; @@ -45,7 +46,7 @@ assert_eq!(33, s1.i); } - #[test] + #[gtest] fn test_add_assign_friend_by_value() { let mut s1 = AddAssignFriendByValue { i: 11 }; let s2 = AddAssignFriendByValue { i: 22 }; @@ -53,7 +54,7 @@ assert_eq!(33, s1.i); } - #[test] + #[gtest] fn test_add_assign_inline_friend_by_value() { let mut s1 = AddAssignInlineFriendByValue { i: 111 }; let s2 = AddAssignInlineFriendByValue { i: 222 };
diff --git a/rs_bindings_from_cc/test/struct/operators/add_test.rs b/rs_bindings_from_cc/test/struct/operators/add_test.rs index d5c38b3..7eb79eb 100644 --- a/rs_bindings_from_cc/test/struct/operators/add_test.rs +++ b/rs_bindings_from_cc/test/struct/operators/add_test.rs
@@ -5,42 +5,43 @@ #[cfg(test)] mod tests { use add::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_add_const_member_int() { let s = AddableConstMemberInt { i: 11 }; assert_eq!(33, &s + 22); } - #[test] + #[gtest] fn test_add_const_member_by_ref() { let s1 = AddableConstMemberByRef { i: 11 }; let s2 = AddableConstMemberByRef { i: 22 }; assert_eq!(33, (&s1 + &s2).i); } - #[test] + #[gtest] fn test_add_non_const_member_by_ref() { let mut s1 = AddableNonConstMemberByRef { i: 11 }; let s2 = AddableNonConstMemberByRef { i: 22 }; assert_eq!(33, (&mut s1 + &s2).i); } - #[test] + #[gtest] fn test_add_const_member_by_value() { let s1 = AddableConstMemberByValue { i: 11 }; let s2 = AddableConstMemberByValue { i: 22 }; assert_eq!(33, (&s1 + s2).i); } - #[test] + #[gtest] fn test_add_non_const_member_by_value() { let mut s1 = AddableNonConstMemberByValue { i: 11 }; let s2 = AddableNonConstMemberByValue { i: 22 }; assert_eq!(33, (&mut s1 + s2).i); } - #[test] + #[gtest] fn test_add_returns_void() { let mut s1 = AddableReturnsVoid { i: 11 }; let s2 = AddableReturnsVoid { i: 22 }; @@ -48,7 +49,7 @@ assert_eq!(s1.i, 33); } - #[test] + #[gtest] fn test_add_nontrivial_by_value() { ctor::emplace! { let s1 = ctor::ctor!(AddableNontrivialByValue {i: 11}); @@ -60,56 +61,56 @@ assert_eq!(sum.i, 33); } - #[test] + #[gtest] fn test_add_free_by_const_ref() { let s1 = UnpinStructByConstRef { i: 11 }; let s2 = UnpinStructByConstRef { i: 22 }; assert_eq!(33, (&s1 + &s2).i); } - #[test] + #[gtest] fn test_add_free_by_mut_ref() { let mut s1 = UnpinStructByMutRef { i: 11 }; let mut s2 = UnpinStructByMutRef { i: 22 }; assert_eq!(33, (&mut s1 + &mut s2).i); } - #[test] + #[gtest] fn test_add_free_by_value() { let s1 = UnpinStructByValue { i: 11 }; let s2 = UnpinStructByValue { i: 22 }; assert_eq!(33, (s1 + s2).i); } - #[test] + #[gtest] fn test_add_overloaded() { let s = AddableOverloaded { int16_char: b'A', int32_char: b'B' }; assert_eq!(b'A', s + 0i16); assert_eq!(b'B', s + 0i32); } - #[test] + #[gtest] fn test_add_friend_by_const_ref() { let s1 = AddableFriendByConstRef { i: 11 }; let s2 = AddableFriendByConstRef { i: 22 }; assert_eq!(33, (&s1 + &s2).i); } - #[test] + #[gtest] fn test_add_friend_by_ref() { let mut s1 = AddableFriendByRef { i: 11 }; let mut s2 = AddableFriendByRef { i: 22 }; assert_eq!(33, (&mut s1 + &mut s2).i); } - #[test] + #[gtest] fn test_add_friend_by_value() { let s1 = AddableFriendByValue { i: 11 }; let s2 = AddableFriendByValue { i: 22 }; assert_eq!(33, (s1 + s2).i); } - #[test] + #[gtest] fn test_add_returns_nontrivial() { ctor::emplace! { let s1 = ctor::ctor!(AddableReturnsNontrivial {i: 11});
diff --git a/rs_bindings_from_cc/test/struct/operators/operators_test.rs b/rs_bindings_from_cc/test/struct/operators/operators_test.rs index 0d85ea0..421e901 100644 --- a/rs_bindings_from_cc/test/struct/operators/operators_test.rs +++ b/rs_bindings_from_cc/test/struct/operators/operators_test.rs
@@ -4,10 +4,11 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; use operators::*; use static_assertions::{assert_impl_all, assert_not_impl_any}; - #[test] + #[gtest] fn test_eq_member_func_same_operands() { let s1 = TestStruct2 { i: 1005 }; let s2 = TestStruct2 { i: 2005 }; @@ -16,7 +17,7 @@ assert!(s1 != s3); } - #[test] + #[gtest] fn test_eq_member_func_different_operands() { let s1 = TestStruct2 { i: 1005 }; let s2 = TestStruct1 { i: 2005 }; @@ -28,7 +29,7 @@ assert_impl_all!(TestStruct2: PartialEq<TestStruct1>); assert_not_impl_any!(TestStruct1: PartialEq<TestStruct2>); } - #[test] + #[gtest] fn test_lt_member_func_same_operands() { let s1 = TestStruct2 { i: 1001 }; let s2 = TestStruct2 { i: 2002 }; @@ -37,7 +38,7 @@ assert!(s1 >= s3); } - #[test] + #[gtest] fn test_lt_member_func_different_operands() { // PartialOrd is only implemented if the operands of operator< are of the same // type. @@ -45,13 +46,13 @@ assert_not_impl_any!(TestStruct1: PartialOrd<TestStruct2>); } - #[test] + #[gtest] fn test_non_operator_method_name() { let s2 = TestStruct2 { i: 2005 }; assert_eq!(2005, s2.operator1()); } - #[test] + #[gtest] fn test_eq_out_of_line_definition() { let s1 = OperandForOutOfLineDefinition { i: 1005 }; let s2 = OperandForOutOfLineDefinition { i: 2005 }; @@ -60,42 +61,42 @@ assert!(s1 != s3); } - #[test] + #[gtest] fn test_eq_free_func() { let s1 = OperandForFreeFunc { i: 1005 }; let s2 = OperandForFreeFunc { i: 2005 }; assert!(s1 == s2); } - #[test] + #[gtest] fn test_eq_by_ref() { let s1 = OperandByRef { i: 1005 }; let s2 = OperandByRef { i: 2005 }; assert!(s1 == s2); } - #[test] + #[gtest] fn test_eq_by_value() { let s1 = OperandByValue { i: 1005 }; let s2 = OperandByValue { i: 2005 }; assert!(s1 == s2); } - #[test] + #[gtest] fn test_eq_by_ref_and_value() { let s1 = OperandByRefAndValue { i: 1005 }; let s2 = OperandByRefAndValue { i: 2005 }; assert!(s1 == s2); } - #[test] + #[gtest] fn test_eq_by_value_and_ref() { let s1 = OperandByValueAndRef { i: 1005 }; let s2 = OperandByValueAndRef { i: 2005 }; assert!(s1 == s2); } - #[test] + #[gtest] fn test_eq_free_func_different_namespace() { // We probably should try to mimic "argument-dependent lookup" (ADL) and // only generate bindings for PartialEq if `operator==` free function is @@ -111,7 +112,7 @@ // PartialEq); } - #[test] + #[gtest] fn test_lt_out_of_line_definition() { let s1 = OperandForOutOfLineDefinition { i: 1001 }; let s2 = OperandForOutOfLineDefinition { i: 2002 }; @@ -120,124 +121,124 @@ assert!(s1 >= s3); } - #[test] + #[gtest] fn test_lt_free_func() { let s1 = OperandForFreeFunc { i: 1001 }; let s2 = OperandForFreeFunc { i: 2002 }; assert!(s1 < s2); } - #[test] + #[gtest] fn test_lt_by_ref() { let s1 = OperandByRef { i: 1001 }; let s2 = OperandByRef { i: 2002 }; assert!(s1 < s2); } - #[test] + #[gtest] fn test_lt_by_value() { let s1 = OperandByValue { i: 1001 }; let s2 = OperandByValue { i: 2002 }; assert!(s1 < s2); } - #[test] + #[gtest] fn test_lt_by_ref_and_value() { let s1 = OperandByRefAndValue { i: 1001 }; let s2 = OperandByRefAndValue { i: 2002 }; assert!(s1 < s2); } - #[test] + #[gtest] fn test_lt_by_value_and_ref() { let s1 = OperandByValueAndRef { i: 1001 }; let s2 = OperandByValueAndRef { i: 2002 }; assert!(s1 < s2); } - #[test] + #[gtest] fn test_many_operators_neg() { let s = ManyOperators { i: 7 }; assert_eq!(-7, (-&s).i); } - #[test] + #[gtest] fn test_many_operators_not() { let s = ManyOperators { i: 7 }; assert_eq!(0, (!&s).i); } - #[test] + #[gtest] fn test_many_operators_add() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(10, (&s1 + s2).i); } - #[test] + #[gtest] fn test_many_operators_sub() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(4, (&s1 - s2).i); } - #[test] + #[gtest] fn test_many_operators_mul() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(21, (&s1 * s2).i); } - #[test] + #[gtest] fn test_many_operators_div() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(2, (&s1 / s2).i); } - #[test] + #[gtest] fn test_many_operators_rem() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(1, (&s1 % s2).i); } - #[test] + #[gtest] fn test_many_operators_bit_and() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(3, (&s1 & s2).i); } - #[test] + #[gtest] fn test_many_operators_bit_or() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(7, (&s1 | s2).i); } - #[test] + #[gtest] fn test_many_operators_bit_xor() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(4, (&s1 ^ s2).i); } - #[test] + #[gtest] fn test_many_operators_shl() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(56, (&s1 << s2).i); } - #[test] + #[gtest] fn test_many_operators_shr() { let s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; assert_eq!(0, (&s1 >> s2).i); } - #[test] + #[gtest] fn test_many_operators_add_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -245,7 +246,7 @@ assert_eq!(10, s1.i); } - #[test] + #[gtest] fn test_many_operators_sub_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -253,7 +254,7 @@ assert_eq!(4, s1.i); } - #[test] + #[gtest] fn test_many_operators_mul_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -261,7 +262,7 @@ assert_eq!(21, s1.i); } - #[test] + #[gtest] fn test_many_operators_div_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -269,7 +270,7 @@ assert_eq!(2, s1.i); } - #[test] + #[gtest] fn test_many_operators_rem_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -277,7 +278,7 @@ assert_eq!(1, s1.i); } - #[test] + #[gtest] fn test_many_operators_bit_and_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -285,7 +286,7 @@ assert_eq!(3, s1.i); } - #[test] + #[gtest] fn test_many_operators_bit_or_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -293,7 +294,7 @@ assert_eq!(7, s1.i); } - #[test] + #[gtest] fn test_many_operators_bit_xor_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -301,7 +302,7 @@ assert_eq!(4, s1.i); } - #[test] + #[gtest] fn test_many_operators_shl_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 }; @@ -309,7 +310,7 @@ assert_eq!(56, s1.i); } - #[test] + #[gtest] fn test_many_operators_shr_assign() { let mut s1 = ManyOperators { i: 7 }; let s2 = ManyOperators { i: 3 };
diff --git a/rs_bindings_from_cc/test/templates/SFINAE/BUILD b/rs_bindings_from_cc/test/templates/SFINAE/BUILD index 773d17b..66b02c8 100644 --- a/rs_bindings_from_cc/test/templates/SFINAE/BUILD +++ b/rs_bindings_from_cc/test/templates/SFINAE/BUILD
@@ -14,4 +14,7 @@ cc_deps = [ ":sfinae", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/SFINAE/test.rs b/rs_bindings_from_cc/test/templates/SFINAE/test.rs index 107e420..bd667fb 100644 --- a/rs_bindings_from_cc/test/templates/SFINAE/test.rs +++ b/rs_bindings_from_cc/test/templates/SFINAE/test.rs
@@ -2,5 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_build() {}
diff --git a/rs_bindings_from_cc/test/templates/bridging/BUILD b/rs_bindings_from_cc/test/templates/bridging/BUILD index ac7393f..4cf912d 100644 --- a/rs_bindings_from_cc/test/templates/bridging/BUILD +++ b/rs_bindings_from_cc/test/templates/bridging/BUILD
@@ -31,5 +31,6 @@ ], deps = [ "//support:forward_declare", + "//third_party/gtest_rust/googletest", ], )
diff --git a/rs_bindings_from_cc/test/templates/bridging/test.rs b/rs_bindings_from_cc/test/templates/bridging/test.rs index a236aaf..6b7b254 100644 --- a/rs_bindings_from_cc/test/templates/bridging/test.rs +++ b/rs_bindings_from_cc/test/templates/bridging/test.rs
@@ -5,8 +5,9 @@ #[cfg(test)] mod tests { use forward_declare::CcCast; + use googletest::prelude::*; - #[test] + #[gtest] fn test_bridging() { let x = class_template_instantiation1::Create(123);
diff --git a/rs_bindings_from_cc/test/templates/definition_in_cc/BUILD b/rs_bindings_from_cc/test/templates/definition_in_cc/BUILD index a5d1a53..3872684 100644 --- a/rs_bindings_from_cc/test/templates/definition_in_cc/BUILD +++ b/rs_bindings_from_cc/test/templates/definition_in_cc/BUILD
@@ -15,4 +15,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":definition_in_cc"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/definition_in_cc/test.rs b/rs_bindings_from_cc/test/templates/definition_in_cc/test.rs index 6ae0841..ac07d4d 100644 --- a/rs_bindings_from_cc/test/templates/definition_in_cc/test.rs +++ b/rs_bindings_from_cc/test/templates/definition_in_cc/test.rs
@@ -4,7 +4,9 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_member_function_of_class_template_defined_in_cc_file() { let s = definition_in_cc::MyTypeAlias::Create(123); assert_eq!(123, *s.value());
diff --git a/rs_bindings_from_cc/test/templates/extern_definition/BUILD b/rs_bindings_from_cc/test/templates/extern_definition/BUILD index 30f0394..04132ab 100644 --- a/rs_bindings_from_cc/test/templates/extern_definition/BUILD +++ b/rs_bindings_from_cc/test/templates/extern_definition/BUILD
@@ -23,4 +23,7 @@ ":actual_instantiation", ":extern_definition", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/extern_definition/test.rs b/rs_bindings_from_cc/test/templates/extern_definition/test.rs index 87a7a26..68ff611 100644 --- a/rs_bindings_from_cc/test/templates/extern_definition/test.rs +++ b/rs_bindings_from_cc/test/templates/extern_definition/test.rs
@@ -5,8 +5,9 @@ #[cfg(test)] mod tests { use actual_instantiation::*; + use googletest::prelude::*; - #[test] + #[gtest] fn test_member_function_of_class_template_defined_in_cc_file() { let s = actual_instantiation_ns::MyTypeAlias::Create(123); assert_eq!(123, *s.value());
diff --git a/rs_bindings_from_cc/test/templates/failed_template_instantiation/BUILD b/rs_bindings_from_cc/test/templates/failed_template_instantiation/BUILD index 6922144..538c350 100644 --- a/rs_bindings_from_cc/test/templates/failed_template_instantiation/BUILD +++ b/rs_bindings_from_cc/test/templates/failed_template_instantiation/BUILD
@@ -14,4 +14,7 @@ cc_deps = [ ":failed_template_instantiation", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/failed_template_instantiation/test.rs b/rs_bindings_from_cc/test/templates/failed_template_instantiation/test.rs index 7f5fa6d..1e814fd 100644 --- a/rs_bindings_from_cc/test/templates/failed_template_instantiation/test.rs +++ b/rs_bindings_from_cc/test/templates/failed_template_instantiation/test.rs
@@ -3,8 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception use failed_template_instantiation::*; +use googletest::prelude::*; -#[test] +#[gtest] fn test_build() { let ok = Ok::default(); Func1(ok);
diff --git a/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/BUILD b/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/BUILD index 2cadd8d..6e18f8b 100644 --- a/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/BUILD +++ b/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/BUILD
@@ -14,6 +14,9 @@ cc_deps = [ ":failed_template_instantiation_member_function", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_test_cc_library( @@ -39,4 +42,7 @@ "nobuilder", "notap", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/test.rs b/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/test.rs index a9cab06..795608d 100644 --- a/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/test.rs +++ b/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/test.rs
@@ -3,17 +3,18 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception use failed_template_instantiation_member_function::*; +use googletest::prelude::*; /// Test to ensure that Crubit can import class template specialization with /// un-instantiable member function. -#[test] +#[gtest] fn test_failed_template_instantiation_member_function() { InvokeNoOp(AForNoMethod::default()); InvokeMethodReturnAuto(AForHasMethodReturningVoid::default()); assert_eq!(1, InvokeMethodReturnAutoAndInt(AForHasMethodReturningInt::default())); } -#[test] +#[gtest] fn test_failed_template_instantiation_member_function_preserves_instantiable() { AForNoMethod::default().NoOp();
diff --git a/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/test_recursive.rs b/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/test_recursive.rs index a1e511c..50990a0 100644 --- a/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/test_recursive.rs +++ b/rs_bindings_from_cc/test/templates/failed_template_instantiation_member_function/test_recursive.rs
@@ -2,10 +2,12 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +use googletest::prelude::*; + /// Test to ensure that Crubit can import class template specialization with /// un-instantiable member function that passes the type check but has an /// incorrect function body. -#[test] +#[gtest] fn test_build() { // TODO:(b/248542210): Assert `AForInt` is generated and does not have // method `Call_FailMethod`, `FailMethod`, `FailStaticMethod`.
diff --git a/rs_bindings_from_cc/test/templates/forward_declared_class_template/BUILD b/rs_bindings_from_cc/test/templates/forward_declared_class_template/BUILD index 45a92ce..99204bd 100644 --- a/rs_bindings_from_cc/test/templates/forward_declared_class_template/BUILD +++ b/rs_bindings_from_cc/test/templates/forward_declared_class_template/BUILD
@@ -14,6 +14,9 @@ cc_deps = [ ":use_forward_declared_template", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_test_cc_library( @@ -34,6 +37,9 @@ ":definition_forward_declared_template_with_crubit_disabled", ":use_forward_declared_template", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_test_cc_library( @@ -57,4 +63,7 @@ "nobuilder", "notap", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_definition.rs b/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_definition.rs index cb8210f..ab3cc39 100644 --- a/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_definition.rs +++ b/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_definition.rs
@@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +#[gtest] fn test_build() { // Currently, the generated bindings of // `definition_forward_declared_template` doesn't compile: "cannot find
diff --git a/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_definition_with_crubit_disabled.rs b/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_definition_with_crubit_disabled.rs index cb42af1..ba6f832 100644 --- a/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_definition_with_crubit_disabled.rs +++ b/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_definition_with_crubit_disabled.rs
@@ -2,7 +2,9 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_build() { // Crubit is disabled, so there isn't any API to test. }
diff --git a/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_forward_declaration.rs b/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_forward_declaration.rs index 107e420..bd667fb 100644 --- a/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_forward_declaration.rs +++ b/rs_bindings_from_cc/test/templates/forward_declared_class_template/test_forward_declaration.rs
@@ -2,5 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_build() {}
diff --git a/rs_bindings_from_cc/test/templates/func_return_and_param_types/BUILD b/rs_bindings_from_cc/test/templates/func_return_and_param_types/BUILD index 61fda3f..c4439c0 100644 --- a/rs_bindings_from_cc/test/templates/func_return_and_param_types/BUILD +++ b/rs_bindings_from_cc/test/templates/func_return_and_param_types/BUILD
@@ -15,4 +15,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":func_return_and_param_types"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/func_return_and_param_types/test.rs b/rs_bindings_from_cc/test/templates/func_return_and_param_types/test.rs index 8e5e3eb..e1059dc 100644 --- a/rs_bindings_from_cc/test/templates/func_return_and_param_types/test.rs +++ b/rs_bindings_from_cc/test/templates/func_return_and_param_types/test.rs
@@ -5,10 +5,11 @@ #[cfg(test)] mod tests { use func_return_and_param_types::*; + use googletest::prelude::*; // This tests whether Crubit supports template specialization/instantiation in a // function return type, or in a function parameter type - see b/228868369. - #[test] + #[gtest] fn test_template_instantiation_in_return_value_and_parameter_type() { // Note that the Rust code below never needs to refer to the // mangled name of the Rust struct that the class template
diff --git a/rs_bindings_from_cc/test/templates/method_params/BUILD b/rs_bindings_from_cc/test/templates/method_params/BUILD index cfb300a..32ae4b6 100644 --- a/rs_bindings_from_cc/test/templates/method_params/BUILD +++ b/rs_bindings_from_cc/test/templates/method_params/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":method_params"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/method_params/test.rs b/rs_bindings_from_cc/test/templates/method_params/test.rs index 2410c43..3f48ade 100644 --- a/rs_bindings_from_cc/test/templates/method_params/test.rs +++ b/rs_bindings_from_cc/test/templates/method_params/test.rs
@@ -4,7 +4,9 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_const_ref_to_self() { // Among other things, this test provides coverage against infinite // recursion around Importer::ConvertTemplateSpecializationType which @@ -15,7 +17,7 @@ assert_eq!(1 + 2, s1.AddOneOtherItem(&s2)); } - #[test] + #[gtest] fn test_repeating_parameter_type() { // Among other things, this test provides coverage for the (not // currently implemented, but still considered for the future) mangling
diff --git a/rs_bindings_from_cc/test/templates/no_instantiation_in_template_target/BUILD b/rs_bindings_from_cc/test/templates/no_instantiation_in_template_target/BUILD index 5d114c0..52e50eb 100644 --- a/rs_bindings_from_cc/test/templates/no_instantiation_in_template_target/BUILD +++ b/rs_bindings_from_cc/test/templates/no_instantiation_in_template_target/BUILD
@@ -24,4 +24,7 @@ cc_deps = [ ":type_alias_in_different_target", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/no_instantiation_in_template_target/test.rs b/rs_bindings_from_cc/test/templates/no_instantiation_in_template_target/test.rs index f66a5ad..97f16b8 100644 --- a/rs_bindings_from_cc/test/templates/no_instantiation_in_template_target/test.rs +++ b/rs_bindings_from_cc/test/templates/no_instantiation_in_template_target/test.rs
@@ -4,7 +4,9 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_alias_to_template_without_instantiation_in_different_target() { let s = type_alias_in_different_target::TypeAliasInDifferentTarget::Create(321); assert_eq!(321, *s.value());
diff --git a/rs_bindings_from_cc/test/templates/non_type_template_params/BUILD b/rs_bindings_from_cc/test/templates/non_type_template_params/BUILD index 53a6d16..a73ca4b 100644 --- a/rs_bindings_from_cc/test/templates/non_type_template_params/BUILD +++ b/rs_bindings_from_cc/test/templates/non_type_template_params/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":non_type_template_params"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/non_type_template_params/test.rs b/rs_bindings_from_cc/test/templates/non_type_template_params/test.rs index 5dc1318..67283d1 100644 --- a/rs_bindings_from_cc/test/templates/non_type_template_params/test.rs +++ b/rs_bindings_from_cc/test/templates/non_type_template_params/test.rs
@@ -4,15 +4,16 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; use non_type_template_params::*; - #[test] + #[gtest] fn test_non_type_template_params() { assert_eq!(123 * 100, MyMultiplierX100::Multiply(123)); assert_eq!(123 * 1000, MyMultiplierX1000::Multiply(123)); } - #[test] + #[gtest] fn test_big_const() { assert_eq!(18446744073709551615, BigNumericConst::GetValue()); }
diff --git a/rs_bindings_from_cc/test/templates/out_of_line_definition/BUILD b/rs_bindings_from_cc/test/templates/out_of_line_definition/BUILD index e7284d3..b2d816c 100644 --- a/rs_bindings_from_cc/test/templates/out_of_line_definition/BUILD +++ b/rs_bindings_from_cc/test/templates/out_of_line_definition/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":out_of_line_definition"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/out_of_line_definition/test.rs b/rs_bindings_from_cc/test/templates/out_of_line_definition/test.rs index 94589b9..2e0507e 100644 --- a/rs_bindings_from_cc/test/templates/out_of_line_definition/test.rs +++ b/rs_bindings_from_cc/test/templates/out_of_line_definition/test.rs
@@ -4,7 +4,9 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_member_function_of_class_template_defined_out_of_line_in_h_file() { let s = out_of_line_definition::MyTypeAlias::Create(123); assert_eq!(123, *s.value());
diff --git a/rs_bindings_from_cc/test/templates/struct_fields/BUILD b/rs_bindings_from_cc/test/templates/struct_fields/BUILD index 0f2b7d0..816edcc 100644 --- a/rs_bindings_from_cc/test/templates/struct_fields/BUILD +++ b/rs_bindings_from_cc/test/templates/struct_fields/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":struct_fields"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/struct_fields/test.rs b/rs_bindings_from_cc/test/templates/struct_fields/test.rs index d4cc0e2..10e9fd9 100644 --- a/rs_bindings_from_cc/test/templates/struct_fields/test.rs +++ b/rs_bindings_from_cc/test/templates/struct_fields/test.rs
@@ -4,11 +4,12 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; use struct_fields::*; // This tests whether Crubit supports template specialization/instantiation in a // struct field - see b/228868369. - #[test] + #[gtest] fn test_template_instantiation_in_return_value_and_parameter_type() { // Note that the Rust code below never needs to refer to the // mangled name of the Rust struct that the class template
diff --git a/rs_bindings_from_cc/test/templates/template_template_params/BUILD b/rs_bindings_from_cc/test/templates/template_template_params/BUILD index 88eb7f0..0834b76 100644 --- a/rs_bindings_from_cc/test/templates/template_template_params/BUILD +++ b/rs_bindings_from_cc/test/templates/template_template_params/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":template_template_params"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/template_template_params/test.rs b/rs_bindings_from_cc/test/templates/template_template_params/test.rs index 06b543b..7816b9e 100644 --- a/rs_bindings_from_cc/test/templates/template_template_params/test.rs +++ b/rs_bindings_from_cc/test/templates/template_template_params/test.rs
@@ -4,7 +4,9 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_template_template_params() { assert_eq!(42, template_template_params::MyTypeAlias::GetPolicy()); }
diff --git a/rs_bindings_from_cc/test/templates/transitive_template_deps/BUILD b/rs_bindings_from_cc/test/templates/transitive_template_deps/BUILD index 4c2c2a7..70523d3 100644 --- a/rs_bindings_from_cc/test/templates/transitive_template_deps/BUILD +++ b/rs_bindings_from_cc/test/templates/transitive_template_deps/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":use_template"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/transitive_template_deps/test.rs b/rs_bindings_from_cc/test/templates/transitive_template_deps/test.rs index 107e420..bd667fb 100644 --- a/rs_bindings_from_cc/test/templates/transitive_template_deps/test.rs +++ b/rs_bindings_from_cc/test/templates/transitive_template_deps/test.rs
@@ -2,5 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] +use googletest::prelude::*; + +#[gtest] fn test_build() {}
diff --git a/rs_bindings_from_cc/test/templates/two_template_parameters/BUILD b/rs_bindings_from_cc/test/templates/two_template_parameters/BUILD index 53c8c64..70eaf13 100644 --- a/rs_bindings_from_cc/test/templates/two_template_parameters/BUILD +++ b/rs_bindings_from_cc/test/templates/two_template_parameters/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":two_template_parameters"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/templates/two_template_parameters/test.rs b/rs_bindings_from_cc/test/templates/two_template_parameters/test.rs index cddd66d..4fa6202 100644 --- a/rs_bindings_from_cc/test/templates/two_template_parameters/test.rs +++ b/rs_bindings_from_cc/test/templates/two_template_parameters/test.rs
@@ -4,7 +4,9 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_two_template_parameters() { let s = two_template_parameters::AliasToTemplateWithTwoParams { value1: 123, value2: 456.789 };
diff --git a/rs_bindings_from_cc/test/templates/type_alias/BUILD b/rs_bindings_from_cc/test/templates/type_alias/BUILD index 674dbca..87f9765 100644 --- a/rs_bindings_from_cc/test/templates/type_alias/BUILD +++ b/rs_bindings_from_cc/test/templates/type_alias/BUILD
@@ -25,5 +25,6 @@ ], deps = [ "//support:forward_declare", + "//third_party/gtest_rust/googletest", ], )
diff --git a/rs_bindings_from_cc/test/templates/type_alias/test.rs b/rs_bindings_from_cc/test/templates/type_alias/test.rs index 602a7fd..0ab8c83 100644 --- a/rs_bindings_from_cc/test/templates/type_alias/test.rs +++ b/rs_bindings_from_cc/test/templates/type_alias/test.rs
@@ -5,21 +5,22 @@ #[cfg(test)] mod tests { use forward_declare::CcCast; + use googletest::prelude::*; - #[test] + #[gtest] fn test_alias_to_template_instantiation() { let s = type_alias::MyTypeAlias::Create(123); assert_eq!(123, *s.value()); } - #[test] + #[gtest] fn test_aliases_in_same_target_are_compatible() { let s: type_alias::MyTypeAlias = type_alias::MyTypeAlias::Create(456); let s2: type_alias::OtherTypeAliasInSameTarget = s; assert_eq!(456, *s2.value()); } - #[test] + #[gtest] fn test_alias_in_different_target_than_template() { let s = type_alias_in_different_target::TypeAliasInDifferentTarget::Create(789); assert_eq!(789, *s.value());
diff --git a/rs_bindings_from_cc/test/templates/type_alias_access_rule/test.rs b/rs_bindings_from_cc/test/templates/type_alias_access_rule/test.rs index d5661c1..008bb70 100644 --- a/rs_bindings_from_cc/test/templates/type_alias_access_rule/test.rs +++ b/rs_bindings_from_cc/test/templates/type_alias_access_rule/test.rs
@@ -5,6 +5,6 @@ #[cfg(test)] mod tests { - #[test] + #[gtest] fn test_compile() {} }
diff --git a/rs_bindings_from_cc/test/textual_headers/BUILD b/rs_bindings_from_cc/test/textual_headers/BUILD index 4259cfa..cf06ad0 100644 --- a/rs_bindings_from_cc/test/textual_headers/BUILD +++ b/rs_bindings_from_cc/test/textual_headers/BUILD
@@ -47,10 +47,16 @@ name = "struct_from_textual_hdr_test", srcs = ["uses_struct_from_textual_header.rs"], cc_deps = [":uses_struct_from_textual_hdr"], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_rust_test( name = "struct_travels_through_textual_hdrs_test", srcs = ["uses_struct_from_layers_of_textual_headers.rs"], cc_deps = [":uses_struct_from_textual_hdr_in_textual_hdr"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/textual_headers/uses_struct_from_layers_of_textual_headers.rs b/rs_bindings_from_cc/test/textual_headers/uses_struct_from_layers_of_textual_headers.rs index 64f2384..ecc736a 100644 --- a/rs_bindings_from_cc/test/textual_headers/uses_struct_from_layers_of_textual_headers.rs +++ b/rs_bindings_from_cc/test/textual_headers/uses_struct_from_layers_of_textual_headers.rs
@@ -4,8 +4,9 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; - #[test] + #[gtest] fn test_access_to_struct_through_the_right_crate() { // MyStruct was defined in a textual header of :defines_struct_in_textual_hdr, // but we should consider that header to belong to whichever target
diff --git a/rs_bindings_from_cc/test/textual_headers/uses_struct_from_textual_header.rs b/rs_bindings_from_cc/test/textual_headers/uses_struct_from_textual_header.rs index 9e16849..de0b828 100644 --- a/rs_bindings_from_cc/test/textual_headers/uses_struct_from_textual_header.rs +++ b/rs_bindings_from_cc/test/textual_headers/uses_struct_from_textual_header.rs
@@ -4,8 +4,9 @@ #[cfg(test)] mod tests { + use googletest::prelude::*; - #[test] + #[gtest] fn test_access_to_struct_from_textual_header() { // MyStruct was defined in a textual header of :defines_struct_in_textual_hdr, // but we should consider that header to belong to whichever target
diff --git a/rs_bindings_from_cc/test/type_alias/BUILD b/rs_bindings_from_cc/test/type_alias/BUILD index b57b63a..ae42d97 100644 --- a/rs_bindings_from_cc/test/type_alias/BUILD +++ b/rs_bindings_from_cc/test/type_alias/BUILD
@@ -17,4 +17,7 @@ proc_macro_deps = [ "//common:item_exists", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/type_alias/test.rs b/rs_bindings_from_cc/test/type_alias/test.rs index d580737..b3e7362 100644 --- a/rs_bindings_from_cc/test/type_alias/test.rs +++ b/rs_bindings_from_cc/test/type_alias/test.rs
@@ -1,7 +1,10 @@ // Part of the Crubit project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#[test] + +use googletest::prelude::*; + +#[gtest] fn test_return_value() { use type_alias::return_underlying; use type_alias::Int; @@ -10,7 +13,7 @@ } /// Vector aliases are not supported (yet???). -#[test] +#[gtest] fn test_vector_alias() { assert!(!item_exists::type_exists!(type_alias::MyVector)); assert!(!item_exists::value_exists!(type_alias::VectorFunction));
diff --git a/rs_bindings_from_cc/test/types/BUILD b/rs_bindings_from_cc/test/types/BUILD index f23ae22..22bbed3 100644 --- a/rs_bindings_from_cc/test/types/BUILD +++ b/rs_bindings_from_cc/test/types/BUILD
@@ -36,4 +36,7 @@ ":types_nonptr", ], proc_macro_deps = ["//common:item_exists"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/types/thread_safety/BUILD b/rs_bindings_from_cc/test/types/thread_safety/BUILD index 88056e7..f1c0a74 100644 --- a/rs_bindings_from_cc/test/types/thread_safety/BUILD +++ b/rs_bindings_from_cc/test/types/thread_safety/BUILD
@@ -20,5 +20,8 @@ ":thread_safe_types", ":thread_unsafe_types", ], - deps = ["@crate_index//:static_assertions"], + deps = [ + "//third_party/gtest_rust/googletest", + "@crate_index//:static_assertions", + ], )
diff --git a/rs_bindings_from_cc/test/types/thread_safety/test.rs b/rs_bindings_from_cc/test/types/thread_safety/test.rs index 406baab..fac3e04 100644 --- a/rs_bindings_from_cc/test/types/thread_safety/test.rs +++ b/rs_bindings_from_cc/test/types/thread_safety/test.rs
@@ -2,19 +2,20 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +use googletest::prelude::*; use static_assertions::{assert_impl_all, assert_not_impl_any}; -#[test] +#[gtest] fn test_unsafe_struct() { assert_not_impl_any!(thread_unsafe_types::Struct: Send, Sync); } -#[test] +#[gtest] fn test_unsafe_union() { assert_not_impl_any!(thread_unsafe_types::Union: Send, Sync); } -#[test] +#[gtest] fn test_enum() { assert_impl_all!(thread_safe_types::Enum: Send, Sync); }
diff --git a/rs_bindings_from_cc/test/types/types_test.rs b/rs_bindings_from_cc/test/types/types_test.rs index 5fe335f..84cd148 100644 --- a/rs_bindings_from_cc/test/types/types_test.rs +++ b/rs_bindings_from_cc/test/types/types_test.rs
@@ -5,6 +5,7 @@ #![allow(unreachable_code)] // compilation-only test. use core::ffi::c_void; +use googletest::prelude::*; macro_rules! struct_field_type_is { ($mod:ident, $($cc_name:ident => $rs_type:ty),* $(,)?) => { @@ -240,7 +241,7 @@ ConstStructRef => &types_inferred_lifetimes::ExampleStruct, ); -#[test] +#[gtest] fn test_typemap_suppresses_bindings() { assert!(!item_exists::type_exists!(types_nonptr::MyI8Class)); assert!(!item_exists::type_exists!(types_nonptr::MyI8Struct));
diff --git a/rs_bindings_from_cc/test/void_pointers/BUILD b/rs_bindings_from_cc/test/void_pointers/BUILD index 7922d85..cbed041 100644 --- a/rs_bindings_from_cc/test/void_pointers/BUILD +++ b/rs_bindings_from_cc/test/void_pointers/BUILD
@@ -14,4 +14,7 @@ name = "main", srcs = ["test.rs"], cc_deps = [":void_pointers"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/rs_bindings_from_cc/test/void_pointers/test.rs b/rs_bindings_from_cc/test/void_pointers/test.rs index 70fc918..a6e177d 100644 --- a/rs_bindings_from_cc/test/void_pointers/test.rs +++ b/rs_bindings_from_cc/test/void_pointers/test.rs
@@ -4,7 +4,9 @@ #[cfg(test)] mod tests { - #[test] + use googletest::prelude::*; + + #[gtest] fn test_invoke_memcpy() { use void_pointers::invoke_memcpy;
diff --git a/support/BUILD b/support/BUILD index d10a39d..a3b3903 100644 --- a/support/BUILD +++ b/support/BUILD
@@ -28,6 +28,7 @@ crate = ":ctor_proc_macros_proc_macro_internal", deps = [ "//common:token_stream_matchers", + "//third_party/gtest_rust/googletest", ], ) @@ -36,6 +37,9 @@ srcs = ["ctor.rs"], proc_macro_deps = [":ctor_proc_macros"], rustc_flags = ["-Zallow-features=negative_impls"], + deps = [ + "//third_party/gtest_rust/googletest", + ], ) crubit_rust_test( @@ -44,6 +48,7 @@ rustc_flags = ["-Zallow-features=negative_impls"], deps = [ ":ctor", + "//third_party/gtest_rust/googletest", ], ) @@ -52,6 +57,7 @@ srcs = ["ctor_macro_test.rs"], deps = [ ":ctor", + "//third_party/gtest_rust/googletest", ], ) @@ -76,7 +82,10 @@ crubit_rust_test( name = "forward_declare_macros_test", srcs = ["forward_declare_macros_test.rs"], - deps = [":forward_declare"], + deps = [ + ":forward_declare", + "//third_party/gtest_rust/googletest", + ], ) rust_library( @@ -92,4 +101,7 @@ name = "oops_test", srcs = ["oops.rs"], rustc_flags = ["-Zallow-features=negative_impls"], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/support/cc_import/BUILD b/support/cc_import/BUILD index 4f15d0d..e078b0d 100644 --- a/support/cc_import/BUILD +++ b/support/cc_import/BUILD
@@ -53,5 +53,8 @@ crubit_rust_test( name = "merged_namespaces_test", crate = "merged_namespaces", - deps = ["//common:token_stream_matchers"], + deps = [ + "//common:token_stream_matchers", + "//third_party/gtest_rust/googletest", + ], )
diff --git a/support/cc_import/merged_namespaces.rs b/support/cc_import/merged_namespaces.rs index a80adac..97cc2bb 100644 --- a/support/cc_import/merged_namespaces.rs +++ b/support/cc_import/merged_namespaces.rs
@@ -166,9 +166,10 @@ #[cfg(test)] mod tests { use super::*; + use googletest::prelude::*; use std::ops::Deref; - #[test] + #[gtest] fn from_json() { let json = r#"{ "label": "//foo/bar:baz", @@ -186,7 +187,7 @@ assert_eq!(&*ns.namespaces[0].name, "top_level"); } - #[test] + #[gtest] fn test_merge_namespace_hierarchies() { let hierarchy_one: JsonNamespaceHierarchy = serde_json::from_str( r#"{ @@ -244,7 +245,7 @@ assert_eq!(labels.iter().map(Deref::deref).collect::<Vec<_>>(), ["//foo/bar:xyz"]); } - #[test] + #[gtest] #[should_panic(expected = "Cannot merge namespaces with different names, got 'a' and 'b'")] fn test_merge_different_namespaces() { let mut namespace_one = MergedNamespace::from_json_namespace( @@ -272,7 +273,7 @@ namespace_one.merge(namespace_two); } - #[test] + #[gtest] fn test_merge_namespaces() { let json_namespace_one: JsonNamespace = serde_json::from_str( r#"{ @@ -346,7 +347,7 @@ assert_eq!(d_labels.iter().map(Deref::deref).collect::<Vec<_>>(), ["//:label2"]); } - #[test] + #[gtest] fn test_to_tokens() { let hierarchy_one: JsonNamespaceHierarchy = serde_json::from_str( r#"{
diff --git a/support/cc_std/test/string_view/BUILD b/support/cc_std/test/string_view/BUILD index 60aac47..9bd6ba3 100644 --- a/support/cc_std/test/string_view/BUILD +++ b/support/cc_std/test/string_view/BUILD
@@ -19,4 +19,7 @@ ":string_view_apis", "//support/cc_std", ], + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/support/cc_template/BUILD b/support/cc_template/BUILD index 5be6337..d8bbe26 100644 --- a/support/cc_template/BUILD +++ b/support/cc_template/BUILD
@@ -40,6 +40,7 @@ ], crate = ":cc_template_impl", deps = [ + "//third_party/gtest_rust/googletest", "@crate_index//:maplit", ], )
diff --git a/support/cc_template/cc_template_impl.rs b/support/cc_template/cc_template_impl.rs index 80cf897..1efe392 100644 --- a/support/cc_template/cc_template_impl.rs +++ b/support/cc_template/cc_template_impl.rs
@@ -72,6 +72,7 @@ #[cfg(test)] mod tests { use super::*; + use googletest::prelude::*; use maplit::hashmap; use std::path::Path; @@ -79,7 +80,7 @@ read_instantiations_map().expect_err(no_error_happened_msg).to_string() } - #[test] + #[gtest] fn test_env_var_not_set() { let err_message = get_error_from_read_instantiations_map("The env var was unexpectedly set."); @@ -90,7 +91,7 @@ ); } - #[test] + #[gtest] fn test_instantiations_file_not_found() { env::set_var("CRUBIT_INSTANTIATIONS_FILE", "path/does/not/exist"); @@ -103,7 +104,7 @@ ); } - #[test] + #[gtest] fn test_instantiations_file_deserialization_error() { let path = Path::join(Path::new(&env::var("TEST_TMPDIR").unwrap()), "my_file.not_json"); std::fs::write(&path, "definitely not json").unwrap(); @@ -122,7 +123,7 @@ ); } - #[test] + #[gtest] fn test_instantiations_deserialization_success() { let path = Path::join(Path::new(&env::var("TEST_TMPDIR").unwrap()), "instantiations.json"); let key = "std::string<bool>"; @@ -136,7 +137,7 @@ assert_eq!(deserialized_map, hashmap! { key.to_string() => value.to_string() }); } - #[test] + #[gtest] fn test_successful_expansion() { let expanded = get_instantiation_struct_name( quote! { std::vector<bool> }, @@ -151,7 +152,7 @@ ); } - #[test] + #[gtest] fn test_parsing_valid_cc_instantiations() { validate_user_input("e! {vector<bool>}).unwrap(); validate_user_input("e! {std::vector<bool>}).unwrap();
diff --git a/support/cc_template/test/BUILD b/support/cc_template/test/BUILD index be4aa1e..82bd941 100644 --- a/support/cc_template/test/BUILD +++ b/support/cc_template/test/BUILD
@@ -13,4 +13,7 @@ rustc_env = { "CRUBIT_INSTANTIATIONS_FILE": "$(location __cc_template_instantiations.json)", }, + deps = [ + "//third_party/gtest_rust/googletest", + ], )
diff --git a/support/cc_template/test/cc_template_integration_test.rs b/support/cc_template/test/cc_template_integration_test.rs index 6e0a450..c67b3a6 100644 --- a/support/cc_template/test/cc_template_integration_test.rs +++ b/support/cc_template/test/cc_template_integration_test.rs
@@ -5,6 +5,7 @@ #![cfg(test)] use cc_template::cc_template; +use googletest::prelude::*; /// Test the `cc_template!` macro with: /// * the JSON file `__cc_template_instantiations.json` (the environment @@ -15,7 +16,7 @@ #[allow(non_camel_case_types)] mod __cc_template_instantiations_rs_api; -#[test] +#[gtest] fn test_in_mocked_context() { let x = <cc_template!(my_namespace::MyTemplate<MyArg>)>::new(42); assert!(x.value == 42);
diff --git a/support/ctor.rs b/support/ctor.rs index 41a6214..8c98dbc 100644 --- a/support/ctor.rs +++ b/support/ctor.rs
@@ -1241,17 +1241,18 @@ #[cfg(test)] mod test { use super::*; + use googletest::prelude::*; use std::cell::RefCell; use std::pin::Pin; use std::sync::Mutex; - #[test] + #[gtest] fn test_default_rust_type() { emplace! {let x = u32::ctor_new(());} assert_eq!(*x, 0); } - #[test] + #[gtest] fn test_copy_rust_type() { let x: u32 = 42; let mut y = Box::emplace(copy(&x)); @@ -1271,7 +1272,7 @@ assert_eq!(*y, 100); } - #[test] + #[gtest] fn test_copy_smart_ptr() { let x = Box::new(42_u32); emplace! { @@ -1282,7 +1283,7 @@ } /// Tests that the assigned variables have the correct type. - #[test] + #[gtest] fn test_emplace_type() { let x: u32 = 42; emplace! { @@ -1291,7 +1292,7 @@ let _foo: Pin<&mut u32> = foo; // type checks OK } - #[test] + #[gtest] fn test_emplace() { let x: u32 = 42; emplace! { @@ -1300,7 +1301,7 @@ assert_eq!(*foo, 42); } - #[test] + #[gtest] fn test_emplace_mut() { let x: u32 = 42; emplace! { @@ -1311,7 +1312,7 @@ assert_eq!(*foo, 0); } - #[test] + #[gtest] fn test_emplace_multi() { let x: u32 = 42; emplace! { @@ -1322,7 +1323,7 @@ assert_eq!(*bar, 42); } - #[test] + #[gtest] fn test_emplace_type_syntax() { let x: u32 = 42; emplace! { @@ -1335,7 +1336,7 @@ assert_eq!(*bar, 42); } - #[test] + #[gtest] fn test_ctor_macro() { struct MyStruct { x: u32, @@ -1359,7 +1360,7 @@ }); } - #[test] + #[gtest] fn test_ctor_macro_unit_struct() { struct MyStruct; unsafe impl RecursivelyPinned for MyStruct { @@ -1369,7 +1370,7 @@ emplace! { let _my_struct = ctor!(MyStruct {});} } - #[test] + #[gtest] fn test_ctor_macro_named_tuple_struct() { struct MyStruct(u32, u32); unsafe impl RecursivelyPinned for MyStruct { @@ -1383,7 +1384,7 @@ assert_eq!(my_struct.1, 2); } - #[test] + #[gtest] fn test_ctor_macro_tuple_struct() { struct MyStruct(u32, u32); unsafe impl RecursivelyPinned for MyStruct { @@ -1394,7 +1395,7 @@ assert_eq!(my_struct.1, 2); } - #[test] + #[gtest] fn test_ctor_macro_manuallydrop_struct() { struct MyStruct { x: ManuallyDrop<Vec<u32>>, @@ -1408,7 +1409,7 @@ assert_eq!(my_struct.y, 0); } - #[test] + #[gtest] fn test_ctor_macro_union() { union MyUnion { x: ManuallyDrop<Vec<u32>>, @@ -1429,7 +1430,7 @@ assert_eq!(unsafe { my_union.y }, 24); } - #[test] + #[gtest] fn test_ctor_macro_nested_struct() { mod nested { pub struct MyStruct { @@ -1448,7 +1449,7 @@ assert_eq!(my_struct.y, 2); } - #[test] + #[gtest] fn test_ctor_macro_nested_tuple_struct() { mod nested { pub struct MyStruct(pub u32, pub u32); @@ -1463,7 +1464,7 @@ /// Test that the ctor macro safety check doesn't rely on the struct not /// implementing Drop. - #[test] + #[gtest] fn test_ctor_macro_drop_struct() { struct MyStruct { x: String, @@ -1514,7 +1515,7 @@ impl !Unpin for PanicCtor<'_> {} /// Tests that drop() is called when the Ctor doesn't panic. - #[test] + #[gtest] fn test_emplace_drop() { let is_dropped = Mutex::new(false); { @@ -1525,7 +1526,7 @@ /// Tests that when a panic occurs during emplace!{}, the uninitialized /// value is not dropped. - #[test] + #[gtest] fn test_emplace_no_drop_on_panic() { let is_dropped = Mutex::new(false); let panic_result = std::panic::catch_unwind(|| { @@ -1538,7 +1539,7 @@ /// Tests that when a panic occurs during initialization of a struct with /// ctor!, the initialized fields are dropped, and the uninitialized /// fields are not. - #[test] + #[gtest] fn test_ctor_macro_drop() { struct MyStruct<'a> { x: DropNotify<'a>, @@ -1561,7 +1562,7 @@ assert!(!*y_dropped.lock().unwrap()); } - #[test] + #[gtest] fn test_ctor_initialized_fields_struct() { pub struct CtorOnly { pub field: i32, @@ -1584,7 +1585,7 @@ assert_eq!(x.field, 3); } - #[test] + #[gtest] fn ctor_initialized_fields_tuple_struct() { pub struct CtorOnly(pub i32, [(); 0]); pub struct CtorOnlyPubFields(i32); @@ -1642,7 +1643,7 @@ /// Tests the ctor/drop order for copy-constructible Unpin types: ctor comes /// before drop. - #[test] + #[gtest] fn test_copy_ctor_drop_order() { let log = RefCell::new(vec![]); let log = &log; @@ -1657,7 +1658,7 @@ /// Tests the ctor/drop order for move-constructible Unpin types: ctor comes /// before drop. - #[test] + #[gtest] fn test_move_ctor_drop_order() { let log = RefCell::new(vec![]); let log = &log; @@ -1674,7 +1675,7 @@ /// Non-obvious fact: you can mov() an owned reference type! Moving anything /// also performs a rust move, but the resulting rvalue reference is /// still valid for a temporary's lifetime. - #[test] + #[gtest] fn test_mov_box() { struct S; let x: Pin<Box<S>> = Box::pin(S); @@ -1682,19 +1683,19 @@ // let _x = x; // fails to compile: x is moved! } - #[test] + #[gtest] fn test_mov_mut_ref_to_unpin() { takes_rvalue_reference(mov!(&mut 1)); } - #[test] + #[gtest] fn test_mov_pinned_mut_ref() { let x = &mut 2; let pinned_mut_ref = Pin::new(x); takes_rvalue_reference(mov!(pinned_mut_ref)); } - #[test] + #[gtest] fn test_ctor_then() { emplace! { let x = 40.ctor_then(|mut y| { *y += 2 }); @@ -1703,13 +1704,13 @@ } /// Test that a slot can be created in a temporary. - #[test] + #[gtest] fn test_slot_temporary() { assert_eq!(*emplace!(Slot::new(42)).as_opt().unwrap(), 42); } /// Test that a slot can be created in a local. - #[test] + #[gtest] fn test_slot_local() { emplace! {let slot = Slot::new(42); } assert_eq!(*slot.as_opt().unwrap(), 42); @@ -1717,7 +1718,7 @@ /// Shows the use of Slot to implement a "slotted return value", similar to /// moveit. - #[test] + #[gtest] fn test_slotted_return_value() { // TODO(jeanpierreda): delete this, use doctests when doctests work. fn foo(slot: Pin<&mut Slot<u32>>) -> Pin<&mut u32> { @@ -1730,7 +1731,7 @@ } /// Shows the use of Slot to implement output parameters. - #[test] + #[gtest] fn test_slotted_output_parameter() { // TODO(jeanpierreda): delete this, use doctests when doctests work. fn foo(slot: Pin<&mut Slot<u32>>) { @@ -1742,7 +1743,7 @@ assert_eq!(*slot.as_opt().unwrap(), 42); } - #[test] + #[gtest] fn test_ctor_trait_captures() { fn adder<'a, 'b>( x: &'a i32, @@ -1764,7 +1765,7 @@ // deprecated and removed. // // ``` - // #[test] + // #[gtest] // fn test_ctor_native_captures() { // fn adder<'a, 'b>( // x: &'a i32,
diff --git a/support/ctor_proc_macros.rs b/support/ctor_proc_macros.rs index 7aded22..4fd1709 100644 --- a/support/ctor_proc_macros.rs +++ b/support/ctor_proc_macros.rs
@@ -499,6 +499,7 @@ #[cfg(test)] mod test { use super::*; + use googletest::prelude::*; use token_stream_matchers::assert_rs_matches; /// Essentially a change detector, but handy for debugging. @@ -507,7 +508,7 @@ /// asserting on the output is as close as we can get. Once negative /// compilation tests are added, it would be better to test various /// safety features that way. - #[test] + #[gtest] fn test_recursively_pinned_struct() { let definition = recursively_pinned_impl(quote! {}, quote! {#[repr(C)] struct S {x: i32}}).unwrap(); @@ -550,7 +551,7 @@ } /// The enum version of `test_recursively_pinned_struct`. - #[test] + #[gtest] fn test_recursively_pinned_enum() { let definition = recursively_pinned_impl( quote! {},
diff --git a/support/oops.rs b/support/oops.rs index 3e1c884..ae90e58 100644 --- a/support/oops.rs +++ b/support/oops.rs
@@ -205,12 +205,13 @@ #[cfg(test)] mod test { use super::*; + use googletest::prelude::*; fn ptr_location<T: std::ops::Deref>(x: T) -> usize { &*x as *const _ as *const u8 as usize } - #[test] + #[gtest] fn test_unpin_upcast() { #[derive(Default)] struct Base(i32); @@ -245,7 +246,7 @@ assert_eq!(derived.base.0, 42); } - #[test] + #[gtest] fn test_nonunpin_upcast() { #[derive(Default)] struct Base(i32);