Skip to content

Ensure OpenSimVersion=4.0 is written to STO header. #2383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions OpenSim/Common/Test/testSTOFileAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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" }),
Expand Down Expand Up @@ -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;
Expand Down