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


使用

相关推荐
文水爱心帮扶10 小时前
文明劝导暖街头,青春志愿护通行|文水县爱心帮扶志愿者协会开展暑期交通文明活动
junit
流星白龙3 天前
【Redis】2.Redis重大版本
数据库·redis·junit
测试修炼手册4 天前
[测试技术] TestNG 入门与实战:分组、数据驱动与并行执行
junit·单元测试·log4j
START_GAME4 天前
LuaTools的使用指南
junit
测试修炼手册5 天前
[测试技术] JUnit 6 入门与实战:断言、参数化与 Mockito
数据库·junit·sqlserver
大黄说说9 天前
Hyperf 协程 PHP 实战:高并发秒杀接口从 0 到 1 落地
junit
名字还没想好☜12 天前
用 Redis + Redisson 实现分布式锁:从踩坑到生产可用
java·redis·分布式·junit·分布式锁·redisson
ipad协议源码12 天前
为何网站会出现的挂马?
junit·软件开发·开源源码
再玩一会儿看代码13 天前
JUnit 测试框架详解:从实际开发、业务测试到 Java 面试高频问题
java·经验分享·笔记·junit·面试