public void Data_is_retained() { var zipper = Zipper <int> .FromTree(t1); var tree = zipper.ToTree(); Assert.Equal(t1, tree); }
public void Dead_end() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.Left().Left(); Assert.Null(actual); }
public void Traversing_up_from_top() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.Up(); Assert.Null(actual); }
public void Data_is_retained() { var zipper = Zipper <int> .FromTree(t1); var tree = zipper.ToTree(); Assert.That(tree, Is.EqualTo(t1)); }
public void Set_value() { var zipper = Zipper <int> .FromTree(t1); var updatedZipper = zipper.Left().SetValue(5); var tree = updatedZipper.ToTree(); Assert.That(tree, Is.EqualTo(t2)); }
public void Set_left_with_leaf() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.Left().SetLeft(new BinTree(5, null, null)).ToTree(); var expected = new BinTree(1, new BinTree(2, new BinTree(5, null, null), new BinTree(3, null, null)), new BinTree(4, null, null)); Assert.Equal(expected, actual); }
public void Set_value_after_traversing_up() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.Left().Right().Up().SetValue(5).ToTree(); var expected = new BinTree(1, new BinTree(5, null, new BinTree(3, null, null)), new BinTree(4, null, null)); Assert.Equal(expected, actual); }
public void Set_right_to_null() { var zipper = Zipper <int> .FromTree(t1); var updatedZipper = zipper.Left().SetRight(null); var tree = updatedZipper.ToTree(); Assert.Equal(t4, tree); }
public void Left_right_and_up() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.Left().Up().Right().Up().Left().Right().Value(); var expected = 3; Assert.Equal(expected, actual); }
public void Data_is_retained() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.ToTree(); var expected = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); Assert.Equal(expected, actual); }
public void Different_paths_to_same_zipper() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.Left().Up().Right(); var expected = Zipper.FromTree(new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null))).Right(); Assert.Equal(expected, actual); }
public void Tree_from_deep_focus() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.Left().Right().ToTree(); var expected = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); Assert.Equal(expected, actual); }
public void Set_left_with_value() { var zipper = Zipper <int> .FromTree(t1); var updatedZipper = zipper.Left().SetLeft(new BinTree <int>(5, null, null)); var tree = updatedZipper.ToTree(); Assert.Equal(t3, tree); }
public void Set_right_with_subtree() { var tree = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(4, null, null)); var sut = Zipper.FromTree(tree); var actual = sut.SetRight(new BinTree(6, new BinTree(7, null, null), new BinTree(8, null, null))).ToTree(); var expected = new BinTree(1, new BinTree(2, null, new BinTree(3, null, null)), new BinTree(6, new BinTree(7, null, null), new BinTree(8, null, null))); Assert.Equal(expected, actual); }
public void Set_value() { var zipper = Zipper <int> .FromTree(t1); var updatedZipper = zipper.Left().SetValue(5); var tree = updatedZipper.ToTree(); Assert.Equal(t2, tree); }
public void Tree_from_deep_focus() { var zipper = Zipper <int> .FromTree(t1); Assert.That(zipper.Left().Right().ToTree(), Is.EqualTo(t1)); }
public void Left_right_and_value() { var zipper = Zipper <int> .FromTree(t1); Assert.Equal(3, zipper.Left().Right().Value); }
public void Different_paths_to_same_zipper() { var zipper = Zipper <int> .FromTree(t1); Assert.Equal(zipper.Right().ToTree(), zipper.Left().Up().Right().ToTree()); }
public void Left_right_and_value() { var zipper = Zipper <int> .FromTree(t1); Assert.That(zipper.Left().Right().Value, Is.EqualTo(3)); }
public void Tree_from_deep_focus() { var zipper = Zipper <int> .FromTree(t1); Assert.Equal(t1, zipper.Left().Right().ToTree()); }
public void Dead_end() { var zipper = Zipper <int> .FromTree(t1); Assert.Null(zipper.Left().Left()); }