From 4c0470d24b00445b67a5a0accde8538d8c810730 Mon Sep 17 00:00:00 2001 From: clsr Date: Fri, 25 Aug 2017 15:04:40 +0200 Subject: Make TableBlock extend ContentBlock; add AppendChild to ContainerBlock --- write_test.go | 150 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 77 insertions(+), 73 deletions(-) (limited to 'write_test.go') diff --git a/write_test.go b/write_test.go index bf829a0..18809b1 100644 --- a/write_test.go +++ b/write_test.go @@ -108,79 +108,83 @@ content name: "section", args: []string{"of the"}, children: []Block{ - &TableBlock{[]Block{ - &HeaderBlock{ContentBlock{ - name: "header", - args: []string{}, - children: []Block{ - &TextBlock{ - Contents: TextPlainContents{[]string{ - "Column 1", - }}, - }, - &TextBlock{ - Contents: TextPlainContents{[]string{ - "Column 2", - }}, + &TableBlock{ContentBlock{ + name: "table", + args: nil, + children: []Block{ + &HeaderBlock{ContentBlock{ + name: "header", + args: []string{}, + children: []Block{ + &TextBlock{ + Contents: TextPlainContents{[]string{ + "Column 1", + }}, + }, + &TextBlock{ + Contents: TextPlainContents{[]string{ + "Column 2", + }}, + }, }, - }, - }}, - &RowBlock{ContentBlock{ - name: "row", - args: []string{}, - children: []Block{ - &TextBlock{ - Contents: TextPlainContents{[]string{ - "CNM", - }}, + }}, + &RowBlock{ContentBlock{ + name: "row", + args: []string{}, + children: []Block{ + &TextBlock{ + Contents: TextPlainContents{[]string{ + "CNM", + }}, + }, + &TextBlock{ + Contents: TextPlainContents{[]string{ + "document", + "format", + }}, + }, }, - &TextBlock{ - Contents: TextPlainContents{[]string{ - "document", - "format", + }}, + &RowBlock{ContentBlock{ + name: "row", + args: []string{""}, + children: []Block{ + &SectionBlock{ContentBlock{ + name: "section", + args: []string{"", "", ""}, }}, - }, - }, - }}, - &RowBlock{ContentBlock{ - name: "row", - args: []string{""}, - children: []Block{ - &SectionBlock{ContentBlock{ - name: "section", - args: []string{"", "", ""}, - }}, - &ListBlock{ContentBlock{ - name: "list", - args: nil, - children: []Block{ - &TextBlock{ - Contents: TextPlainContents{[]string{ - "ipsum", - }}, - }, - &ListBlock{ContentBlock{ - name: "list", - args: []string{"ordered"}, - children: []Block{ - &ListBlock{ContentBlock{ - name: "list", - args: []string{"unordered"}, - children: []Block{ - &TextBlock{ - Contents: TextPlainContents{[]string{ - "dolor", - "sit amet", - }}, - }, - }, + &ListBlock{ContentBlock{ + name: "list", + args: nil, + children: []Block{ + &TextBlock{ + Contents: TextPlainContents{[]string{ + "ipsum", }}, }, - }}, - }, - }}, - }, - }}, + &ListBlock{ContentBlock{ + name: "list", + args: []string{"ordered"}, + children: []Block{ + &ListBlock{ContentBlock{ + name: "list", + args: []string{"unordered"}, + children: []Block{ + &TextBlock{ + Contents: TextPlainContents{[]string{ + "dolor", + "sit amet", + }}, + }, + }, + }}, + }, + }}, + }, + }}, + }, + }}, + }, }}, }, }}, @@ -205,12 +209,12 @@ func TestWrite(t *testing.T) { t.Fatalf("Write error: %v", err) } w := buf.String() - t.Log("====================") - t.Log("expected:\n" + k) - t.Log("--------------------") - t.Log(" got:\n" + w) - t.Log("====================") if k != w { + t.Log("====================") + t.Log("expected:\n" + k) + t.Log("--------------------") + t.Log(" got:\n" + w) + t.Log("====================") t.Fatal("Write: output did not match expected document") } }) -- cgit