root/OpenSceneGraph/trunk/examples/osgunittests/osgunittests.cpp @ 1844

Revision 1844, 2.1 kB (checked in by robert, 12 years ago)

Added desciptions to all the demos.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#include <osg/UnitTestFramework>
2#include <osg/ArgumentParser>
3#include <osg/ApplicationUsage>
4
5int main( int argc, char** argv )
6{
7    osg::ArgumentParser arguments(&argc,argv);
8
9    // set up the usage document, in case we need to print out how to use this program.
10    arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which runs units tests.");
11    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options]");
12    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
13    arguments.getApplicationUsage()->addCommandLineOption("qt","Display qualified tests.");
14 
15
16    bool printQualifiedTest = false;
17    while (arguments.read("qt")) printQualifiedTest = true;
18
19    // if user request help write it out to cout.
20    if (arguments.read("-h") || arguments.read("--help"))
21    {
22        std::cout<<arguments.getApplicationUsage()->getCommandLineUsage()<<std::endl;
23        arguments.getApplicationUsage()->write(std::cout,arguments.getApplicationUsage()->getCommandLineOptions());
24        return 1;
25    }
26
27    // any option left unread are converted into errors to write out later.
28    arguments.reportRemainingOptionsAsUnrecognized();
29
30    // report any errors if they have occured when parsing the program aguments.
31    if (arguments.errors())
32    {
33        arguments.writeErrorMessages(std::cout);
34        return 1;
35    }
36   
37    if (arguments.argc()<=1)
38    {
39        arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
40        return 1;
41    }
42
43
44    if (printQualifiedTest)
45    {
46         std::cout<<"*****   Qualified Tests  ******"<<std::endl;
47
48         osgUtx::QualifiedTestPrinter printer;
49         osgUtx::TestGraph::instance().root()->accept( printer );   
50         std::cout<<std::endl;
51    }
52
53    std::cout<<"******   Running tests   ******"<<std::endl;
54
55    // Global Data or Context
56    osgUtx::TestContext ctx;
57    osgUtx::TestRunner runner( ctx );
58    runner.specify("root");
59
60    osgUtx::TestGraph::instance().root()->accept( runner );
61
62    return 0;
63}
Note: See TracBrowser for help on using the browser.