summaryrefslogtreecommitdiff
path: root/go/run-length-encoding/run_length_encoding_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/run-length-encoding/run_length_encoding_test.go')
-rw-r--r--go/run-length-encoding/run_length_encoding_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/go/run-length-encoding/run_length_encoding_test.go b/go/run-length-encoding/run_length_encoding_test.go
new file mode 100644
index 0000000..2440d65
--- /dev/null
+++ b/go/run-length-encoding/run_length_encoding_test.go
@@ -0,0 +1,53 @@
+package encode
+
+import "testing"
+
+func TestRunLengthEncode(t *testing.T) {
+ for _, tc := range encodeTests {
+ t.Run(tc.description, func(t *testing.T) {
+ if actual := RunLengthEncode(tc.input); actual != tc.expected {
+ t.Errorf("RunLengthEncode(%q) = %q, want:%q", tc.input, actual, tc.expected)
+ }
+ })
+ }
+}
+func TestRunLengthDecode(t *testing.T) {
+ for _, tc := range decodeTests {
+ t.Run(tc.description, func(t *testing.T) {
+ if actual := RunLengthDecode(tc.input); actual != tc.expected {
+ t.Errorf("RunLengthDecode(%q) = %q, want:%q", tc.input, actual, tc.expected)
+ }
+ })
+ }
+}
+func TestRunLengthEncodeDecode(t *testing.T) {
+ for _, tc := range encodeDecodeTests {
+ t.Run(tc.description, func(t *testing.T) {
+ if actual := RunLengthDecode(RunLengthEncode(tc.input)); actual != tc.expected {
+ t.Errorf("RunLengthDecode(RunLengthEncode(%q)) = %q, want:%q", tc.input, actual, tc.expected)
+ }
+ })
+ }
+}
+
+func BenchmarkRunLengthEncode(b *testing.B) {
+ if testing.Short() {
+ b.Skip("skipping benchmark in short mode.")
+ }
+ for i := 0; i < b.N; i++ {
+ for _, test := range encodeTests {
+ RunLengthEncode(test.input)
+ }
+ }
+}
+
+func BenchmarkRunLengthDecode(b *testing.B) {
+ if testing.Short() {
+ b.Skip("skipping benchmark in short mode.")
+ }
+ for i := 0; i < b.N; i++ {
+ for _, test := range decodeTests {
+ RunLengthDecode(test.input)
+ }
+ }
+}