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 天前
JUnit-自动化测试框架
java·junit·单元测试·自动化
laoliu19962 天前
GGE Lua 详细教程
开发语言·junit·lua
长路 ㅤ   2 天前
Java单元测试JUnit
junit·单元测试·springboot·注解·断言
Hello.Reader4 天前
Redis性能基准测试
数据库·redis·junit
_GR4 天前
一篇博客学习Lua_安装使用+语法详解
开发语言·junit·lua
qq_433888936 天前
Junit多线程的坑
java·spring·junit
艺杯羹25 天前
Maven 之 JUnit 测试体系构建全解析
java·junit·maven
转码的小石1 个月前
深入Java大厂面试:从Spring框架到微服务架构的技术解析
java·spring boot·spring cloud·微服务·junit·spring security·hibernate
专注代码七年1 个月前
Spring Boot单元测试终极指南:从环境搭建到分层测试实战
java·spring boot·junit
xiaoxi6661 个月前
用好 JUnit 5 的高级特性:提升单测效率和质量
junit