(t *testing.T)
| 32 | } |
| 33 | |
| 34 | func TestEncrypt(t *testing.T) { |
| 35 | fn := func(text string, keyWord string) (bool, error) { |
| 36 | encrypt, err := Encrypt([]rune(text), keyWord) |
| 37 | if err != nil && !errors.Is(err, ErrNoTextToEncrypt) && !errors.Is(err, ErrKeyMissing) { |
| 38 | t.Error("Unexpected error ", err) |
| 39 | } |
| 40 | return text == string(encrypt), err |
| 41 | } |
| 42 | for _, s := range texts { |
| 43 | if check, err := fn(s, getRandomString()); check || err != nil { |
| 44 | t.Error("String ", s, " not encrypted") |
| 45 | } |
| 46 | } |
| 47 | if _, err := fn(getRandomString(), ""); err == nil { |
| 48 | t.Error("Error! empty string encryption") |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestDecrypt(t *testing.T) { |
| 53 | for _, s := range texts { |
nothing calls this directly
no test coverage detected