summaryrefslogtreecommitdiff
path: root/caesar_test.go
blob: 04b853bc7d82187ce179954fe60c787d3a9fcd2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package caesar

import (
	"testing"
)

func TestEncode(t *testing.T) {
	msg := "Attack at dawn"
	if Encode(msg) != "Dwwdfn dw gdzq" {
		t.Fail()
	}
}

func TestCaesar(t *testing.T) {
	if testing.Short() {
		t.Skip()
	}
	msg := "Attack at dawn"
	t.Logf("testing encoding message %s", msg)
	encoded := Encode(msg)
	if encoded == msg {
		t.Log("expected ciphertext and plaintext to differ")
		t.Fail()
	}
	decoded := Decode(encoded)
	if decoded != msg {
		t.Logf("expected recovered plaintext to match message, but got: %s", decoded)
		t.Fail()
	}
}

func BenchmarkCaesar(b *testing.B) {
	b.Fail()
}