mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tests/factor ~ test first 100000 integers for expected results
This commit is contained in:
parent
6a525c950d
commit
c5296f00d0
2 changed files with 22 additions and 0 deletions
|
@ -333,6 +333,7 @@ filetime = "0.2"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
|
sha1 = { version="0.6", features=["std"] }
|
||||||
tempfile = "3.1"
|
tempfile = "3.1"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
unindent = "0.1"
|
unindent = "0.1"
|
||||||
|
|
|
@ -21,6 +21,27 @@ const LOG_PRIMES: f64 = 14.0; // ceil(log2(NUM_PRIMES))
|
||||||
|
|
||||||
const NUM_TESTS: usize = 100;
|
const NUM_TESTS: usize = 100;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_first_100000_integers() {
|
||||||
|
extern crate sha1;
|
||||||
|
|
||||||
|
let n_integers = 100_000;
|
||||||
|
let mut instring = String::new();
|
||||||
|
for i in 0..=n_integers {
|
||||||
|
instring.push_str(&(format!("{} ", i))[..]);
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("STDIN='{}'", instring);
|
||||||
|
let result = new_ucmd!().pipe_in(instring.as_bytes()).run();
|
||||||
|
let stdout = result.stdout;
|
||||||
|
|
||||||
|
assert!(result.success);
|
||||||
|
|
||||||
|
// `seq 0 100000 | factor | sha1sum` => "4ed2d8403934fa1c76fe4b84c5d4b8850299c359"
|
||||||
|
let hash_check = sha1::Sha1::from(stdout.as_bytes()).hexdigest();
|
||||||
|
assert_eq!(hash_check, "4ed2d8403934fa1c76fe4b84c5d4b8850299c359");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_random() {
|
fn test_random() {
|
||||||
let primes = Sieve::primes().take(NUM_PRIMES).collect::<Vec<u64>>();
|
let primes = Sieve::primes().take(NUM_PRIMES).collect::<Vec<u64>>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue