summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2015-06-27 16:42:50 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2015-06-27 16:46:37 +0100
commit817ea87b6edab2d25a2994f076562ee03aa91fc6 (patch)
treebaa428c5a4afac90fa518debb6340e715d06ed38 /lib
parentfabde384a33324dc9a9c55c1f4003196ec90564c (diff)
stats: Test we do correctly invalidate the sorted array
Chris had a doubt, and I was lazy and didn't do a similar test for the quartiles/median than for the mean (test_invalidate_mean()). Plug that gap. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/tests/igt_stats.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/tests/igt_stats.c b/lib/tests/igt_stats.c
index c0649f33..dfdc5072 100644
--- a/lib/tests/igt_stats.c
+++ b/lib/tests/igt_stats.c
@@ -120,6 +120,24 @@ static void test_quartiles(void)
igt_stats_fini(&stats);
}
+static void test_invalidate_sorted(void)
+{
+ igt_stats_t stats;
+ static const uint64_t s1_truncated[] =
+ { 47, 49, 6, 7, 15, 36, 39, 40, 41, 42};
+ double median1, median2;
+
+ igt_stats_init(&stats, ARRAY_SIZE(s1_truncated) + 1);
+ igt_stats_push_array(&stats, s1_truncated, ARRAY_SIZE(s1_truncated));
+ median1 = igt_stats_get_median(&stats);
+
+ igt_stats_push(&stats, 43);
+ median2 = igt_stats_get_median(&stats);
+
+ igt_assert_eq_double(median2, 40);
+ igt_assert(median1 != median2);
+}
+
static void test_mean(void)
{
igt_stats_t stats;
@@ -193,6 +211,7 @@ igt_simple_main
test_min_max();
test_range();
test_quartiles();
+ test_invalidate_sorted();
test_mean();
test_invalidate_mean();
test_std_deviation();