aboutsummaryrefslogtreecommitdiff
path: root/src/embed/internal/embedtest/embed_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/embed/internal/embedtest/embed_test.go')
-rw-r--r--src/embed/internal/embedtest/embed_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/embed/internal/embedtest/embed_test.go b/src/embed/internal/embedtest/embed_test.go
index 2d50f5e01f..b41359f4c2 100644
--- a/src/embed/internal/embedtest/embed_test.go
+++ b/src/embed/internal/embedtest/embed_test.go
@@ -129,3 +129,43 @@ func TestUninitialized(t *testing.T) {
t.Errorf("in uninitialized embed.FS, . is not a directory")
}
}
+
+var (
+ //go:embed "testdata/hello.txt"
+ helloT []T
+ //go:embed "testdata/hello.txt"
+ helloUint8 []uint8
+ //go:embed "testdata/hello.txt"
+ helloEUint8 []EmbedUint8
+ //go:embed "testdata/hello.txt"
+ helloBytes EmbedBytes
+ //go:embed "testdata/hello.txt"
+ helloString EmbedString
+)
+
+type T byte
+type EmbedUint8 uint8
+type EmbedBytes []byte
+type EmbedString string
+
+// golang.org/issue/47735
+func TestAliases(t *testing.T) {
+ all := testDirAll
+ want, e := all.ReadFile("testdata/hello.txt")
+ if e != nil {
+ t.Fatal("ReadFile:", e)
+ }
+ check := func(g interface{}) {
+ got := reflect.ValueOf(g)
+ for i := 0; i < got.Len(); i++ {
+ if byte(got.Index(i).Uint()) != want[i] {
+ t.Fatalf("got %v want %v", got.Bytes(), want)
+ }
+ }
+ }
+ check(helloT)
+ check(helloUint8)
+ check(helloEUint8)
+ check(helloBytes)
+ check(helloString)
+}