2012-02-16 21:48:57 -07:00
|
|
|
// run
|
2009-08-20 12:12:04 -06:00
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
func main() {
|
2010-03-24 17:46:53 -06:00
|
|
|
c := make(chan int, 10)
|
2009-08-20 12:12:04 -06:00
|
|
|
if len(c) != 0 || cap(c) != 10 {
|
2010-03-24 17:46:53 -06:00
|
|
|
println("chan len/cap ", len(c), cap(c), " want 0 10")
|
|
|
|
panic("fail")
|
2009-08-20 12:12:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < 3; i++ {
|
2010-03-24 17:46:53 -06:00
|
|
|
c <- i
|
2009-08-20 12:12:04 -06:00
|
|
|
}
|
|
|
|
if len(c) != 3 || cap(c) != 10 {
|
2010-03-24 17:46:53 -06:00
|
|
|
println("chan len/cap ", len(c), cap(c), " want 3 10")
|
|
|
|
panic("fail")
|
2009-08-20 12:12:04 -06:00
|
|
|
}
|
2010-03-24 17:46:53 -06:00
|
|
|
|
|
|
|
c = make(chan int)
|
2009-08-20 12:12:04 -06:00
|
|
|
if len(c) != 0 || cap(c) != 0 {
|
2010-03-24 17:46:53 -06:00
|
|
|
println("chan len/cap ", len(c), cap(c), " want 0 0")
|
|
|
|
panic("fail")
|
2009-08-20 12:12:04 -06:00
|
|
|
}
|
|
|
|
}
|