Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SeFHT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
josc941e
SeFHT
Commits
422b506a
Commit
422b506a
authored
1 year ago
by
Jonathan Schöbel
Browse files
Options
Downloads
Patches
Plain Diff
Validator: added self-closing predicate
Other predicates may follow.
parent
55bbb701
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
sefht.geany
+3
-3
3 additions, 3 deletions
sefht.geany
src/lib/sefht/validator_tag.c
+21
-0
21 additions, 0 deletions
src/lib/sefht/validator_tag.c
src/lib/sefht/validator_tag.h
+9
-0
9 additions, 0 deletions
src/lib/sefht/validator_tag.h
tests/test_validator_tag.c
+81
-0
81 additions, 0 deletions
tests/test_validator_tag.c
with
114 additions
and
3 deletions
sefht.geany
+
3
−
3
View file @
422b506a
...
...
@@ -61,8 +61,8 @@ FILE_NAME_28=1867;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fp
FILE_NAME_29=2191;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator.c;0;8
FILE_NAME_30=1159;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator.h;0;8
FILE_NAME_31=1008;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_html.h;0;8
FILE_NAME_32=1
4105
;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_tag.c;0;8
FILE_NAME_33=
1251
;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_tag.h;0;8
FILE_NAME_32=1
3800
;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_tag.c;0;8
FILE_NAME_33=
2116
;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_tag.h;0;8
FILE_NAME_34=1150;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_tag_data.h;0;8
FILE_NAME_35=22399;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_attr.c;0;8
FILE_NAME_36=1051;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_attr.h;0;8
...
...
@@ -82,7 +82,7 @@ FILE_NAME_49=24;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprg
FILE_NAME_50=4221;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_text.c;0;8
FILE_NAME_51=994;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_text_mark.c;0;8
FILE_NAME_52=2447;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_validator.c;0;8
FILE_NAME_53=
9430
;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_validator_tag.c;0;8
FILE_NAME_53=
20787
;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_validator_tag.c;0;8
FILE_NAME_54=58751;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_validator_attr.c;0;8
FILE_NAME_55=497;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftodo.txt;0;8
FILE_NAME_56=201;YAML;0;EUTF-8;0;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2F.gitlab-ci.yml;0;4
...
...
This diff is collapsed.
Click to expand it.
src/lib/sefht/validator_tag.c
+
21
−
0
View file @
422b506a
...
...
@@ -587,6 +587,27 @@ SH_Validator_check_tag (struct SH_Validator * validator,
return
find_tag
(
validator
,
tag
,
&
index
);
}
bool
SH_Validator_is_self_closing_tag
(
const
struct
SH_Validator
*
validator
,
const
char
*
tag
,
/*@null@*/
/*@out@*/
struct
SH_Status
*
status
)
/*@globals fileSystem@*/
/*@modifies fileSystem@*/
/*@modifies status@*/
{
size_t
index
;
if
(
!
find_tag
(
validator
,
tag
,
&
index
))
{
set_status
(
status
,
E_VALUE
,
2
,
"no such tag"
);
return
FALSE
;
}
set_success
(
status
);
return
(
TAG_T_VOID
==
validator
->
tags
[
index
].
type
);
}
bool
/*@alt void@*/
SH_Validator_register_tag
(
struct
SH_Validator
*
validator
,
...
...
This diff is collapsed.
Click to expand it.
src/lib/sefht/validator_tag.h
+
9
−
0
View file @
422b506a
...
...
@@ -75,4 +75,13 @@ SH_Validator_check_tag (struct SH_Validator * validator,
const
char
*
tag
)
/*@*/
;
bool
SH_Validator_is_self_closing_tag
(
const
SH_Validator
*
validator
,
const
char
*
tag
,
/*@null@*/
/*@out@*/
struct
SH_Status
*
status
)
/*@globals fileSystem@*/
/*@modifies fileSystem@*/
/*@modifies status@*/
;
#endif
/* SEFHT_VALIDATOR_TAG_H */
This diff is collapsed.
Click to expand it.
tests/test_validator_tag.c
+
81
−
0
View file @
422b506a
...
...
@@ -607,6 +607,85 @@ START_TEST(test_validator_tag_check)
}
END_TEST
START_TEST
(
test_validator_tag_self_closing_no_status
)
{
struct
SH_Validator
*
validator
;
bool
result
;
/* setup */
validator
=
SH_Validator_new
(
NULL
);
ck_assert_ptr_ne
(
NULL
,
validator
);
result
=
SH_Validator_register_tag
(
validator
,
"html"
,
SH_TAG_TYPE_NORMAL
,
NULL
);
ck_assert_int_eq
(
TRUE
,
result
);
result
=
SH_Validator_register_tag
(
validator
,
"link"
,
SH_TAG_TYPE_VOID
,
NULL
);
ck_assert_int_eq
(
TRUE
,
result
);
/* test - self closing */
result
=
SH_Validator_is_self_closing_tag
(
validator
,
"link"
,
NULL
);
ck_assert_int_eq
(
TRUE
,
result
);
/* test - not self closing */
result
=
SH_Validator_is_self_closing_tag
(
validator
,
"html"
,
NULL
);
ck_assert_int_eq
(
FALSE
,
result
);
/* test - invalid tag */
result
=
SH_Validator_is_self_closing_tag
(
validator
,
"body"
,
NULL
);
ck_assert_int_eq
(
FALSE
,
result
);
/* cleanup */
SH_Validator_free
(
validator
);
}
START_TEST
(
test_validator_tag_self_closing_with_status
)
{
struct
SH_Status
status
;
struct
SH_Validator
*
validator
;
bool
result
;
/* setup */
validator
=
SH_Validator_new
(
NULL
);
ck_assert_ptr_ne
(
NULL
,
validator
);
result
=
SH_Validator_register_tag
(
validator
,
"html"
,
SH_TAG_TYPE_NORMAL
,
NULL
);
ck_assert_int_eq
(
TRUE
,
result
);
result
=
SH_Validator_register_tag
(
validator
,
"link"
,
SH_TAG_TYPE_VOID
,
NULL
);
ck_assert_int_eq
(
TRUE
,
result
);
/* test - self closing */
_status_preinit
(
status
);
result
=
SH_Validator_is_self_closing_tag
(
validator
,
"link"
,
&
status
);
ck_assert_int_eq
(
TRUE
,
result
);
ck_assert_int_eq
(
SUCCESS
,
status
.
status
);
/* test - not self closing */
_status_preinit
(
status
);
result
=
SH_Validator_is_self_closing_tag
(
validator
,
"html"
,
&
status
);
ck_assert_int_eq
(
FALSE
,
result
);
ck_assert_int_eq
(
SUCCESS
,
status
.
status
);
/* test - invalid tag */
_status_preinit
(
status
);
result
=
SH_Validator_is_self_closing_tag
(
validator
,
"body"
,
&
status
);
ck_assert_int_eq
(
FALSE
,
result
);
ck_assert_int_eq
(
E_VALUE
,
status
.
status
);
/* cleanup */
SH_Validator_free
(
validator
);
}
Suite
*
test_suite
(
void
)
{
Suite
*
s
;
...
...
@@ -628,6 +707,8 @@ Suite * test_suite (void)
tcase_add_test
(
tc_core
,
test_validator_tag_deregister_no_status
);
tcase_add_test
(
tc_core
,
test_validator_tag_deregister_with_status
);
tcase_add_test
(
tc_core
,
test_validator_tag_check
);
tcase_add_test
(
tc_core
,
test_validator_tag_self_closing_no_status
);
tcase_add_test
(
tc_core
,
test_validator_tag_self_closing_with_status
);
suite_add_tcase
(
s
,
tc_core
);
return
s
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment