|
1 | 1 | #!/usr/bin/env bats |
2 | 2 | load bats-extra |
3 | 3 |
|
4 | | -# local version: 1.1.0.0 |
| 4 | +# generated on 2026-06-29T06:30:35+00:00 |
| 5 | +# local version: 2.0.0.0 |
5 | 6 |
|
6 | | -# run-length encode a string |
7 | | - |
8 | | -@test "encode empty string" { |
9 | | - #[[ $BATS_RUN_SKIPPED == "true" ]] || skip |
| 7 | +@test "run-length encode a string: empty string" { |
| 8 | + # [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
10 | 9 | expected="" |
11 | 10 | run bash run_length_encoding.sh encode "" |
12 | 11 | assert_success |
13 | 12 | assert_output "$expected" |
14 | 13 | } |
15 | 14 |
|
16 | | -@test "encode single characters only are encoded without count" { |
| 15 | +@test "run-length encode a string: single characters only are encoded without count" { |
17 | 16 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
18 | 17 | expected="XYZ" |
19 | 18 | run bash run_length_encoding.sh encode "XYZ" |
20 | 19 | assert_success |
21 | 20 | assert_output "$expected" |
22 | 21 | } |
23 | 22 |
|
24 | | -@test "encode string with no single characters" { |
| 23 | +@test "run-length encode a string: string with no single characters" { |
25 | 24 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
26 | 25 | expected="2A3B4C" |
27 | 26 | run bash run_length_encoding.sh encode "AABBBCCCC" |
28 | 27 | assert_success |
29 | 28 | assert_output "$expected" |
30 | 29 | } |
31 | 30 |
|
32 | | -@test "encode single characters mixed with repeated characters" { |
| 31 | +@test "run-length encode a string: single characters mixed with repeated characters" { |
33 | 32 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
34 | 33 | expected="12WB12W3B24WB" |
35 | 34 | run bash run_length_encoding.sh encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" |
36 | 35 | assert_success |
37 | 36 | assert_output "$expected" |
38 | 37 | } |
39 | 38 |
|
40 | | -@test "encode multiple whitespace mixed in string" { |
| 39 | +@test "run-length encode a string: multiple whitespace mixed in string" { |
41 | 40 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
42 | 41 | expected="2 hs2q q2w2 " |
43 | 42 | run bash run_length_encoding.sh encode " hsqq qww " |
44 | 43 | assert_success |
45 | 44 | assert_output "$expected" |
46 | 45 | } |
47 | 46 |
|
48 | | -@test "encode lowercase characters" { |
| 47 | +@test "run-length encode a string: lowercase characters" { |
49 | 48 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
50 | 49 | expected="2a3b4c" |
51 | 50 | run bash run_length_encoding.sh encode "aabbbcccc" |
52 | 51 | assert_success |
53 | 52 | assert_output "$expected" |
54 | 53 | } |
55 | 54 |
|
56 | | -# run-length decode a string |
57 | | - |
58 | | -@test "decode empty string" { |
| 55 | +@test "run-length decode a string: empty string" { |
59 | 56 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
60 | 57 | expected="" |
61 | 58 | run bash run_length_encoding.sh decode "" |
62 | 59 | assert_success |
63 | 60 | assert_output "$expected" |
64 | 61 | } |
65 | 62 |
|
66 | | -@test "single characters only" { |
| 63 | +@test "run-length decode a string: single characters only" { |
67 | 64 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
68 | 65 | expected="XYZ" |
69 | 66 | run bash run_length_encoding.sh decode "XYZ" |
70 | 67 | assert_success |
71 | 68 | assert_output "$expected" |
72 | 69 | } |
73 | 70 |
|
74 | | -@test "decode string with no single characters" { |
| 71 | +@test "run-length decode a string: string with no single characters" { |
75 | 72 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
76 | 73 | expected="AABBBCCCC" |
77 | 74 | run bash run_length_encoding.sh decode "2A3B4C" |
78 | 75 | assert_success |
79 | 76 | assert_output "$expected" |
80 | 77 | } |
81 | 78 |
|
82 | | -@test "decode single characters with repeated characters" { |
| 79 | +@test "run-length decode a string: single characters with repeated characters" { |
83 | 80 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
84 | 81 | expected="WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" |
85 | 82 | run bash run_length_encoding.sh decode "12WB12W3B24WB" |
86 | 83 | assert_success |
87 | 84 | assert_output "$expected" |
88 | 85 | } |
89 | 86 |
|
90 | | -@test "decode multiple whitespace mixed in string" { |
| 87 | +@test "run-length decode a string: multiple whitespace mixed in string" { |
91 | 88 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
92 | 89 | expected=" hsqq qww " |
93 | 90 | run bash run_length_encoding.sh decode "2 hs2q q2w2 " |
94 | 91 | assert_success |
95 | 92 | assert_output "$expected" |
96 | 93 | } |
97 | 94 |
|
98 | | -@test "decode lower case string" { |
| 95 | +@test "run-length decode a string: lowercase string" { |
99 | 96 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
100 | 97 | expected="aabbbcccc" |
101 | 98 | run bash run_length_encoding.sh decode "2a3b4c" |
102 | 99 | assert_success |
103 | 100 | assert_output "$expected" |
104 | 101 | } |
105 | 102 |
|
106 | | -# encode and then decode |
107 | | - |
108 | | -@test "encode followed by decode gives original string" { |
| 103 | +@test "encode and then decode: encode followed by decode gives original string" { |
109 | 104 | [[ $BATS_RUN_SKIPPED == "true" ]] || skip |
110 | 105 | expected="zzz ZZ zZ" |
111 | 106 | run bash run_length_encoding.sh encode "zzz ZZ zZ" |
|
0 commit comments