aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2013-12-11 16:47:19 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-12-12 11:01:32 +0100
commitc3f4330fa3a2cf6328cfddd9f00a1b6fd1cb51c3 (patch)
tree60df323fd7836b1cd25fc36366cd1d85b3b5e256
parentf86fb7a953cc020d4bc1bdf67179ae69436aa730 (diff)
tests/TypesTest: Add OSMO_ASSERT_STR_EQ which prints out the parameters
Use it to compare rbb
-rw-r--r--tests/types/TypesTest.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index e269417..cb4f5b6 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -30,6 +30,14 @@ extern "C" {
#include <osmocom/core/utils.h>
}
+#define OSMO_ASSERT_STR_EQ(a, b) \
+ do { \
+ if (strcmp(a, b)) { \
+ printf("String mismatch:\nGot:\t%s\nWant:\t%s\n", a, b); \
+ OSMO_ASSERT(false); \
+ } \
+ } while (0)
+
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
@@ -186,7 +194,8 @@ static void test_rlc_dl_ul_basic()
gprs_rlc_v_n v_n;
int count;
const char *rbb;
- char win_rbb[64];
+ char win_rbb[65];
+ win_rbb[64] = '\0';
v_n.reset();
@@ -199,7 +208,7 @@ static void test_rlc_dl_ul_basic()
rbb = "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII";
OSMO_ASSERT(ul_win.ssn() == 0);
ul_win.update_rbb(&v_n, win_rbb);
- OSMO_ASSERT(!memcmp(rbb, win_rbb, 64));
+ OSMO_ASSERT_STR_EQ(win_rbb, rbb);
/* simulate to have received 0, 1 and 5 */
OSMO_ASSERT(ul_win.is_in_window(0));
@@ -214,7 +223,7 @@ static void test_rlc_dl_ul_basic()
rbb = "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIR";
OSMO_ASSERT(ul_win.ssn() == 1);
ul_win.update_rbb(&v_n, win_rbb);
- OSMO_ASSERT(!memcmp(rbb, win_rbb, 64));
+ OSMO_ASSERT_STR_EQ(win_rbb, rbb);
OSMO_ASSERT(ul_win.is_in_window(1));
v_n.mark_received(1);
@@ -228,7 +237,7 @@ static void test_rlc_dl_ul_basic()
rbb = "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIRR";
OSMO_ASSERT(ul_win.ssn() == 2);
ul_win.update_rbb(&v_n, win_rbb);
- OSMO_ASSERT(!memcmp(rbb, win_rbb, 64));
+ OSMO_ASSERT_STR_EQ(win_rbb, rbb);
OSMO_ASSERT(ul_win.is_in_window(5));
v_n.mark_received(5);
@@ -242,7 +251,7 @@ static void test_rlc_dl_ul_basic()
rbb = "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIRRIIIR";
OSMO_ASSERT(ul_win.ssn() == 6);
ul_win.update_rbb(&v_n, win_rbb);
- OSMO_ASSERT(!memcmp(rbb, win_rbb, 64));
+ OSMO_ASSERT_STR_EQ(win_rbb, rbb);
OSMO_ASSERT(ul_win.is_in_window(65));
OSMO_ASSERT(ul_win.is_in_window(2));
@@ -258,7 +267,7 @@ static void test_rlc_dl_ul_basic()
rbb = "IIIRIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIR";
OSMO_ASSERT(ul_win.ssn() == 66);
ul_win.update_rbb(&v_n, win_rbb);
- OSMO_ASSERT(!memcmp(rbb, win_rbb, 64));
+ OSMO_ASSERT_STR_EQ(win_rbb, rbb);
OSMO_ASSERT(ul_win.is_in_window(2));
OSMO_ASSERT(!ul_win.is_in_window(66));