diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-04-21 09:57:52 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-04-21 09:57:52 +0000 |
| commit | ca5f94534beb3fb395a397a2fe991f4c64fb2f84 (patch) | |
| tree | 1ab95c541266dc554500d201865f683616a11dbc /src/DllPlugInTester/CommandLineParserTest.cpp | |
| parent | aa3e46e802dc5139e3e2c32e6a00526697e8a0aa (diff) | |
| download | cppunit-ca5f94534beb3fb395a397a2fe991f4c64fb2f84.tar.gz | |
Src/DllPlugInTester/makefile.
src/DllPlugInTester/makefile.am: removed ld.so from LDADD flags.
* src/DllPlugInTester/CommandLineParser.h:
* src/DllPlugInTester/CommandLineParser.cpp: rewrote, fixed problem
with double quotes in command line...
* src/DllPlugInTester/CommandLineParserTest.h:
* src/DllPlugInTester/CommandLineParserTest.cpp:
* src/DllPlugInTester/DllPlugInTesterTest.cpp: added, unit tests for
CommandLineParser.
* src/msvc6/TestPlugIn/*: removed.
Diffstat (limited to 'src/DllPlugInTester/CommandLineParserTest.cpp')
| -rw-r--r-- | src/DllPlugInTester/CommandLineParserTest.cpp | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/src/DllPlugInTester/CommandLineParserTest.cpp b/src/DllPlugInTester/CommandLineParserTest.cpp new file mode 100644 index 0000000..8f2f2bf --- /dev/null +++ b/src/DllPlugInTester/CommandLineParserTest.cpp @@ -0,0 +1,221 @@ +#include "CommandLineParser.h" +#include "CommandLineParserTest.h" + +CPPUNIT_TEST_SUITE_REGISTRATION( CommandLineParserTest ); + + +CommandLineParserTest::CommandLineParserTest() : + CppUnit::TestCase() +{ +} + + +CommandLineParserTest::~CommandLineParserTest() +{ +} + + +void +CommandLineParserTest::setUp() +{ + _parser = NULL; +} + + +void +CommandLineParserTest::tearDown() +{ + delete _parser; +} + + +void +CommandLineParserTest::parse( char **lines ) +{ + int count =0; + for ( char **line = lines; *line != NULL; ++line, ++count ); + + delete _parser; + _parser = new CommandLineParser( count, lines ); + _parser->parse(); +} + + +void +CommandLineParserTest::testEmptyCommandLine() +{ + static char *lines[] = { "", NULL }; + parse( lines ); + + std::string none; + CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() ); + CPPUNIT_ASSERT( !_parser->noTestProgress() ); + CPPUNIT_ASSERT( !_parser->useBriefTestProgress() ); + CPPUNIT_ASSERT( !_parser->useCompilerOutputter() ); + CPPUNIT_ASSERT( !_parser->useCoutStream() ); + CPPUNIT_ASSERT( !_parser->useTextOutputter() ); + CPPUNIT_ASSERT( !_parser->useXmlOutputter() ); +} + + +void +CommandLineParserTest::testFlagCompiler() +{ + static char *lines[] = { "", "-c", NULL }; + parse( lines ); + + std::string none; + CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() ); + CPPUNIT_ASSERT( !_parser->noTestProgress() ); + CPPUNIT_ASSERT( !_parser->useBriefTestProgress() ); + CPPUNIT_ASSERT( _parser->useCompilerOutputter() ); + CPPUNIT_ASSERT( !_parser->useCoutStream() ); + CPPUNIT_ASSERT( !_parser->useTextOutputter() ); + CPPUNIT_ASSERT( !_parser->useXmlOutputter() ); + CPPUNIT_ASSERT_EQUAL( 0, _parser->getPlugInCount() ); +} + + +void +CommandLineParserTest::testLongFlagBriefProgress() +{ + static char *lines[] = { "", "--brief-progress", NULL }; + parse( lines ); + + std::string none; + CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() ); + CPPUNIT_ASSERT( !_parser->noTestProgress() ); + CPPUNIT_ASSERT( _parser->useBriefTestProgress() ); + CPPUNIT_ASSERT( !_parser->useCompilerOutputter() ); + CPPUNIT_ASSERT( !_parser->useCoutStream() ); + CPPUNIT_ASSERT( !_parser->useTextOutputter() ); + CPPUNIT_ASSERT( !_parser->useXmlOutputter() ); + CPPUNIT_ASSERT_EQUAL( 0, _parser->getPlugInCount() ); +} + + +void +CommandLineParserTest::testFileName() +{ + static char *lines[] = { "", "TestPlugIn.dll", NULL }; + parse( lines ); + + std::string none; + CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() ); + CPPUNIT_ASSERT( !_parser->noTestProgress() ); + CPPUNIT_ASSERT( !_parser->useBriefTestProgress() ); + CPPUNIT_ASSERT( !_parser->useCompilerOutputter() ); + CPPUNIT_ASSERT( !_parser->useCoutStream() ); + CPPUNIT_ASSERT( !_parser->useTextOutputter() ); + CPPUNIT_ASSERT( !_parser->useXmlOutputter() ); + + CPPUNIT_ASSERT_EQUAL( 1, _parser->getPlugInCount() ); + + CommandLinePlugInInfo info( _parser->getPlugInAt( 0 ) ); + CPPUNIT_ASSERT_EQUAL( std::string("TestPlugIn.dll"), info.m_fileName ); + CPPUNIT_ASSERT_EQUAL( 0, int(info.m_parameters.size()) ); +} + + +void +CommandLineParserTest::testTestPath() +{ + static char *lines[] = { "", ":Core", NULL }; + parse( lines ); + + std::string none; + CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() ); + CPPUNIT_ASSERT_EQUAL( std::string("Core"), _parser->getTestPath() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() ); + CPPUNIT_ASSERT( !_parser->noTestProgress() ); + CPPUNIT_ASSERT( !_parser->useBriefTestProgress() ); + CPPUNIT_ASSERT( !_parser->useCompilerOutputter() ); + CPPUNIT_ASSERT( !_parser->useCoutStream() ); + CPPUNIT_ASSERT( !_parser->useTextOutputter() ); + CPPUNIT_ASSERT( !_parser->useXmlOutputter() ); + CPPUNIT_ASSERT_EQUAL( 0, _parser->getPlugInCount() ); +} + + +void +CommandLineParserTest::testParameterWithSpace() +{ + static char *lines[] = { "", "--xml", "Test Results.xml", NULL }; + parse( lines ); + + std::string none; + CPPUNIT_ASSERT_EQUAL( none, _parser->getEncoding() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getTestPath() ); + CPPUNIT_ASSERT_EQUAL( std::string("Test Results.xml"), + _parser->getXmlFileName() ); + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlStyleSheet() ); + CPPUNIT_ASSERT( !_parser->noTestProgress() ); + CPPUNIT_ASSERT( !_parser->useBriefTestProgress() ); + CPPUNIT_ASSERT( !_parser->useCompilerOutputter() ); + CPPUNIT_ASSERT( !_parser->useCoutStream() ); + CPPUNIT_ASSERT( !_parser->useTextOutputter() ); + CPPUNIT_ASSERT( _parser->useXmlOutputter() ); + CPPUNIT_ASSERT_EQUAL( 0, _parser->getPlugInCount() ); +} + + +void +CommandLineParserTest::testMissingStyleSheetParameterThrow() +{ + static char *lines[] = { "", "--xsl", NULL }; + parse( lines ); +} + + +void +CommandLineParserTest::testMissingEncodingParameterThrow() +{ + static char *lines[] = { "", "--encoding", NULL }; + parse( lines ); +} + + +void +CommandLineParserTest::testXmlFileNameIsOptional() +{ + static char *lines[] = { "", "--xml", NULL }; + parse( lines ); + + std::string none; + CPPUNIT_ASSERT_EQUAL( none, _parser->getXmlFileName() ); +} + + +void +CommandLineParserTest::testPlugInsWithParameters() +{ + static char *lines[] = { "", "TestPlugIn1.dll=login = lain", + "Clocker.dll", NULL }; + parse( lines ); + + CPPUNIT_ASSERT_EQUAL( 2, _parser->getPlugInCount() ); + + CommandLinePlugInInfo info1( _parser->getPlugInAt( 0 ) ); + + CPPUNIT_ASSERT_EQUAL( std::string("TestPlugIn1.dll"), info1.m_fileName ); + CPPUNIT_ASSERT_EQUAL( 1, int(info1.m_parameters.size()) ); + CPPUNIT_ASSERT_EQUAL( std::string("login = lain"), + info1.m_parameters[0] ); + + CommandLinePlugInInfo info2( _parser->getPlugInAt( 1 ) ); + CPPUNIT_ASSERT_EQUAL( std::string("Clocker.dll"), info2.m_fileName ); + CPPUNIT_ASSERT_EQUAL( 0, int(info2.m_parameters.size()) ); +} |
