Skip to content

Commit 39f8590

Browse files
authored
Sync tests for variable-length-quantity and wordy (#323)
* sync tests for variable-length-quantity * sync tests for wordy
1 parent 50913d2 commit 39f8590

4 files changed

Lines changed: 90 additions & 0 deletions

File tree

exercises/practice/variable-length-quantity/.meta/tests.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ description = "Encode a series of integers, producing a series of bytes. -> zero
1515
[be44d299-a151-4604-a10e-d4b867f41540]
1616
description = "Encode a series of integers, producing a series of bytes. -> arbitrary single byte"
1717

18+
[890bc344-cb80-45af-b316-6806a6971e81]
19+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric single byte"
20+
1821
[ea399615-d274-4af6-bbef-a1c23c9e1346]
1922
description = "Encode a series of integers, producing a series of bytes. -> largest single byte"
2023

@@ -24,6 +27,9 @@ description = "Encode a series of integers, producing a series of bytes. -> smal
2427
[63955a49-2690-4e22-a556-0040648d6b2d]
2528
description = "Encode a series of integers, producing a series of bytes. -> arbitrary double byte"
2629

30+
[4977d113-251b-4d10-a3ad-2f5a7756bb58]
31+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric double byte"
32+
2733
[29da7031-0067-43d3-83a7-4f14b29ed97a]
2834
description = "Encode a series of integers, producing a series of bytes. -> largest double byte"
2935

@@ -33,6 +39,9 @@ description = "Encode a series of integers, producing a series of bytes. -> smal
3339
[5df0bc2d-2a57-4300-a653-a75ee4bd0bee]
3440
description = "Encode a series of integers, producing a series of bytes. -> arbitrary triple byte"
3541

42+
[6731045f-1e00-4192-b5ae-98b22e17e9f7]
43+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric triple byte"
44+
3645
[f51d8539-312d-4db1-945c-250222c6aa22]
3746
description = "Encode a series of integers, producing a series of bytes. -> largest triple byte"
3847

@@ -42,6 +51,9 @@ description = "Encode a series of integers, producing a series of bytes. -> smal
4251
[11ed3469-a933-46f1-996f-2231e05d7bb6]
4352
description = "Encode a series of integers, producing a series of bytes. -> arbitrary quadruple byte"
4453

54+
[b45ef770-cbba-48c2-bd3c-c6362679516e]
55+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric quadruple byte"
56+
4557
[d5f3f3c3-e0f1-4e7f-aad0-18a44f223d1c]
4658
description = "Encode a series of integers, producing a series of bytes. -> largest quadruple byte"
4759

@@ -51,6 +63,9 @@ description = "Encode a series of integers, producing a series of bytes. -> smal
5163
[5f34ff12-2952-4669-95fe-2d11b693d331]
5264
description = "Encode a series of integers, producing a series of bytes. -> arbitrary quintuple byte"
5365

66+
[9be46731-7cd5-415c-b960-48061cbc1154]
67+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric quintuple byte"
68+
5469
[7489694b-88c3-4078-9864-6fe802411009]
5570
description = "Encode a series of integers, producing a series of bytes. -> maximum 32-bit integer input"
5671

exercises/practice/variable-length-quantity/test-variable-length-quantity.bats

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ load bats-extra
2121
assert_output "40"
2222
}
2323

24+
@test "encode asymmetric single byte" {
25+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
26+
run gawk -f variable-length-quantity.awk -v action=encode <<< "53"
27+
assert_success
28+
assert_output "53"
29+
}
30+
2431
@test "encode largest single byte" {
2532
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
2633
run gawk -f variable-length-quantity.awk -v action=encode <<< "7F"
@@ -42,6 +49,13 @@ load bats-extra
4249
assert_output "C0 00"
4350
}
4451

