aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/rust/hello_lib/src/greeter.rs
diff options
context:
space:
mode:
authorGravatar David Chen <dzc@google.com>2015-10-05 12:21:32 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-10-05 15:16:40 +0000
commitab141f8d1035eb30bbb9dc09d89ea6a3ba83cc0f (patch)
tree587e9401adeb385d3d859a3c4458b7d7945f2674 /examples/rust/hello_lib/src/greeter.rs
parent73ee6215490ed957c13c8dbe03814b039d6ddd5c (diff)
[rust] Add rust_bench_test and rust_doc_test rules and improve usability of rust_test rule.
* Add rust_bench_test rule to run benchmark tests * Add rust_doc_test rule to run Rust documentation tests. * Enable rust_test and rust_bench_test to depend directly on a rust_library target. * Rename rust_docs rule to rust_doc for consistency. RELNOTES: [rust] Add rust_bench_test and rust_doc_test rules and improve usability of rust_test tule. -- MOS_MIGRATED_REVID=104648497
Diffstat (limited to 'examples/rust/hello_lib/src/greeter.rs')
-rw-r--r--examples/rust/hello_lib/src/greeter.rs11
1 files changed, 11 insertions, 0 deletions
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"));
+ }
+}