mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
@@ -114,6 +114,7 @@ TEST_PROGS := \
|
||||
basename \
|
||||
cat \
|
||||
cksum \
|
||||
comm \
|
||||
cp \
|
||||
cut \
|
||||
dirname \
|
||||
|
||||
@@ -72,6 +72,7 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &getopts::Matches) {
|
||||
(false, true) => Ordering::Greater,
|
||||
(true , false) => Ordering::Less,
|
||||
(true , true) => match(&na, &nb) {
|
||||
(&Ok(0), &Ok(0)) => break,
|
||||
(&Ok(0), _) => Ordering::Greater,
|
||||
(_, &Ok(0)) => Ordering::Less,
|
||||
_ => ra.cmp(&rb),
|
||||
@@ -85,6 +86,7 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &getopts::Matches) {
|
||||
ensure_nl(ra);
|
||||
print!("{}{}", delim[1], ra);
|
||||
}
|
||||
ra.clear();
|
||||
na = a.read_line(ra);
|
||||
},
|
||||
Ordering::Greater => {
|
||||
@@ -92,6 +94,7 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &getopts::Matches) {
|
||||
ensure_nl(rb);
|
||||
print!("{}{}", delim[2], rb);
|
||||
}
|
||||
rb.clear();
|
||||
nb = b.read_line(rb);
|
||||
},
|
||||
Ordering::Equal => {
|
||||
@@ -99,6 +102,8 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &getopts::Matches) {
|
||||
ensure_nl(ra);
|
||||
print!("{}{}", delim[3], ra);
|
||||
}
|
||||
ra.clear();
|
||||
rb.clear();
|
||||
na = a.read_line(ra);
|
||||
nb = b.read_line(rb);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#[macro_use] mod common;
|
||||
|
||||
use common::util;
|
||||
|
||||
static UTIL_NAME: &'static str = "comm";
|
||||
|
||||
#[test]
|
||||
fn test_comm_ab_no_args() {
|
||||
let (at, mut ucmd) = util::testing(UTIL_NAME);
|
||||
let result = ucmd.args(&["a", "b"]).run();
|
||||
assert_eq!(result.stdout, at.read("ab.expected"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_comm_ab_dash_one() {
|
||||
let (at, mut ucmd) = util::testing(UTIL_NAME);
|
||||
let result = ucmd.args(&["a", "b", "-1"]).run();
|
||||
assert_eq!(result.stdout, at.read("ab1.expected"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_comm_ab_dash_two() {
|
||||
let (at, mut ucmd) = util::testing(UTIL_NAME);
|
||||
let result = ucmd.args(&["a", "b", "-2"]).run();
|
||||
assert_eq!(result.stdout, at.read("ab2.expected"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_comm_ab_dash_three() {
|
||||
let (at, mut ucmd) = util::testing(UTIL_NAME);
|
||||
let result = ucmd.args(&["a", "b", "-3"]).run();
|
||||
assert_eq!(result.stdout, at.read("ab3.expected"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_comm_aempty() {
|
||||
let (at, mut ucmd) = util::testing(UTIL_NAME);
|
||||
let result = ucmd.args(&["a", "empty"]).run();
|
||||
assert_eq!(result.stdout, at.read("aempty.expected"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_comm_emptyempty() {
|
||||
let (at, mut ucmd) = util::testing(UTIL_NAME);
|
||||
let result = ucmd.args(&["empty", "empty"]).run();
|
||||
assert_eq!(result.stdout, at.read("emptyempty.expected"));
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
a
|
||||
z
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
a
|
||||
b
|
||||
z
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
b
|
||||
z
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
a
|
||||
z
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
a
|
||||
b
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
a
|
||||
z
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
b
|
||||
z
|
||||
Vendored
Reference in New Issue
Block a user