diff --git a/README.md b/README.md index 9061650c..6436b2b5 100644 --- a/README.md +++ b/README.md @@ -337,6 +337,22 @@ The first way is to actually code new features for EZC3D. The easiest way to do The second way is to provide me with non-working C3D files (See the C3D Softwares section below for more details). There is another repository for test files in the pyomeca (https://github.com/pyomeca/ezc3d_c3dTestFiles). You can fork this project, add your C3D in according to the recommendations and pull request it. This will be greatly appreciated by me and the biomechanics community! +## Using the test suite +EZC3D is tested with the test suite from google `gtest` (https://github.com/google/googletest). + +If you want to add or change some tests, you are very welcome to do so (actually it makes me very happy!). You should compile EZC3D with the `BUILD_TESTS` options turned on. The google test suite should download itself automatically. + +Afterwards, you can create a new test with the following function declaration +```c++ +TEST(NameOfTestStructure, NameOfTest) { + // Your test here... +} +``` + +You are invited to write tests for true positive, false positive, true negative and false negative using different combinations of `EXPECT_EQ` (or `EXPECT_FLOAT_EQ` if you compare float-precision numbers), `EXPECT_NE`, `ASSERT_TRUE`, `EXPECT_THROW` and `EXPECT_NO_THROW`. For a complete explaination of the google test suite, please refer to one of the numerous tutorial on the web. + +I also implemented some useful function such as `compareHeader(myFirstC3d, mySecondC3d)` and `compareData(myFirstC3d, mySecondC3d)` which strickly compares header and data respectively. If you expect differences though, these function are for no use and you should copy-paste the content of them in your test (and change whatever is expected to be different). It is also possible to create a fully filled structure using the `fillC3D(c3dTestStruct& c3dStruc, bool withPoints, bool withAnalogs)` function and it can be tested with the `defaultHeaderTest` and `defaultParametersTest` function. Again, if you expect differences with the default setting, you should not use these default testing functions, but copy the relevant part in you extra test. + # Supported generated C3D The software companies have loosely implemented the C3D standard proposed by http://C3D.org. Hence, there are some workaround that must be incorporated to the code to be able to read the C3D created using third-party softwares. So far, C3D from three different companies were tested. Vicon (https://www.vicon.com/), Qualisys (https://www.qualisys.com/) and Optotrak (https://www.ndigital.com/msci/products/optotrak-certus/). But I am sure there is plenty of other obscure companies or simply cases that were not tested from these companies (simply because I don't have C3D to test). If you find yourself with a bug when trying to read a C3D that should work, please open an issue and provide me with the corresponding C3D (see How to contribute). diff --git a/binding/python3/CMakeLists.txt b/binding/python3/CMakeLists.txt index f0041aa0..ba3c3ed0 100644 --- a/binding/python3/CMakeLists.txt +++ b/binding/python3/CMakeLists.txt @@ -63,4 +63,4 @@ INSTALL(TARGETS _${PROJECT_NAME} DESTINATION ${PYTHON_INSTALL_DESTINATION} ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/_version.py - DESTINATION ${PYTHON_INSTALL_DESTINATION}) + DESTINATION ${PYTHON_INSTALL_DESTINATION}/${PROJECT_NAME}) diff --git a/src/Parameter.cpp b/src/Parameter.cpp index 9fd18ff2..68f52492 100644 --- a/src/Parameter.cpp +++ b/src/Parameter.cpp @@ -75,6 +75,11 @@ void ezc3d::ParametersNS::GroupNS::Parameter::write( // Assusimng dimension[0] is the number of characters // and dimension[1] is the number of string dimension[0] = longestElement(); + + // Remove unecessary dimension + if (dimension.size() == 2 && dimension[1] == 1) { + dimension = {dimension[0]}; + } } // Write the parameter values @@ -161,7 +166,7 @@ size_t ezc3d::ParametersNS::GroupNS::Parameter::writeImbricatedParameter( static_cast(_data_type)); else if (_data_type == DATA_TYPE::CHAR){ std::string toWrite(_param_data_string[cmp]); - toWrite.resize(dim[0]); // Pad with \0 + toWrite.resize(dim[0], ' '); // Pad with x20 f.write(toWrite.c_str(), static_cast(dim[0] * DATA_TYPE::BYTE)); } @@ -298,13 +303,8 @@ size_t ezc3d::ParametersNS::GroupNS::Parameter::longestElement() const{ if (_dimension.size() == 1) return _param_data_string[0].size(); else { - if (_dimension.size() != 2) { - throw std::runtime_error( - "longestElement is only implemented for 1d or 2d CHAR matrix. " - "Please report this error for help improving ezc3d."); - } size_t longestSoFar(0); - for (size_t i = 0; i<_dimension[1]; ++i){ + for (size_t i = 0; i<_param_data_string.size(); ++i){ if (_param_data_string[i].size() > longestSoFar) longestSoFar = _param_data_string[i].size(); } diff --git a/src/Point.cpp b/src/Point.cpp index 4f97bc28..798cfae3 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -37,10 +37,11 @@ void ezc3d::DataNS::Points3dNS::Point::write(std::fstream &f) const { } else { float zero(0); + float minusOne(-1); f.write(reinterpret_cast(&zero), ezc3d::DATA_TYPE::FLOAT); f.write(reinterpret_cast(&zero), ezc3d::DATA_TYPE::FLOAT); f.write(reinterpret_cast(&zero), ezc3d::DATA_TYPE::FLOAT); - f.write(reinterpret_cast(&_data[3]), ezc3d::DATA_TYPE::FLOAT); + f.write(reinterpret_cast(&minusOne), ezc3d::DATA_TYPE::FLOAT); } } diff --git a/test/test_ezc3d.cpp b/test/test_ezc3d.cpp index cfebc34c..8fc5ccc1 100644 --- a/test/test_ezc3d.cpp +++ b/test/test_ezc3d.cpp @@ -194,14 +194,27 @@ void compareHeader(const ezc3d::c3d& c3d1, const ezc3d::c3d& c3d2){ } } -void compareData(const ezc3d::c3d& c3d1, const ezc3d::c3d& c3d2){ +void compareData(const ezc3d::c3d& c3d1, const ezc3d::c3d& c3d2 + , bool skipResidual = false){ // All the data should be the same for (size_t f=0; f