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是coord0

gety是coord2


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

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


使用

相关推荐
肠畔码农9 小时前
深度解密 Redis 核心引擎:从 MULTI/EXEC 事务机制到 EVAL 脚本的原子性演进
数据库·redis·junit
会编程的吕洞宾2 天前
Spring Cloud Gateway限流:Redis令牌桶防刷实战
数据库·redis·junit
難釋懷5 天前
Nginx-Lua
nginx·junit·lua
萧瑟余晖5 天前
Java深入解析篇三十七之JUnit 5 详解
java·junit
骑士雄师8 天前
superpowers使用流程
junit·skill
重庆小透明9 天前
深入探寻微服务【第五篇微服务限流实战】
微服务·junit·架构
難釋懷9 天前
Nginx-Openresty
nginx·junit·openresty
難釋懷20 天前
Nginx外置缓存-redis2-nginx-module
nginx·缓存·junit
山城码农笑松哥23 天前
Redis 8.8 新特性实操笔记:原生数组、INCREX 限流、XNACK 流处理
redis·笔记·junit
難釋懷1 个月前
Nginx内存缓存
nginx·缓存·junit