app_test.go 615 B

123456789101112131415161718192021222324
  1. package main
  2. import (
  3. "testing"
  4. )
  5. func TestDecodeEncode(t *testing.T) {
  6. text := `This is a long looong test sentence,
  7. with some big (biiiiig) words!`
  8. encodedText, encodedWords := EncodeText([]rune(text))
  9. if encodedText == text {
  10. t.Errorf("Encoded text '%s' should be different than provided text '%s'!", encodedText, text)
  11. }
  12. if len(encodedWords) != 8 {
  13. t.Errorf("There should be 8 encoded words! %v", encodedWords)
  14. }
  15. decodedText := DecodeText([]rune(encodedText), encodedWords)
  16. if decodedText != text {
  17. t.Errorf("Decoded text '%s' should be same as provided text '%s'!", decodedText, text)
  18. }
  19. }