| 8 | ) |
| 9 | |
| 10 | func TestEncrypt(t *testing.T) { |
| 11 | var caesarTestData = []struct { |
| 12 | description string |
| 13 | input string |
| 14 | key int |
| 15 | expected string |
| 16 | }{ |
| 17 | { |
| 18 | "Basic caesar encryption with letter 'a'", |
| 19 | "a", |
| 20 | 3, |
| 21 | "d", |
| 22 | }, |
| 23 | { |
| 24 | "Basic caesar encryption wrap around alphabet on letter 'z'", |
| 25 | "z", |
| 26 | 3, |
| 27 | "c", |
| 28 | }, |
| 29 | { |
| 30 | "Encrypt a simple string with caesar encryiption", |
| 31 | "hello", |
| 32 | 3, |
| 33 | "khoor", |
| 34 | }, |
| 35 | { |
| 36 | "Encrypt a simple string with key 13", |
| 37 | "hello", |
| 38 | 13, |
| 39 | "uryyb", |
| 40 | }, |
| 41 | { |
| 42 | "Encrypt a simple string with key -13", |
| 43 | "hello", |
| 44 | -13, |
| 45 | "uryyb", |
| 46 | }, |
| 47 | { |
| 48 | "With key of 26 output should be the same as the input", |
| 49 | "no change", |
| 50 | 26, |
| 51 | "no change", |
| 52 | }, |
| 53 | { |
| 54 | "Encrypt sentence with key 10", |
| 55 | "the quick brown fox jumps over the lazy dog.", |
| 56 | 10, |
| 57 | "dro aesmu lbygx pyh tewzc yfob dro vkji nyq.", |
| 58 | }, |
| 59 | { |
| 60 | "Encrypt sentence with key 10", |
| 61 | "The Quick Brown Fox Jumps over the Lazy Dog.", |
| 62 | 10, |
| 63 | "Dro Aesmu Lbygx Pyh Tewzc yfob dro Vkji Nyq.", |
| 64 | }, |
| 65 | } |
| 66 | for _, test := range caesarTestData { |
| 67 | t.Run(test.description, func(t *testing.T) { |