Change variable name

This commit is contained in:
Sushant 2019-02-18 19:39:36 +01:00
parent 74e52749d4
commit 19b0b02102
1 changed files with 35 additions and 35 deletions

View File

@ -6,42 +6,42 @@ import kotlin.test.assertTrue
class StringComparisonUnitTest { class StringComparisonUnitTest {
@Test @Test
fun `compare using equals operator`() { fun `compare using equals operator`() {
val first = "kotlin" val first = "kotlin"
val second = "kotlin" val second = "kotlin"
val firstCapitalized = "KOTLIN" val firstCapitalized = "KOTLIN"
assertTrue { first == second } assertTrue { first == second }
assertFalse { first == firstCapitalized } assertFalse { first == firstCapitalized }
} }
@Test @Test
fun `compare using referential equals operator`() { fun `compare using referential equals operator`() {
val first = "kotlin" val first = "kotlin"
val second = "kotlin" val second = "kotlin"
val firstBuildAgain = buildString { "kotlin" } val copyOfFirst = buildString { "kotlin" }
assertTrue { first === second } assertTrue { first === second }
assertFalse { first === firstBuildAgain } assertFalse { first === copyOfFirst }
} }
@Test @Test
fun `compare using equals method`() { fun `compare using equals method`() {
val first = "kotlin" val first = "kotlin"
val second = "kotlin" val second = "kotlin"
val firstCapitalized = "KOTLIN" val firstCapitalized = "KOTLIN"
assertTrue { first.equals(second) } assertTrue { first.equals(second) }
assertFalse { first.equals(firstCapitalized) } assertFalse { first.equals(firstCapitalized) }
assertTrue { first.equals(firstCapitalized, true) } assertTrue { first.equals(firstCapitalized, true) }
} }
@Test @Test
fun `compare using compare method`() { fun `compare using compare method`() {
val first = "kotlin" val first = "kotlin"
val second = "kotlin" val second = "kotlin"
val firstCapitalized = "KOTLIN" val firstCapitalized = "KOTLIN"
assertTrue { first.compareTo(second) == 0 } assertTrue { first.compareTo(second) == 0 }
assertTrue { first.compareTo(firstCapitalized) == 32 } assertTrue { first.compareTo(firstCapitalized) == 32 }
assertTrue { firstCapitalized.compareTo(first) == -32 } assertTrue { firstCapitalized.compareTo(first) == -32 }
assertTrue { first.compareTo(firstCapitalized, true) == 0 } assertTrue { first.compareTo(firstCapitalized, true) == 0 }
} }
} }