Debian Codegraph @

yaml_test_suite_test.go

raw symbols SCIP
1 //go:build !windows
2
3 package yaml_testscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/
4
5 import (
6 "bytesscip-go gomod github.com/golang/go/src go1.21.0 bytes/"
7 "encoding/jsonscip-go gomod github.com/golang/go/src go1.21.0 `encoding/json`/"
8 "ioscip-go gomod github.com/golang/go/src go1.21.0 io/"
9 "runtime/debugscip-go gomod github.com/golang/go/src go1.21.0 `runtime/debug`/"
10 "testingscip-go gomod github.com/golang/go/src go1.21.0 testing/"
11
12 "github.com/goccy/go-yamlscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/"
13 "github.com/goccy/go-yaml/testdata/yaml-test-suitescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/"
14 )
15
16 var failureTestNamesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/failureTestNames. = []string{
17 "anchors-on-empty-scalars", // no json.
18 "aliases-in-flow-objects", // no json.
19 "aliases-in-explicit-block-mapping", // no json.
20 "block-mapping-with-missing-keys", // no json.
21 "empty-implicit-key-in-single-pair-flow-sequences", // no json.
22 "empty-keys-in-block-and-flow-mapping", // no json.
23 "empty-lines-at-end-of-document", // no json.
24 "flow-mapping-separate-values", // no json.
25 "flow-sequence-in-flow-mapping", // no json.
26 "implicit-flow-mapping-key-on-one-line", // no json.
27 "mapping-key-and-flow-sequence-item-anchors", // no json.
28 "nested-implicit-complex-keys", // no json.
29 "question-mark-edge-cases/00", // no json.
30 "question-mark-edge-cases/01", // no json.
31 "single-character-streams/01", // no json.
32 "single-pair-implicit-entries", // no json.
33 "spec-example-2-11-mapping-between-sequences", // no json.
34 "spec-example-6-12-separation-spaces", // no json.
35 "spec-example-7-16-flow-mapping-entries", // no json.
36 "spec-example-7-3-completely-empty-flow-nodes", // no json.
37 "spec-example-8-18-implicit-block-mapping-entries", // no json.
38 "spec-example-8-19-compact-block-mappings", // no json.
39 "syntax-character-edge-cases/00", // no json.
40 "tags-on-empty-scalars", // no json.
41 "various-combinations-of-explicit-block-mappings", // no json.
42 "various-trailing-comments", // no json.
43 "various-trailing-comments-1-3", // no json.
44 "zero-indented-sequences-in-explicit-mapping-keys", // no json.
45
46 "colon-at-the-beginning-of-adjacent-flow-scalar",
47 "comment-without-whitespace-after-doublequoted-scalar",
48 "construct-binary",
49 "dash-in-flow-sequence",
50 "flow-collections-over-many-lines/01",
51 "flow-mapping-colon-on-line-after-key/02",
52 "invalid-comment-after-comma",
53 "invalid-comment-after-end-of-flow-sequence",
54 "invalid-comma-in-tag",
55 "plain-dashes-in-flow-sequence",
56 "spec-example-9-3-bare-documents",
57 "spec-example-9-6-stream",
58 "spec-example-9-6-stream-1-3",
59 "tabs-in-various-contexts/003",
60 "tabs-that-look-like-indentation/04",
61 "tag-shorthand-used-in-documents-but-only-defined-in-the-first",
62 "trailing-line-of-spaces/01", // last '\n' character is needed ?
63 "wrong-indented-flow-sequence", // error ?
64 "wrong-indented-multiline-quoted-scalar", // error ?
65 }
66
67 var failureTestNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/failureTestNameMap. map[string]struct{}
68
69 func initscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/init().() {
70 failureTestNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/failureTestNameMap. = make(map[string]struct{})
71 for _, name := range failureTestNamesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/failureTestNames. {
72 failureTestNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/failureTestNameMap.[name] = struct{}{}
73 }
74 }
75
76 func TestYAMLTestSuitescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/TestYAMLTestSuite().(t *testingscip-go gomod github.com/golang/go/src go1.21.0 testing/.Tscip-go gomod github.com/golang/go/src go1.21.0 testing/T#) {
77 tests, err := yamltestsuitescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/.TestSuitesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuites().()
78 if err != nil {
79 t.Fatalscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Fatal().(err)
80 }
81
82 for _, test := range tests {
83 if _, exists := failureTestNameMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/failureTestNameMap.[test.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#Name.]; exists {
84 continue
85 }
86 t.Runscip-go gomod github.com/golang/go/src go1.21.0 testing/T#Run().(test.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#Name., func(t *testingscip-go gomod github.com/golang/go/src go1.21.0 testing/.Tscip-go gomod github.com/golang/go/src go1.21.0 testing/T#) {
87 defer func() {
88 if e := recover(); e != nil {
89 t.Fatalfscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Fatalf().("panic occurred.\n[input]\n%s\nstack[%s]", string(test.InYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#InYAML.), debugscip-go gomod github.com/golang/go/src go1.21.0 `runtime/debug`/.Stackscip-go gomod github.com/golang/go/src go1.21.0 `runtime/debug`/Stack().())
90 }
91 }()
92
93 if test.Errorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#Error. {
94 var v any
95 if err := yamlscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/.Unmarshalscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Unmarshal().(test.InYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#InYAML., &v); err == nil {
96 t.Fatalfscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Fatalf().("expected error.\n[input]\n%s\n", string(test.InYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#InYAML.))
97 }
98 return
99 }
100
101 dec := yamlscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/.NewDecoderscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/NewDecoder().(bytesscip-go gomod github.com/golang/go/src go1.21.0 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.21.0 bytes/NewReader().(test.InYAMLscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#InYAML.))
102 var idx int
103 for {
104 var v any
105 if err := dec.Decodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml`/Decoder#Decode().(&v); err != nil {
106 if err == ioscip-go gomod github.com/golang/go/src go1.21.0 io/.EOFscip-go gomod github.com/golang/go/src go1.21.0 io/EOF. {
107 break
108 }
109 t.Fatalscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Fatal().(err)
110 }
111 if len(test.InJSONscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#InJSON.) <= idx {
112 t.Fatalfscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Fatalf().("expected json value is nothing but got %v", v)
113 }
114 expected, err := jsonscip-go gomod github.com/golang/go/src go1.21.0 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.21.0 `encoding/json`/Marshal().(test.InJSONscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#InJSON.[idx])
115 if err != nil {
116 t.Fatalfscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Fatalf().("failed to encode json value: %v", err)
117 }
118 got, err := jsonscip-go gomod github.com/golang/go/src go1.21.0 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.21.0 `encoding/json`/Marshal().(v)
119 if err != nil {
120 t.Fatalfscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Fatalf().("failed to encode json value: %v", err)
121 }
122 if !bytesscip-go gomod github.com/golang/go/src go1.21.0 bytes/.Equalscip-go gomod github.com/golang/go/src go1.21.0 bytes/Equal().(expected, got) {
123 t.Fatalfscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Fatalf().("json mismatch [%s]:\n[expected]\n%s\n[got]\n%s\n", test.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/testdata/yaml-test-suite`/TestSuite#Name., string(expected), string(got))
124 }
125 idx++
126 }
127 })
128 }
129 total := len(tests)
130 failed := len(failureTestNamesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml_test`/failureTestNames.)
131 passed := total - failed
132 passedRate := float32(passed) / float32(total) * 100
133 t.Logfscip-go gomod github.com/golang/go/src go1.21.0 testing/common#Logf().("total:[%d] passed:[%d] failure:[%d] passedRate:[%f%%]", total, passed, failed, passedRate)
134 }