mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
First commit
This commit is contained in:
commit
8ffb773f43
2121 changed files with 1118910 additions and 0 deletions
86
vendor/github.com/andybalholm/cascadia/parser_test.go
generated
vendored
Normal file
86
vendor/github.com/andybalholm/cascadia/parser_test.go
generated
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
package cascadia
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var identifierTests = map[string]string{
|
||||
"x": "x",
|
||||
"96": "",
|
||||
"-x": "-x",
|
||||
`r\e9 sumé`: "résumé",
|
||||
`a\"b`: `a"b`,
|
||||
}
|
||||
|
||||
func TestParseIdentifier(t *testing.T) {
|
||||
for source, want := range identifierTests {
|
||||
p := &parser{s: source}
|
||||
got, err := p.parseIdentifier()
|
||||
|
||||
if err != nil {
|
||||
if want == "" {
|
||||
// It was supposed to be an error.
|
||||
continue
|
||||
}
|
||||
t.Errorf("parsing %q: got error (%s), want %q", source, err, want)
|
||||
continue
|
||||
}
|
||||
|
||||
if want == "" {
|
||||
if err == nil {
|
||||
t.Errorf("parsing %q: got %q, want error", source, got)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if p.i < len(source) {
|
||||
t.Errorf("parsing %q: %d bytes left over", source, len(source)-p.i)
|
||||
continue
|
||||
}
|
||||
|
||||
if got != want {
|
||||
t.Errorf("parsing %q: got %q, want %q", source, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var stringTests = map[string]string{
|
||||
`"x"`: "x",
|
||||
`'x'`: "x",
|
||||
`'x`: "",
|
||||
"'x\\\r\nx'": "xx",
|
||||
`"r\e9 sumé"`: "résumé",
|
||||
`"a\"b"`: `a"b`,
|
||||
}
|
||||
|
||||
func TestParseString(t *testing.T) {
|
||||
for source, want := range stringTests {
|
||||
p := &parser{s: source}
|
||||
got, err := p.parseString()
|
||||
|
||||
if err != nil {
|
||||
if want == "" {
|
||||
// It was supposed to be an error.
|
||||
continue
|
||||
}
|
||||
t.Errorf("parsing %q: got error (%s), want %q", source, err, want)
|
||||
continue
|
||||
}
|
||||
|
||||
if want == "" {
|
||||
if err == nil {
|
||||
t.Errorf("parsing %q: got %q, want error", source, got)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if p.i < len(source) {
|
||||
t.Errorf("parsing %q: %d bytes left over", source, len(source)-p.i)
|
||||
continue
|
||||
}
|
||||
|
||||
if got != want {
|
||||
t.Errorf("parsing %q: got %q, want %q", source, got, want)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue