Change variable name
This commit is contained in:
parent
74e52749d4
commit
19b0b02102
|
@ -6,42 +6,42 @@ import kotlin.test.assertTrue
|
|||
|
||||
class StringComparisonUnitTest {
|
||||
|
||||
@Test
|
||||
fun `compare using equals operator`() {
|
||||
val first = "kotlin"
|
||||
val second = "kotlin"
|
||||
val firstCapitalized = "KOTLIN"
|
||||
assertTrue { first == second }
|
||||
assertFalse { first == firstCapitalized }
|
||||
}
|
||||
@Test
|
||||
fun `compare using equals operator`() {
|
||||
val first = "kotlin"
|
||||
val second = "kotlin"
|
||||
val firstCapitalized = "KOTLIN"
|
||||
assertTrue { first == second }
|
||||
assertFalse { first == firstCapitalized }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `compare using referential equals operator`() {
|
||||
val first = "kotlin"
|
||||
val second = "kotlin"
|
||||
val firstBuildAgain = buildString { "kotlin" }
|
||||
assertTrue { first === second }
|
||||
assertFalse { first === firstBuildAgain }
|
||||
}
|
||||
@Test
|
||||
fun `compare using referential equals operator`() {
|
||||
val first = "kotlin"
|
||||
val second = "kotlin"
|
||||
val copyOfFirst = buildString { "kotlin" }
|
||||
assertTrue { first === second }
|
||||
assertFalse { first === copyOfFirst }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `compare using equals method`() {
|
||||
val first = "kotlin"
|
||||
val second = "kotlin"
|
||||
val firstCapitalized = "KOTLIN"
|
||||
assertTrue { first.equals(second) }
|
||||
assertFalse { first.equals(firstCapitalized) }
|
||||
assertTrue { first.equals(firstCapitalized, true) }
|
||||
}
|
||||
@Test
|
||||
fun `compare using equals method`() {
|
||||
val first = "kotlin"
|
||||
val second = "kotlin"
|
||||
val firstCapitalized = "KOTLIN"
|
||||
assertTrue { first.equals(second) }
|
||||
assertFalse { first.equals(firstCapitalized) }
|
||||
assertTrue { first.equals(firstCapitalized, true) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `compare using compare method`() {
|
||||
val first = "kotlin"
|
||||
val second = "kotlin"
|
||||
val firstCapitalized = "KOTLIN"
|
||||
assertTrue { first.compareTo(second) == 0 }
|
||||
assertTrue { first.compareTo(firstCapitalized) == 32 }
|
||||
assertTrue { firstCapitalized.compareTo(first) == -32 }
|
||||
assertTrue { first.compareTo(firstCapitalized, true) == 0 }
|
||||
}
|
||||
@Test
|
||||
fun `compare using compare method`() {
|
||||
val first = "kotlin"
|
||||
val second = "kotlin"
|
||||
val firstCapitalized = "KOTLIN"
|
||||
assertTrue { first.compareTo(second) == 0 }
|
||||
assertTrue { first.compareTo(firstCapitalized) == 32 }
|
||||
assertTrue { firstCapitalized.compareTo(first) == -32 }
|
||||
assertTrue { first.compareTo(firstCapitalized, true) == 0 }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue