summaryrefslogtreecommitdiff
path: root/go/atbash-cipher/atbash_cipher_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-08-30 02:05:53 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-08-30 02:05:53 +0200
commit89539daca2be78d19e36e0f5b952d3ec259c8e78 (patch)
treec53d21d07c628c0d48c056cca40df648fe79bfe2 /go/atbash-cipher/atbash_cipher_test.go
parentbfb81139b65cd99b4a231e42a810214388194ec7 (diff)
Solve Atbash
Diffstat (limited to 'go/atbash-cipher/atbash_cipher_test.go')
-rw-r--r--go/atbash-cipher/atbash_cipher_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/go/atbash-cipher/atbash_cipher_test.go b/go/atbash-cipher/atbash_cipher_test.go
new file mode 100644
index 0000000..08f274e
--- /dev/null
+++ b/go/atbash-cipher/atbash_cipher_test.go
@@ -0,0 +1,40 @@
+package atbash
+
+import "testing"
+
+var tests = []struct {
+ expected string
+ s string
+}{
+ {"ml", "no"},
+ {"ml", "no"},
+ {"bvh", "yes"},
+ {"lnt", "OMG"},
+ {"lnt", "O M G"},
+ {"nrmwy oldrm tob", "mindblowingly"},
+ {"gvhgr mt123 gvhgr mt", "Testing, 1 2 3, testing."},
+ {"gifgs rhurx grlm", "Truth is fiction."},
+ {"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", "The quick brown fox jumps over the lazy dog."},
+}
+
+func TestAtbash(t *testing.T) {
+ for _, test := range tests {
+ actual := Atbash(test.s)
+ if actual != test.expected {
+ t.Errorf("Atbash(%s): expected %s, actual %s", test.s, test.expected, actual)
+ }
+ }
+}
+
+func BenchmarkAtbash(b *testing.B) {
+ b.StopTimer()
+ for _, test := range tests {
+ b.StartTimer()
+
+ for i := 0; i < b.N; i++ {
+ Atbash(test.s)
+ }
+
+ b.StopTimer()
+ }
+}