File: test_sum.rs

package info (click to toggle)
rust-coreutils 0.0.30-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,752 kB
  • sloc: sh: 1,088; python: 407; javascript: 72; makefile: 51
file content (81 lines) | stat: -rw-r--r-- 1,805 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use crate::common::util::TestScenario;

#[test]
fn test_invalid_arg() {
    new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
}

#[test]
fn test_bsd_single_file() {
    new_ucmd!()
        .arg("lorem_ipsum.txt")
        .succeeds()
        .stdout_only_fixture("bsd_single_file.expected");
}

#[test]
fn test_bsd_multiple_files() {
    new_ucmd!()
        .arg("lorem_ipsum.txt")
        .arg("alice_in_wonderland.txt")
        .succeeds()
        .stdout_only_fixture("bsd_multiple_files.expected");
}

#[test]
fn test_bsd_stdin() {
    new_ucmd!()
        .pipe_in_fixture("lorem_ipsum.txt")
        .succeeds()
        .stdout_only_fixture("bsd_stdin.expected");
}

#[test]
fn test_sysv_single_file() {
    new_ucmd!()
        .arg("-s")
        .arg("lorem_ipsum.txt")
        .succeeds()
        .stdout_only_fixture("sysv_single_file.expected");
}

#[test]
fn test_sysv_multiple_files() {
    new_ucmd!()
        .arg("-s")
        .arg("lorem_ipsum.txt")
        .arg("alice_in_wonderland.txt")
        .succeeds()
        .stdout_only_fixture("sysv_multiple_files.expected");
}

#[test]
fn test_sysv_stdin() {
    new_ucmd!()
        .arg("-s")
        .pipe_in_fixture("lorem_ipsum.txt")
        .succeeds()
        .stdout_only_fixture("sysv_stdin.expected");
}

#[test]
fn test_invalid_file() {
    let (at, mut ucmd) = at_and_ucmd!();

    at.mkdir("a");

    ucmd.arg("a").fails().stderr_is("sum: a: Is a directory\n");
}

#[test]
fn test_invalid_metadata() {
    let (_, mut ucmd) = at_and_ucmd!();

    ucmd.arg("b")
        .fails()
        .stderr_is("sum: b: No such file or directory\n");
}