From 8869d9c63580a7a57deeb0ba97807061deab7602 Mon Sep 17 00:00:00 2001 From: George Herbert Date: Thu, 28 May 2020 10:40:09 +0100 Subject: [PATCH] Fix maximum wages of 9,999,999.99 being invalid (#42) --- .../calculator/utils/validation/WageValidator.kt | 2 +- .../utils/validation/WageValidatorTests.kt | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/commonMain/kotlin/uk/gov/hmrc/calculator/utils/validation/WageValidator.kt b/src/commonMain/kotlin/uk/gov/hmrc/calculator/utils/validation/WageValidator.kt index 5b14cc9..55b2bb4 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/calculator/utils/validation/WageValidator.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/calculator/utils/validation/WageValidator.kt @@ -25,5 +25,5 @@ object WageValidator { fun isAboveMinimumWages(wages: Double) = wages > 0 - fun isBelowMaximumWages(wages: Double) = wages < 9999999.99 + fun isBelowMaximumWages(wages: Double) = wages <= 9999999.99 } diff --git a/src/commonTest/kotlin/uk/gov/hmrc/calculator/utils/validation/WageValidatorTests.kt b/src/commonTest/kotlin/uk/gov/hmrc/calculator/utils/validation/WageValidatorTests.kt index ac76a3b..e6b0609 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/calculator/utils/validation/WageValidatorTests.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/calculator/utils/validation/WageValidatorTests.kt @@ -51,10 +51,20 @@ class WageValidatorTests { } @Test - fun `Validate wages below max`() { + fun `Validate wages below max no decimal`() { assertTrue(WageValidator.isBelowMaximumWages(9999999.0)) } + @Test + fun `Validate wages below max with decimal`() { + assertTrue(WageValidator.isBelowMaximumWages(9999999.99)) + } + + @Test + fun `Validate wages below max with decimal but 3 places`() { + assertFalse(WageValidator.isBelowMaximumWages(9999999.991)) + } + @Test fun `Validate wages above max`() { assertFalse(WageValidator.isBelowMaximumWages(10000000.0))