summaryrefslogtreecommitdiff
path: root/lib/tests
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2015-06-27 09:41:57 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2015-06-27 16:04:07 +0100
commit87009f3d7b155bc2c650d1395f74a2c6e80f0cf6 (patch)
tree3ad16b9ed158703713d818fc2923764e457b2e66 /lib/tests
parent17ed69fbb817bff6f76d3e3beffc2fd30abdf187 (diff)
stats: Factor out a fixture to initialize stats
We're going to use this simple fixture once more, might as well make a function instead of copy/pasting code. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/igt_stats.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/tests/igt_stats.c b/lib/tests/igt_stats.c
index 5c5e86a4..6916f251 100644
--- a/lib/tests/igt_stats.c
+++ b/lib/tests/igt_stats.c
@@ -25,6 +25,15 @@
#include "igt_core.h"
#include "igt_stats.h"
+static void push_fixture_1(igt_stats_t *stats)
+{
+ igt_stats_push(stats, 2);
+ igt_stats_push(stats, 4);
+ igt_stats_push(stats, 6);
+ igt_stats_push(stats, 8);
+ igt_stats_push(stats, 10);
+}
+
/* Make sure we zero igt_stats_t fields at init() time */
static void test_init_zero(void)
{
@@ -54,15 +63,9 @@ static void test_mean(void)
double mean;
igt_stats_init(&stats, 5);
-
- igt_stats_push(&stats, 2);
- igt_stats_push(&stats, 4);
- igt_stats_push(&stats, 6);
- igt_stats_push(&stats, 8);
- igt_stats_push(&stats, 10);
+ push_fixture_1(&stats);
mean = igt_stats_get_mean(&stats);
-
igt_assert(mean == (2 + 4 + 6 + 8 + 10) / 5.);
igt_stats_fini(&stats);
@@ -74,12 +77,7 @@ static void test_invalidate_mean(void)
double mean1, mean2;
igt_stats_init(&stats, 6);
-
- igt_stats_push(&stats, 2);
- igt_stats_push(&stats, 4);
- igt_stats_push(&stats, 6);
- igt_stats_push(&stats, 8);
- igt_stats_push(&stats, 10);
+ push_fixture_1(&stats);
mean1 = igt_stats_get_mean(&stats);
igt_assert(mean1 == (2 + 4 + 6 + 8 + 10) / 5.);