Skip to content

Commit

Permalink
libtest: add assert_object_repr_equals() and assert_object_str_equals()
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Scheidler <[email protected]>
  • Loading branch information
bazsi committed Mar 2, 2025
1 parent 651284c commit 2526611
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions libtest/filterx-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,27 @@ assert_object_json_equals(FilterXObject *obj, const gchar *expected_json_repr)
filterx_object_unref(assoc_object);
}

void
assert_object_repr_equals(FilterXObject *obj, const gchar *expected_repr)
{
GString *repr = g_string_new("foobar");
gsize len = repr->len;

cr_assert(filterx_object_repr_append(obj, repr) == TRUE);
cr_assert_str_eq(repr->str + len, expected_repr);
g_string_free(repr, TRUE);
}

void
assert_object_str_equals(FilterXObject *obj, const gchar *expected_str)
{
GString *str = g_string_new("foobar");
gsize len = str->len;

cr_assert(filterx_object_str_append(obj, str) == TRUE);
cr_assert_str_eq(str->str + len, expected_str);
g_string_free(str, TRUE);
}

FilterXObject *
filterx_test_dict_new(void)
Expand Down
2 changes: 2 additions & 0 deletions libtest/filterx-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

void assert_marshaled_object(FilterXObject *obj, const gchar *repr, LogMessageValueType type);
void assert_object_json_equals(FilterXObject *obj, const gchar *expected_json_repr);
void assert_object_repr_equals(FilterXObject *obj, const gchar *expected_repr);
void assert_object_str_equals(FilterXObject *obj, const gchar *expected_repr);

FILTERX_DECLARE_TYPE(test_dict);
FILTERX_DECLARE_TYPE(test_list);
Expand Down

0 comments on commit 2526611

Please sign in to comment.