diff --git a/OpenSim/Common/Test/testSTOFileAdapter.cpp b/OpenSim/Common/Test/testSTOFileAdapter.cpp index 5d2fccca86..2d2e1ecb97 100644 --- a/OpenSim/Common/Test/testSTOFileAdapter.cpp +++ b/OpenSim/Common/Test/testSTOFileAdapter.cpp @@ -243,6 +243,8 @@ int main() { filenames.push_back("subject01_walk1_grf.mot"); std::string tmpfile{"testmotfileadapter.mot"}; + std::remove(tmpfile.c_str()); + std::cout << "Testing STOFileAdapter::read() and STOFileAdapter::write()" << std::endl; for(const auto& filename : filenames) { @@ -273,8 +275,6 @@ int main() { compareFiles(filename, tmpfile); } - std::remove(tmpfile.c_str()); - // test detection of invalid column labels TimeSeriesTable table{}; SimTK_TEST_MUST_THROW_EXC(table.setColumnLabels({ "c1", "c2", "", "c4" }), @@ -335,6 +335,27 @@ int main() { SimTK_TEST(outputTables["table"]->getNumRows() == 2); SimTK_TEST(outputTables["table"]->getNumColumns() == 2); + + std::cout << "Testing for the presence of OpenSimVersion in the header." + << std::endl; + { + auto table = STOFileAdapter::read("test.sto"); + std::string filename = "OpenSimVersionHeader.sto"; + STOFileAdapter::write(table, filename); + std::ifstream ifs("OpenSimVersionHeader.sto"); + std::string line; + bool pass = false; + const std::string versionString = + "OpenSimVersion=" + OpenSim::GetVersion(); + while (std::getline(ifs, line)) { + if (line.find(versionString) != std::string::npos) { + pass = true; + break; + } + } + SimTK_TEST(pass); + } + std::cout << "\nAll tests passed!" << std::endl; return 0;