minify-html/test/hb/unit/attr/val/quoted.test.c

58 lines
1.6 KiB
C
Raw Normal View History

#include <stdio.h>
#include <hb/rule.h>
#include <hb/unit.h>
// An attribute value:
// - delimited by double quotes
// - containing one single quote literal
// - containing one single quote encoded
// - containing three double quotes encoded
// - with multiple whitespace sequences of length 2 and higher, including at the start and end
#define INPUT "\" abc&apos;'&quot; &quot;&quot; a \" 1"
int main(void) {
printf("Test started\n");
hb_rule_init();
hb_err_set* suppressed = hb_err_set_create();
hb_rune* out = calloc(sizeof(INPUT) - 1, sizeof(hb_rune));
hb_cfg cfg = {
.collapse_whitespace = {
.mode = HB_CFG_SET_MODE_ALL,
.set = NULL,
},
.destroy_whole_whitespace = {
.mode = HB_CFG_SET_MODE_ALL,
.set = NULL,
},
.trim_whitespace = {
.mode = HB_CFG_SET_MODE_ALL,
.set = NULL,
},
.suppressed_errors = *suppressed,
.trim_class_attributes = true,
.decode_entities = true,
.remove_attr_quotes = true,
.remove_comments = true,
.remove_optional_tags = true,
.remove_tag_whitespace = true,
};
hb_proc proc = {
.cfg = &cfg,
.name = "test",
.src = INPUT "\xFF",
.src_len = sizeof(INPUT) - 1,
.src_next = 0,
.out = out,
.out_next = 0,
};
hb_unit_attr_type type = hb_unit_attr_val_quoted(&proc, true);
printf("%s\n", out);
hb_err_set_destroy(suppressed);
}