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转为字符串比较就可以了


使用

相关推荐
什么都想学的阿超19 小时前
【Redis系列 03】掌握Redis编程艺术:事务、管道与Lua脚本完全指南
redis·junit·lua
爱瑞瑞6 天前
Junit5测试类编写笔记
junit
黄暄6 天前
分布式锁优化:使用Lua脚本保证释放锁的原子性问题
java·redis·分布式·后端·junit·lua
cxh_陈8 天前
org.junit.runners.model.InvalidTestClassError:此类问题的解决
java·开发语言·junit
.生产的驴11 天前
SpringBoot 执行Lua脚本 服务端执行 减少性能损耗 优化性能 优化连接性能
java·数据库·spring boot·后端·junit·maven·lua
小小数媒成员11 天前
Unity—lua基础语法
unity·junit·lua
奋斗的老史12 天前
利用Lua脚本限制用户的访问频率
开发语言·junit·lua
渡梦酒13 天前
Redis批量删除Key的三种方式
数据库·redis·junit
兰德里的折磨55013 天前
为什么要使用stream流
java·jvm·spring boot·spring·junit·log4j·intellij-idea
i1yo_kiki14 天前
junit单元测试
junit·log4j