Add initial project files

This commit is contained in:
2023-02-07 04:44:07 +00:00
commit af7291815d
27 changed files with 1415 additions and 0 deletions

36
pkg/deesee/codec_test.go Normal file
View File

@@ -0,0 +1,36 @@
package deesee
import "testing"
// TestEncrypt tests the Encrypt and Decrypt function.
func TestCryptDecrypt(t *testing.T) {
// Case is a struct to store test cases.
type Case struct {
name string
key int
A string
B string
}
// Run the test cases.
for _, tt := range []Case{
{"Test encrypt-decrypt: simple text",
5, "clark", "hqfwp"},
{"Test encrypt-decrypt: text with shifted outbounds chars",
3, "cherry blossom", "fkhuub eorvvrp"},
{"Test encrypt-decrypt: text with shifted outbounds chars and non-letter chars",
3, "cherry123 blossom!", "fkhuub123 eorvvrp!"},
} {
t.Run(tt.name, func(t *testing.T) {
enc := Encrypt(tt.A, tt.key)
if enc != tt.B {
t.Errorf("Encrypt() = %v, want %v", enc, tt.B)
}
dec := Decrypt(enc, tt.key)
if dec != tt.A {
t.Errorf("Decrypt() = %v, want %v", dec, tt.A)
}
})
}
}