summaryrefslogtreecommitdiff
path: root/src/pkg/exp/iterable/iterable_test.go
diff options
context:
space:
mode:
authorDavid Symonds <dsymonds@golang.org>2009-11-16 13:39:59 -0800
committerDavid Symonds <dsymonds@golang.org>2009-11-16 13:39:59 -0800
commit2653e6d60459add75b934528a17827848ea08ec8 (patch)
tree11dc8f3c02144f201b6f05068489064bc08a72cd /src/pkg/exp/iterable/iterable_test.go
parent6b0013630ae216ce9cd9572b084f79c3317d9764 (diff)
downloadgolang-2653e6d60459add75b934528a17827848ea08ec8.tar.gz
Add some primitive type aliases to exp/iterable and define Iter on them.
R=rsc http://codereview.appspot.com/155065 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/exp/iterable/iterable_test.go')
-rw-r--r--src/pkg/exp/iterable/iterable_test.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/pkg/exp/iterable/iterable_test.go b/src/pkg/exp/iterable/iterable_test.go
index 1580357ee..c6307dca0 100644
--- a/src/pkg/exp/iterable/iterable_test.go
+++ b/src/pkg/exp/iterable/iterable_test.go
@@ -8,17 +8,24 @@ import (
"testing";
)
-type IntArray []int
-
-func (arr IntArray) Iter() <-chan interface{} {
- ch := make(chan interface{});
- go func() {
- for _, x := range arr {
- ch <- x
- }
- close(ch);
- }();
- return ch;
+func TestArrayTypes(t *testing.T) {
+ // Test that conversion works correctly.
+ bytes := ByteArray([]byte{1, 2, 3});
+ if x := Data(bytes)[1].(byte); x != 2 {
+ t.Error("Data(bytes)[1].(byte) = %v, want 2", x)
+ }
+ ints := IntArray([]int{1, 2, 3});
+ if x := Data(ints)[2].(int); x != 3 {
+ t.Error("Data(ints)[2].(int) = %v, want 3", x)
+ }
+ floats := FloatArray([]float{1, 2, 3});
+ if x := Data(floats)[0].(float); x != 1 {
+ t.Error("Data(floats)[0].(float) = %v, want 1", x)
+ }
+ strings := StringArray([]string{"a", "b", "c"});
+ if x := Data(strings)[1].(string); x != "b" {
+ t.Error(`Data(strings)[1].(string) = %q, want "b"`, x)
+ }
}
var oneToFive = IntArray{1, 2, 3, 4, 5}