| 634 | } |
| 635 | |
| 636 | func TestDirective(t *testing.T) { |
| 637 | s := `<?xml version="1.0" encoding="UTF-8"?> |
| 638 | <!DOCTYPE Workspace> |
| 639 | <Workspace xmlns="http://www.qlcplus.org/Workspace" CurrentWindow="FixtureManager"> |
| 640 | <Creator> |
| 641 | <Name>Q Light Controller Plus</Name> |
| 642 | <Version>4.12.3</Version> |
| 643 | </Creator> |
| 644 | </Workspace>` |
| 645 | doc, err := Parse(strings.NewReader(s)) |
| 646 | if err != nil { |
| 647 | t.Fatal(err.Error()) |
| 648 | } |
| 649 | |
| 650 | top := doc.FirstChild |
| 651 | n := top.NextSibling.NextSibling |
| 652 | if n == nil { |
| 653 | t.Error("should be not nil, but got nil") |
| 654 | return |
| 655 | } |
| 656 | if v := n.Type; v != NotationNode { |
| 657 | t.Errorf("expected the node type is NotationNode, but got %d", v) |
| 658 | } |
| 659 | if expected, val := `<!DOCTYPE Workspace>`, n.OutputXML(true); expected != val { |
| 660 | t.Errorf("expected %s but got %s", expected, val) |
| 661 | } |
| 662 | |
| 663 | list := Find(doc, `//*`) |
| 664 | if m := len(list); m != 4 { |
| 665 | t.Errorf("expected count is 4 but got %d", m) |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | func TestLineNumbers(t *testing.T) { |
| 670 | s := `<?xml version="1.0" encoding="UTF-8"?> |