|
| 1 | +RailFenceCipher = require 'rail_fence_cipher' |
| 2 | + |
| 3 | +describe 'rail-fence-cipher', -> |
| 4 | + describe 'encode', -> |
| 5 | + it 'encode with two rails', -> |
| 6 | + result = RailFenceCipher.encode 2, 'XOXOXOXOXOXOXOXOXO' |
| 7 | + expected = 'XXXXXXXXXOOOOOOOOO' |
| 8 | + assert.are.equal expected, result |
| 9 | + |
| 10 | + pending 'encode with three rails', -> |
| 11 | + result = RailFenceCipher.encode 3, 'WEAREDISCOVEREDFLEEATONCE' |
| 12 | + expected = 'WECRLTEERDSOEEFEAOCAIVDEN' |
| 13 | + assert.are.equal expected, result |
| 14 | + |
| 15 | + pending 'encode with ending in the middle', -> |
| 16 | + result = RailFenceCipher.encode 4, 'EXERCISES' |
| 17 | + expected = 'ESXIEECSR' |
| 18 | + assert.are.equal expected, result |
| 19 | + |
| 20 | + describe 'decode', -> |
| 21 | + pending 'decode with three rails', -> |
| 22 | + result = RailFenceCipher.decode 3, 'TEITELHDVLSNHDTISEIIEA' |
| 23 | + expected = 'THEDEVILISINTHEDETAILS' |
| 24 | + assert.are.equal expected, result |
| 25 | + |
| 26 | + pending 'decode with five rails', -> |
| 27 | + result = RailFenceCipher.decode 5, 'EIEXMSMESAORIWSCE' |
| 28 | + expected = 'EXERCISMISAWESOME' |
| 29 | + assert.are.equal expected, result |
| 30 | + |
| 31 | + pending 'decode with six rails', -> |
| 32 | + result = RailFenceCipher.decode 6, '133714114238148966225439541018335470986172518171757571896261' |
| 33 | + expected = '112358132134558914423337761098715972584418167651094617711286' |
| 34 | + assert.are.equal expected, result |
0 commit comments