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