图灵学院JAVA高级架构师第三期
download:图灵学院JAVA高级架构师第三期
func TestQuickSort3(t *testing.T) {
values := []int{5}
QuickSort(values)
if values[0] != 5 {
t.Error("QuickSort() failed. Got", values, "Expected 5")
}
}
bubble_test.go
// bubble_test.go
package bubblesort
import "testing"
func TestBubbleSort1(t *testing.T) {
values := []int{5, 4, 3, 2, 1}
BubbleSort(values)
if values[0] != 1 || values[1] != 2 || values[2] != 3 || values[3] != 4 ||
values[4] !=5 {
t.Error("BubbleSort() failed. Got", values, "Expected 1 2 3 4 5")
}
}
func TestBubbleSort2(t *testing.T) {
values := []int{5, 5, 3, 2, 1}
BubbleSort(values)
if values[0] != 1 || values[1] != 2 || values[2] != 3 || values[3] != 5 ||
values[4] !=5 {
t.Error("BubbleSort() failed. Got", values, "Expected 1 2 3 5 5")
}
}
func TestBubbleSort3(t *testing.T) {
values := []int{5}
BubbleSort(values)
if values[0] != 5 {
t.Error("BubbleSort() failed. Got", values, "Expected 5")
}
}
運轉前準備:
準備“unsorted.dat”文件。
運轉過程:
go build sorter/slgorithms/qsortgo build sorter/algorithms/bubblesortgo test sorter/algorithms/qsortgo test sorter/algorithms/bubblesortgo install sorter/algorithms/qsortgo install sorter/algorithms/bubblesortgo build sortergo install sorter
運轉結果:
【图灵学院JAVA高级架构师第三期】輸出文件:sorted.dat
推荐阅读
- JAVA(抽象类与接口的区别&重载与重写&内存泄漏)
- 事件代理
- Java|Java OpenCV图像处理之SIFT角点检测详解
- java中如何实现重建二叉树
- 数组常用方法一
- 【Hadoop踩雷】Mac下安装Hadoop3以及Java版本问题
- Java|Java基础——数组
- RxJava|RxJava 在Android项目中的使用(一)
- java之static、static|java之static、static final、final的区别与应用
- 08黑龙江迟淑荣弯柳树网络学院第五期学习赵宗瑞老师主讲的(传统文化与身心健康)教育体系心得体会