Skip to content
Merged
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
31 changes: 10 additions & 21 deletions src/test/scala/floodsim/model/weather/WeatherTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,58 @@ import org.scalatest.matchers.should.Matchers

class WeatherTest extends AnyFlatSpec with Matchers:

"Weather enum" should "have correct waterDelta values" in {
"Weather enum" should "have correct waterDelta values" in:
Weather.IntenseSun.waterDelta shouldBe -0.5
Weather.ClearSky.waterDelta shouldBe -0.1
Weather.LightClouds.waterDelta shouldBe 0.0
Weather.HeavyClouds.waterDelta shouldBe 0.2
Weather.LightRain.waterDelta shouldBe 0.5
Weather.HeavyRain.waterDelta shouldBe 1.0
}

"Weather.random" should "return a valid Weather instance" in {
"Weather.random" should "return a valid Weather instance" in:
for _ <- 1 to 100 do
val result = Weather.random
Weather.values should contain(result)
}

"Weather.forIntensity" should "return IntenseSun for intensities <= -0.1" in {
"Weather.forIntensity" should "return IntenseSun for intensities <= -0.1" in:
Weather.forIntensity(-100.0) shouldBe Weather.IntenseSun
Weather.forIntensity(-1.0) shouldBe Weather.IntenseSun
Weather.forIntensity(-0.1) shouldBe Weather.IntenseSun
}

it should "return ClearSky for intensities between -0.1 and 0.0" in {
it should "return ClearSky for intensities between -0.1 and 0.0" in:
Weather.forIntensity(-0.09) shouldBe Weather.ClearSky
Weather.forIntensity(-0.05) shouldBe Weather.ClearSky
Weather.forIntensity(0.0) shouldBe Weather.ClearSky
}

it should "return LightClouds for intensities between 0.0 and 0.2" in {
it should "return LightClouds for intensities between 0.0 and 0.2" in:
Weather.forIntensity(0.01) shouldBe Weather.LightClouds
Weather.forIntensity(0.1) shouldBe Weather.LightClouds
Weather.forIntensity(0.2) shouldBe Weather.LightClouds
}

it should "return HeavyClouds for intensities between 0.2 and 0.5" in {
it should "return HeavyClouds for intensities between 0.2 and 0.5" in:
Weather.forIntensity(0.21) shouldBe Weather.HeavyClouds
Weather.forIntensity(0.3) shouldBe Weather.HeavyClouds
Weather.forIntensity(0.5) shouldBe Weather.HeavyClouds
}

it should "return LightRain for intensities between 0.5 and 1.0" in {
it should "return LightRain for intensities between 0.5 and 1.0" in:
Weather.forIntensity(0.51) shouldBe Weather.LightRain
Weather.forIntensity(0.75) shouldBe Weather.LightRain
Weather.forIntensity(1.0) shouldBe Weather.LightRain
}

it should "return HeavyRain for intensities > 1.0" in {
it should "return HeavyRain for intensities > 1.0" in:
Weather.forIntensity(1.01) shouldBe Weather.HeavyRain
Weather.forIntensity(2.0) shouldBe Weather.HeavyRain
Weather.forIntensity(Double.MaxValue) shouldBe Weather.HeavyRain
}

it should "handle edge cases correctly" in {
it should "handle edge cases correctly" in:
Weather.forIntensity(Double.NegativeInfinity) shouldBe Weather.IntenseSun
Weather.forIntensity(Double.MinValue) shouldBe Weather.IntenseSun
Weather.forIntensity(Double.PositiveInfinity) shouldBe Weather.HeavyRain
Weather.forIntensity(Double.NaN) shouldBe Weather.HeavyRain
}

it should "match exact boundary values correctly" in {
it should "match exact boundary values correctly" in:
Weather.forIntensity(-0.1) shouldBe Weather.IntenseSun
Weather.forIntensity(0.0) shouldBe Weather.ClearSky
Weather.forIntensity(0.2) shouldBe Weather.LightClouds
Weather.forIntensity(0.5) shouldBe Weather.HeavyClouds
Weather.forIntensity(1.0) shouldBe Weather.LightRain
}

Loading