#include #include #include #include #include extern "C" { #include "drv/hl854x/mec.c" static struct di_drv_hl854x_ctx ctx; } TEST(drv_hl854x_mec, cb_csq) { struct { std::string str; int8_t rssi; int8_t ber; } cb_csq_expect[] = { /* BER tests */ { "99,0,-8", 0, 0 }, { "99,1,-8", 0, 1 }, { "99,2,-8", 0, 2 }, { "99,3,-8", 0, 3 }, { "99,4,-8", 0, 4 }, { "99,5,-8", 0, 5 }, { "99,6,-8", 0, 6 }, { "99,7,-8", 0, 7 }, { "99,8,-8", 0, -1 }, { "99,99,-8", 0, -1 }, /* RSSI tests */ { "0,99,-8", -113, -1 }, { "1,99,-8", -111, -1 }, { "2,99,-8", -109, -1 }, { "11,99,-8", -91, -1 }, { "30,99,-8", -53, -1 }, { "31,99,-8", -51, -1 }, { "32,99,-8", 0, -1 }, { "98,99,-8", 0, -1 }, { "99,99,-8", 0, -1 } }; di_drv_hl854x_init(&ctx); for (size_t n = 0; n < sizeof(cb_csq_expect)/sizeof(cb_csq_expect[0]); n++) { ctx.me.match.str = const_cast(cb_csq_expect[n].str.c_str()); di_drv_hl854x_mec_cb_csq(&ctx.me); EXPECT_EQ(cb_csq_expect[n].rssi, ctx.carrier.rssi); EXPECT_EQ(cb_csq_expect[n].ber, ctx.carrier.ber); } } TEST(drv_hl854x_mec, cb_cpin) { di_drv_hl854x_init(&ctx); struct { std::string s_str; enum di_drv_hl854x_sim_status s; } cb_cpin_expect[] = { { "READY", HL854X_SIM_STATUS_READY }, { "SIM PIN", HL854X_SIM_STATUS_SIM_PIN }, { "SIM PUK", HL854X_SIM_STATUS_SIM_PUK }, { "FOOBAR", HL854X_SIM_STATUS_UNKNOWN } }; for (size_t n = 0; n < sizeof(cb_cpin_expect)/sizeof(cb_cpin_expect[0]); n++) { ctx.me.match.str = const_cast(cb_cpin_expect[n].s_str.c_str()); di_drv_hl854x_mec_cb_cpin(&ctx.me); EXPECT_EQ(cb_cpin_expect[n].s, ctx.sim.status); } }