43 lines
850 B
Go
43 lines
850 B
Go
package bloat_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.bivouac.wiki/go/bloat"
|
|
)
|
|
|
|
// TestPlain without keys...
|
|
func TestPlain(t *testing.T) {
|
|
type foo struct {
|
|
Abc bool `xml:"Abc"`
|
|
Plain string `xml:"Plain"`
|
|
}
|
|
sender, err := bloat.NewPlainBloat[foo]()
|
|
if err != nil {
|
|
t.Log(err.Error())
|
|
t.Errorf("init failed")
|
|
}
|
|
data := foo{
|
|
Abc: true,
|
|
Plain: "this is plain",
|
|
}
|
|
recipient, err := bloat.NewPlainBloat[foo]()
|
|
if err != nil {
|
|
t.Log(err.Error())
|
|
t.Errorf("recipient init failed")
|
|
}
|
|
plain, err := sender.WritePlain(data, recipient)
|
|
if err != nil {
|
|
t.Log(err.Error())
|
|
t.Errorf("writing plain failed")
|
|
}
|
|
// t.Log(string(plain))
|
|
res, err := recipient.ReadPlain(plain, sender)
|
|
if res.Plain != "this is plain" {
|
|
t.Errorf("text does not match")
|
|
}
|
|
if err != nil {
|
|
t.Log(err.Error())
|
|
t.Errorf("verification failed")
|
|
}
|
|
}
|