Skip to content

Commit f38447a

Browse files
committed
fix failing tests
1 parent 2e75acc commit f38447a

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

pkg/MeshTypes/triangle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ func (t *Triangle) Normal() Vector {
1313
}
1414

1515
func (obj *Triangle) Copy() Triangle {
16-
return Triangle{V0: obj.V0, V1: obj.V1, V2: obj.V2}
16+
return Triangle{V0: obj.V0.Copy(), V1: obj.V1.Copy(), V2: obj.V2.Copy()}
1717
}

tests/MeshTypes/mesh_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ func TestRotateAndTranslate(t *testing.T) {
8181
result := a.Copy()
8282
result.RotateAndTranslate(translationMatrix)
8383
want := a.Copy()
84-
for _, triangle := range want.Triangles {
84+
for triangle_id := range want.Triangles {
85+
triangle := &want.Triangles[triangle_id]
8586
triangle.V0.Position = translationMatrix.MulPosition(triangle.V0.Position) // safe to use as func is tested in another place
8687
triangle.V1.Position = translationMatrix.MulPosition(triangle.V1.Position)
8788
triangle.V2.Position = translationMatrix.MulPosition(triangle.V2.Position)

tests/MeshTypes/triangle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestTriangleCopy(t *testing.T) {
2727
V2: MeshTypes.Vertex{Position: MeshTypes.Vector{X: 13, Y: 14, Z: 15}, Normal: &MeshTypes.Vector{X: 16, Y: 17, Z: 18}},
2828
}
2929
copy := a.Copy()
30-
if !(reflect.DeepEqual(copy, a) && a.V0 != copy.V0 && a.V1 != copy.V1 && a.V2 != copy.V2) {
30+
if !(reflect.DeepEqual(copy, a) && a.V0.Normal != copy.V0.Normal && a.V1.Normal != copy.V1.Normal && a.V2.Normal != copy.V2.Normal) {
3131
t.Error("Triangle Copy() returned value does not match expected value")
3232
}
3333
}

0 commit comments

Comments
 (0)