File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
core-kotlin-modules/core-kotlin-strings-4/src/test/kotlin/com/baeldung/equalsIgnoreCaseInKotlin Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.baeldung.equalsIgnoreCaseInKotlin
2
+
3
+ import org.junit.jupiter.api.Assertions.assertFalse
4
+ import org.junit.jupiter.api.Assertions.assertTrue
5
+ import org.junit.jupiter.api.Test
6
+
7
+ class EqualsIgnoreCaseInKotlinUnitTest {
8
+
9
+ @Test
10
+ fun `test string case insensitive comparison using equals and lowercase methods` () {
11
+ val result1 = " Hello" .lowercase() == " hello" .lowercase()
12
+ val result2 = " Hello" .lowercase() == " world" .lowercase()
13
+
14
+ assertTrue(result1)
15
+ assertFalse(result2)
16
+ }
17
+
18
+ @Test
19
+ fun `test string case insensitive comparison using equals methods` () {
20
+ val result1 = " Hello" .equals(" hello" , true )
21
+ val result2 = " Hello" .equals(" world" , true )
22
+
23
+ assertTrue(result1)
24
+ assertFalse(result2)
25
+ }
26
+
27
+ @Test
28
+ fun `test string case insensitive comparison using compareTo method` () {
29
+ val result1 = " Hello" .compareTo(" hello" , true ) == 0
30
+ val result2 = " Hello" .compareTo(" world" , true ) == 0
31
+
32
+ assertTrue(result1)
33
+ assertFalse(result2)
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments