1
1
mirror of https://github.com/wader/fq.git synced 2024-12-26 15:02:28 +03:00
fq/pkg/fqtest/fqtest_test.go
2021-09-12 13:08:50 +02:00

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))
}