gf256_test.go 619 B

1234567891011121314151617181920212223242526272829303132333435
  1. package sss
  2. import (
  3. "testing"
  4. )
  5. func TestMul(t *testing.T) {
  6. if v, want := mul(90, 21), byte(254); v != want {
  7. t.Errorf("Was %v, but expected %v", v, want)
  8. }
  9. }
  10. func TestDiv(t *testing.T) {
  11. if v, want := div(90, 21), byte(189); v != want {
  12. t.Errorf("Was %v, but expected %v", v, want)
  13. }
  14. }
  15. func TestDivZero(t *testing.T) {
  16. if v, want := div(0, 2), byte(0); v != want {
  17. t.Errorf("Was %v, but expected %v", v, want)
  18. }
  19. }
  20. func TestDivByZero(t *testing.T) {
  21. defer func() {
  22. m := recover()
  23. if m != "div by zero" {
  24. t.Error(m)
  25. }
  26. }()
  27. div(2, 0)
  28. t.Error("Shouldn't have been able to divide those")
  29. }