mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
tests/sort: refactor to match other tests
Instead of using numerals to denote individual cases, I used descriptive case names. I also changed the extension for the expected output fixture to match other tests. I removed one redundant test and another unnecessary helper function.
This commit is contained in:
parent
977d352c05
commit
b290c10845
17 changed files with 16 additions and 29 deletions
2
tests/fixtures/sort/numeric5.ans
vendored
2
tests/fixtures/sort/numeric5.ans
vendored
|
@ -1,2 +0,0 @@
|
||||||
.022
|
|
||||||
.024
|
|
2
tests/fixtures/sort/numeric5.txt
vendored
2
tests/fixtures/sort/numeric5.txt
vendored
|
@ -1,2 +0,0 @@
|
||||||
.022
|
|
||||||
.024
|
|
|
@ -7,54 +7,45 @@ static UTIL_NAME: &'static str = "sort";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn numeric1() {
|
fn test_numeric_floats_and_ints() {
|
||||||
numeric_helper(1);
|
test_helper("numeric_floats_and_ints", &String::from("-n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn numeric2() {
|
fn test_numeric_floats() {
|
||||||
numeric_helper(2);
|
test_helper("numeric_floats", &String::from("-n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn numeric3() {
|
fn test_numeric_unfixed_floats() {
|
||||||
numeric_helper(3);
|
test_helper("numeric_unfixed_floats", &String::from("-n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn numeric4() {
|
fn test_numeric_fixed_floats() {
|
||||||
numeric_helper(4);
|
test_helper("numeric_fixed_floats", &String::from("-n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn numeric5() {
|
fn test_numeric_unsorted_ints() {
|
||||||
numeric_helper(5);
|
test_helper("numeric_unsorted_ints", &String::from("-n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn numeric6() {
|
fn test_human_block_sizes() {
|
||||||
numeric_helper(6);
|
test_helper("human_block_sizes", &String::from("-h"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn human1() {
|
fn test_month_default() {
|
||||||
test_helper(&String::from("human1"), &String::from("-h"));
|
test_helper("month_default", &String::from("-M"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn test_helper(file_name: &str, args: &String) {
|
||||||
fn month1() {
|
|
||||||
test_helper(&String::from("month1"), &String::from("-M"));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn numeric_helper(test_num: isize) {
|
|
||||||
test_helper(&format!("numeric{}", test_num), &String::from("-n"))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_helper(file_name: &String, args: &String) {
|
|
||||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
let (at, mut ucmd) = testing(UTIL_NAME);
|
||||||
ucmd.arg(args);
|
ucmd.arg(args);
|
||||||
let out = ucmd.arg(format!("{}{}", file_name, ".txt")).run().stdout;
|
let out = ucmd.arg(format!("{}{}", file_name, ".txt")).run().stdout;
|
||||||
|
|
||||||
let filename = format!("{}{}", file_name, ".ans");
|
let filename = format!("{}{}", file_name, ".expected");
|
||||||
assert_eq!(out, at.read(&filename));
|
assert_eq!(out, at.read(&filename));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue