Skip to content

Commit e6a7ec7

Browse files
committed
refactor: Remove 'main', add tests in TurkishToLatinConversion
1 parent 2f9f75a commit e6a7ec7

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

src/main/java/com/thealgorithms/conversions/TurkishToLatinConversion.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.thealgorithms.conversions;
22

3-
import java.util.Scanner;
4-
53
/**
64
* Converts turkish character to latin character
75
*
@@ -11,19 +9,6 @@ public final class TurkishToLatinConversion {
119
private TurkishToLatinConversion() {
1210
}
1311

14-
/**
15-
* Main method
16-
*
17-
* @param args Command line arguments
18-
*/
19-
public static void main(String[] args) {
20-
Scanner sc = new Scanner(System.in);
21-
System.out.println("Input the string: ");
22-
String b = sc.next();
23-
System.out.println("Converted: " + convertTurkishToLatin(b));
24-
sc.close();
25-
}
26-
2712
/**
2813
* This method converts a turkish character to latin character.
2914
*
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.thealgorithms.conversions;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import org.junit.jupiter.params.ParameterizedTest;
6+
import org.junit.jupiter.params.provider.CsvSource;
7+
8+
public class TurkishToLatinConversionTest {
9+
10+
@ParameterizedTest
11+
@CsvSource({
12+
"'çalışma', 'calisma'", // Turkish to Latin conversion for lowercase
13+
"'ÇALIŞMA', 'CALISMA'", // Turkish to Latin conversion for uppercase
14+
"'İSTANBUL', 'ISTANBUL'", // Special case of 'İ' to 'I'
15+
"'istanbul', 'istanbul'", // Special case of 'ı' to 'i'
16+
"'GÜL', 'GUL'", // Special case of 'Ü' to 'U'
17+
"'gül', 'gul'", // Special case of 'ü' to 'u'
18+
"'ÖĞRENME', 'OGRENME'", // Special case of 'Ö' to 'O' and 'Ğ' to 'G'
19+
"'öğrenme', 'ogrenme'", // Special case of 'ö' to 'o' and 'ğ' to 'g'
20+
"'ŞEHIR', 'SEHIR'", // Special case of 'Ş' to 'S'
21+
"'şehir', 'sehir'", // Special case of 'ş' to 's'
22+
"'HELLO', 'HELLO'", // String with no Turkish characters, should remain unchanged
23+
"'Merhaba Dünya!', 'Merhaba Dunya!'", // Mixed Turkish and Latin characters with punctuation
24+
"'Çift kişilik yataklı odalar', 'Cift kisilik yatakli odalar'", // Full sentence conversion
25+
"'', ''" // Empty string case
26+
})
27+
public void
28+
testConvertTurkishToLatin(String input, String expectedOutput) {
29+
assertEquals(expectedOutput, TurkishToLatinConversion.convertTurkishToLatin(input));
30+
}
31+
}

0 commit comments

Comments
 (0)