github.com/Psiphon-Labs/psiphon-tunnel-core@v2.0.28+incompatible/psiphon/common/sss/gf256_test.go (about) 1 package sss 2 3 import ( 4 "testing" 5 ) 6 7 func TestMul(t *testing.T) { 8 if v, want := mul(90, 21), byte(254); v != want { 9 t.Errorf("Was %v, but expected %v", v, want) 10 } 11 } 12 13 func TestDiv(t *testing.T) { 14 if v, want := div(90, 21), byte(189); v != want { 15 t.Errorf("Was %v, but expected %v", v, want) 16 } 17 } 18 19 func TestDivZero(t *testing.T) { 20 if v, want := div(0, 2), byte(0); v != want { 21 t.Errorf("Was %v, but expected %v", v, want) 22 } 23 } 24 25 func TestDivByZero(t *testing.T) { 26 defer func() { 27 m := recover() 28 if m != "div by zero" { 29 t.Error(m) 30 } 31 }() 32 33 div(2, 0) 34 t.Error("Shouldn't have been able to divide those") 35 }