From 67e6f675e6cf7d5a4f3180c52430cf66aa14be3e Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 20 Jun 2016 12:25:43 +0200 Subject: [PATCH] example_osgobjectcache: Add a check that we really get the correct nodes. --- examples/osgobjectcache/osgobjectcache.cpp | 38 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/examples/osgobjectcache/osgobjectcache.cpp b/examples/osgobjectcache/osgobjectcache.cpp index 4fd6e6201..e894513ae 100644 --- a/examples/osgobjectcache/osgobjectcache.cpp +++ b/examples/osgobjectcache/osgobjectcache.cpp @@ -21,6 +21,7 @@ #include +#include osg::Group* createObjectCache() { @@ -41,11 +42,38 @@ osg::Group* createObjectCache() options3->setObjectCacheHint(osgDB::Options::CACHE_ALL); osg::ref_ptr node1 = osgDB::readRefNodeFile("cessna.osg"); - osg::ref_ptr node2 = osgDB::readRefNodeFile("cessna.osg", options1.get()); - osg::ref_ptr node3 = osgDB::readRefNodeFile("cessna.osg", options2.get()); - osg::ref_ptr node4 = osgDB::readRefNodeFile("cessna.osg", options1.get()); - osg::ref_ptr node5 = osgDB::readRefNodeFile("cessna.osg", options2.get()); - osg::ref_ptr node6 = osgDB::readRefNodeFile("cessna.osg", options3.get()); + osg::ref_ptr node2 = osgDB::readRefNodeFile("cessna.osg"); + osg::ref_ptr node3 = osgDB::readRefNodeFile("cessna.osg", options1.get()); + osg::ref_ptr node4 = osgDB::readRefNodeFile("cessna.osg", options2.get()); + osg::ref_ptr node5 = osgDB::readRefNodeFile("cessna.osg", options1.get()); + osg::ref_ptr node6 = osgDB::readRefNodeFile("cessna.osg", options2.get()); + osg::ref_ptr node7 = osgDB::readRefNodeFile("cessna.osg", options3.get()); + osg::ref_ptr node8 = osgDB::readRefNodeFile("cessna.osg", options3.get()); + + // check that we really get the correct nodes + if (node1 != node2) + { + fprintf(stderr, "error reading node from object cache using default options\n"); + exit(1); + } + + if (node3 != node5) + { + fprintf(stderr, "error reading node from object cache stored with options '%s'\n", options1.get()->getOptionString().c_str()); + exit(1); + } + + if (node4 != node6) + { + fprintf(stderr, "error reading node from object cache stored with options '%s'\n", options2.get()->getOptionString().c_str()); + exit(1); + } + + if (node7 != node8) + { + fprintf(stderr, "error reading node from object cache stored with options '%s'\n", options3.get()->getOptionString().c_str()); + exit(1); + } group->addChild(node1); group->addChild(node2);