View Javadoc
1   package ch.hslu.exercises.sw12.ex7;
2   
3   import org.junit.jupiter.api.Test;
4   
5   import static org.junit.jupiter.api.Assertions.*;
6   
7   class LanguageTest {
8       @Test
9       void testLanguageAlgo() {
10          assertTrue(Language.isWordLanguage("0"));
11          assertTrue(Language.isWordLanguage("010"));
12          assertTrue(Language.isWordLanguage("01110"));
13          assertTrue(Language.isWordLanguage("0111010"));
14          assertTrue(Language.isWordLanguage("0101110"));
15          assertTrue(Language.isWordLanguage("0101010"));
16  
17          assertFalse(Language.isWordLanguage("00101010"));
18          assertFalse(Language.isWordLanguage("011110"));
19          assertFalse(Language.isWordLanguage("abc"));
20          assertFalse(Language.isWordLanguage(""));
21          assertFalse(Language.isWordLanguage(" "));
22      }
23  
24      @Test
25      void testLanguageRegx() {
26          assertTrue(Language.isWordLanguageRegex("0"));
27          assertTrue(Language.isWordLanguageRegex("010"));
28          assertTrue(Language.isWordLanguageRegex("01110"));
29          assertTrue(Language.isWordLanguageRegex("0111010"));
30          assertTrue(Language.isWordLanguageRegex("0101110"));
31          assertTrue(Language.isWordLanguageRegex("0101010"));
32  
33          assertFalse(Language.isWordLanguageRegex("00101010"));
34          assertFalse(Language.isWordLanguageRegex("011110"));
35          assertFalse(Language.isWordLanguageRegex("abc"));
36          assertFalse(Language.isWordLanguageRegex(""));
37          assertFalse(Language.isWordLanguageRegex(" "));
38      }
39  
40  }