Skip to content

Commit

Permalink
Added yahdlcTestSetGetState unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppefrandsen committed Oct 21, 2016
1 parent a5546e6 commit 1942b5d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion C/test/yahdlc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,37 @@ BOOST_AUTO_TEST_CASE(yahdlcTestGetDataInvalidInputs) {
BOOST_CHECK_EQUAL(ret, -EINVAL);
}

BOOST_AUTO_TEST_CASE(yahdlcTestSetGetState) {
int ret;
yahdlc_state_t state, yahdlc_state;

state.fcs = 123;

ret = yahdlc_set_state(NULL);
BOOST_CHECK_EQUAL(ret, -EINVAL);

ret = yahdlc_set_state(&state);
BOOST_CHECK_EQUAL(ret, 0);

ret = yahdlc_get_state(NULL);
BOOST_CHECK_EQUAL(ret, -EINVAL);

ret = yahdlc_get_state(&yahdlc_state);
BOOST_CHECK_EQUAL(ret, 0);
BOOST_CHECK_EQUAL(state.control_escape, yahdlc_state.control_escape);
BOOST_CHECK_EQUAL(state.fcs, yahdlc_state.fcs);
BOOST_CHECK_EQUAL(state.start_index, yahdlc_state.start_index);
BOOST_CHECK_EQUAL(state.end_index, yahdlc_state.end_index);
BOOST_CHECK_EQUAL(state.src_index, yahdlc_state.src_index);
BOOST_CHECK_EQUAL(state.dest_index, yahdlc_state.dest_index);
}

BOOST_AUTO_TEST_CASE(yahdlcTestGetDataReset) {
yahdlc_state_t state, yahdlc_state;

yahdlc_get_data_reset();
yahdlc_get_data_reset_with_state(&state);
yahdlc_get_state(&yahdlc_state);

BOOST_CHECK_EQUAL(state.control_escape, yahdlc_state.control_escape);
BOOST_CHECK_EQUAL(state.fcs, yahdlc_state.fcs);
BOOST_CHECK_EQUAL(state.start_index, yahdlc_state.start_index);
Expand Down

0 comments on commit 1942b5d

Please sign in to comment.