From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 3 Dec 2022 17:00:20 +0530 Subject: Adds most of the tools --- v_windows/v/old/vlib/net/html/parser_test.v | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 v_windows/v/old/vlib/net/html/parser_test.v (limited to 'v_windows/v/old/vlib/net/html/parser_test.v') diff --git a/v_windows/v/old/vlib/net/html/parser_test.v b/v_windows/v/old/vlib/net/html/parser_test.v new file mode 100644 index 0000000..274a47c --- /dev/null +++ b/v_windows/v/old/vlib/net/html/parser_test.v @@ -0,0 +1,41 @@ +module html + +import strings + +fn test_split_parse() { + mut parser := Parser{} + parser.init() + parser.split_parse(' Hum... ') + parser.split_parse('A Tit') + parser.split_parse('\nle') + parser.split_parse('\t\t\t

') + parser.split_parse('Nice Test!

') + parser.split_parse('') + parser.finalize() + assert parser.tags.len == 11 + assert parser.tags[3].content == ' Hum... A Tit\nle' +} + +fn test_giant_string() { + mut temp_html := strings.new_builder(200) + mut parser := Parser{} + temp_html.write_string('Giant String') + for counter := 0; counter < 2000; counter++ { + temp_html.write_string("
Look at $counter
") + } + temp_html.write_string('') + parser.parse_html(temp_html.str()) + assert parser.tags.len == 4009 +} + +fn test_script_tag() { + mut parser := Parser{} + script_content := "\nvar googletag = googletag || {};\ngoogletag.cmd = googletag.cmd || [];if(3 > 5) {console.log('Birl');}\n" + temp_html := '' + parser.parse_html(temp_html) + assert parser.tags[2].content.len == script_content.replace('\n', '').len +} -- cgit v1.2.3