-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/add-tests'
- Loading branch information
Showing
3 changed files
with
60 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<lines.length; ++i) { | ||
assertTrue(lines[i].matches(linePattern), | ||
"Line <" + lines[i] + "> doesn't match"); | ||
} | ||
} | ||
} |