mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-06 00:54:32 +08:00
Remove 'main', add tests in TurkishToLatinConversion
(#5944)
This commit is contained in:
@ -775,6 +775,7 @@
|
|||||||
* [OctalToHexadecimalTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/conversions/OctalToHexadecimalTest.java)
|
* [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)
|
* [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)
|
* [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)
|
* [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)
|
* [UnitsConverterTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/conversions/UnitsConverterTest.java)
|
||||||
* datastructures
|
* datastructures
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.thealgorithms.conversions;
|
package com.thealgorithms.conversions;
|
||||||
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts turkish character to latin character
|
* Converts turkish character to latin character
|
||||||
*
|
*
|
||||||
@ -11,21 +9,12 @@ public final class TurkishToLatinConversion {
|
|||||||
private 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.
|
* 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
|
* @param param String paramter
|
||||||
* @return String
|
* @return String
|
||||||
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user