(t *testing.T)
| 50 | } |
| 51 | |
| 52 | func TestDecrypt(t *testing.T) { |
| 53 | for _, s := range texts { |
| 54 | keyWord := getRandomString() |
| 55 | encrypt, errEncrypt := Encrypt([]rune(s), keyWord) |
| 56 | if errEncrypt != nil && |
| 57 | !errors.Is(errEncrypt, ErrNoTextToEncrypt) && |
| 58 | !errors.Is(errEncrypt, ErrKeyMissing) { |
| 59 | t.Error("Unexpected error ", errEncrypt) |
| 60 | } |
| 61 | if errEncrypt != nil { |
| 62 | t.Error(errEncrypt) |
| 63 | } |
| 64 | decrypt, errDecrypt := Decrypt([]rune(encrypt), keyWord) |
| 65 | if errDecrypt != nil && |
| 66 | !errors.Is(errDecrypt, ErrNoTextToEncrypt) && |
| 67 | !errors.Is(errDecrypt, ErrKeyMissing) { |
| 68 | t.Error("Unexpected error ", errDecrypt) |
| 69 | } |
| 70 | if errDecrypt != nil { |
| 71 | t.Error(errDecrypt) |
| 72 | } |
| 73 | if reflect.DeepEqual(encrypt, decrypt) { |
| 74 | t.Error("String ", s, " not encrypted") |
| 75 | } |
| 76 | if reflect.DeepEqual(encrypt, s) { |
| 77 | t.Error("String ", s, " not encrypted") |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func TestEncryptDecrypt(t *testing.T) { |
| 83 | text := []rune("Test text for checking the algorithm") |
nothing calls this directly
no test coverage detected