mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Add MorseCodeConverter algorithm (#5749)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.thealgorithms.conversions;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MorseCodeConverterTest {
|
||||
|
||||
@Test
|
||||
public void testTextToMorse() {
|
||||
assertEquals(".- -...", MorseCodeConverter.textToMorse("AB"));
|
||||
assertEquals(".... . .-.. .-.. --- | .-- --- .-. .-.. -..", MorseCodeConverter.textToMorse("HELLO WORLD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMorseToText() {
|
||||
assertEquals("AB", MorseCodeConverter.morseToText(".- -..."));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user