grade_test.go 936 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package fp_test
  2. import (
  3. "testing"
  4. fp "github.com/cloudflare/mitmengine/fputil"
  5. "github.com/cloudflare/mitmengine/testutil"
  6. )
  7. func TestGradeString(t *testing.T) {
  8. var tests = []struct {
  9. in fp.Grade
  10. out string
  11. }{
  12. {fp.GradeEmpty, "empty"},
  13. {fp.GradeA, "A"},
  14. {fp.GradeB, "B"},
  15. {fp.GradeC, "C"},
  16. {fp.GradeF, "F"},
  17. {fp.Grade(255), "Grade(255)"},
  18. }
  19. for _, test := range tests {
  20. actual := test.in.String()
  21. testutil.Equals(t, test.out, actual)
  22. }
  23. }
  24. func TestGradeMerge(t *testing.T) {
  25. var tests = []struct {
  26. in1 fp.Grade
  27. in2 fp.Grade
  28. out fp.Grade
  29. }{
  30. {fp.GradeEmpty, fp.GradeEmpty, fp.GradeEmpty},
  31. {fp.GradeA, fp.GradeEmpty, fp.GradeA},
  32. {fp.GradeA, fp.GradeB, fp.GradeB},
  33. {fp.GradeB, fp.GradeA, fp.GradeB},
  34. {fp.GradeF, fp.GradeC, fp.GradeF},
  35. {fp.GradeF, fp.GradeF, fp.GradeF},
  36. }
  37. for _, test := range tests {
  38. actual := test.in1.Merge(test.in2)
  39. testutil.Equals(t, test.out, actual)
  40. }
  41. }