1 Star 0 Fork 0

lius511/simple-db-hw-2021

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
HeapPageIdTest.java 2.08 KB
一键复制 编辑 原始数据 按行查看 历史
Tianyu Li 提交于 2021-02-24 10:00 +08:00 . add lab1 + README
package simpledb;
import junit.framework.JUnit4TestAdapter;
import org.junit.Before;
import org.junit.Test;
import simpledb.storage.HeapPageId;
import simpledb.systemtest.SimpleDbTestBase;
import static org.junit.Assert.*;
public class HeapPageIdTest extends SimpleDbTestBase {
private HeapPageId pid;
@Before public void createPid() {
pid = new HeapPageId(1, 1);
}
/**
* Unit test for HeapPageId.getTableId()
*/
@Test public void getTableId() {
assertEquals(1, pid.getTableId());
}
/**
* Unit test for HeapPageId.pageno()
*/
@Test public void pageno() {
assertEquals(1, pid.getPageNumber());
}
/**
* Unit test for HeapPageId.hashCode()
*/
@Test public void testHashCode() {
int code1, code2;
// NOTE(ghuo): the hashCode could be anything. test determinism,
// at least.
pid = new HeapPageId(1, 1);
code1 = pid.hashCode();
assertEquals(code1, pid.hashCode());
assertEquals(code1, pid.hashCode());
pid = new HeapPageId(2, 2);
code2 = pid.hashCode();
assertEquals(code2, pid.hashCode());
assertEquals(code2, pid.hashCode());
}
/**
* Unit test for HeapPageId.equals()
*/
@Test public void equals() {
HeapPageId pid1 = new HeapPageId(1, 1);
HeapPageId pid1Copy = new HeapPageId(1, 1);
HeapPageId pid2 = new HeapPageId(2, 2);
// .equals() with null should return false
assertNotEquals(null, pid1);
// .equals() with the wrong type should return false
assertNotEquals(pid1, new Object());
assertEquals(pid1, pid1);
assertEquals(pid1, pid1Copy);
assertEquals(pid1Copy, pid1);
assertEquals(pid2, pid2);
assertNotEquals(pid1, pid2);
assertNotEquals(pid1Copy, pid2);
assertNotEquals(pid2, pid1);
assertNotEquals(pid2, pid1Copy);
}
/**
* JUnit suite target
*/
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(HeapPageIdTest.class);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/lius511/simple-db-hw-2021.git
git@gitee.com:lius511/simple-db-hw-2021.git
lius511
simple-db-hw-2021
simple-db-hw-2021
master

搜索帮助