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


使用

相关推荐
SoleMotive.2 天前
redis实现漏桶算法--https://blog.csdn.net/m0_74908430/article/details/155076710
redis·算法·junit
虹科网络安全3 天前
艾体宝干货 | Redis Python 开发系列#4 保证原子性与性能
redis·python·junit
我发在否3 天前
OpenResty > 平滑升级:1.25.x → 1.27.x
junit·openresty
IMPYLH3 天前
Lua 的 pairs 函数
开发语言·笔记·后端·junit·单元测试·lua
安冬的码畜日常3 天前
【JUnit实战3_35】第二十二章:用 JUnit 5 实现测试金字塔策略
测试工具·junit·单元测试·集成测试·系统测试·bdd·测试金字塔
IMPYLH6 天前
Lua 的 collectgarbage 函数
开发语言·笔记·junit·单元测试·lua
IMPYLH7 天前
Lua 的 assert 函数
开发语言·笔记·junit·单元测试·lua
倚肆9 天前
Spring Boot 日志系统全面详解
spring boot·junit·单元测试
百***489310 天前
Nginx实现接口复制
运维·nginx·junit
安冬的码畜日常11 天前
【JUnit实战3_33】第二十章:用 JUnit 5 进行测试驱动开发(TDD)(下)——TDD 项目的重构过程及新功能的开发实战
测试工具·junit·单元测试·测试驱动开发·tdd·junit5·test-driven