Skip to content

Commit

Permalink
Added count_by_value test
Browse files Browse the repository at this point in the history
  • Loading branch information
iduartgomez committed May 3, 2020
1 parent 5897453 commit 7f06f72
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_rdd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,26 @@ fn count_aprox() -> Result<()> {
Ok(())
}

#[test]
fn count_by_value_aprox() -> Result<()> {
let sc = CONTEXT.clone();

// this should complete and return the final value, so confidence should be 100%
let time_out = std::time::Duration::from_nanos(100);
let mut res: Vec<_> = sc
.make_rdd(vec![1i32, 2, 2, 3, 3, 3], 6)
.count_by_value_aprox(time_out, Some(0.9))?
.get_final_value()?
.into_iter()
.map(|(k, v)| (k, v.mean))
.collect();
res.sort_by(|e1, e2| e1.0.cmp(&e2.0));

let expected = vec![(1i32, 1.0f64), (2, 2.0), (3, 3.0)];
assert_eq!(res, expected);
Ok(())
}

#[test]
fn test_is_empty() {
let sc = CONTEXT.clone();
Expand Down

0 comments on commit 7f06f72

Please sign in to comment.