rewrite 6 snapshot tests as integration test

This commit is contained in:
Lawrence Chou 2018-10-15 23:22:23 +08:00 committed by David Peter
parent afc5aacb28
commit 58198d0700
8 changed files with 124 additions and 253 deletions

10
tests/examples/tabs.txt Normal file
View File

@ -0,0 +1,10 @@
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?

View File

@ -1,10 +1,7 @@
extern crate assert_cmd;
mod tester;
use assert_cmd::prelude::*;
use std::process::Command;
use tester::BatTester;
fn bat() -> Command {
let mut cmd = Command::main_binary().unwrap();
@ -15,10 +12,6 @@ fn bat() -> Command {
cmd
}
fn tester() -> BatTester {
BatTester::new()
}
#[test]
fn basic() {
bat()
@ -105,32 +98,140 @@ fn line_range_last_3() {
#[test]
fn tabs_passthrough_wrapped() {
tester().test_snapshot("tabs_passthrough_wrapped", "full", 0, true);
bat()
.arg("tabs.txt")
.arg("--tabs=0")
.arg("--wrap=character")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_4_wrapped() {
tester().test_snapshot("tabs_4_wrapped", "full", 4, true);
bat()
.arg("tabs.txt")
.arg("--tabs=4")
.arg("--wrap=character")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_8_wrapped() {
tester().test_snapshot("tabs_8_wrapped", "full", 8, true);
bat()
.arg("tabs.txt")
.arg("--tabs=8")
.arg("--wrap=character")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_passthrough() {
tester().test_snapshot("tabs_passthrough", "full", 0, false);
bat()
.arg("tabs.txt")
.arg("--tabs=0")
.arg("--wrap=never")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_4() {
tester().test_snapshot("tabs_4", "full", 4, false);
bat()
.arg("tabs.txt")
.arg("--tabs=4")
.arg("--wrap=never")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_8() {
tester().test_snapshot("tabs_8", "full", 8, false);
bat()
.arg("tabs.txt")
.arg("--tabs=8")
.arg("--wrap=never")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]

View File

@ -1,40 +0,0 @@
───────┬────────────────────────────────────────────────────────────────────────
│ File: sample.rs
───────┼────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
23 + │
24 │ // Tab alignment:
25 │ /*
26 │ Indent
27 │ 1 2 3 4
28 │ 1 ?
29 │ 22 ?
30 │ 333 ?
31 │ 4444 ?
32 │ 55555 ?
33 │ 666666 ?
34 │ 7777777 ?
35 │ 88888888 ?
36 ~ │ */
───────┴────────────────────────────────────────────────────────────────────────

View File

@ -1,40 +0,0 @@
───────┬────────────────────────────────────────────────────────────────────────
│ File: sample.rs
───────┼────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
23 + │
24 │ // Tab alignment:
25 │ /*
26 │ Indent
27 │ 1 2 3 4
28 │ 1 ?
29 │ 22 ?
30 │ 333 ?
31 │ 4444 ?
32 │ 55555 ?
33 │ 666666 ?
34 │ 7777777 ?
35 │ 88888888 ?
36 ~ │ */
───────┴────────────────────────────────────────────────────────────────────────

View File

@ -1,40 +0,0 @@
───────┬────────────────────────────────────────────────────────────────────────
│ File: sample.rs
───────┼────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
23 + │
24 │ // Tab alignment:
25 │ /*
26 │ Indent
27 │ 1 2 3 4
28 │ 1 ?
29 │ 22 ?
30 │ 333 ?
31 │ 4444 ?
32 │ 55555 ?
33 │ 666666 ?
34 │ 7777777 ?
35 │ 88888888 ?
36 ~ │ */
───────┴────────────────────────────────────────────────────────────────────────

View File

@ -1,40 +0,0 @@
───────┬────────────────────────────────────────────────────────────────────────
│ File: sample.rs
───────┼────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
23 + │
24 │ // Tab alignment:
25 │ /*
26 │ Indent
27 │ 1 2 3 4
28 │ 1 ?
29 │ 22 ?
30 │ 333 ?
31 │ 4444 ?
32 │ 55555 ?
33 │ 666666 ?
34 │ 7777777 ?
35 │ 88888888 ?
36 ~ │ */
───────┴────────────────────────────────────────────────────────────────────────

View File

@ -1,40 +0,0 @@
───────┬────────────────────────────────────────────────────────────────────────
│ File: sample.rs
───────┼────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
23 + │
24 │ // Tab alignment:
25 │ /*
26 │ Indent
27 │ 1 2 3 4
28 │ 1 ?
29 │ 22 ?
30 │ 333 ?
31 │ 4444 ?
32 │ 55555 ?
33 │ 666666 ?
34 │ 7777777 ?
35 │ 88888888 ?
36 ~ │ */
───────┴────────────────────────────────────────────────────────────────────────

View File

@ -1,40 +0,0 @@
───────┬────────────────────────────────────────────────────────────────────────
│ File: sample.rs
───────┼────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
23 + │
24 │ // Tab alignment:
25 │ /*
26 │ Indent
27 │ 1 2 3 4
28 │ 1 ?
29 │ 22 ?
30 │ 333 ?
31 │ 4444 ?
32 │ 55555 ?
33 │ 666666 ?
34 │ 7777777 ?
35 │ 88888888 ?
36 ~ │ */
───────┴────────────────────────────────────────────────────────────────────────