-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jodz4k/main
Wrote some tests
- Loading branch information
Showing
3 changed files
with
195 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,105 @@ | ||
Class { | ||
#name : #ECECForagerTest, | ||
#superclass : #TestCase, | ||
#name : 'ECECForagerTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'restrainedForager', | ||
'unrestrainedForager' | ||
], | ||
#category : #'ECEC-Model-Tests' | ||
#category : 'ECEC-Model-Tests', | ||
#package : 'ECEC-Model-Tests' | ||
} | ||
|
||
{ #category : #initialization } | ||
{ #category : 'running' } | ||
ECECForagerTest >> setUp [ | ||
|
||
super setUp. | ||
restrainedForager := ECECRestrainedForager new. | ||
unrestrainedForager := ECECUnrestrainedForager new. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
ECECForagerTest >> testPov [ | ||
{ #category : 'running' } | ||
ECECForagerTest >> tearDown [ | ||
|
||
ECECForager initializeParameters. | ||
super tearDown. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testCatabolicRate [ | ||
|
||
ECECForager catabolicRate: 13. | ||
|
||
self assert: ECECForager catabolicRate equals: 13 | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testConsumeEnergy [ | ||
|
||
| newEnergy | | ||
restrainedForager energy: 13. | ||
restrainedForager consumeEnergy. | ||
newEnergy := restrainedForager energy. | ||
|
||
self assert: newEnergy < 13. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testEnergy [ | ||
|
||
restrainedForager energy: 13. | ||
|
||
self assert: restrainedForager energy equals: 13. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testFertilityThreshold [ | ||
|
||
ECECForager fertilityThreshold: 13. | ||
|
||
self assert: ECECForager fertilityThreshold equals: 13. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testHarvestRate [ | ||
|
||
self assert: restrainedForager pov isColor. | ||
self assert: unrestrainedForager pov isColor. | ||
ECECForager harvestRate: 13. | ||
|
||
self assert: ECECForager harvestRate equals: 13. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testInitialEnergy [ | ||
|
||
ECECForager initialEnergy: 13. | ||
|
||
self assert: ECECForager initialEnergy equals: 13. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testPov [ | ||
|
||
self assert: restrainedForager pov color isColor. | ||
self assert: unrestrainedForager pov color isColor. | ||
self deny: restrainedForager pov equals: unrestrainedForager pov. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testPovCowClassRestrained [ | ||
|
||
self assert: restrainedForager cowPovClass equals: CMPurpleCow. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testPovCowClassUnrestrained [ | ||
|
||
self assert: unrestrainedForager cowPovClass equals: CMBrownCow. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECForagerTest >> testPovEnergyClass [ | ||
|
||
| pov | | ||
pov := restrainedForager povEnergy. | ||
self assert: pov class equals: CMPointOfView. | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
Class { | ||
#name : 'ECECVegetationUnitTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'vegetationUnit' | ||
], | ||
#category : 'ECEC-Model-Tests', | ||
#package : 'ECEC-Model-Tests' | ||
} | ||
|
||
{ #category : 'running' } | ||
ECECVegetationUnitTest >> setUp [ | ||
super setUp. | ||
|
||
vegetationUnit := ECECVegetationUnit new. | ||
vegetationUnit randomNumberGenerator: (Random seed: 13). | ||
] | ||
|
||
{ #category : 'running' } | ||
ECECVegetationUnitTest >> tearDown [ | ||
|
||
ECECVegetationUnit initializeParameters. | ||
super tearDown. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECVegetationUnitTest >> testAsString [ | ||
|
||
| expectedString | | ||
vegetationUnit id: 13. | ||
expectedString := 'an ECECVegetationUnit -id: 13 -n: 0 -o: 0 | ||
id: 13 | ||
coordinates: nil | ||
biomass: 0.0'. | ||
|
||
self assert: vegetationUnit asString equals: expectedString. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECVegetationUnitTest >> testBiomassAccessors [ | ||
|
||
vegetationUnit biomass: 13. | ||
|
||
self assert: vegetationUnit biomass equals: 13. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECVegetationUnitTest >> testGrowBiomass [ | ||
| oldBiomass newBiomass | | ||
|
||
vegetationUnit biomass: 1. | ||
|
||
oldBiomass := vegetationUnit biomass. | ||
vegetationUnit growBiomass. | ||
newBiomass := vegetationUnit biomass. | ||
|
||
self assert: newBiomass > oldBiomass | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECVegetationUnitTest >> testInitialBiomassIsZero [ | ||
|
||
|
||
self assert: vegetationUnit biomass equals: 0. | ||
] | ||
|
||
{ #category : 'tests' } | ||
ECECVegetationUnitTest >> testInitializeParameters [ | ||
|
||
self assert: ECECVegetationUnit k equals: 10. | ||
self assert: ECECVegetationUnit r equals: 0.2. | ||
|
||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ECECVegetationUnitTest >> testInitializeWithRandomBiomass [ | ||
|
||
vegetationUnit initializeWithRandomBiomass. | ||
|
||
self assert: vegetationUnit biomass closeTo: 0.11401195. | ||
|
||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ECECVegetationUnitTest >> testK [ | ||
|
||
ECECVegetationUnit k: 13. | ||
|
||
self assert: ECECVegetationUnit k equals: 13. | ||
|
||
|
||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ECECVegetationUnitTest >> testR [ | ||
|
||
ECECVegetationUnit r: 13. | ||
|
||
self assert: ECECVegetationUnit r equals: 13. | ||
|
||
|
||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Package { #name : #'ECEC-Model-Tests' } | ||
Package { #name : 'ECEC-Model-Tests' } |