aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2019-02-26 17:20:41 +0100
committerMax <msuraev@sysmocom.de>2019-02-26 23:01:02 +0000
commit360e021d0aaffab17d03f1b586836865c72fc1a3 (patch)
treed5ac3adc9db5f6e3568ba2c16b7fd62b3e625b6b
parent807dde070f8bf84c119ab3c7e471d3fe29c5c617 (diff)
EDGE tests: reduce code duplication
* move duplicated code into helper function * use proper parameter types Change-Id: I8a9528032629e5df629996da5cd8b808efede017
-rw-r--r--tests/edge/EdgeTest.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 98ca206..6ce2334 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -105,11 +105,22 @@ static void check_coding_scheme(GprsCodingScheme& cs, GprsCodingScheme::Mode mod
}
+static bool check_strong_monotonicity(const GprsCodingScheme *cs, uint8_t last_UL, uint8_t last_DL)
+{
+ if (cs->maxBytesUL() <= last_UL)
+ return false;
+
+ if (cs->maxBytesDL() <= last_DL)
+ return false;
+
+ return true;
+}
+
static void test_coding_scheme()
{
unsigned i;
- unsigned last_size_UL;
- unsigned last_size_DL;
+ uint8_t last_size_UL;
+ uint8_t last_size_DL;
GprsCodingScheme::Scheme gprs_schemes[] = {
GprsCodingScheme::CS1,
GprsCodingScheme::CS2,
@@ -152,9 +163,7 @@ static void test_coding_scheme()
OSMO_ASSERT(GprsCodingScheme::Scheme(current_cs) == gprs_schemes[i]);
OSMO_ASSERT(current_cs == GprsCodingScheme(gprs_schemes[i]));
- /* Check strong monotonicity */
- OSMO_ASSERT(current_cs.maxBytesUL() > last_size_UL);
- OSMO_ASSERT(current_cs.maxBytesDL() > last_size_DL);
+ OSMO_ASSERT(check_strong_monotonicity(&current_cs, last_size_UL, last_size_DL));
last_size_UL = current_cs.maxBytesUL();
last_size_DL = current_cs.maxBytesDL();
@@ -179,9 +188,7 @@ static void test_coding_scheme()
OSMO_ASSERT(GprsCodingScheme::Scheme(current_cs) == egprs_schemes[i].s);
OSMO_ASSERT(current_cs == GprsCodingScheme(egprs_schemes[i].s));
- /* Check strong monotonicity */
- OSMO_ASSERT(current_cs.maxBytesUL() > last_size_UL);
- OSMO_ASSERT(current_cs.maxBytesDL() > last_size_DL);
+ OSMO_ASSERT(check_strong_monotonicity(&current_cs, last_size_UL, last_size_DL));
last_size_UL = current_cs.maxBytesUL();
last_size_DL = current_cs.maxBytesDL();