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


使用

相关推荐
工程师老罗1 天前
Java笔试面试题AI答之单元测试JUnit(6)
java·junit·单元测试
筑天兄5 天前
【Lua学习】Lua入门
学习·junit·lua
笔下天地宽5 天前
java: 程序包org.junit.jupiter.api不存在
java·junit·intellij-idea·jpa
喜欢猪猪7 天前
谈谈OpenResty 简介及其容器化实践
junit
惜.己8 天前
spring项目整合log4j2日志框架(含log4j无法打印出日志的情况,含解决办法)
java·spring·junit·单元测试·log4j·idea
weixin_443290698 天前
5-【JavaWeb】JUnit 单元测试及JUL 日志系统
junit·单元测试
惜.己9 天前
spring如何整合druid连接池?
xml·java·数据库·后端·spring·junit·idea
工程师老罗11 天前
Java笔试面试题AI答之单元测试JUnit(4)
java·junit·单元测试
CoderCodingNo13 天前
log4j 控制台和文件输出乱码问题解决
junit·单元测试·log4j
CCTV果冻爽17 天前
LuaJit分析(七)LuaJit -b 命令分析
junit