Files
coding/coding_test.go

37 lines
653 B
Go
Raw Normal View History

2023-12-24 17:57:00 -05:00
package coding_test
import (
"bufio"
"os"
"testing"
"github.com/samber/lo"
"github.com/securemesh/coding"
2023-12-26 08:12:24 -08:00
"github.com/securemesh/coding/seeds"
2023-12-24 17:57:00 -05:00
)
func TestSimple(t *testing.T) {
msg := []byte("this is a test. this is only a test.")
2023-12-26 08:12:24 -08:00
encoded := coding.Encode(seeds.ChatHeap(), msg)
2023-12-24 17:57:00 -05:00
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()
2023-12-26 08:12:24 -08:00
e := coding.Encode(seeds.ChatHeap(), msg)
2023-12-24 17:57:00 -05:00
orig += len(msg)
encoded += len(e)
}
t.Logf("orig=%d encoded=%d", orig, encoded)
}