1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2026-01-15 17:51:07 +00:00

basic byte and numeric sort

tests for numeric sort
This commit is contained in:
Michael Yin 2014-07-07 10:55:47 -04:00
parent 9c27aac8fe
commit bde6d8d643
14 changed files with 230 additions and 0 deletions

2
test/fixtures/sort/numeric1.ans vendored Normal file
View file

@ -0,0 +1,2 @@
0
.02

2
test/fixtures/sort/numeric1.txt vendored Normal file
View file

@ -0,0 +1,2 @@
.02
0

2
test/fixtures/sort/numeric2.ans vendored Normal file
View file

@ -0,0 +1,2 @@
.02
.03

2
test/fixtures/sort/numeric2.txt vendored Normal file
View file

@ -0,0 +1,2 @@
.03
.02

2
test/fixtures/sort/numeric3.ans vendored Normal file
View file

@ -0,0 +1,2 @@
.000
.01

2
test/fixtures/sort/numeric3.txt vendored Normal file
View file

@ -0,0 +1,2 @@
.01
.000

2
test/fixtures/sort/numeric4.ans vendored Normal file
View file

@ -0,0 +1,2 @@
.00
.01

2
test/fixtures/sort/numeric4.txt vendored Normal file
View file

@ -0,0 +1,2 @@
.01
.00

2
test/fixtures/sort/numeric5.ans vendored Normal file
View file

@ -0,0 +1,2 @@
.022
.024

2
test/fixtures/sort/numeric5.txt vendored Normal file
View file

@ -0,0 +1,2 @@
.022
.024

46
test/sort.rs Normal file
View file

@ -0,0 +1,46 @@
use std::io::process::Command;
use std::io::File;
use std::string::String;
static PROGNAME: &'static str = "./sort";
#[test]
fn numeric1() {
numeric_helper(1);
}
#[test]
fn numeric2() {
numeric_helper(2);
}
#[test]
fn numeric3() {
numeric_helper(3);
}
#[test]
fn numeric4() {
numeric_helper(4);
}
#[test]
fn numeric5() {
numeric_helper(5);
}
fn numeric_helper(test_num: int) {
let mut cmd = Command::new(PROGNAME);
cmd.arg("-n");
let po = match cmd.clone().arg(format!("{}{}{}", "numeric", test_num, ".txt")).output() {
Ok(p) => p,
Err(err) => fail!("{}", err),
};
let answer = match File::open(&Path::new(format!("{}{}{}", "numeric", test_num, ".ans")))
.read_to_end() {
Ok(answer) => answer,
Err(err) => fail!("{}", err),
};
assert_eq!(String::from_utf8(po.output), String::from_utf8(answer));
}