1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 05:57:46 +00:00

Merge pull request #570 from jbcrail/fix-sort-test

Fix failing test for sort.
This commit is contained in:
Heather 2015-05-07 00:19:53 +03:00
commit 5ec1c7bea4
2 changed files with 17 additions and 14 deletions

View file

@ -152,7 +152,7 @@ fn frac_compare(a: &String, b: &String) -> Ordering {
#[inline(always)]
fn print_sorted<S, T: Iterator<Item=S>>(iter: T) where S: std::fmt::Display {
for line in iter {
print!("{}", line);
println!("{}", line);
}
}

View file

@ -1,8 +1,7 @@
#![allow(unstable)]
use std::old_io::process::Command;
use std::old_io::File;
use std::string::String;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::process::Command;
static PROGNAME: &'static str = "./sort";
@ -34,15 +33,19 @@ fn numeric5() {
fn numeric_helper(test_num: isize) {
let mut cmd = Command::new(PROGNAME);
cmd.arg("-n");
let po = match cmd.clone().arg(format!("{}{}{}", "numeric", test_num, ".txt")).output() {
let po = match cmd.arg(format!("{}{}{}", "numeric", test_num, ".txt")).output() {
Ok(p) => p,
Err(err) => panic!("{}", err),
Err(err) => panic!("{}", err)
};
let answer = match File::open(&Path::new(format!("{}{}{}", "numeric", test_num, ".ans")))
.read_to_end() {
Ok(answer) => answer,
Err(err) => panic!("{}", err),
};
assert_eq!(String::from_utf8(po.output).unwrap(), String::from_utf8(answer).unwrap());
let filename = format!("{}{}{}", "numeric", test_num, ".ans");
let mut f = File::open(Path::new(&filename)).unwrap_or_else(|err| {
panic!("{}", err)
});
let mut answer = vec!();
match f.read_to_end(&mut answer) {
Ok(_) => {},
Err(err) => panic!("{}", err)
}
assert_eq!(String::from_utf8(po.stdout).unwrap(), String::from_utf8(answer).unwrap());
}