Rewrites StringUtilsTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-20 23:10:34 -07:00
parent 309f823cc4
commit a49a104475

View file

@ -1,19 +1,19 @@
package info.nightscout.core.utils package info.nightscout.core.utils
import com.google.common.truth.Truth.assertThat
import info.nightscout.core.utils.receivers.StringUtils import info.nightscout.core.utils.receivers.StringUtils
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class StringUtilsTest { class StringUtilsTest {
@Test fun removeSurroundingQuotesTest() { @Test fun removeSurroundingQuotesTest() {
var compareString = "test" var compareString = "test"
Assertions.assertEquals(compareString, StringUtils.removeSurroundingQuotes(compareString)) assertThat(StringUtils.removeSurroundingQuotes(compareString)).isEqualTo(compareString)
Assertions.assertEquals(compareString, StringUtils.removeSurroundingQuotes("\"" + compareString + "\"")) assertThat(StringUtils.removeSurroundingQuotes("\"" + compareString + "\"")).isEqualTo(compareString)
Assertions.assertEquals("\"" + compareString, StringUtils.removeSurroundingQuotes("\"" + compareString)) assertThat(StringUtils.removeSurroundingQuotes("\"" + compareString)).isEqualTo("\"" + compareString)
compareString = "te\"st" compareString = """te"st"""
Assertions.assertEquals(compareString, StringUtils.removeSurroundingQuotes(compareString)) assertThat(StringUtils.removeSurroundingQuotes(compareString)).isEqualTo(compareString)
Assertions.assertEquals(compareString, StringUtils.removeSurroundingQuotes("\"" + compareString + "\"")) assertThat(StringUtils.removeSurroundingQuotes("\"" + compareString + "\"")).isEqualTo(compareString)
Assertions.assertEquals("\"" + compareString, StringUtils.removeSurroundingQuotes("\"" + compareString)) assertThat(StringUtils.removeSurroundingQuotes("\"" + compareString)).isEqualTo("\"" + compareString)
} }
} }