mirror of
https://github.com/wader/fq.git
synced 2024-12-25 14:23:18 +03:00
41 lines
699 B
Go
41 lines
699 B
Go
package fqtest_test
|
|
|
|
import (
|
|
"log"
|
|
"regexp"
|
|
"testing"
|
|
|
|
"github.com/wader/fq/internal/deepequal"
|
|
"github.com/wader/fq/pkg/fqtest"
|
|
)
|
|
|
|
func TestSectionParser(t *testing.T) {
|
|
actualSections := fqtest.SectionParser(
|
|
regexp.MustCompile(`^(?:(a:)|(b:))$`),
|
|
`
|
|
a:
|
|
c
|
|
c
|
|
b:
|
|
a:
|
|
c
|
|
a:
|
|
`[1:])
|
|
|
|
expectedSections := []fqtest.Section{
|
|
{LineNr: 1, Name: "a:", Value: "c\nc\n"},
|
|
{LineNr: 4, Name: "b:", Value: ""},
|
|
{LineNr: 5, Name: "a:", Value: "c\n"},
|
|
{LineNr: 7, Name: "a:", Value: ""},
|
|
}
|
|
|
|
deepequal.Error(t, "sections", expectedSections, actualSections)
|
|
}
|
|
|
|
func TestUnescape(t *testing.T) {
|
|
|
|
s := fqtest.Unescape(`asd\n\r\t \0b11110000 asd \0xffcb sdfd `)
|
|
log.Printf("s: %v\n", []byte(s))
|
|
|
|
}
|