Skip to content

Commit

Permalink
test for unnamed meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
Twinklebear committed Oct 4, 2019
1 parent 2df1233 commit 4e3c592
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions empty_name_triangle.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# A simple triangle object for testing
v 0 0 0
v 1 0 0
v 0 1 0

f -3 -2 -1
24 changes: 24 additions & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ fn simple_triangle() {
assert_eq!(mesh.indices, expect_idx);
}

#[test]
fn empty_name_triangle() {
let m = tobj::load_obj(&Path::new("empty_name_triangle.obj"));
assert!(m.is_ok());
let (models, mats) = m.unwrap();
// We expect a single model with no materials
assert_eq!(models.len(), 1);
assert!(mats.is_empty());
// Confirm our triangle is loaded correctly
assert_eq!(models[0].name, "unnamed_object");
let mesh = &models[0].mesh;
assert!(mesh.normals.is_empty());
assert!(mesh.texcoords.is_empty());
assert_eq!(mesh.material_id, None);

// Verify each position is loaded properly
let expect_pos = vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0];
assert_eq!(mesh.positions, expect_pos);
// Verify the indices are loaded properly
let expect_idx = vec![0, 1, 2];
assert_eq!(mesh.indices, expect_idx);
}


#[test]
fn multiple_face_formats() {
let m = tobj::load_obj(&Path::new("quad.obj"));
Expand Down

0 comments on commit 4e3c592

Please sign in to comment.