OSDN Git Service

libgo: Update to weekly.2011-12-14.
[pf3gnuchains/gcc-fork.git] / libgo / go / go / doc / comment_test.go
index 6424053..e8d7f2e 100644 (file)
@@ -5,6 +5,7 @@
 package doc
 
 import (
+       "reflect"
        "testing"
 )
 
@@ -38,3 +39,45 @@ func TestIsHeading(t *testing.T) {
                }
        }
 }
+
+var blocksTests = []struct {
+       in  string
+       out []block
+}{
+       {
+               in: `Para 1.
+Para 1 line 2.
+
+Para 2.
+
+Section
+
+Para 3.
+
+       pre
+       pre1
+
+Para 4.
+       pre
+       pre2
+`,
+               out: []block{
+                       {opPara, []string{"Para 1.\n", "Para 1 line 2.\n"}},
+                       {opPara, []string{"Para 2.\n"}},
+                       {opHead, []string{"Section"}},
+                       {opPara, []string{"Para 3.\n"}},
+                       {opPre, []string{"pre\n", "pre1\n"}},
+                       {opPara, []string{"Para 4.\n"}},
+                       {opPre, []string{"pre\n", "pre2\n"}},
+               },
+       },
+}
+
+func TestBlocks(t *testing.T) {
+       for i, tt := range blocksTests {
+               b := blocks(tt.in)
+               if !reflect.DeepEqual(b, tt.out) {
+                       t.Errorf("#%d: mismatch\nhave: %v\nwant: %v", i, b, tt.out)
+               }
+       }
+}