TEST(sml_proc_par_value, parse_time) { hex2binary("72620472620265000000FF", sml_buf_get_current_buf(buf)); sml_proc_par_value *t = sml_proc_par_value_parse(buf); TEST_ASSERT_NOT_NULL(t); TEST_ASSERT_EQUAL(SML_PROC_PAR_VALUE_TAG_TIME, *(t->tag)); TEST_ASSERT_EQUAL(11, buf->cursor); sml_proc_par_value_free( t ); }
TEST(sml_proc_par_value, write_time) { sml_proc_par_value *ppv = sml_proc_par_value_init(); ppv->tag = sml_u8_init(SML_PROC_PAR_VALUE_TAG_TIME); sml_time *t = sml_time_init(); t->data.sec_index = sml_u32_init(255); t->tag = sml_u8_init(SML_TIME_SEC_INDEX); ppv->data.time = t; sml_proc_par_value_write(ppv, buf); expected_buf(buf, "72620472620165000000FF", 11); sml_proc_par_value_free( ppv ); }
void sml_tree_free(sml_tree *tree) { if (tree) { sml_octet_string_free(tree->parameter_name); sml_proc_par_value_free(tree->parameter_value); int i; for (i = 0; i < tree->child_list_len; i++) { sml_tree_free(tree->child_list[i]); } free(tree->child_list); free(tree); } }
sml_proc_par_value *sml_proc_par_value_parse(sml_buffer *buf) { if (sml_buf_optional_is_skipped(buf)) { return 0; } sml_proc_par_value *ppv = sml_proc_par_value_init(); if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) { buf->error = 1; goto error; } if (sml_buf_get_next_length(buf) != 2) { buf->error = 1; goto error; } ppv->tag = sml_u8_parse(buf); if (sml_buf_has_errors(buf)) goto error; switch (*(ppv->tag)) { case SML_PROC_PAR_VALUE_TAG_VALUE: ppv->data.value = sml_value_parse(buf); break; case SML_PROC_PAR_VALUE_TAG_PERIOD_ENTRY: ppv->data.period_entry = sml_period_entry_parse(buf); break; case SML_PROC_PAR_VALUE_TAG_TUPEL_ENTRY: ppv->data.tupel_entry = sml_tupel_entry_parse(buf); break; case SML_PROC_PAR_VALUE_TAG_TIME: ppv->data.time = sml_time_parse(buf); break; default: buf->error = 1; goto error; } return ppv; error: sml_proc_par_value_free(ppv); return 0; }
TEST(sml_proc_par_value, init) { sml_proc_par_value *t = sml_proc_par_value_init(); TEST_ASSERT_NOT_NULL(t); sml_proc_par_value_free( t ); }