about summary refs log tree commit diff
path: root/rustc_tools_util
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2018-09-07 19:06:02 +0200
committerMatthias Krüger <matthias.krueger@famsik.de>2018-09-07 19:18:45 +0200
commita14155088bc3cb7fa8dee3484e37a3212265ed8c (patch)
treef33a36728bf5f7fec7bc0e2b432a1f7b35c1f9c5 /rustc_tools_util
parent202db3e09c27eb950abc498a2854b7e8ee7536b6 (diff)
downloadrust-a14155088bc3cb7fa8dee3484e37a3212265ed8c.tar.gz
rust-a14155088bc3cb7fa8dee3484e37a3212265ed8c.zip
rustc_tools_util: add test
Diffstat (limited to 'rustc_tools_util')
-rw-r--r--rustc_tools_util/src/lib.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/rustc_tools_util/src/lib.rs b/rustc_tools_util/src/lib.rs
index b2ec9612290..aad9ee88fc7 100644
--- a/rustc_tools_util/src/lib.rs
+++ b/rustc_tools_util/src/lib.rs
@@ -1,3 +1,4 @@
+#![feature(test)]
 #![feature(tool_lints)]
 
 use std::env;
@@ -84,3 +85,28 @@ pub fn get_commit_date() -> Option<String> {
         .ok()
         .and_then(|r| String::from_utf8(r.stdout).ok())
 }
+
+#[cfg(test)]
+mod test {
+    use super::*;
+
+    #[test]
+    fn test_struct_local() {
+        let vi = get_version_info!();
+        assert_eq!(vi.major, 0);
+        assert_eq!(vi.minor, 1);
+        assert_eq!(vi.patch, 0);
+        assert_eq!(vi.crate_name, "rustc_tools_util");
+        // hard to make positive tests for these since they will always change
+        assert!(vi.commit_hash.is_none());
+        assert!(vi.commit_date.is_none());
+    }
+
+    #[test]
+    fn test_display_local() {
+        let vi = get_version_info!();
+        let fmt = format!("{}", vi);
+        assert_eq!(fmt, "rustc_tools_util 0.1.0");
+    }
+
+}