Skip to content

Commit ff08877

Browse files
authored
Sync raindrops with problem-specifications (#1786)
[no important files changed]
1 parent 96f03aa commit ff08877

File tree

3 files changed

+166
-45
lines changed

3 files changed

+166
-45
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% for test in cases %}
2+
#[test]
3+
{% if loop.index != 1 -%}
4+
#[ignore]
5+
{% endif -%}
6+
fn test_{{ test.description | slugify | replace(from="-", to="_") }}() {
7+
let input = {{ test.input.number | json_encode() }};
8+
let output = {{ crate_name }}::{{ fn_names[0] }}(input);
9+
let expected = {{ test.expected | json_encode() }};
10+
assert_eq!(output, expected);
11+
}
12+
{% endfor -%}
Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,64 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[1575d549-e502-46d4-a8e1-6b7bec6123d8]
13+
description = "the sound for 1 is 1"
14+
15+
[1f51a9f9-4895-4539-b182-d7b0a5ab2913]
16+
description = "the sound for 3 is Pling"
17+
18+
[2d9bfae5-2b21-4bcd-9629-c8c0e388f3e0]
19+
description = "the sound for 5 is Plang"
20+
21+
[d7e60daa-32ef-4c23-b688-2abff46c4806]
22+
description = "the sound for 7 is Plong"
23+
24+
[6bb4947b-a724-430c-923f-f0dc3d62e56a]
25+
description = "the sound for 6 is Pling as it has a factor 3"
26+
27+
[ce51e0e8-d9d4-446d-9949-96eac4458c2d]
28+
description = "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base"
29+
30+
[0dd66175-e3e2-47fc-8750-d01739856671]
31+
description = "the sound for 9 is Pling as it has a factor 3"
32+
33+
[022c44d3-2182-4471-95d7-c575af225c96]
34+
description = "the sound for 10 is Plang as it has a factor 5"
35+
36+
[37ab74db-fed3-40ff-b7b9-04acdfea8edf]
37+
description = "the sound for 14 is Plong as it has a factor of 7"
38+
39+
[31f92999-6afb-40ee-9aa4-6d15e3334d0f]
40+
description = "the sound for 15 is PlingPlang as it has factors 3 and 5"
41+
42+
[ff9bb95d-6361-4602-be2c-653fe5239b54]
43+
description = "the sound for 21 is PlingPlong as it has factors 3 and 7"
44+
45+
[d2e75317-b72e-40ab-8a64-6734a21dece1]
46+
description = "the sound for 25 is Plang as it has a factor 5"
47+
48+
[a09c4c58-c662-4e32-97fe-f1501ef7125c]
49+
description = "the sound for 27 is Pling as it has a factor 3"
50+
51+
[bdf061de-8564-4899-a843-14b48b722789]
52+
description = "the sound for 35 is PlangPlong as it has factors 5 and 7"
53+
54+
[c4680bee-69ba-439d-99b5-70c5fd1a7a83]
55+
description = "the sound for 49 is Plong as it has a factor 7"
56+
57+
[17f2bc9a-b65a-4d23-8ccd-266e8c271444]
58+
description = "the sound for 52 is 52"
59+
60+
[e46677ed-ff1a-419f-a740-5c713d2830e4]
61+
description = "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7"
62+
63+
[13c6837a-0fcd-4b86-a0eb-20572f7deb0b]
64+
description = "the sound for 3125 is Plang as it has a factor 5"
Lines changed: 90 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,160 @@
11
#[test]
2-
fn test_1() {
3-
assert_eq!("1", raindrops::raindrops(1));
2+
fn test_the_sound_for_1_is_1() {
3+
let input = 1;
4+
let output = raindrops::raindrops(input);
5+
let expected = "1";
6+
assert_eq!(output, expected);
47
}
58

69
#[test]
710
#[ignore]
8-
fn test_3() {
9-
assert_eq!("Pling", raindrops::raindrops(3));
11+
fn test_the_sound_for_3_is_pling() {
12+
let input = 3;
13+
let output = raindrops::raindrops(input);
14+
let expected = "Pling";
15+
assert_eq!(output, expected);
1016
}
1117

1218
#[test]
1319
#[ignore]
14-
fn test_5() {
15-
assert_eq!("Plang", raindrops::raindrops(5));
20+
fn test_the_sound_for_5_is_plang() {
21+
let input = 5;
22+
let output = raindrops::raindrops(input);
23+
let expected = "Plang";
24+
assert_eq!(output, expected);
1625
}
1726

1827
#[test]
1928
#[ignore]
20-
fn test_7() {
21-
assert_eq!("Plong", raindrops::raindrops(7));
29+
fn test_the_sound_for_7_is_plong() {
30+
let input = 7;
31+
let output = raindrops::raindrops(input);
32+
let expected = "Plong";
33+
assert_eq!(output, expected);
2234
}
2335

2436
#[test]
2537
#[ignore]
26-
fn test_6() {
27-
assert_eq!("Pling", raindrops::raindrops(6));
38+
fn test_the_sound_for_6_is_pling_as_it_has_a_factor_3() {
39+
let input = 6;
40+
let output = raindrops::raindrops(input);
41+
let expected = "Pling";
42+
assert_eq!(output, expected);
2843
}
2944

3045
#[test]
3146
#[ignore]
32-
fn test_8() {
33-
assert_eq!("8", raindrops::raindrops(8));
47+
fn test_2_to_the_power_3_does_not_make_a_raindrop_sound_as_3_is_the_exponent_not_the_base() {
48+
let input = 8;
49+
let output = raindrops::raindrops(input);
50+
let expected = "8";
51+
assert_eq!(output, expected);
3452
}
3553

3654
#[test]
3755
#[ignore]
38-
fn test_9() {
39-
assert_eq!("Pling", raindrops::raindrops(9));
56+
fn test_the_sound_for_9_is_pling_as_it_has_a_factor_3() {
57+
let input = 9;
58+
let output = raindrops::raindrops(input);
59+
let expected = "Pling";
60+
assert_eq!(output, expected);
4061
}
4162

4263
#[test]
4364
#[ignore]
44-
fn test_10() {
45-
assert_eq!("Plang", raindrops::raindrops(10));
65+
fn test_the_sound_for_10_is_plang_as_it_has_a_factor_5() {
66+
let input = 10;
67+
let output = raindrops::raindrops(input);
68+
let expected = "Plang";
69+
assert_eq!(output, expected);
4670
}
4771

4872
#[test]
4973
#[ignore]
50-
fn test_14() {
51-
assert_eq!("Plong", raindrops::raindrops(14));
74+
fn test_the_sound_for_14_is_plong_as_it_has_a_factor_of_7() {
75+
let input = 14;
76+
let output = raindrops::raindrops(input);
77+
let expected = "Plong";
78+
assert_eq!(output, expected);
5279
}
5380

5481
#[test]
5582
#[ignore]
56-
fn test_15() {
57-
assert_eq!("PlingPlang", raindrops::raindrops(15));
83+
fn test_the_sound_for_15_is_plingplang_as_it_has_factors_3_and_5() {
84+
let input = 15;
85+
let output = raindrops::raindrops(input);
86+
let expected = "PlingPlang";
87+
assert_eq!(output, expected);
5888
}
5989

6090
#[test]
6191
#[ignore]
62-
fn test_21() {
63-
assert_eq!("PlingPlong", raindrops::raindrops(21));
92+
fn test_the_sound_for_21_is_plingplong_as_it_has_factors_3_and_7() {
93+
let input = 21;
94+
let output = raindrops::raindrops(input);
95+
let expected = "PlingPlong";
96+
assert_eq!(output, expected);
6497
}
6598

6699
#[test]
67100
#[ignore]
68-
fn test_25() {
69-
assert_eq!("Plang", raindrops::raindrops(25));
101+
fn test_the_sound_for_25_is_plang_as_it_has_a_factor_5() {
102+
let input = 25;
103+
let output = raindrops::raindrops(input);
104+
let expected = "Plang";
105+
assert_eq!(output, expected);
70106
}
71107

72108
#[test]
73109
#[ignore]
74-
fn test_27() {
75-
assert_eq!("Pling", raindrops::raindrops(27));
110+
fn test_the_sound_for_27_is_pling_as_it_has_a_factor_3() {
111+
let input = 27;
112+
let output = raindrops::raindrops(input);
113+
let expected = "Pling";
114+
assert_eq!(output, expected);
76115
}
77116

78117
#[test]
79118
#[ignore]
80-
fn test_35() {
81-
assert_eq!("PlangPlong", raindrops::raindrops(35));
119+
fn test_the_sound_for_35_is_plangplong_as_it_has_factors_5_and_7() {
120+
let input = 35;
121+
let output = raindrops::raindrops(input);
122+
let expected = "PlangPlong";
123+
assert_eq!(output, expected);
82124
}
83125

84126
#[test]
85127
#[ignore]
86-
fn test_49() {
87-
assert_eq!("Plong", raindrops::raindrops(49));
128+
fn test_the_sound_for_49_is_plong_as_it_has_a_factor_7() {
129+
let input = 49;
130+
let output = raindrops::raindrops(input);
131+
let expected = "Plong";
132+
assert_eq!(output, expected);
88133
}
89134

90135
#[test]
91136
#[ignore]
92-
fn test_52() {
93-
assert_eq!("52", raindrops::raindrops(52));
137+
fn test_the_sound_for_52_is_52() {
138+
let input = 52;
139+
let output = raindrops::raindrops(input);
140+
let expected = "52";
141+
assert_eq!(output, expected);
94142
}
95143

96144
#[test]
97145
#[ignore]
98-
fn test_105() {
99-
assert_eq!("PlingPlangPlong", raindrops::raindrops(105));
146+
fn test_the_sound_for_105_is_plingplangplong_as_it_has_factors_3_5_and_7() {
147+
let input = 105;
148+
let output = raindrops::raindrops(input);
149+
let expected = "PlingPlangPlong";
150+
assert_eq!(output, expected);
100151
}
101152

102153
#[test]
103154
#[ignore]
104-
fn test_3125() {
105-
assert_eq!("Plang", raindrops::raindrops(3125));
106-
}
107-
108-
#[test]
109-
#[ignore]
110-
fn test_12121() {
111-
assert_eq!("12121", raindrops::raindrops(12_121));
155+
fn test_the_sound_for_3125_is_plang_as_it_has_a_factor_5() {
156+
let input = 3125;
157+
let output = raindrops::raindrops(input);
158+
let expected = "Plang";
159+
assert_eq!(output, expected);
112160
}

0 commit comments

Comments
 (0)