From 2760ddf8142b9396006eb4c1bd74f63a3c31b530 Mon Sep 17 00:00:00 2001 From: gardncl Date: Sun, 30 Apr 2017 12:21:33 -0400 Subject: [PATCH] 13.12-13.13 --- .../src/test/java/CollatzConjectureTest.java | 22 +++++++++++++ .../java/ComputeStringDecompositionsTest.java | 33 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 hashtables/src/test/java/CollatzConjectureTest.java create mode 100644 hashtables/src/test/java/ComputeStringDecompositionsTest.java diff --git a/hashtables/src/test/java/CollatzConjectureTest.java b/hashtables/src/test/java/CollatzConjectureTest.java new file mode 100644 index 0000000..d426e95 --- /dev/null +++ b/hashtables/src/test/java/CollatzConjectureTest.java @@ -0,0 +1,22 @@ +import org.junit.Test; + +import static org.junit.Assert.*; + +public class CollatzConjectureTest { + + private boolean expected; + private int n; + + @Test + public void testCollatzConjecture() throws Exception { + expected = true; + n = 10000; + + test(expected, n); + } + + private void test(boolean expected, int n) { + assertEquals(expected, CollatzConjecture.testCollatzConjecture(n)); + } + +} \ No newline at end of file diff --git a/hashtables/src/test/java/ComputeStringDecompositionsTest.java b/hashtables/src/test/java/ComputeStringDecompositionsTest.java new file mode 100644 index 0000000..1fecc14 --- /dev/null +++ b/hashtables/src/test/java/ComputeStringDecompositionsTest.java @@ -0,0 +1,33 @@ +import org.junit.Test; + +import java.util.Arrays; +import java.util.List; + +import static org.junit.Assert.*; + +public class ComputeStringDecompositionsTest { + + private List expected; + private String s; + private List words; + + @Test + public void findAllSubstring1() throws Exception { + expected = Arrays.asList( + "aplanacan", + "canaplana" + ); + s = "amanaplanacanalcanaplanaalpmna"; + words = Arrays.asList( + "can", + "apl", + "ana" + ); + + test(expected, s, words); + } + + private void test(List expected, String s, List words) { + AssertUtils.assertSameContents(expected, ComputeStringDecompositions.findAllSubstring(s, words)); + } +} \ No newline at end of file