Verified Commit 63e2e7b5 authored by Daniel Mangold's avatar Daniel Mangold
Browse files

Version 1.1

parents a9ad70a5 60640779
1.0
src/test/java/h05/Utils.java afb4a4a21023642a53304ab9bbf2f6a9
1.1
src/test/java/h05/Utils.java 1a1d16bb8fcfcbe2447f77431ee08c58
src/test/java/h05/Assertions.java 02349c33cf60fea1b77b0c457bf1fad8
src/test/java/h05/ListItemTest.java d746f290bee1694c5b79e77538c86fa5
src/test/java/h05/MyTreeNodeTest.java d2de48e7fa2087a08fc6d81fdb273064
src/test/java/h05/MyTreeTest.java 5a77bf969645a08aa50966f4d5cb9319
src/test/java/h05/MyParenthesesTreeIteratorTest.java 311cd428d3c3c82069f28905bd5831e7
src/test/java/h05/provider/TreeProvider.java 955510b43e5a8b60e0d92aebbdf1b6a9
src/test/java/h05/provider/RandomTreeProvider.java 4f610933595546a166e106ad9929b290
\ No newline at end of file
src/test/java/h05/MyTreeTest.java 21eda0d65bd51a6ad9d23512d413d470
src/test/java/h05/MyParenthesesTreeIteratorTest.java 1d434eea48f0fbab3361973a8a0b4e00
src/test/java/h05/provider/TreeProvider.java 74b0b9564f5f6fe05d09f8fbef1f22c8
src/test/java/h05/provider/RandomTreeProvider.java 5a414c51f6a1907cda59ea7ad4deacce
\ No newline at end of file
### Version 1.1
Fixed parentheses generation and tests (missing `\n` at the end) \
Fixed link to changelog
### Version 1.0
Initial tests \
Addendum: Optimized RandomTreeProvider
\ No newline at end of file
......@@ -55,16 +55,17 @@ public class MyParenthesesTreeIteratorTest {
Iterator<Character> iterator = MyTreeTest.getIterator(treeString);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < treeString.length(); i++)
for (int i = 0; i < treeString.length() - 1; i++)
try {
Character next = iterator.next();
builder.append(next != null ? next : "");
} catch (NoSuchElementException e) {
fail("Iterator has fewer elements than expected: " + (i + 1) + "/" + treeString.length(), e);
fail("Iterator has fewer elements than expected: " + (i + 1) + "/" + (treeString.length() - 1), e);
}
assertEquals(treeString, builder.toString(), "Characters returned by iterator does not equal expected");
assertEquals(treeString.substring(0, treeString.length() - 1), builder.toString(),
"Characters returned by iterator does not equal expected");
assertThrows(NoSuchElementException.class, iterator::next, "Iterator has more elements than expected");
}
......@@ -72,20 +73,20 @@ public class MyParenthesesTreeIteratorTest {
@ArgumentsSource(RandomTreeProvider.class)
public void testHasNext(String treeString) throws ReflectiveOperationException {
requireTest(MyTreeTest.class.getDeclaredMethod("testIterator"));
requireTest(MyParenthesesTreeIteratorTest.class.getDeclaredMethod("testNext", String.class), "()");
requireTest(MyParenthesesTreeIteratorTest.class.getDeclaredMethod("testNext", String.class), "()\n");
Iterator<Character> iterator = MyTreeTest.getIterator(treeString);
for (int i = 0; i < treeString.length(); i++, iterator.next())
for (int i = 0; i < treeString.length() - 1; i++, iterator.next())
assertTrue(iterator.hasNext(),
"Iterator should not have reached end yet, number of elements: " + (i + 1) + "/" + treeString.length());
"Iterator should not have reached end yet, number of elements: " + (i + 1) + "/" + (treeString.length() - 1));
assertFalse(iterator.hasNext(), "Iterator has more elements than expected");
}
@Test
public void testRemove() throws ReflectiveOperationException {
Iterator<Character> iterator = MyTreeTest.getIterator("");
Iterator<Character> iterator = MyTreeTest.getIterator("\n");
assertThrows(UnsupportedOperationException.class, iterator::remove);
}
......
......@@ -162,7 +162,7 @@ public class MyTreeTest {
public void testIterator() throws ReflectiveOperationException {
requireTest(MyParenthesesTreeIteratorTest.class);
Object instance = constructor.newInstance(new StringReader(""), RANDOM.nextBoolean());
Object instance = constructor.newInstance(new StringReader("\n"), false);
assertEquals(MyParenthesesTreeIteratorTest.myParenthesesTreeIteratorClass, iterator.invoke(instance).getClass(),
"Returned object does not have type MyParenthesesTreeIterator");
......@@ -181,8 +181,10 @@ public class MyTreeTest {
assertTrue((Boolean) isIsomorphic.invoke(instance1, instance2), "Trees are isomorphic");
assertTrue((Boolean) isIsomorphic.invoke(instance2, instance1), "Trees are isomorphic");
assertTrue((Boolean) isIsomorphic.invoke(instance1, instance1), "Trees are isomorphic");
assertTrue((Boolean) isIsomorphic.invoke(instance2, instance2), "Trees are isomorphic");
String nonIsomorphicTreeString = "(((((())))))";
String nonIsomorphicTreeString = "(((((())))))\n";
Object nonIsomorphicInstance = constructor.newInstance(new StringReader(nonIsomorphicTreeString), false);
assertFalse((Boolean) isIsomorphic.invoke(instance1, nonIsomorphicInstance), "Trees are not isomorphic");
......
......@@ -27,7 +27,7 @@ public class Utils {
public static final Map<Class<?>, Boolean> CLASS_CORRECT = new HashMap<>();
public static final Map<Method, Boolean> METHOD_CORRECT = new HashMap<>();
private static final String LOCAL_VERSION = "1.0";
private static final String LOCAL_VERSION = "1.1", ASSIGNMENT_ID = "H05";
private static final Map<TestType.Type, String> METHOD_LOOKUP = Map.of(
TestType.Type.CLASS, "checkClass",
TestType.Type.INTERFACE, "checkInterface"
......@@ -168,7 +168,7 @@ public class Utils {
private static class Updater {
private static final String REPOSITORY_URL = "https://git.rwth-aachen.de/aud-tests/AuD-2021-H05-Student/-/raw/master/";
private static final String REPOSITORY_URL = "https://git.rwth-aachen.de/aud-tests/AuD-2021-" + ASSIGNMENT_ID + "-Student/-/";
/**
* Checks if the repository is newer than the local copy and does the following actions
......@@ -196,7 +196,7 @@ public class Utils {
if (remoteVersion.isNewerThan(localVersion)) {
System.out.println("Update available! Local version: " + localVersion + " -- Remote version: " + remoteVersion);
System.out.println("Changelog: " + REPOSITORY_URL + "changelog.txt");
System.out.println("Changelog: " + REPOSITORY_URL + "blob/master/changelog.md");
} else
System.out.println("Local tests are up to date");
......@@ -250,7 +250,7 @@ public class Utils {
.connectTimeout(Duration.ofSeconds(20))
.build();
HttpRequest request = HttpRequest.newBuilder(
URI.create(REPOSITORY_URL + resource)).build();
URI.create(REPOSITORY_URL + "raw/master/" + resource)).build();
try {
return client.send(request, HttpResponse.BodyHandlers.ofString());
......
......@@ -14,7 +14,7 @@ public class RandomTreeProvider implements ArgumentsProvider {
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
return Stream.generate(() -> Arguments.of(randomTreeString(MAX_TREE_DEPTH))).limit(MAX_STREAM_SIZE);
return Stream.generate(() -> Arguments.of(randomTreeString(MAX_TREE_DEPTH) + '\n')).limit(MAX_STREAM_SIZE);
}
public static String randomTreeString(int maxTreeDepth) {
......
......@@ -14,16 +14,16 @@ public class TreeProvider implements ArgumentsProvider {
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
return Stream.of(
Arguments.of("()()", false),
Arguments.of("(())(()())", false),
Arguments.of("", false),
Arguments.of("()()\n", false),
Arguments.of("(())(()())\n", false),
Arguments.of("\n", false),
Arguments.of("()\n()", false),
Arguments.of("()\nabc", false),
Arguments.of("\n()", false),
Arguments.of("abc", true),
Arguments.of("(()))", true),
Arguments.of(")()()", true),
Arguments.of("(((()()))", true)
Arguments.of("", true),
Arguments.of("abc\n", true),
Arguments.of("(()))\n", true),
Arguments.of(")()()\n", true),
Arguments.of("(((()()))\n", true)
);
}
......
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