forked from rsc/markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable_test.go
More file actions
40 lines (36 loc) · 805 Bytes
/
table_test.go
File metadata and controls
40 lines (36 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package markdown
import "testing"
var tableCountTests = []struct {
row string
n int
}{
{"|", 1},
{"|x|", 1},
{"||", 1},
{"| |", 1},
{"| | |", 2},
{"| | Foo | Bar |", 3},
{"| | Foo | Bar |", 3},
{"", 1},
{"|a|b", 2},
{"|a| ", 1},
{" |b", 1},
{"a|b", 2},
{`x\|y`, 1},
{`x\\|y`, 1},
{`x\\\|y`, 1},
{`x\\\\|y`, 1},
{`x\\\\\|y`, 1},
{`| 0\|1\\|2\\\|3\\\\|4\\\\\|5\\\\\\|6\\\\\\\|7\\\\\\\\|8 |`, 1},
}
func TestTableCount(t *testing.T) {
for _, tt := range tableCountTests {
n := tableCount(tableTrimOuter(tt.row))
if n != tt.n {
t.Errorf("tableCount(%#q) = %d, want %d", tt.row, n, tt.n)
}
}
}