diff --git a/program/Hellos.java b/program/Hellos.java deleted file mode 100644 index ef93add..0000000 --- a/program/Hellos.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * A simple Java program used to demonstrate merge conflicts when - * multiple people edit the same piece of code. - */ -public class Hellos { - - public static void main(String[] args) { - StringBuilder builder = new StringBuilder(); - - builder.append("Hello, folks!\n"); - builder.append(nic_says_hello()); - builder.append(kk_says_hello()); - - System.out.println(builder.toString()); - } - - private static String nic_says_hello() { - return "Nic says 'Howdy!'\n"; - } - - private static String kk_says_hello() { - return "KK says 'Hello!'\n"; - } - -} diff --git a/program/umm/csci3601/Hellos.java b/program/umm/csci3601/Hellos.java new file mode 100644 index 0000000..b001f60 --- /dev/null +++ b/program/umm/csci3601/Hellos.java @@ -0,0 +1,35 @@ +package umm.csci3601; + +/** + * A simple Java program used to demonstrate merge conflicts when + * multiple people edit the same piece of code. + */ +public class Hellos { + + public static final String WELCOME_LINE = "Hello, folks!"; + + public static void main(String[] args) { + String output = generateOutput(); + + System.out.println(output); + } + + public static String generateOutput() { + StringBuilder builder = new StringBuilder(); + + builder.append(WELCOME_LINE + "\n"); + builder.append(nicSaysHello()); + builder.append(kkSaysHello()); + + return builder.toString(); + } + + private static String nicSaysHello() { + return "Nic says 'Hello!'\n"; + } + + private static String kkSaysHello() { + return "KK says 'Hello!'\n"; + } + +} diff --git a/tests/umm/csci3601/HellosTest.java b/tests/umm/csci3601/HellosTest.java new file mode 100644 index 0000000..db6be07 --- /dev/null +++ b/tests/umm/csci3601/HellosTest.java @@ -0,0 +1,25 @@ +package umm.csci3601; + +import org.junit.jupiter.api.Test; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class HellosTest { + @Test + public void testLineStructure() { + String output = Hellos.generateOutput(); + String[] lines = output.split("\n"); + Hellos.WELCOME_LINE.equals(lines[0]); + + String linePattern = "\\w+ says 'Hello!'"; + + for (int i=1; i doesn't match"); + } + } +}