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


使用

相关推荐
安冬的码畜日常4 天前
【JUnit实战3_30】第十八章:REST API 接口测试(下)—— REST API 接口的 MockMvc + JUnit 5 测试实战
测试工具·junit·单元测试·restful·rest api·junit5
安冬的码畜日常6 天前
【JUnit实战3_25】第十五章:表现层测试(上)—— HtmlUnit 在网页测试中的用法
测试工具·junit·gui测试·htmlunit·junit5
学IT的周星星6 天前
Spring 框架整合 JUnit 单元测试
java·spring·junit·单元测试
千里镜宵烛6 天前
Lua 面向对象编程完全指南:从元表到私密性,解锁灵活封装技巧
junit·单元测试·lua
千里镜宵烛6 天前
深入 Lua 环境机制:全局变量的 “容器” 与 “隔离术”
开发语言·junit·lua
一叶飘零_sweeeet6 天前
从测试小白到高手:JUnit 5 核心注解 @BeforeEach 与 @AfterEach 的实战指南
java·junit
安冬的码畜日常6 天前
【JUnit实战3_24】 第十四章:JUnit 5 扩展模型(Extension API)实战(下)
测试工具·junit·单元测试·jdbc·junit5扩展·junit extension
千里镜宵烛7 天前
深入 Lua 元表与元方法
junit
安冬的码畜日常9 天前
【JUnit实战3_26】第十五章:表现层测试(下)—— Selenium 在网页测试中的用法
selenium·测试工具·junit·gui测试·junit5·表现层测试
千里镜宵烛10 天前
Lua--数据文件和持久性
开发语言·junit·lua