Skip to content
Snippets Groups Projects
Commit e8deb8ce authored by Jonathan Schöbel's avatar Jonathan Schöbel
Browse files

NodeFragment: added tests for get_attr method.

added tests for getter
parent 51a3ab66
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ long_line_behaviour=1
long_line_column=72
[files]
current_page=16
current_page=31
FILE_NAME_0=923;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fconfigure.ac;0;8
FILE_NAME_1=73;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2FMakefile.am;0;8
FILE_NAME_2=1143;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Fmain.c;0;8
......@@ -57,10 +57,10 @@ FILE_NAME_24=4735;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fp
FILE_NAME_25=901;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Flog.h;0;4
FILE_NAME_26=907;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fmacro.h;0;8
FILE_NAME_27=1078;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fsefht.h;0;8
FILE_NAME_28=533;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2FMakefile.am;0;8
FILE_NAME_28=1044;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2FMakefile.am;0;8
FILE_NAME_29=1085;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_cms.c;0;8
FILE_NAME_30=3283;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_data.c;0;8
FILE_NAME_31=53309;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_node_fragment.c;0;8
FILE_NAME_31=12038;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_node_fragment.c;0;8
FILE_NAME_32=15195;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_attr.c;0;8
FILE_NAME_33=11068;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_text.c;0;8
FILE_NAME_34=5744;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_validator.c;0;8
......
......@@ -36,6 +36,7 @@ sefht_data_test_LDADD += $(LDADD)
sefht_node_fragment_test_SOURCES = test_node_fragment.c
sefht_node_fragment_test_LDADD =
sefht_node_fragment_test_LDADD += $(OBJECT_PREFIX)attr.o
sefht_node_fragment_test_LDADD += $(OBJECT_PREFIX)data.o
sefht_node_fragment_test_LDADD += $(OBJECT_PREFIX)fragment.o
sefht_node_fragment_test_LDADD += $(OBJECT_PREFIX)text.o
......
......@@ -436,6 +436,89 @@ START_TEST(test_node_fragment_attr_alloc)
}
END_TEST
START_TEST(test_node_fragment_attr_get_no_status)
{
SH_Attr * attr1;
const SH_Attr * attr2;
SH_Data * data;
SH_NodeFragment * fragment;
bool result;
/* setup */
attr1 = SH_Attr_new ("name", "value", NULL);
ck_assert_ptr_ne (NULL, attr1);
data = SH_Data_new (NULL);
ck_assert_ptr_ne (NULL, data);
fragment = (SH_NodeFragment *)SH_NodeFragment_new ("html", data,
NULL);
ck_assert_ptr_ne (NULL, fragment);
result = SH_NodeFragment_append_attr_copy (fragment, attr1, NULL);
ck_assert_int_eq (TRUE, result);
/* test - success */
attr2 = SH_NodeFragment_get_attr (fragment, 0, NULL);
ck_assert_ptr_ne (NULL, attr2);
ck_assert (Attr_is_equal (attr1, attr2));
/* test - fail */
attr2 = SH_NodeFragment_get_attr (fragment, 1, NULL);
ck_assert_ptr_eq (NULL, attr2);
/* cleanup */
SH_NodeFragment_free (fragment);
SH_Data_free (data);
SH_Attr_free (attr1);
}
END_TEST
START_TEST(test_node_fragment_attr_get_with_status)
{
struct SH_Status status;
SH_Attr * attr1;
const SH_Attr * attr2;
SH_Data * data;
SH_NodeFragment * fragment;
bool result;
/* setup */
attr1 = SH_Attr_new ("name", "value", NULL);
ck_assert_ptr_ne (NULL, attr1);
data = SH_Data_new (NULL);
ck_assert_ptr_ne (NULL, data);
fragment = (SH_NodeFragment *)SH_NodeFragment_new ("html", data,
NULL);
ck_assert_ptr_ne (NULL, fragment);
result = SH_NodeFragment_append_attr_copy (fragment, attr1, NULL);
ck_assert_int_eq (TRUE, result);
/* test - success */
_status_preinit (status);
attr2 = SH_NodeFragment_get_attr (fragment, 0, &status);
ck_assert_ptr_ne (NULL, attr2);
ck_assert_int_eq (SUCCESS, status.status);
ck_assert (Attr_is_equal (attr1, attr2));
/* test - fail */
_status_preinit (status);
attr2 = SH_NodeFragment_get_attr (fragment, 1, &status);
ck_assert_ptr_eq (NULL, attr2);
ck_assert_int_eq (E_VALUE, status.status);
/* cleanup */
SH_NodeFragment_free (fragment);
SH_Data_free (data);
SH_Attr_free (attr1);
}
END_TEST
START_TEST(test_node_fragment_child_alloc)
{
#define alloc_size get_child_alloc_size
......@@ -1828,6 +1911,8 @@ Suite * fragment_suite (void)
tcase_add_test (tc_core, test_node_fragment_tag_with_status);
tcase_add_test (tc_core, test_node_fragment_tag_raw);
tcase_add_test (tc_core, test_node_fragment_attr_alloc);
tcase_add_test (tc_core, test_node_fragment_attr_get_no_status);
tcase_add_test (tc_core, test_node_fragment_attr_get_with_status);
tcase_add_test (tc_core, test_node_fragment_child_alloc);
tcase_add_test (tc_core, test_node_fragment_child);
tcase_add_test (tc_core, test_node_fragment_get_child);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment