encodedText_test.go 886 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package weirdtext
  2. import (
  3. "testing"
  4. )
  5. func TestInvalidPrefix(t *testing.T) {
  6. input := `
  7. ---weir---
  8. Tihs is a lnog lnooog tset setcnnee,
  9. wtih smoe big (biiiiig) wdros!
  10. ---weir---
  11. This long looong sentence some test with words`
  12. test := EncodedText{}
  13. err := test.FromString(input)
  14. if err == nil {
  15. t.Errorf("There should be error as prefix is invalid!")
  16. }
  17. }
  18. func TestInvalidString(t *testing.T) {
  19. testCases := []string{
  20. `
  21. ---weird---
  22. Tihs is a lnog lnooog tset setcnnee,
  23. wtih smoe big (biiiiig) wdros!
  24. ---weird---`,
  25. `
  26. ---weird---
  27. ---weird---
  28. This long looong sentence some test with words`,
  29. `
  30. ---weird---
  31. Tihs is a lnog lnooog tset setcnnee,
  32. wtih smoe big (biiiiig) wdros!
  33. ---weird---
  34. `,
  35. }
  36. for _, input := range testCases {
  37. test := EncodedText{}
  38. err := test.FromString(input)
  39. if err == nil {
  40. t.Errorf("There should be error as string is invalid!")
  41. }
  42. }
  43. }