Skip to content

Commit

Permalink
add io tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed May 9, 2019
1 parent 067a400 commit d314cf3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Save(doc *Document, name string) error {
return save(doc, name, false)
}

// Save will save a document as a GLB file with the specified by name.
// SaveBinary will save a document as a GLB file with the specified by name.
func SaveBinary(doc *Document, name string) error {
return save(doc, name, true)
}
Expand Down
47 changes: 47 additions & 0 deletions io_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package gltf

import "testing"

func TestRelativeFileHandler_ReadFull(t *testing.T) {
type args struct {
uri string
data []byte
}
tests := []struct {
name string
h *RelativeFileHandler
args args
wantErr bool
}{
{"no dir", new(RelativeFileHandler), args{"a.bin", []byte{}}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.h.ReadFull(tt.args.uri, tt.args.data); (err != nil) != tt.wantErr {
t.Errorf("RelativeFileHandler.ReadFull() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

func TestProtocolRegistry_ReadFull(t *testing.T) {
type args struct {
uri string
data []byte
}
tests := []struct {
name string
reg ProtocolRegistry
args args
wantErr bool
}{
{"invalid url", make(ProtocolRegistry), args{"%$·$·23", []byte{}}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.reg.ReadFull(tt.args.uri, tt.args.data); (err != nil) != tt.wantErr {
t.Errorf("ProtocolRegistry.ReadFull() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

0 comments on commit d314cf3

Please sign in to comment.