@@ -112,7 +112,7 @@ func TestReadAccessor(t *testing.T) {
112112 want any
113113 wantErr bool
114114 }{
115- {"nodata" , args {& gltf.Document {}, & gltf.Accessor {}}, nil , false },
115+ {"nodata" , args {& gltf.Document {}, & gltf.Accessor {}}, [] float32 {} , false },
116116 {"base" , args {& gltf.Document {Buffers : []* gltf.Buffer {
117117 {ByteLength : 9 , Data : []byte {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }},
118118 }, BufferViews : []* gltf.BufferView {{
@@ -542,6 +542,9 @@ func TestReadPosition(t *testing.T) {
542542 want [][3 ]float32
543543 wantErr bool
544544 }{
545+ {"nil-bufferView" , args {nil , & gltf.Accessor {
546+ Type : gltf .AccessorVec3 , ComponentType : gltf .ComponentFloat ,
547+ }, nil }, [][3 ]float32 {}, false },
545548 {"float32" , args {[]byte {0 , 0 , 128 , 63 , 0 , 0 , 0 , 64 , 0 , 0 , 64 , 64 }, & gltf.Accessor {
546549 BufferView : gltf .Index (0 ), Count : 1 , Type : gltf .AccessorVec3 , ComponentType : gltf .ComponentFloat ,
547550 }, nil }, [][3 ]float32 {{1 , 2 , 3 }}, false },
@@ -557,13 +560,14 @@ func TestReadPosition(t *testing.T) {
557560 }
558561 for _ , tt := range tests {
559562 t .Run (tt .name , func (t * testing.T ) {
560- doc := & gltf.Document {
561- BufferViews : []* gltf.BufferView {
563+ doc := new (gltf.Document )
564+ if tt .args .data != nil {
565+ doc .BufferViews = []* gltf.BufferView {
562566 {Buffer : 0 , ByteLength : len (tt .args .data )},
563- },
564- Buffers : []* gltf.Buffer {
567+ }
568+ doc . Buffers = []* gltf.Buffer {
565569 {Data : tt .args .data , ByteLength : len (tt .args .data )},
566- },
570+ }
567571 }
568572 got , err := modeler .ReadPosition (doc , tt .args .acr , tt .args .buffer )
569573 if (err != nil ) != tt .wantErr {
0 commit comments