version_test.go 1017 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package fp_test
  2. import (
  3. "testing"
  4. fp "github.com/cloudflare/mitmengine/fputil"
  5. "github.com/cloudflare/mitmengine/testutil"
  6. )
  7. func TestVersionString(t *testing.T) {
  8. var tests = []struct {
  9. in fp.Version
  10. out string
  11. }{
  12. {fp.VersionEmpty, ""},
  13. {fp.VersionSSL2, "200"},
  14. {fp.VersionSSL3, "300"},
  15. {fp.VersionTLS10, "301"},
  16. {fp.VersionTLS11, "302"},
  17. {fp.VersionTLS12, "303"},
  18. {fp.VersionTLS13, "304"},
  19. {fp.Version(255), "ff"},
  20. }
  21. for _, test := range tests {
  22. actual := test.in.String()
  23. testutil.Equals(t, test.out, actual)
  24. }
  25. }
  26. func TestVersionGrade(t *testing.T) {
  27. var tests = []struct {
  28. in fp.Version
  29. out fp.Grade
  30. }{
  31. {fp.VersionEmpty, fp.GradeEmpty},
  32. {fp.VersionSSL2, fp.GradeF},
  33. {fp.VersionSSL3, fp.GradeC},
  34. {fp.VersionTLS10, fp.GradeB},
  35. {fp.VersionTLS11, fp.GradeB},
  36. {fp.VersionTLS12, fp.GradeA},
  37. {fp.VersionTLS13, fp.GradeA},
  38. {fp.Version(255), fp.GradeF},
  39. }
  40. for _, test := range tests {
  41. actual := test.in.Grade()
  42. testutil.Equals(t, test.out, actual)
  43. }
  44. }