HotColdTemperature: Fix warm-but-colder temperature bug

Because the word "cold" is used both as a temperature ("The device is
cold"), and in a temperature change ("but colder than last time."),
HotColdTemperature tried to interpret COLDER temperature changes as a
COLD temperature match. By matching only the section of the temperature
string preceding the optional comma, this bug is avoided.
This commit is contained in:
Jordan Atwood
2019-06-30 23:10:05 -07:00
parent 76d4031445
commit 45e1441072
2 changed files with 5 additions and 1 deletions

View File

@@ -73,5 +73,7 @@ public class HotColdTemperatureTest
assertEquals(HotColdTemperature.ICE_COLD, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, "The device is ice cold."));
assertEquals(HotColdTemperature.VERY_COLD, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, "The device is very cold."));
assertEquals(HotColdTemperature.VERY_HOT, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES, "The device is very hot."));
assertEquals(HotColdTemperature.COLD, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.BEGINNER_HOT_COLD_TEMPERATURES, "The device is cold, and warmer than last time."));
assertEquals(HotColdTemperature.WARM, HotColdTemperature.getFromTemperatureSet(HotColdTemperature.BEGINNER_HOT_COLD_TEMPERATURES, "The device is warm, but colder than last time."));
}
}