63 lines
1.1 KiB
Go
63 lines
1.1 KiB
Go
package twt_fbs_test
|
|
|
|
import (
|
|
"bytes"
|
|
_ "embed"
|
|
"encoding/base64"
|
|
"fmt"
|
|
"log"
|
|
"testing"
|
|
|
|
"go.yarn.social/lextwt"
|
|
"go.yarn.social/types"
|
|
|
|
twt_fbs "go.sour.is/lextwt-encoding/twt-fbs"
|
|
)
|
|
|
|
func TestToLextwt(t *testing.T) {
|
|
twt, err := lextwt.ParseLine("2021-01-24T02:19:54-07:00 (#asdf1234) @xuu This is a `twt`!\u2028Next Line!", &types.Twter{Nick: "xuu@sour.is", URI: "https://xuu.txt"})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
fb := twt_fbs.EncodeTwt(twt)
|
|
|
|
// t.Log(enc(fb))
|
|
|
|
out, err := twt_fbs.DecodeLextwt(fb)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
outs := fmt.Sprint(out)
|
|
twts := fmt.Sprint(twt)
|
|
|
|
if outs != twts {
|
|
t.Errorf("got %q, want %q", outs, twts)
|
|
}
|
|
}
|
|
|
|
//go:embed example.txt
|
|
var input []byte
|
|
|
|
func TestToRegistry(t *testing.T) {
|
|
registry, err := lextwt.ParseRegistry(bytes.NewReader(input))
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
fb := twt_fbs.EncodeRegistry(registry)
|
|
|
|
t.Log(enc(fb))
|
|
|
|
out, err := twt_fbs.DecodeRegistry(fb)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
outs := fmt.Sprint(out)
|
|
t.Log(outs)
|
|
}
|
|
|
|
var enc = base64.RawStdEncoding.EncodeToString
|