Files
coding/coding_test.go
2023-12-26 08:12:24 -08:00

37 lines
653 B
Go

package coding_test
import (
"bufio"
"os"
"testing"
"github.com/samber/lo"
"github.com/securemesh/coding"
"github.com/securemesh/coding/seeds"
)
func TestSimple(t *testing.T) {
msg := []byte("this is a test. this is only a test.")
encoded := coding.Encode(seeds.ChatHeap(), msg)
t.Logf("orig=%d encoded=%d", len(msg), len(encoded))
}
func TestSMS(t *testing.T) {
fh := lo.Must(os.Open("sms.txt"))
defer fh.Close()
s := bufio.NewScanner(fh)
orig := 0
encoded := 0
for s.Scan() {
msg := s.Bytes()
e := coding.Encode(seeds.ChatHeap(), msg)
orig += len(msg)
encoded += len(e)
}
t.Logf("orig=%d encoded=%d", orig, encoded)
}