1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Add test for paste.

This commit is contained in:
Joseph Crail 2015-05-07 16:51:55 -04:00
parent b00a49eab2
commit 0ea0e7504a
4 changed files with 76 additions and 0 deletions

View file

@ -164,6 +164,7 @@ TEST_PROGS := \
mkdir \
mv \
nl \
paste \
seq \
sort \
test \

View file

@ -0,0 +1,16 @@
white #FFFFFF
silver #C0C0C0
gray #808080
black #000000
red #FF0000
maroon #800000
yellow #FFFF00
olive #808000
lime #00FF00
green #008000
aqua #00FFFF
teal #008080
blue #0000FF
navy #000080
fuchsia #FF00FF
purple #800080

32
test/fixtures/paste/html_colors.txt vendored Normal file
View file

@ -0,0 +1,32 @@
white
#FFFFFF
silver
#C0C0C0
gray
#808080
black
#000000
red
#FF0000
maroon
#800000
yellow
#FFFF00
olive
#808000
lime
#00FF00
green
#008000
aqua
#00FFFF
teal
#008080
blue
#0000FF
navy
#000080
fuchsia
#FF00FF
purple
#800080

27
test/paste.rs Normal file
View file

@ -0,0 +1,27 @@
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::process::Command;
static PROGNAME: &'static str = "./paste";
#[test]
fn test_combine_pairs_of_lines() {
let po = Command::new(PROGNAME)
.arg("-s")
.arg("-d")
.arg("\t\n")
.arg("html_colors.txt")
.output()
.unwrap_or_else(|err| panic!("{}", err));
let mut f = File::open(Path::new("html_colors.expected")).unwrap_or_else(|err| {
panic!("{}", err)
});
let mut expected = vec!();
match f.read_to_end(&mut expected) {
Ok(_) => {},
Err(err) => panic!("{}", err)
}
assert_eq!(String::from_utf8(po.stdout).unwrap(), String::from_utf8(expected).unwrap());
}