exercism/rust/prime-factors/tests/prime-factors.rs
2017-09-09 16:31:21 -04:00

38 lines
672 B
Rust

extern crate prime_factors;
use prime_factors::factors;
#[test]
fn test_no_factors() {
assert_eq!(factors(1), vec![]);
}
#[test]
fn test_prime_number() {
assert_eq!(factors(2), vec![2]);
}
#[test]
fn test_square_of_a_prime() {
assert_eq!(factors(9), vec![3, 3]);
}
#[test]
fn test_cube_of_a_prime() {
assert_eq!(factors(8), vec![2, 2, 2]);
}
#[test]
fn test_product_of_primes_and_non_primes() {
assert_eq!(factors(12), vec![2, 2, 3]);
}
#[test]
fn test_product_of_primes() {
assert_eq!(factors(901255), vec![5, 17, 23, 461]);
}
#[test]
fn test_factors_include_large_prime() {
assert_eq!(factors(93819012551), vec![11, 9539, 894119]);
}