changes for angry travis

This commit is contained in:
David Stephan 2018-07-27 18:39:36 -07:00
parent b630e2326b
commit 8cdd4ebddc

View File

@ -19,6 +19,7 @@
#include <osgSim/MultiSwitch> #include <osgSim/MultiSwitch>
#include <osg/Node> #include <osg/Node>
#include <osgDB/Registry> #include <osgDB/Registry>
#include <stdexcept>
#include <iostream> #include <iostream>
@ -31,14 +32,14 @@ void testSerializer(const osgSim::MultiSwitch::SwitchSetList &values,
osg::ref_ptr<osgSim::MultiSwitch> ms(new osgSim::MultiSwitch); osg::ref_ptr<osgSim::MultiSwitch> ms(new osgSim::MultiSwitch);
if (values.size() > 0) { if (values.size() > 0) {
int nchildren = values[0].size(); size_t nchildren = values[0].size();
for (int i = 0; i < nchildren; i++) { for (size_t i = 0; i < nchildren; i++) {
ms->addChild(new osg::Node); ms->addChild(new osg::Node);
} }
} }
ms->setSwitchSetList(values); ms->setSwitchSetList(values);
for (int i = 0; i < names.size(); i++) { for (size_t i = 0; i < names.size(); i++) {
ms->setValueName(i, names[i]); ms->setValueName(i, names[i]);
} }
@ -47,40 +48,65 @@ void testSerializer(const osgSim::MultiSwitch::SwitchSetList &values,
std::stringstream ss; std::stringstream ss;
// write // write
auto wresult = rw->writeNode(*ms, ss, options); osgDB::ReaderWriter::WriteResult wresult = rw->writeNode(*ms, ss, options);
// read // read
auto rresult = rw->readNode(ss, options); osgDB::ReaderWriter::ReadResult rresult = rw->readNode(ss, options);
osg::ref_ptr<osg::Node> node = rresult.takeNode(); osg::ref_ptr<osg::Node> node = rresult.takeNode();
osg::ref_ptr<osgSim::MultiSwitch> ms2(dynamic_cast<osgSim::MultiSwitch*>(node.get())); osg::ref_ptr<osgSim::MultiSwitch> ms2(dynamic_cast<osgSim::MultiSwitch*>(node.get()));
assert2(ms2 != nullptr); assert2(ms2 != NULL);
assert2(ms2->getSwitchSetList() == values); assert2(ms2->getSwitchSetList() == values);
for (int i = 0; i < values.size(); i++) { for (size_t i = 0; i < values.size(); i++) {
assert2(ms2->getValueName(i) == names[i]); assert2(ms2->getValueName(i) == names[i]);
} }
assert2(ms->getNumChildren() == ms2->getNumChildren()); assert2(ms->getNumChildren() == ms2->getNumChildren());
} }
int main( int argc, char **argv ) int main()
{ {
testSerializer( osgSim::MultiSwitch::SwitchSetList values;
{ osgSim::MultiSwitch::SwitchSetNameList names;
{false, false}, //testSerializer(
{true, true} // {
}, // {false, false},
{ "offs", "ons" } // {true, true}
); // },
// { "offs", "ons" }
//);
std::vector<bool> offs(false, 2);
std::vector<bool> ons(true, 2);
values.push_back(offs);
values.push_back(ons);
names.push_back("offs");
names.push_back("ons");
testSerializer(values, names);
testSerializer({}, {}); //testSerializer({}, {});
values.clear();
names.clear();
testSerializer(values, names);
testSerializer( //testSerializer(
{ // {
{ true, true, false, true, false, true } // { true, true, false, true, false, true }
}, // },
{"stuff"} // {"stuff"}
); //);
values.clear();
std::vector<bool> stuff;
stuff.push_back(true);
stuff.push_back(true);
stuff.push_back(false);
stuff.push_back(true);
stuff.push_back(false);
stuff.push_back(true);
values.push_back(stuff);
names.clear();
names.push_back("stuff");
testSerializer(values, names);
return 0; return 0;
} }