Repository navigation
Expand file tree
/
Copy patharray_horizontal_rules_test.go
More file actions
57 lines (54 loc) · 1.61 KB
/
Copy patharray_horizontal_rules_test.go
File metadata and controls
57 lines (54 loc) · 1.61 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: Apache-2.0
package mathjax_test
import (
"encoding/json"
"os"
"testing"
mathjax "github.com/d2lang/mathjax-go"
)
func TestArrayHorizontalRuleOriginalReferences(t *testing.T) {
data, err := os.ReadFile("testdata/array_horizontal_rules_mathjax_3_2_2.json")
if err != nil {
t.Fatal(err)
}
var fixture struct {
MathjaxGitCommit string
Counts struct{ Total, Exact, Raw, ExactErrors, ExactValid int }
Cases []struct {
Name, TeX, SVG string
Display bool
}
}
if err := json.Unmarshal(data, &fixture); err != nil {
t.Fatal(err)
}
if fixture.MathjaxGitCommit != "ad8f5c21cb810236551da8c6512ba733e67357ee" || fixture.Counts.Total != 2444 || fixture.Counts.Exact != 2412 || fixture.Counts.Raw != 32 || fixture.Counts.ExactErrors != 750 || fixture.Counts.ExactValid != 1662 || len(fixture.Cases) != 2412 {
t.Fatal("unbound array horizontal-rule references")
}
seenNames := map[string]bool{}
seenInputs := map[struct {
tex string
display bool
}]bool{}
for _, c := range fixture.Cases {
input := struct {
tex string
display bool
}{c.TeX, c.Display}
if c.Name == "" || c.SVG == "" || seenNames[c.Name] || seenInputs[input] {
t.Fatal("invalid original reference", c.Name)
}
seenNames[c.Name], seenInputs[input] = true, true
t.Run(c.Name, func(t *testing.T) {
options := mathjax.DefaultOptions()
options.Display = c.Display
got, err := mathjax.RenderWithOptions(c.TeX, options)
if err != nil {
t.Fatal(err)
}
if got != c.SVG {
t.Fatalf("complete original SVG differs\ngot: %s\nwant: %s", got, c.SVG)
}
})
}
}