Skip to content

Commit 265fbfa

Browse files
committed
Add mul/div smoke test.
Signed-off-by: Felix Fontein <felix@fontein.de>
1 parent 3ae9e47 commit 265fbfa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

shamir/shamir_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,22 @@ func TestCombine(t *testing.T) {
115115
}
116116
}
117117

118+
func TestField_MulDivSmoke(t *testing.T) {
119+
for a := range 256 {
120+
for b := range 256 {
121+
if b == 0 {
122+
if out := mult(uint8(a), uint8(b)); out != 0 {
123+
t.Fatalf("Bad: %v * %v = %v 0", a, b, out)
124+
}
125+
} else {
126+
if out := div(mult(uint8(a), uint8(b)), uint8(b)); out != uint8(a) {
127+
t.Fatalf("Bad: (%v * %v) / %v = %v %v", a, b, b, out, a)
128+
}
129+
}
130+
}
131+
}
132+
}
133+
118134
func TestField_Add(t *testing.T) {
119135
if out := add(16, 16); out != 0 {
120136
t.Fatalf("Bad: %v 16", out)

0 commit comments

Comments
 (0)