52+
@test "encode asymmetric double byte" {
53+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
54+
run gawk -f variable-length-quantity.awk -v action=encode <<< "AD"
55+
assert_success
56+
assert_output "81 2D"
57+
}
58+
4559
@test "encode largest double byte" {
4660
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
4761
run gawk -f variable-length-quantity.awk -v action=encode <<< "3FFF"
@@ -63,6 +77,13 @@ load bats-extra
6377
assert_output "C0 80 00"
6478
}
6579

80+
@test "encode asymmetric triple byte" {
81+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
82+
run gawk -f variable-length-quantity.awk -v action=encode <<< "1D59C"
83+
assert_success
84+
assert_output "87 AB 1C"
85+
}
86+
6687
@test "encode largest triple byte" {
6788
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
6889
run gawk -f variable-length-quantity.awk -v action=encode <<< "1FFFFF"
@@ -84,6 +105,13 @@ load bats-extra
84105
assert_output "C0 80 80 00"
85106
}
86107

108+
@test "encode asymmetric quadruple byte" {
109+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
110+
run gawk -f variable-length-quantity.awk -v action=encode <<< "357704"
111+
assert_success
112+
assert_output "81 D5 EE 04"
113+
}
114+
87115
@test "encode largest quadruple byte" {
88116
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
89117
run gawk -f variable-length-quantity.awk -v action=encode <<< "FFFFFFF"
@@ -105,6 +133,13 @@ load bats-extra
105133
assert_output "8F F8 80 80 00"
106134
}
107135

136+
@test "encode asymmetric quintuple byte" {
137+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
138+
run gawk -f variable-length-quantity.awk -v action=encode <<< "86656105"
139+
assert_success
140+
assert_output "88 B3 95 C2 05"
141+
}
142+
108143
@test "encode maximum 32-bit integer input" {
109144
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
110145
run gawk -f variable-length-quantity.awk -v action=encode <<< "FFFFFFFF"

exercises/practice/wordy/.meta/tests.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,21 @@
1212
[88bf4b28-0de3-4883-93c7-db1b14aa806e]
1313
description = "just a number"
1414

15+
[18983214-1dfc-4ebd-ac77-c110dde699ce]
16+
description = "just a zero"
17+
18+
[607c08ee-2241-4288-916d-dae5455c87e6]
19+
description = "just a negative number"
20+
1521
[bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0]
1622
description = "addition"
1723

24+
[bb9f2082-171c-46ad-ad4e-c3f72087c1b5]
25+
description = "addition with a left hand zero"
26+
27+
[6fa05f17-405a-4742-80ae-5d1a8edb0d5d]
28+
description = "addition with a right hand zero"
29+
1830
[79e49e06-c5ae-40aa-a352-7a3a01f70015]
1931
description = "more addition"
2032

exercises/practice/wordy/test-wordy.bats

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,41 @@ load bats-extra
88
assert_output "5"
99
}
1010

11+
@test "just a zero" {
12+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
13+
run gawk -f wordy.awk <<< "What is 0?"
14+
assert_success
15+
assert_output "0"
16+
}
17+
18+
@test "just a negative number" {
19+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
20+
run gawk -f wordy.awk <<< "What is -123?"
21+
assert_success
22+
assert_output "-123"
23+
}
24+
1125
@test "addition" {
1226
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
1327
run gawk -f wordy.awk <<< "What is 1 plus 1?"
1428
assert_success
1529
assert_output "2"
1630
}
1731

32+
@test "addition with a left hand zero" {
33+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
34+
run gawk -f wordy.awk <<< "What is 0 plus 2?"
35+
assert_success
36+
assert_output "2"
37+
}
38+
39+
@test "addition with a right hand zero" {
40+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
41+
run gawk -f wordy.awk <<< "What is 3 plus 0?"
42+
assert_success
43+
assert_output "3"
44+
}
45+
1846
@test "more addition" {
1947
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
2048
run gawk -f wordy.awk <<< "What is 53 plus 2?"

0 commit comments

Comments
 (0)