fixed bug in boolean_parse
This commit is contained in:
parent
fc54f29a15
commit
c05eff388c
5 changed files with 8 additions and 0 deletions
|
@ -41,11 +41,14 @@ sml_boolean *sml_boolean_parse(sml_buffer *buf) {
|
|||
}
|
||||
|
||||
if (sml_buf_get_current_byte(buf)) {
|
||||
sml_buf_update_bytes_read(buf, 1);
|
||||
return sml_boolean_init(SML_BOOLEAN_TRUE);
|
||||
}
|
||||
else {
|
||||
sml_buf_update_bytes_read(buf, 1);
|
||||
return sml_boolean_init(SML_BOOLEAN_FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void sml_boolean_write(sml_boolean *boolean, sml_buffer *buf) {
|
||||
|
|
|
@ -50,6 +50,7 @@ TEST(sml_boolean, parse_false) {
|
|||
sml_boolean *b = sml_boolean_parse(buf);
|
||||
TEST_ASSERT_NOT_NULL(b);
|
||||
TEST_ASSERT_EQUAL(SML_BOOLEAN_FALSE, *b);
|
||||
TEST_ASSERT_EQUAL(2, buf->cursor);
|
||||
}
|
||||
|
||||
TEST(sml_boolean, parse_optional) {
|
||||
|
|
|
@ -55,6 +55,8 @@ TEST(sml_octet_string, parse_multiple_tl_fields) {
|
|||
TEST(sml_octet_string, parse_optional) {
|
||||
hex2binary("01", sml_buf_get_current_buf(buf));
|
||||
octet_string *str = sml_octet_string_parse(buf);
|
||||
|
||||
TEST_ASSERT_FALSE(sml_buf_has_errors(buf));
|
||||
TEST_ASSERT_NULL(str);
|
||||
TEST_ASSERT_EQUAL(1, buf->cursor);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ TEST(sml_status, parse_optional) {
|
|||
|
||||
TEST_ASSERT_NULL(s);
|
||||
TEST_ASSERT_FALSE(sml_buf_has_errors(buf));
|
||||
TEST_ASSERT_EQUAL(1, buf->cursor);
|
||||
}
|
||||
|
||||
TEST(sml_status, write_status32) {
|
||||
|
|
|
@ -62,6 +62,7 @@ TEST(sml_value, parse_unsigned32) {
|
|||
TEST_ASSERT_NOT_NULL(v);
|
||||
TEST_ASSERT_EQUAL(1, *(v->data.uint32));
|
||||
TEST_ASSERT_EQUAL((SML_TYPE_UNSIGNED | SML_TYPE_NUMBER_32), v->type);
|
||||
TEST_ASSERT_EQUAL(5, buf->cursor);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue