Skip to content

Commit

Permalink
fixup! tests/unittests: add registry_string_path tests
Browse files Browse the repository at this point in the history
Fix new registry_node_t format
  • Loading branch information
LasseRosenow committed Apr 12, 2024
1 parent 4a9c124 commit f9d8c3e
Showing 1 changed file with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ static void tests_registry_to_parameter_string_path(void)
{
registry_node_t node = {
.type = REGISTRY_NODE_PARAMETER,
.location.parameter = &registry_tests_nested_group_parameter,
.instance = &test_instance,
.value.parameter = {
.instance = &test_instance,
.parameter = &registry_tests_nested_group_parameter,
},
};

int size = registry_node_to_string_path(&node, NULL);
Expand All @@ -79,8 +81,10 @@ static void tests_registry_to_group_string_path(void)
{
registry_node_t node = {
.type = REGISTRY_NODE_GROUP,
.location.group = &registry_tests_nested_group,
.instance = &test_instance,
.value.group = {
.instance = &test_instance,
.group = &registry_tests_nested_group,
},
};

int size = registry_node_to_string_path(&node, NULL);
Expand All @@ -95,7 +99,7 @@ static void tests_registry_to_instance_string_path(void)
{
registry_node_t node = {
.type = REGISTRY_NODE_INSTANCE,
.instance = &test_instance,
.value.instance = &test_instance,
};

int size = registry_node_to_string_path(&node, NULL);
Expand All @@ -110,7 +114,7 @@ static void tests_registry_to_schema_string_path(void)
{
registry_node_t node = {
.type = REGISTRY_NODE_SCHEMA,
.location.schema = &registry_tests_nested,
.value.schema = &registry_tests_nested,
};

int size = registry_node_to_string_path(&node, NULL);
Expand All @@ -125,7 +129,7 @@ static void tests_registry_to_namespace_string_path(void)
{
registry_node_t node = {
.type = REGISTRY_NODE_NAMESPACE,
.location.namespace = &registry_tests,
.value.namespace = &registry_tests,
};

int size = registry_node_to_string_path(&node, NULL);
Expand All @@ -145,10 +149,10 @@ static void tests_registry_from_parameter_string_path(void)
registry_node_from_string_path(str, sizeof(str), &node);

TEST_ASSERT_EQUAL_INT(REGISTRY_NODE_PARAMETER, node.type);
TEST_ASSERT_EQUAL_STRING("tests", node.location.parameter->schema->namespace->name);
TEST_ASSERT_EQUAL_STRING("nested", node.location.parameter->schema->name);
TEST_ASSERT_EQUAL_STRING("instance-1", node.instance->name);
TEST_ASSERT_EQUAL_STRING("parameter", node.location.parameter->name);
TEST_ASSERT_EQUAL_STRING("tests", node.value.parameter.parameter->schema->namespace->name);
TEST_ASSERT_EQUAL_STRING("nested", node.value.parameter.parameter->schema->name);
TEST_ASSERT_EQUAL_STRING("instance-1", node.value.parameter.instance->name);
TEST_ASSERT_EQUAL_STRING("parameter", node.value.parameter.parameter->name);
}

static void tests_registry_from_group_string_path(void)
Expand All @@ -159,10 +163,10 @@ static void tests_registry_from_group_string_path(void)
registry_node_from_string_path(str, sizeof(str), &node);

TEST_ASSERT_EQUAL_INT(REGISTRY_NODE_GROUP, node.type);
TEST_ASSERT_EQUAL_STRING("tests", node.location.group->schema->namespace->name);
TEST_ASSERT_EQUAL_STRING("nested", node.location.group->schema->name);
TEST_ASSERT_EQUAL_STRING("instance-1", node.instance->name);
TEST_ASSERT_EQUAL_STRING("group", node.location.group->name);
TEST_ASSERT_EQUAL_STRING("tests", node.value.group.group->schema->namespace->name);
TEST_ASSERT_EQUAL_STRING("nested", node.value.group.group->schema->name);
TEST_ASSERT_EQUAL_STRING("instance-1", node.value.group.instance->name);
TEST_ASSERT_EQUAL_STRING("group", node.value.group.group->name);
}

static void tests_registry_from_instance_string_path(void)
Expand All @@ -173,9 +177,9 @@ static void tests_registry_from_instance_string_path(void)
registry_node_from_string_path(str, sizeof(str), &node);

TEST_ASSERT_EQUAL_INT(REGISTRY_NODE_INSTANCE, node.type);
TEST_ASSERT_EQUAL_STRING("tests", node.instance->schema->namespace->name);
TEST_ASSERT_EQUAL_STRING("nested", node.instance->schema->name);
TEST_ASSERT_EQUAL_STRING("instance-1", node.instance->name);
TEST_ASSERT_EQUAL_STRING("tests", node.value.instance->schema->namespace->name);
TEST_ASSERT_EQUAL_STRING("nested", node.value.instance->schema->name);
TEST_ASSERT_EQUAL_STRING("instance-1", node.value.instance->name);
}

static void tests_registry_from_schema_string_path(void)
Expand All @@ -186,8 +190,8 @@ static void tests_registry_from_schema_string_path(void)
registry_node_from_string_path(str, sizeof(str), &node);

TEST_ASSERT_EQUAL_INT(REGISTRY_NODE_SCHEMA, node.type);
TEST_ASSERT_EQUAL_STRING("tests", node.location.schema->namespace->name);
TEST_ASSERT_EQUAL_STRING("nested", node.location.schema->name);
TEST_ASSERT_EQUAL_STRING("tests", node.value.schema->namespace->name);
TEST_ASSERT_EQUAL_STRING("nested", node.value.schema->name);
}

static void tests_registry_from_namespace_string_path(void)
Expand All @@ -198,7 +202,7 @@ static void tests_registry_from_namespace_string_path(void)
registry_node_from_string_path(str, sizeof(str), &node);

TEST_ASSERT_EQUAL_INT(REGISTRY_NODE_NAMESPACE, node.type);
TEST_ASSERT_EQUAL_STRING("tests", node.location.namespace->name);
TEST_ASSERT_EQUAL_STRING("tests", node.value.namespace->name);
}

Test *tests_registry_string_path_tests(void)
Expand Down

0 comments on commit f9d8c3e

Please sign in to comment.