Skip to content

Commit 09debcc

Browse files
authored
594 out of sync unit tests for resistor color duo (#595)
* Syncing unit tests from problem specification of ResistorColorDuo * Updated exercise dir with updated test cases - synced tests and instructions from problem specification
1 parent f651fc7 commit 09debcc

File tree

4 files changed

+131
-18
lines changed

4 files changed

+131
-18
lines changed

dev/src/Exercise@ResistorColorDuo/ResistorColorDuoTest.class.st

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,44 +76,82 @@ ResistorColorDuoTest >> setUp [
7676

7777
{ #category : #tests }
7878
ResistorColorDuoTest >> test01_BrownAndBlack [
79+
"Tip: Remember to review the class [Comment] tab"
80+
<exeTestName: 'Brown and black'>
81+
<exeTestUUID: 'ce11995a-5b93-4950-a5e9-93423693b2fc'>
82+
7983
| result |
8084

81-
result := resistorColorDuoCalculator valueWithColors: #('brown' 'black' ) .
85+
result := resistorColorDuoCalculator valueWithColors: #('brown' 'black') .
8286
self assert: result equals: 10
8387
]
8488

8589
{ #category : #tests }
8690
ResistorColorDuoTest >> test02_BlueAndGrey [
91+
<exeTestName: 'Blue and grey'>
92+
<exeTestUUID: '7bf82f7a-af23-48ba-a97d-38d59406a920'>
93+
8794
| result |
8895

89-
result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey' ) .
96+
result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey') .
9097
self assert: result equals: 68
9198
]
9299

93100
{ #category : #tests }
94101
ResistorColorDuoTest >> test03_YellowAndViolet [
102+
<exeTestName: 'Yellow and violet'>
103+
<exeTestUUID: 'f1886361-fdfd-4693-acf8-46726fe24e0c'>
104+
95105
| result |
96106

97-
result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet' ) .
107+
result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet') .
98108
self assert: result equals: 47
99109
]
100110

101111
{ #category : #tests }
102-
ResistorColorDuoTest >> test04_OrangeAndOrange [
112+
ResistorColorDuoTest >> test04_WhiteAndRed [
113+
<exeTestName: 'White and red'>
114+
<exeTestUUID: 'b7a6cbd2-ae3c-470a-93eb-56670b305640'>
115+
103116
| result |
104117

105-
result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange' ) .
118+
result := resistorColorDuoCalculator valueWithColors: #('white' 'red') .
119+
self assert: result equals: 92
120+
]
121+
122+
{ #category : #tests }
123+
ResistorColorDuoTest >> test05_OrangeAndOrange [
124+
<exeTestName: 'Orange and orange'>
125+
<exeTestUUID: '77a8293d-2a83-4016-b1af-991acc12b9fe'>
126+
127+
| result |
128+
129+
result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange') .
106130
self assert: result equals: 33
107131
]
108132

109133
{ #category : #tests }
110-
ResistorColorDuoTest >> test05_IgnoreExtraColors [
134+
ResistorColorDuoTest >> test06_IgnoreAdditionalColors [
135+
<exeTestName: 'Ignore additional colors'>
136+
<exeTestUUID: '0c4fb44f-db7c-4d03-afa8-054350f156a8'>
137+
111138
| result |
112139

113-
result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange' ) .
140+
result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange') .
114141
self assert: result equals: 51
115142
]
116143

144+
{ #category : #tests }
145+
ResistorColorDuoTest >> test07_BlackAndBrownOnedigit [
146+
<exeTestName: 'Black and brown, one-digit'>
147+
<exeTestUUID: '4a8ceec5-0ab4-4904-88a4-daf953a5e818'>
148+
149+
| result |
150+
151+
result := resistorColorDuoCalculator valueWithColors: #('black' 'brown') .
152+
self assert: result equals: 1
153+
]
154+
117155
{ #category : #extra }
118156
ResistorColorDuoTest >> testDetectInvalidColors [
119157
"first color"

exercises/practice/resistor-color-duo/.docs/instructions.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
If you want to build something using a Raspberry Pi, you'll probably use _resistors_.
44
For this exercise, you need to know two things about them:
55

6-
* Each resistor has a resistance value.
7-
* Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read.
6+
- Each resistor has a resistance value.
7+
- Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read.
88

99
To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values.
1010
Each band has a position and a numeric value.
@@ -31,4 +31,3 @@ The band colors are encoded as follows:
3131
From the example above:
3232
brown-green should return 15
3333
brown-green-violet should return 15 too, ignoring the third color.
34-
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
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.
411

512
[ce11995a-5b93-4950-a5e9-93423693b2fc]
613
description = "Brown and black"
@@ -11,8 +18,14 @@ description = "Blue and grey"
1118
[f1886361-fdfd-4693-acf8-46726fe24e0c]
1219
description = "Yellow and violet"
1320

21+
[b7a6cbd2-ae3c-470a-93eb-56670b305640]
22+
description = "White and red"
23+
1424
[77a8293d-2a83-4016-b1af-991acc12b9fe]
1525
description = "Orange and orange"
1626

1727
[0c4fb44f-db7c-4d03-afa8-054350f156a8]
1828
description = "Ignore additional colors"
29+
30+
[4a8ceec5-0ab4-4904-88a4-daf953a5e818]
31+
description = "Black and brown, one-digit"

exercises/practice/resistor-color-duo/ResistorColorDuoTest.class.st

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,95 @@ ResistorColorDuoTest >> setUp [
7676

7777
{ #category : #tests }
7878
ResistorColorDuoTest >> test01_BrownAndBlack [
79+
"Tip: Remember to review the class [Comment] tab"
80+
<exeTestName: 'Brown and black'>
81+
<exeTestUUID: 'ce11995a-5b93-4950-a5e9-93423693b2fc'>
82+
7983
| result |
8084

81-
result := resistorColorDuoCalculator valueWithColors: #('brown' 'black' ) .
85+
result := resistorColorDuoCalculator valueWithColors: #('brown' 'black') .
8286
self assert: result equals: 10
8387
]
8488

8589
{ #category : #tests }
8690
ResistorColorDuoTest >> test02_BlueAndGrey [
91+
<exeTestName: 'Blue and grey'>
92+
<exeTestUUID: '7bf82f7a-af23-48ba-a97d-38d59406a920'>
93+
8794
| result |
8895

89-
result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey' ) .
96+
result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey') .
9097
self assert: result equals: 68
9198
]
9299

93100
{ #category : #tests }
94101
ResistorColorDuoTest >> test03_YellowAndViolet [
102+
<exeTestName: 'Yellow and violet'>
103+
<exeTestUUID: 'f1886361-fdfd-4693-acf8-46726fe24e0c'>
104+
95105
| result |
96106

97-
result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet' ) .
107+
result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet') .
98108
self assert: result equals: 47
99109
]
100110

101111
{ #category : #tests }
102-
ResistorColorDuoTest >> test04_OrangeAndOrange [
112+
ResistorColorDuoTest >> test04_WhiteAndRed [
113+
<exeTestName: 'White and red'>
114+
<exeTestUUID: 'b7a6cbd2-ae3c-470a-93eb-56670b305640'>
115+
116+
| result |
117+
118+
result := resistorColorDuoCalculator valueWithColors: #('white' 'red') .
119+
self assert: result equals: 92
120+
]
121+
122+
{ #category : #tests }
123+
ResistorColorDuoTest >> test05_OrangeAndOrange [
124+
<exeTestName: 'Orange and orange'>
125+
<exeTestUUID: '77a8293d-2a83-4016-b1af-991acc12b9fe'>
126+
103127
| result |
104128

105-
result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange' ) .
129+
result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange') .
106130
self assert: result equals: 33
107131
]
132+
133+
{ #category : #tests }
134+
ResistorColorDuoTest >> test06_IgnoreAdditionalColors [
135+
<exeTestName: 'Ignore additional colors'>
136+
<exeTestUUID: '0c4fb44f-db7c-4d03-afa8-054350f156a8'>
137+
138+
| result |
139+
140+
result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange') .
141+
self assert: result equals: 51
142+
]
143+
144+
{ #category : #tests }
145+
ResistorColorDuoTest >> test07_BlackAndBrownOnedigit [
146+
<exeTestName: 'Black and brown, one-digit'>
147+
<exeTestUUID: '4a8ceec5-0ab4-4904-88a4-daf953a5e818'>
148+
149+
| result |
150+
151+
result := resistorColorDuoCalculator valueWithColors: #('black' 'brown') .
152+
self assert: result equals: 1
153+
]
154+
155+
{ #category : #extra }
156+
ResistorColorDuoTest >> testDetectInvalidColors [
157+
"first color"
158+
self
159+
should: [resistorColorDuoCalculator valueWithColors: #('unknown' 'black' )]
160+
raise: Error
161+
whoseDescriptionIncludes: 'Invalid color'
162+
description: 'Should get an error with an unknown color'.
163+
164+
"second color"
165+
self
166+
should: [resistorColorDuoCalculator valueWithColors: #('black' 'unknown' )]
167+
raise: Error
168+
whoseDescriptionIncludes: 'Invalid color'
169+
description: 'Should get an error with an unknown color'
170+
]

0 commit comments

Comments
 (0)