(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestProjectDocumentTopLevelBlockOrder(t *testing.T) { |
| 165 | t.Parallel() |
| 166 | document := &docs.Document{Body: &docs.Body{Content: []*docs.StructuralElement{ |
| 167 | nil, |
| 168 | {StartIndex: 0, EndIndex: 1, SectionBreak: &docs.SectionBreak{}}, |
| 169 | testParagraph(1, 7, "first\n"), |
| 170 | {StartIndex: 7, EndIndex: 12, TableOfContents: &docs.TableOfContents{}}, |
| 171 | {StartIndex: 12, EndIndex: 20, Table: &docs.Table{TableRows: []*docs.TableRow{nil}}}, |
| 172 | testParagraph(20, 27, "last\n"), |
| 173 | }}} |
| 174 | |
| 175 | projection := ProjectDocument(document) |
| 176 | if projection.Legacy == nil { |
| 177 | t.Fatal("legacy projection is nil") |
| 178 | } |
| 179 | wantKinds := []DocumentBlockKind{ |
| 180 | DocumentBlockSectionBreak, |
| 181 | DocumentBlockParagraph, |
| 182 | DocumentBlockTableOfContents, |
| 183 | DocumentBlockTable, |
| 184 | DocumentBlockParagraph, |
| 185 | } |
| 186 | gotKinds := make([]DocumentBlockKind, len(projection.Legacy.Blocks)) |
| 187 | for index, block := range projection.Legacy.Blocks { |
| 188 | gotKinds[index] = block.Kind |
| 189 | } |
| 190 | if !reflect.DeepEqual(gotKinds, wantKinds) { |
| 191 | t.Fatalf("block kinds = %v, want %v", gotKinds, wantKinds) |
| 192 | } |
| 193 | if projection.Legacy.Blocks[1].ItemIndex != 0 || |
| 194 | projection.Legacy.Blocks[3].ItemIndex != 0 || |
| 195 | projection.Legacy.Blocks[4].ItemIndex != 1 { |
| 196 | t.Fatalf("blocks = %+v", projection.Legacy.Blocks) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | func TestProjectDocumentPreservesProviderUTF16Ranges(t *testing.T) { |
| 201 | t.Parallel() |
nothing calls this directly
no test coverage detected