Ai
1 Star 0 Fork 0

郝黎阳/JHU-CS226-Fall25

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BubbleSortDemoTest.java 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
package sort;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class BubbleSortDemoTest {
@Test
public void testBubbleSort(){
int[] arr = new int[]{64, 34, 25, 12, 22, 11, 90};
BubbleSortDemo.bubbleSort(arr);
int[] result = new int[]{11, 12, 22, 25, 34, 64, 90};
Assertions.assertArrayEquals(result, arr);
}
@Test
public void testBubbleSortOptimized(){
int[] arr = new int[]{64, 34, 25, 12, 22, 11, 90};
BubbleSortDemo.bubbleSortOptimized(arr);
int[] result = new int[]{11, 12, 22, 25, 34, 64, 90};
Assertions.assertArrayEquals(result, arr);
}
@Test
@DisplayName("测试冒泡排序迭代版")
public void testBubbleSortIterative(){
int[] arr = new int[]{64, 34, 25, 12, 22, 11, 90};
BubbleSortDemo.bubbleSortIterative(arr);
int[] result = new int[]{11, 12, 22, 25, 34, 64, 90};
Assertions.assertArrayEquals(result, arr);
}
@Test
@DisplayName("测试冒泡排序递归版")
public void testBubbleSortRecursive(){
int[] arr = new int[]{64, 34, 25, 12, 22, 11, 90};
BubbleSortDemo.bubbleSortRecursive(arr);
int[] result = new int[]{11, 12, 22, 25, 34, 64, 90};
Assertions.assertArrayEquals(result, arr);
}
@Test
@DisplayName("测试冒泡排序递归版自顶向下")
public void testBubbleSortRecursive2(){
int[] arr = new int[]{64, 34, 25, 12, 22, 11, 90};
BubbleSortDemo.bubbleSortRecursive2(arr);
int[] result = new int[]{11, 12, 22, 25, 34, 64, 90};
Assertions.assertArrayEquals(result, arr);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hao-liyang/JHU-CS226-Fall25.git
git@gitee.com:hao-liyang/JHU-CS226-Fall25.git
hao-liyang
JHU-CS226-Fall25
JHU-CS226-Fall25
main

搜索帮助