loci: add missing test for of_object_new_from_message
Also fix embarassing typos in test_of_object_new_from_message_preallocated.
diff --git a/c_gen/templates/locitest/test_utils.c b/c_gen/templates/locitest/test_utils.c
index 563f510..10a6b3d 100644
--- a/c_gen/templates/locitest/test_utils.c
+++ b/c_gen/templates/locitest/test_utils.c
@@ -119,6 +119,29 @@
}
static int
+test_of_object_new_from_message(void)
+{
+ /* v1 OFPT_HELLO, xid=0x12345678 */
+ uint8_t data[] = { 0x01, 0x00, 0x00, 0x08, 0x12, 0x34, 0x56, 0x78 };
+ uint8_t *buf = malloc(sizeof(data));
+ memcpy(buf, data, sizeof(data));
+
+ of_object_t *obj = of_object_new_from_message(buf, sizeof(data));
+
+ TEST_ASSERT(obj != NULL);
+ TEST_ASSERT(obj->version == OF_VERSION_1_0);
+ TEST_ASSERT(obj->object_id == OF_HELLO);
+
+ uint32_t xid;
+ of_hello_xid_get(obj, &xid);
+ TEST_ASSERT(xid == 0x12345678);
+
+ of_object_delete(obj);
+
+ return TEST_PASS;
+}
+
+static int
test_of_object_new_from_message_preallocated(void)
{
/* v1 OFPT_HELLO, xid=0x12345678 */
@@ -129,8 +152,8 @@
&storage, buf, sizeof(buf));
TEST_ASSERT(obj != NULL);
- TEST_ASSERT(obj->version = OF_VERSION_1_0);
- TEST_ASSERT(obj->object_id = OF_HELLO);
+ TEST_ASSERT(obj->version == OF_VERSION_1_0);
+ TEST_ASSERT(obj->object_id == OF_HELLO);
uint32_t xid;
of_hello_xid_get(obj, &xid);
@@ -143,6 +166,7 @@
run_utility_tests(void)
{
RUN_TEST(has_outport);
+ RUN_TEST(of_object_new_from_message);
RUN_TEST(of_object_new_from_message_preallocated);
RUN_TEST(dump_objs);