Giter Club home page Giter Club logo

libigl-unit-tests's Introduction

Unit Tests for libigl

Build Status

Get started with

git clone --recursive [email protected]:libigl/libigl-unit-tests.git

Dependencies

googletest is a submodule

Build and test

Use cmake to generate a Makefile that will build and test upon issuing make:

mkdir build
cd build
cmake ..

Then build and test with

make

This will first compile the tests and then immediately run the tests. If tests are succeeding you should see output similar to:

[       OK ] Example.Sub1 (1056 ms)
[ RUN      ] Example.Sub2 
[       OK ] Example.Sub2 (4 ms)
[ RUN      ] Example.Sub4
[       OK ] Example.Sub4 (2 ms)
[----------] 3 tests from Example (1062 ms total)

Generating new tests

Many libigl functions act on triangle meshes. To make it easy to add a new test for a libigl function, we have a script that will output some boilerplate testing code. So if you issue:

cd include/igl/
../../scripts/new.sh myfun

This will create a test file myfun.cpp containing:

#include <test_common.h>
#include <igl/myfun.h>

class myfun : public ::testing::TestWithParam<std::string> {};

TEST_P(myfun, change_to_meaningful_name)
{
  Eigen::MatrixXd V;
  Eigen::MatrixXi F;
  Eigen::SparseMatrix<double> L;
  // Load example mesh: GetParam() will be name of mesh file
  test_common::load_mesh(GetParam(), V, F);
  // ASSERT_EQ(a,b);
  // ASSERT_TRUE(a==b);
  // ASSERT_NEAR(a,b,1e-15)
  // ASSERT_LT(a,1e-12);
}

INSTANTIATE_TEST_CASE_P
(
 all_meshes,
 myfun,
 ::testing::ValuesIn(test_common::all_meshes()),
 test_common::string_test_name
);

Add a call to igl::myfun and an assertion (e.g., ASSERT_EQ) and this will add a test for all meshes in the data/ folder. (Should also change change_to_meaningful_name to a meaningful name based on what you're testing).

Conventions

When naming a test for a function igl::extra::function_name use:

TEST(extra_function_name, meaning_test_name)
{
  ...
}

where meaning_test_name could identify the type of test or the type of data being used.

Example

The test for igl::copyleft::cgal::order_facets_around_edges in include/igl/copyleft/cgal/order_facets_around_edges.cpp is:

TEST(copyleft_cgal_order_facets_around_edges, TripletFaces)
{
  ...
}

which tests this function on example data containing a triplet of faces.

Guarantees

None.

(Obviously?) The presence of a unit test here for some function (e.g., igl::cotmatrix) is not a guarantee or even an endorsement of the notion that the libigl function igl::cotmatrix is bug free or "fully tested" or "heavily tested" or even "adequately tested".

Need work?

Some of the most used libigl functions

grep -hr "^#include \"" ../libigl/include/igl | sed -e 's/\(\.\.\/\)//g' | sort | uniq -c | sort

still don't have unit tests.

libigl-unit-tests's People

Contributors

alecjacobson avatar danielepanozzo avatar jmespadero avatar qnzhou avatar

Watchers

 avatar  avatar  avatar

Forkers

allo-

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.