Joshua Rutschmann 8年前
コミット
bf9ea707f6
1個のファイルの変更28行の追加2行の削除
  1. 28
    2
      hw6/task1/src/unit_test_pipe.rs

+ 28
- 2
hw6/task1/src/unit_test_pipe.rs ファイルの表示

@@ -1,6 +1,6 @@
1 1
 #[cfg(test)]
2 2
 mod test {
3
-    use read_from_pipe;
3
+    use ::{read_from_pipe, mul_strings, sum_strings, split_into_strings, concatenate_strings};
4 4
     use nix::unistd::{pipe, write};
5 5
 
6 6
     #[test]
@@ -20,5 +20,31 @@ mod test {
20 20
     }
21 21
 
22 22
     #[test]
23
-    fn test_kill_last_child() {}
23
+    fn test_mul_strings() {
24
+        let input = vec!["32".to_string(), "12".to_string(), "-2".to_string()];
25
+        assert_eq!(mul_strings(input).unwrap(), -768);
26
+    }
27
+
28
+    #[test]
29
+    fn test_sum_strings() {
30
+        let input = vec!["6542".to_string(), "542".to_string(), "192".to_string()];
31
+        assert_eq!(sum_strings(input).unwrap(), 7276);
32
+    }
33
+
34
+    #[test]
35
+    fn test_split_strings() {
36
+        assert_eq!(split_into_strings("Das ist ein Test"), vec!["Das", "ist", "ein", "Test"]);
37
+    }
38
+
39
+    #[test]
40
+    fn test_split_strings_nums() {
41
+        assert_eq!(split_into_strings("1 -2 -4 -2 51232"), vec!["1", "-2", "-4", "-2", "51232"]);
42
+    }
43
+
44
+    #[test]
45
+    fn test_concat_string() {
46
+        assert_eq!(concatenate_strings("Hello", "World"), "HelloWorld");
47
+    }
48
+
49
+
24 50
 }

読み込み中…
キャンセル
保存