diff options
Diffstat (limited to 'examples/rust/hello_lib')
-rw-r--r-- | examples/rust/hello_lib/BUILD | 26 | ||||
-rw-r--r-- | examples/rust/hello_lib/src/greeter.rs | 11 |
2 files changed, 32 insertions, 5 deletions
diff --git a/examples/rust/hello_lib/BUILD b/examples/rust/hello_lib/BUILD index a075f8b168..90941e6a42 100644 --- a/examples/rust/hello_lib/BUILD +++ b/examples/rust/hello_lib/BUILD @@ -1,6 +1,12 @@ package(default_visibility = ["//visibility:public"]) -load("/tools/build_rules/rust/rust", "rust_library", "rust_docs", "rust_test") +load( + "/tools/build_rules/rust/rust", + "rust_library", + "rust_test", + "rust_doc", + "rust_doc_test", +) rust_library( name = "hello_lib", @@ -10,13 +16,23 @@ rust_library( ], ) -rust_docs( - name = "hello_lib_docs", - dep = ":hello_lib", +rust_test( + name = "hello_lib_test", + deps = [":hello_lib"], ) rust_test( - name = "greeting", + name = "greeting_test", srcs = ["tests/greeting.rs"], deps = [":hello_lib"], ) + +rust_doc( + name = "hello_lib_doc", + dep = ":hello_lib", +) + +rust_doc_test( + name = "hello_lib_doc_test", + dep = ":hello_lib", +) diff --git a/examples/rust/hello_lib/src/greeter.rs b/examples/rust/hello_lib/src/greeter.rs index 2a7d7153b9..bf332e4bd1 100644 --- a/examples/rust/hello_lib/src/greeter.rs +++ b/examples/rust/hello_lib/src/greeter.rs @@ -60,3 +60,14 @@ impl Greeter { println!("{} {}", &self.greeting, thing); } } + +#[cfg(test)] +mod test { + use super::Greeter; + + #[test] + fn test_greeting() { + let hello = Greeter::new("Hi"); + assert_eq!("Hi Rust", hello.greeting("Rust")); + } +} |