junit写搜索树测试

编程入门 行业动态 更新时间:2024-10-28 18:25:09

junit写搜索树<a href=https://www.elefans.com/category/jswz/34/1771117.html style=测试"/>

junit写搜索树测试

用法
   assertTrue(range.contains("Two"));

2个参数,右边错就打印左边.

AbstractSelfBalancingBinarySearchTree abt;

AbstractBinarySearchTree.Node node;

@Before

public void setUp() {

abt = new AbstractSelfBalancingBinarySearchTree() {

@Override

protected Node createNode(int value, Node parent, Node left, Node right) {

return new Node(value,parent,left,right);

                }

};

node = null;

}这是首先在测试里写的值,node指针

AbstractBinarySearchTree.Node其中每个节点具有一个键(key)和两个子节点,左子节点的键小于父节点的键,右子节点的键大于父节点的键。它是二叉搜索树节点的抽象类

在创建二叉搜索树时通常会定义一个具体的节点类来承 AbstractBinarySearchTree.Node 并实现其抽象方法

AbstractBinarySearchTree abt;  
AbstractBinarySearchTree.Node node;
这两行代码声明了两个类变量。第一个是AbstractBinarySearchTree类型的变量abt,第二个是AbstractBinarySearchTree.Node类型的变量node。这些变量在当前类中可以被使用,但还未被初始化。 


首先我们看看Heap_item

我们只通过了

这一个

传入一个对象

进入了

他们其中一个还有一个分支


要传入一个数组

float是一个x=3.0,y=4.0

给到了p,getx是coord[0]

gety是coord[2]


 为什么assert会错因为,给的各个参数类型不一样

    assertEquals(new Point2D().toString(), airport.getPoint2D().toString());用自己的tostring转为字符串比较就可以了


使用

更多推荐

junit写搜索树测试

本文发布于:2023-11-15 06:54:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1595542.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   junit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!