From d913e6e91e43241b0105afbbad7db5c5bcda0255 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 12 Sep 2023 08:23:52 +0200 Subject: feat: implement BasicEmitter --- integration_tests/tests/test_html5lib.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'integration_tests') diff --git a/integration_tests/tests/test_html5lib.rs b/integration_tests/tests/test_html5lib.rs index 42d93f1..3e07531 100644 --- a/integration_tests/tests/test_html5lib.rs +++ b/integration_tests/tests/test_html5lib.rs @@ -6,7 +6,8 @@ use html5lib_tests::{ use html5tokenizer::{ offset::{Offset, PosTrackingReader, Position}, reader::Reader, - CdataAction, Emitter, Error, Event, InternalState, Token, Tokenizer, TracingEmitter, + BasicEmitter, CdataAction, Emitter, Error, Event, InternalState, Token, Tokenizer, + TracingEmitter, }; use similar_asserts::assert_eq; @@ -68,7 +69,26 @@ fn test_tokenizer_file(path: &Path) { fn run_test(fname: &str, test_i: usize, test: Test) { for state in &test.initial_states { - // TODO: test BasicEmitter here once it's implemented + run_test_inner( + fname, + test_i, + &test, + state, + Tokenizer::new(&test.input, BasicEmitter::default()), + "BasicEmitter string", + ); + + run_test_inner( + fname, + test_i, + &test, + state, + Tokenizer::new( + BufReader::new(test.input.as_bytes()), + BasicEmitter::default(), + ), + "BasicEmitter bufread", + ); run_test_inner( fname, @@ -186,6 +206,12 @@ trait DrainErrors { fn drain_errors(&mut self) -> Box)> + '_>; } +impl DrainErrors for BasicEmitter { + fn drain_errors(&mut self) -> Box)> + '_> { + Box::new(self.drain_errors()) + } +} + impl DrainErrors for TracingEmitter { fn drain_errors(&mut self) -> Box)> + '_> { Box::new(self.drain_errors()) -- cgit v1.2.3