diff mbox

[i-g-t,08/18] stats: Factor out a fixture to initialize stats

Message ID 1435417696-28115-9-git-send-email-damien.lespiau@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lespiau, Damien June 27, 2015, 3:08 p.m. UTC
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>
---
 lib/tests/igt_stats.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
diff mbox

Patch

diff --git a/lib/tests/igt_stats.c b/lib/tests/igt_stats.c
index 5c5e86a..6916f25 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.);