本文整理汇总了Golang中golang.org/x/tour/wc.Test函数的典型用法代码示例。如果您正苦于以下问题:Golang Test函数的具体用法?Golang Test怎么用?Golang Test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Test函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
fmt.Println("### Start Map Exercise ###")
wc.Test(WordCount)
fmt.Println("### End Map Exercise ###")
}
示例2: main
func main() {
pointers()
structs()
arrays()
slices()
ranges()
//pic.Show(Pic) // Note: This will print a base64 encoded image.
maps()
wc.Test(WordCount)
closures()
}
示例3: main
func main() {
pointer()
v := Vertex{1, 2}
v.X = 4
fmt.Println(v)
p := &v
p.X = 1e9
fmt.Println(v)
structLiterals()
array()
slice()
tictactoe()
slicing()
makeslice()
zeroSlice()
appendSlice()
ranges()
pic.Show(Pic)
var vLL = VertexLL{40.68433, -74.39967}
geography("Bell Labs", vLL)
fmt.Println(m["Bell Labs"])
vLL = VertexLL{37.4828, 122.2361}
geography("Redwood City", vLL)
fmt.Println(m["Redwood City"])
fmt.Println(m)
mutateMap()
wc.Test(WordCount)
fmt.Println(hypot(5, 12))
fmt.Println(compute(hypot))
fmt.Println(compute(math.Pow))
exAdder()
f := fibonacci()
for i := 0; i < 10; i++ {
fmt.Println(f())
}
}
示例4: ExerciseMaps
func ExerciseMaps() {
wc.Test(WordCount)
}
示例6: testWordCount
func testWordCount() {
wc.Test(WordCount)
}
示例7: main
//.........这里部分代码省略.........
a2 = append(a2, 0)
printSlice("a2", a2)
// the slice grows as needed.
a2 = append(a2, 1)
printSlice("a2", a2)
// we can add more than one element at a time.
a2 = append(a2, 2, 3, 4)
printSlice("a2", a2)
// range
for i, v := range pow2 {
fmt.Printf("2**%d = %d\n", i, v)
}
pow3 := make([]int, 10)
for i := range pow3 {
pow3[i] = 1 << uint(i)
}
for _, value := range pow3 {
fmt.Printf("%d\n", value)
}
pic.Show(Pic)
// Maps
map1 = make(map[string]LocationCoordinate)
map1["Bell Labs"] = LocationCoordinate{
40.68433, -74.39967,
}
fmt.Println(map1["Bell Labs"])
fmt.Println(map1)
fmt.Println(map2)
//Mutating Maps
map3 := make(map[string]int)
map3["Answer"] = 42
fmt.Println("The value:", map3["Answer"])
v6, ok1 := map3["Answer"]
fmt.Println("The value:", v6, "Present?", ok1)
map3["Answer"] = 48
fmt.Println("The value:", map3["Answer"])
delete(map3, "Answer")
fmt.Println("The value:", map3["Answer"])
v6, ok2 := map3["Answer"]
fmt.Println("The value:", v6, "Present?", ok2)
// map exercise
wc.Test(WordCount)
//functions arevalues too
hypot := func(x, y float64) float64 {
return math.Sqrt(x*x + y*y)
}
fmt.Println(hypot(3, 4))
pos, neg := adder(), adder()
for i := 0; i < 10; i++ {
fmt.Println(
pos(i),
neg(-2*i),
)
}
fib := fibonacci()
for i := 0; i < 10; i++ {
fmt.Println(fib())
}
v7 := &FloatVertex{3, 4}
fmt.Println("FloatVertex", v7.Abs())
f1 := MyFloat(-math.Sqrt2)
fmt.Println(f1.Abs())
v8 := &FloatVertex{3, 4}
v8.Scale(5)
fmt.Println(v8, v8.Abs())
runInterface()
runImplicitInterface()
runStringer()
runErrors()
go say("world")
say("hello")
runGoRoutine()
runBufferedChannel()
runRangeAndClose()
runFibonacci3()
runDefaultSelection()
}
示例9: TestExerciseMaps
func TestExerciseMaps(t *testing.T) {
wc.Test(WordCount)
}
示例10: main
func main() {
wc.Test(WordCount)
fmt.Println(WordCount(" Stas Stas stas "))
}