Hi,

I think I got Allen's OSGNodeTest working (one test still fails, but due
to a potential bug). I'll just attach it. The OSGInitFixture should go
into the UnitTestUtil dir and all tests that require a call to osgInit
need to use a fixture that derives from OSGInitFixture.

Comments ?

        Carsten
#include <UnitTest++.h>

// Unit tests for vec classes

#include <OpenSG/OSGNode.h>
#include <OpenSG/OSGNameAttachment.h>

namespace {

struct OSGInitFixture
{
    OSGInitFixture(void)
    {
        if(initRun == false)
        {
            initRun = true;
            OSG::osgInit(0, 0);
        }
    }
    
    ~OSGInitFixture(void)
    {
    }
    
    static bool initRun;
};

bool OSGInitFixture::initRun = false;

TEST_FIXTURE(OSGInitFixture, CreateNode)
{
   OSG::NodePtr n = OSG::Node::create();
   CHECK(n != OSG::NullFC);
}

TEST_FIXTURE(OSGInitFixture, AddChild)
{
    OSG::NodePtr n = OSG::Node::create();
    OSG::NodePtr c = OSG::Node::create();
    
    n->addChild(c);
    CHECK_EQUAL(n->getNChildren(), 1);
    CHECK_EQUAL(c->getParent(), n);
}

// --- Cloning --- //
TEST_FIXTURE(OSGInitFixture, TreeCloningName)
{
   OSG::NodePtr root = OSG::Node::create();
   OSG::NodePtr child_node = OSG::Node::create();
   root->addChild(child_node);
   OSG::setName(root, "root");
   OSG::setName(child_node, "child_node");
   
   OSG::NodePtr new_root = OSG::cloneTree(root);
   
   CHECK(new_root->getNChildren() == 1);
   CHECK(new_root != root);
   CHECK(new_root->getChild(0) != child_node);
   
   // the next two tests fail - looks like something goes wrong in clone wrt
   // attachments...
   CHECK(OSG::getName(new_root) != 0);
   
   std::string new_name = OSG::getName(new_root);
   CHECK(new_name == "root");   
}

}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core

Reply via email to