Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@
* [OctalToHexadecimalTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/conversions/OctalToHexadecimalTest.java)
* [PhoneticAlphabetConverterTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/conversions/PhoneticAlphabetConverterTest.java)
* [RomanToIntegerTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/conversions/RomanToIntegerTest.java)
* [TurkishToLatinConversionTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/conversions/TurkishToLatinConversionTest.java)
* [UnitConversionsTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/conversions/UnitConversionsTest.java)
* [UnitsConverterTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/conversions/UnitsConverterTest.java)
* datastructures
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.thealgorithms.conversions;

import java.util.Scanner;

/**
* Converts turkish character to latin character
*
Expand All @@ -11,21 +9,12 @@ public final class TurkishToLatinConversion {
private TurkishToLatinConversion() {
}

/**
* Main method
*
* @param args Command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Input the string: ");
String b = sc.next();
System.out.println("Converted: " + convertTurkishToLatin(b));
sc.close();
}

/**
* This method converts a turkish character to latin character.
* Steps:
* 1. Define turkish characters and their corresponding latin characters
* 2. Replace all turkish characters with their corresponding latin characters
* 3. Return the converted string
*
* @param param String paramter
* @return String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.thealgorithms.conversions;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

public class TurkishToLatinConversionTest {

@ParameterizedTest
@CsvSource({
"'çalışma', 'calisma'", // Turkish to Latin conversion for lowercase
"'ÇALIŞMA', 'CALISMA'", // Turkish to Latin conversion for uppercase
"'İSTANBUL', 'ISTANBUL'", // Special case of 'İ' to 'I'
"'istanbul', 'istanbul'", // Special case of 'ı' to 'i'
"'GÜL', 'GUL'", // Special case of 'Ü' to 'U'
"'gül', 'gul'", // Special case of 'ü' to 'u'
"'ÖĞRENME', 'OGRENME'", // Special case of 'Ö' to 'O' and 'Ğ' to 'G'
"'öğrenme', 'ogrenme'", // Special case of 'ö' to 'o' and 'ğ' to 'g'
"'ŞEHIR', 'SEHIR'", // Special case of 'Ş' to 'S'
"'şehir', 'sehir'", // Special case of 'ş' to 's'
"'HELLO', 'HELLO'", // String with no Turkish characters, should remain unchanged
"'Merhaba Dünya!', 'Merhaba Dunya!'", // Mixed Turkish and Latin characters with punctuation
"'Çift kişilik yataklı odalar', 'Cift kisilik yatakli odalar'", // Full sentence conversion
"'', ''" // Empty string case
})
public void
testConvertTurkishToLatin(String input, String expectedOutput) {
assertEquals(expectedOutput, TurkishToLatinConversion.convertTurkishToLatin(input));
}
}