bloat/module_test.go
2025-04-07 01:36:55 -06:00

47 lines
796 B
Go

package bloat
import (
"fmt"
"testing"
)
func TestItem(t *testing.T) {
type typ struct {
A int
B string
}
data := typ{
A: 1,
B: "hello",
}
trySender, err := NewBloat[typ]()
if err != nil {
fmt.Println(err)
t.Errorf("error on newbloat")
}
trySender.Obj = typ{}
tryReceiver, err := NewBloat[typ]()
if err != nil {
fmt.Println(err)
t.Errorf("error on newbloat")
}
cyphertext, err := trySender.Write(data, tryReceiver)
if err != nil {
fmt.Println(err)
t.Errorf("error on write")
}
plainobj, err := tryReceiver.Read(cyphertext, trySender)
if err != nil {
fmt.Println(err)
t.Errorf("error on read")
}
if plainobj.A != 1 {
fmt.Println(err)
t.Errorf("int not equal")
}
if plainobj.B != "hello" {
fmt.Println(err)
t.Errorf("string not hello")
}
}