From 50104cc32a498f7517a51c8dc93106c51c7a54b4 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Wed, 20 Apr 2011 15:44:41 +0200 Subject: Imported Upstream version 2011.03.07.1 --- src/pkg/xml/xml_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/pkg/xml/xml_test.go') diff --git a/src/pkg/xml/xml_test.go b/src/pkg/xml/xml_test.go index 317ecabd9..887bc3d14 100644 --- a/src/pkg/xml/xml_test.go +++ b/src/pkg/xml/xml_test.go @@ -185,6 +185,52 @@ func TestRawToken(t *testing.T) { } } +// Ensure that directives (specifically !DOCTYPE) include the complete +// text of any nested directives, noting that < and > do not change +// nesting depth if they are in single or double quotes. + +var nestedDirectivesInput = ` +]> +">]> +]> +'>]> +]> +'>]> +]> +` + +var nestedDirectivesTokens = []Token{ + CharData([]byte("\n")), + Directive([]byte(`DOCTYPE []`)), + CharData([]byte("\n")), + Directive([]byte(`DOCTYPE [">]`)), + CharData([]byte("\n")), + Directive([]byte(`DOCTYPE []`)), + CharData([]byte("\n")), + Directive([]byte(`DOCTYPE ['>]`)), + CharData([]byte("\n")), + Directive([]byte(`DOCTYPE []`)), + CharData([]byte("\n")), + Directive([]byte(`DOCTYPE ['>]`)), + CharData([]byte("\n")), + Directive([]byte(`DOCTYPE []`)), + CharData([]byte("\n")), +} + +func TestNestedDirectives(t *testing.T) { + p := NewParser(StringReader(nestedDirectivesInput)) + + for i, want := range nestedDirectivesTokens { + have, err := p.Token() + if err != nil { + t.Fatalf("token %d: unexpected error: %s", i, err) + } + if !reflect.DeepEqual(have, want) { + t.Errorf("token %d = %#v want %#v", i, have, want) + } + } +} + func TestToken(t *testing.T) { p := NewParser(StringReader(testInput)) -- cgit v1.2.3