Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion exercises/practice/zipper/src/test/java/ZipperTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -21,54 +22,62 @@ public void setup() {
}

@Test
@DisplayName("data is retained")
public void testToTree() {
assertThat(zipper.toTree()).isEqualTo(binaryTree);
}

@Disabled("Remove to run test")
@Test
@DisplayName("left, right and value")
public void testLeftRightAndValue() {
zipper = binaryTree.getRoot();
assertThat(zipper.left.right.getValue()).isEqualTo(3);
}

@Disabled("Remove to run test")
@Test
@DisplayName("dead end")
public void testDeadEnd() {
zipper = binaryTree.getRoot();
assertThat(zipper.left.left).isNull();
}

@Disabled("Remove to run test")
@Test
@DisplayName("tree from deep focus")
public void testToTreeFromDeepFocus() {
zipper = binaryTree.getRoot();
assertThat(zipper.left.right.toTree()).isEqualTo(binaryTree);
}

@Disabled("Remove to run test")
@Test
@DisplayName("traversing up from top")
public void testTraversingUpFromTop() {
zipper = binaryTree.getRoot();
assertThat(zipper.up).isNull();
}

@Disabled("Remove to run test")
@Test
@DisplayName("left, right, and up")
public void testLeftRightAndUp() {
zipper = binaryTree.getRoot();
assertThat(zipper.left.up.right.up.left.right.getValue()).isEqualTo(3);
}

@Disabled("Remove to run test")
@Test
@DisplayName("test ability to descend multiple levels and return")
public void testAbilityToReturnAfterMultipleLevelDescend() {
zipper = binaryTree.getRoot();
assertThat(zipper.left.right.up.up.getValue()).isEqualTo(1);
}

@Disabled("Remove to run test")
@Test
@DisplayName("set_value")
public void testSetValue() {
zipper = binaryTree.getRoot();
zipper = zipper.left;
Expand All @@ -91,6 +100,7 @@ public void testSetValue() {

@Disabled("Remove to run test")
@Test
@DisplayName("set_value after traversing up")
public void testSetValueAfterTraversingUp() {
zipper = binaryTree.getRoot();
zipper = zipper.left.right.up;
Expand All @@ -113,6 +123,7 @@ public void testSetValueAfterTraversingUp() {

@Disabled("Remove to run test")
@Test
@DisplayName("set_left with leaf")
public void testSetLeftWithLeaf() {
zipper = binaryTree.getRoot();
zipper = zipper.left;
Expand All @@ -138,6 +149,7 @@ public void testSetLeftWithLeaf() {

@Disabled("Remove to run test")
@Test
@DisplayName("set_right with null")
public void testSetRightWithNull() {
zipper = binaryTree.getRoot();
zipper = zipper.left;
Expand All @@ -151,6 +163,7 @@ public void testSetRightWithNull() {

@Disabled("Remove to run test")
@Test
@DisplayName("set_right with subtree")
public void testSetRightWithSubtree() {
BinaryTree subtree = new BinaryTree(6);
subtree.getRoot().setLeft(new Zipper(7));
Expand Down Expand Up @@ -181,6 +194,7 @@ public void testSetRightWithSubtree() {

@Disabled("Remove to run test")
@Test
@DisplayName("set_value on deep focus")
public void testSetValueOnDeepFocus() {
zipper = binaryTree.getRoot();
zipper = zipper.left.right;
Expand All @@ -203,6 +217,7 @@ public void testSetValueOnDeepFocus() {

@Disabled("Remove to run test")
@Test
@DisplayName("different paths to same zipper")
public void differentPathToSameZipper() {
Zipper zipper1 = binaryTree.getRoot().left.up.right;
Zipper zipper2 = binaryTree.getRoot().right;
Expand Down