Merge pull request #722 from ebfe/fix-sum

sum: fix tests
This commit is contained in:
Heather 2015-11-25 01:18:34 -08:00
commit 196254be3b
2 changed files with 4 additions and 4 deletions

View file

@ -32,7 +32,7 @@ fn bsd_sum(mut reader: Box<Read>) -> (usize, u16) {
blocks_read += 1;
for &byte in buf[..n].iter() {
checksum = (checksum >> 1) + ((checksum & 1) << 15);
checksum += byte as u16;
checksum = checksum.wrapping_add(byte as u16);
}
},
_ => break,
@ -45,14 +45,14 @@ fn bsd_sum(mut reader: Box<Read>) -> (usize, u16) {
fn sysv_sum(mut reader: Box<Read>) -> (usize, u16) {
let mut buf = [0; 512];
let mut blocks_read = 0;
let mut ret = 0;
let mut ret = 0u32;
loop {
match reader.read(&mut buf) {
Ok(n) if n != 0 => {
blocks_read += 1;
for &byte in buf[..n].iter() {
ret += byte as u32;
ret = ret.wrapping_add(byte as u32);
}
},
_ => break,

View file

@ -65,7 +65,7 @@ fn test_sysv_multiple_files() {
fn test_sysv_stdin() {
let (at, mut ucmd) = testing(UTIL_NAME);
let input = at.read("lorem_ipsum.txt");
let result = ucmd.run_piped_stdin(input);
let result = ucmd.arg("-s").run_piped_stdin(input);
assert_empty_stderr!(result);
assert!(result.success);