boolean write bug

This commit is contained in:
Juri Glass 2011-07-14 21:02:26 +02:00
parent f564f830e6
commit 12e6f08bcd
2 changed files with 10 additions and 3 deletions

View file

@ -55,7 +55,7 @@ void sml_boolean_write(sml_boolean *boolean, sml_buffer *buf) {
}
sml_buf_set_type_and_length(buf, SML_TYPE_BOOLEAN, 1);
if (boolean == SML_BOOLEAN_FALSE) {
if (*boolean == SML_BOOLEAN_FALSE) {
buf->buffer[buf->cursor] = SML_BOOLEAN_FALSE;
}
else {

View file

@ -58,12 +58,18 @@ TEST(sml_boolean, parse_optional) {
TEST_ASSERT_NULL(b);
}
TEST(sml_boolean, write) {
TEST(sml_boolean, write_true) {
sml_boolean *b = sml_boolean_init(SML_BOOLEAN_TRUE);
sml_boolean_write(b, buf);
expected_buf(buf, "42FF", 2);
}
TEST(sml_boolean, write_false) {
sml_boolean *b = sml_boolean_init(SML_BOOLEAN_FALSE);
sml_boolean_write(b, buf);
expected_buf(buf, "4200", 2);
}
TEST(sml_boolean, write_optional) {
sml_boolean_write(0, buf);
expected_buf(buf, "01", 1);
@ -75,6 +81,7 @@ TEST_GROUP_RUNNER(sml_boolean) {
RUN_TEST_CASE(sml_boolean, parse_true);
RUN_TEST_CASE(sml_boolean, parse_false);
RUN_TEST_CASE(sml_boolean, parse_optional);
RUN_TEST_CASE(sml_boolean, write);
RUN_TEST_CASE(sml_boolean, write_true);
RUN_TEST_CASE(sml_boolean, write_false);
RUN_TEST_CASE(sml_boolean, write_optional);
}