You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
868 B

3 years ago
  1. package modhex
  2. import "testing"
  3. type test struct {
  4. hex string
  5. modhex string
  6. }
  7. func TestEncodeHexDecodeHex(t *testing.T) {
  8. var tests = []test{
  9. {
  10. modhex: "dteffuje",
  11. hex: "2d344e83",
  12. },
  13. {
  14. modhex: "hknhfjbrjnlnldnhcujvddbikngjrtgh",
  15. hex: "69b6481c8baba2b60e8f22179b58cd56",
  16. },
  17. {
  18. modhex: "urtubjtnuihvntcreeeecvbregfjibtn",
  19. hex: "ecde18dbe76fbd0c33330f1c354871db",
  20. },
  21. }
  22. for _, tc := range tests {
  23. modhex, err := EncodeHex(tc.hex)
  24. if err != nil {
  25. t.Errorf("EncodeHex Error: %s\n", err)
  26. }
  27. if modhex != tc.modhex {
  28. t.Errorf("EncodeHex Incorrect: Actual: %s; Expected: %s\n", modhex, tc.modhex)
  29. }
  30. hex, err := DecodeHex(tc.modhex)
  31. if err != nil {
  32. t.Errorf("DecodeHex Error: %s\n", err)
  33. }
  34. if hex != tc.hex {
  35. t.Errorf("DecodeHex Incorrect: Actual: %s; Expected: %s\n", hex, tc.hex)
  36. }
  37. }
  38. }