Commit ce22e5ff authored by Ethan Ordentlich's avatar Ethan Ordentlich
Browse files

Merge branch 'tests' into 'master'

Tests

See merge request !2
parents 749c1ba2 7132f581
1 merge request!2Tests
Pipeline #45397 canceled with stage
Showing with 66 additions and 10 deletions
+66 -10
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ChainingHashDictionaryTests" type="JUnit" factoryName="JUnit" nameIsGenerated="true">
<module name="project05-markov" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="edu.caltech.cs2.datastructures.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="edu.caltech.cs2.datastructures" />
<option name="MAIN_CLASS_NAME" value="edu.caltech.cs2.datastructures.ChainingHashDictionaryTests" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
\ No newline at end of file
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MoveToFrontDictionaryTests" type="JUnit" factoryName="JUnit" nameIsGenerated="true">
<module name="project05-markov" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="edu.caltech.cs2.datastructures.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="edu.caltech.cs2.datastructures" />
<option name="MAIN_CLASS_NAME" value="edu.caltech.cs2.datastructures.MoveToFrontDictionaryTests" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
\ No newline at end of file
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="NGramTests" type="JUnit" factoryName="JUnit" nameIsGenerated="true">
<module name="project05-markov" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="edu.caltech.cs2.datastructures.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="edu.caltech.cs2.datastructures" />
<option name="MAIN_CLASS_NAME" value="edu.caltech.cs2.datastructures.NGramTests" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
\ No newline at end of file
......@@ -61,7 +61,7 @@ public class ChainingHashDictionaryTests implements IDictionaryNGramTests {
@DisplayName("Does not use or import disallowed classes from java.util")
@Test
public void testForInvalidImportsJavaUtil() {
List<String> allowed = List.of("Iterator", "Supplier", "Stream");
List<String> allowed = List.of("Iterator", "function\\.Supplier", "stream\\.Stream");
Inspection.assertNoImportsOfExcept(DICTIONARY_SOURCE, "java\\.util", allowed);
List<String> bannedUsages = List.of("java\\.util\\.(?!" + String.join("|", allowed) + ")");
......@@ -94,14 +94,12 @@ public class ChainingHashDictionaryTests implements IDictionaryNGramTests {
@Timeout(value = 20, unit = SECONDS)
@Test
public void testGrowthCapability() {
Set<IDictionary<Object, Object>> dicts = new HashSet<>();
for (int i = 0; i < 50; i++) {
dicts.add(new ChainingHashDictionary<>(MoveToFrontDictionary::new));
}
for (IDictionary<Object, Object> dict : dicts) {
for (int i = 0; i < 400000; i++) {
dict.put(i, i);
for (int i = 0; i < 25; i++) {
IDictionary<Object, Object> dict = new ChainingHashDictionary<>(MoveToFrontDictionary::new);
for (int j = 0; j < 500000; j++) {
dict.put(j, j);
}
// This _should_ get GC'd with a smaller heap size...
}
}
......
......@@ -6,6 +6,7 @@ import edu.caltech.cs2.textgenerator.NGram;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.provider.Arguments;
import java.util.HashMap;
......@@ -17,6 +18,7 @@ import java.util.stream.Stream;
import static edu.caltech.cs2.project05.Project05TestOrdering.sanityTestLevel;
import static edu.caltech.cs2.project05.Project05TestOrdering.specialTestLevel;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertTrue;
// Wrapper class for all IDictionaries that will be tested using NGram keys to reduce code repetition
......@@ -47,7 +49,7 @@ public interface IDictionaryNGramTests extends IDictionaryTests {
@Override
default Map<Object, Object> generateRandomTestData(int size, Random rand, int maxNodeDegree, int minKeyLength,
int maxKeyLength) {
int maxKeyLength) {
Map<Object, Object> base = new HashMap<>();
for (int i = 0; i < size; i++) {
int keyLength = minKeyLength + rand.nextInt(maxKeyLength - minKeyLength);
......@@ -77,6 +79,7 @@ public interface IDictionaryNGramTests extends IDictionaryTests {
@Order(specialTestLevel)
@DisplayName("Test get() -- complexity")
@Test
@Timeout(value = 20, unit = SECONDS)
default void testGetComplexity() {
Function<Integer, IDictionary<Object, Object>> provide = (Integer numElements) -> {
IDictionary<Object, Object> t = newIDictionary();
......@@ -95,6 +98,7 @@ public interface IDictionaryNGramTests extends IDictionaryTests {
@Order(specialTestLevel)
@DisplayName("Test put() -- complexity")
@Test
@Timeout(value = 20, unit = SECONDS)
default void testPutComplexity() {
Function<Integer, IDictionary<Object, Object>> provide = (Integer numElements) -> {
IDictionary<Object, Object> t = newIDictionary();
......@@ -113,6 +117,7 @@ public interface IDictionaryNGramTests extends IDictionaryTests {
@Order(specialTestLevel)
@DisplayName("Test size() -- complexity")
@Test
@Timeout(value = 20, unit = SECONDS)
default void testSizeComplexity() {
Function<Integer, IDictionary<Object, Object>> provide = (Integer numElements) -> {
IDictionary<Object, Object> t = newIDictionary();
......
......@@ -96,7 +96,6 @@ public class MoveToFrontDictionaryTests implements IDictionaryNGramTests {
}
}
// TODO: what the fuck
@Order(classSpecificTestLevel)
@DisplayName("Check MoveToFrontDictionary class is properly implemented")
@Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment