コード例 #1
0
 public function testSetLeftTreeObject()
 {
     $obj_binaryTree = new BinaryTree('content');
     $obj_binaryTree->setLeftTree(null);
     $this->assertFalse($obj_binaryTree->isEmpty(), 'Binary tree should not be empty.');
     $this->assertEquals('content', $obj_binaryTree->getObject(), 'Binary tree\'s object should equal content.');
     $this->assertNotNull($obj_binaryTree->getLeftTree(), 'Left tree should not be null.');
     $this->assertTrue($obj_binaryTree->getLeftTree()->isEmpty(), 'Left tree should be empty.');
     $this->assertNotNull($obj_binaryTree->getRightTree(), 'Right tree should not be null.');
     $this->assertTrue($obj_binaryTree->getRightTree()->isEmpty(), 'Right tree should be empty.');
     $obj_binaryTree->setLeftTree(new BinaryTree('content L'));
     $this->assertFalse($obj_binaryTree->isEmpty(), 'Binary tree should not be empty.');
     $this->assertEquals('content', $obj_binaryTree->getObject(), 'Binary tree\'s object should equal content.');
     $this->assertNotNull($obj_binaryTree->getLeftTree(), 'Left tree should not be null.');
     $this->assertFalse($obj_binaryTree->getLeftTree()->isEmpty(), 'Left tree should not be empty.');
     $this->assertEquals('content L', $obj_binaryTree->getLeftTree()->getObject(), 'Left tree\'s object should equal content L.');
     $this->assertNotNull($obj_binaryTree->getRightTree(), 'Right tree should not be null.');
     $this->assertTrue($obj_binaryTree->getRightTree()->isEmpty(), 'Right tree should be empty.');
     $obj_binaryTreeEmpty = new BinaryTree();
     $obj_binaryTreeEmpty->setLeftTree(new BinaryTree('content L'));
     $this->assertTrue($obj_binaryTreeEmpty->isEmpty(), 'Binary tree is empty.');
     $this->assertNull($obj_binaryTreeEmpty->getObject(), 'Content should be null.');
     $this->assertNull($obj_binaryTreeEmpty->getLeftTree(), 'Left tree should be null.');
     $this->assertNull($obj_binaryTreeEmpty->getRightTree(), 'Right tree should be null.');
 }