Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

594 out of sync unit tests for resistor color duo #595

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 deletions dev/src/Exercise@ResistorColorDuo/ResistorColorDuoTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -76,44 +76,82 @@ ResistorColorDuoTest >> setUp [

{ #category : #tests }
ResistorColorDuoTest >> test01_BrownAndBlack [
"Tip: Remember to review the class [Comment] tab"
<exeTestName: 'Brown and black'>
<exeTestUUID: 'ce11995a-5b93-4950-a5e9-93423693b2fc'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('brown' 'black' ) .
result := resistorColorDuoCalculator valueWithColors: #('brown' 'black') .
self assert: result equals: 10
]

{ #category : #tests }
ResistorColorDuoTest >> test02_BlueAndGrey [
<exeTestName: 'Blue and grey'>
<exeTestUUID: '7bf82f7a-af23-48ba-a97d-38d59406a920'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey' ) .
result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey') .
self assert: result equals: 68
]

{ #category : #tests }
ResistorColorDuoTest >> test03_YellowAndViolet [
<exeTestName: 'Yellow and violet'>
<exeTestUUID: 'f1886361-fdfd-4693-acf8-46726fe24e0c'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet' ) .
result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet') .
self assert: result equals: 47
]

{ #category : #tests }
ResistorColorDuoTest >> test04_OrangeAndOrange [
ResistorColorDuoTest >> test04_WhiteAndRed [
<exeTestName: 'White and red'>
<exeTestUUID: 'b7a6cbd2-ae3c-470a-93eb-56670b305640'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange' ) .
result := resistorColorDuoCalculator valueWithColors: #('white' 'red') .
self assert: result equals: 92
]

{ #category : #tests }
ResistorColorDuoTest >> test05_OrangeAndOrange [
<exeTestName: 'Orange and orange'>
<exeTestUUID: '77a8293d-2a83-4016-b1af-991acc12b9fe'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange') .
self assert: result equals: 33
]

{ #category : #tests }
ResistorColorDuoTest >> test05_IgnoreExtraColors [
ResistorColorDuoTest >> test06_IgnoreAdditionalColors [
<exeTestName: 'Ignore additional colors'>
<exeTestUUID: '0c4fb44f-db7c-4d03-afa8-054350f156a8'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange' ) .
result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange') .
self assert: result equals: 51
]

{ #category : #tests }
ResistorColorDuoTest >> test07_BlackAndBrownOnedigit [
<exeTestName: 'Black and brown, one-digit'>
<exeTestUUID: '4a8ceec5-0ab4-4904-88a4-daf953a5e818'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('black' 'brown') .
self assert: result equals: 1
]

{ #category : #extra }
ResistorColorDuoTest >> testDetectInvalidColors [
"first color"
Expand Down
5 changes: 2 additions & 3 deletions exercises/practice/resistor-color-duo/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
If you want to build something using a Raspberry Pi, you'll probably use _resistors_.
For this exercise, you need to know two things about them:

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

To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values.
Each band has a position and a numeric value.
Expand All @@ -31,4 +31,3 @@ The band colors are encoded as follows:
From the example above:
brown-green should return 15
brown-green-violet should return 15 too, ignoring the third color.

19 changes: 16 additions & 3 deletions exercises/practice/resistor-color-duo/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

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

[b7a6cbd2-ae3c-470a-93eb-56670b305640]
description = "White and red"

[77a8293d-2a83-4016-b1af-991acc12b9fe]
description = "Orange and orange"

[0c4fb44f-db7c-4d03-afa8-054350f156a8]
description = "Ignore additional colors"

[4a8ceec5-0ab4-4904-88a4-daf953a5e818]
description = "Black and brown, one-digit"
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,95 @@ ResistorColorDuoTest >> setUp [

{ #category : #tests }
ResistorColorDuoTest >> test01_BrownAndBlack [
"Tip: Remember to review the class [Comment] tab"
<exeTestName: 'Brown and black'>
<exeTestUUID: 'ce11995a-5b93-4950-a5e9-93423693b2fc'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('brown' 'black' ) .
result := resistorColorDuoCalculator valueWithColors: #('brown' 'black') .
self assert: result equals: 10
]

{ #category : #tests }
ResistorColorDuoTest >> test02_BlueAndGrey [
<exeTestName: 'Blue and grey'>
<exeTestUUID: '7bf82f7a-af23-48ba-a97d-38d59406a920'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey' ) .
result := resistorColorDuoCalculator valueWithColors: #('blue' 'grey') .
self assert: result equals: 68
]

{ #category : #tests }
ResistorColorDuoTest >> test03_YellowAndViolet [
<exeTestName: 'Yellow and violet'>
<exeTestUUID: 'f1886361-fdfd-4693-acf8-46726fe24e0c'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet' ) .
result := resistorColorDuoCalculator valueWithColors: #('yellow' 'violet') .
self assert: result equals: 47
]

{ #category : #tests }
ResistorColorDuoTest >> test04_OrangeAndOrange [
ResistorColorDuoTest >> test04_WhiteAndRed [
<exeTestName: 'White and red'>
<exeTestUUID: 'b7a6cbd2-ae3c-470a-93eb-56670b305640'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('white' 'red') .
self assert: result equals: 92
]

{ #category : #tests }
ResistorColorDuoTest >> test05_OrangeAndOrange [
<exeTestName: 'Orange and orange'>
<exeTestUUID: '77a8293d-2a83-4016-b1af-991acc12b9fe'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange' ) .
result := resistorColorDuoCalculator valueWithColors: #('orange' 'orange') .
self assert: result equals: 33
]

{ #category : #tests }
ResistorColorDuoTest >> test06_IgnoreAdditionalColors [
<exeTestName: 'Ignore additional colors'>
<exeTestUUID: '0c4fb44f-db7c-4d03-afa8-054350f156a8'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('green' 'brown' 'orange') .
self assert: result equals: 51
]

{ #category : #tests }
ResistorColorDuoTest >> test07_BlackAndBrownOnedigit [
<exeTestName: 'Black and brown, one-digit'>
<exeTestUUID: '4a8ceec5-0ab4-4904-88a4-daf953a5e818'>

| result |

result := resistorColorDuoCalculator valueWithColors: #('black' 'brown') .
self assert: result equals: 1
]

{ #category : #extra }
ResistorColorDuoTest >> testDetectInvalidColors [
"first color"
self
should: [resistorColorDuoCalculator valueWithColors: #('unknown' 'black' )]
raise: Error
whoseDescriptionIncludes: 'Invalid color'
description: 'Should get an error with an unknown color'.

"second color"
self
should: [resistorColorDuoCalculator valueWithColors: #('black' 'unknown' )]
raise: Error
whoseDescriptionIncludes: 'Invalid color'
description: 'Should get an error with an unknown color'
]