diff options
Diffstat (limited to 'caesar_test.go')
-rw-r--r-- | caesar_test.go | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/caesar_test.go b/caesar_test.go index 6a01f43..9754edd 100644 --- a/caesar_test.go +++ b/caesar_test.go @@ -16,14 +16,16 @@ func TestLong(t *testing.T) { if testing.Short() { t.Skip() } - msg := "Attack at dawn" - encoded := Encode(msg) - if encoded == msg { - t.Errorf("expected ciphertext and plaintext to differ") + orig := "Attack at dawn" + msg := orig + for i := 0; i < 1e6; i++ { + msg = Encode(msg) + } + for i := 0; i < 1e6; i++ { + msg = Decode(msg) } - decoded := Decode(encoded) - if decoded != msg { - t.Errorf("expected recovered plaintext to match message, but got: %s", decoded) + if msg != orig { + t.Errorf("expected %q but got %q", orig, msg) } } @@ -45,27 +47,6 @@ func TestEncoderTable(t *testing.T) { } } -func TestEncoderIndividualTable(t *testing.T) { - tests := []struct { - name string - in string - out string - }{ - {"lowers", "abcxyz", "defabc"}, - {"uppers", "ABCXYZ", "DEFABC"}, - {"nums", "1234567890", "4567890123"}, - {"symbols", "!@#$%^&*()", "!@#$%^&*()"}, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - result := Encode(test.in) - if result != test.out { - t.Fatalf("expected %s, got %s", test.out, result) // HL - } - }) - } -} - func BenchmarkFailure(b *testing.B) { b.Fail() } |