From 0fe8b7d6edc1b27c71c8317d2b816534db7a8637 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Mon, 16 Mar 2015 19:31:27 +0100 Subject: fixed-point-tests: remove some code duplication Signed-off-by: David Wagner --- test/test-fixed-point-parameter/Main.py | 36 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'test') diff --git a/test/test-fixed-point-parameter/Main.py b/test/test-fixed-point-parameter/Main.py index 318b2d1..6d7b292 100755 --- a/test/test-fixed-point-parameter/Main.py +++ b/test/test-fixed-point-parameter/Main.py @@ -94,6 +94,13 @@ class FixedPointTester(): Decimal(self._upperAllowedBound) + Decimal(littleValue) ] + self._chainingTests = [ + ('Bound', self.checkBounds), + ('Sanity', self.checkSanity), + ('Consistency', self.checkConsistency), + ('Bijectivity', self.checkBijectivity)] + + def run(self): """ Runs the test suite for a given Qn.m number """ @@ -102,31 +109,14 @@ class FixedPointTester(): for value in self._shouldWork: value = value.normalize() - print('Testing %s for %s' % (value, self._paramPath)) - value, success = self.checkBounds(value) - if not success: - runSuccess = False - print('Bound ERROR for %s' % self._paramPath) - continue - value, success = self.checkSanity(value) - if not success: - runSuccess = False - print('Sanity ERROR %s' % self._paramPath) - continue - - value, success = self.checkConsistency(value) - if not success: - runSuccess = False - print('Consistency ERROR %s' % self._paramPath) - continue - - value, success = self.checkBijectivity(value) - if not success: - runSuccess = False - print('Bijectivity ERROR %s' % self._paramPath) - continue + for testName, testFunc in self._chainingTests: + value, success = testFunc(value) + if not success: + runSuccess = False + print("%s ERROR for %s" % (testName, self._paramPath)) + break for value in self._shouldBreak: value = value.normalize() -- cgit v1.1