[Cppunit-devel] newbie question: create tests from input file
Brought to you by:
blep
From: CppUnit d. m. l. <cpp...@li...> - 2007-02-21 08:52:48
|
Hi, I have an input file with each line contains a specific string that I want to check against a function that returns a boolean. How do I create a single test for each line under cppUnit? So far, I've been doing all this under a single test for all lines: StrTest.h: class StrTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(StrTest); CPPUNIT_TEST(testOpen); CPPUNIT_TEST_SUITE_END(); public: void testOpen() { string line; yutString errStr; ifstream dbFile("forbiddenList.txt"); if (dbFile.is_open()) { while (!dbFile.eof()) { getline(dbFile, line); cout << line << endl; if (!line.empty()) CPPUNIT_ASSERT(isValidString(line, errStr) == true); ... strTest.cc: int main() { CppUnit::TextUi::TestRunner runner; runner.addTest(StrTest::suite()); runner.run(); } Thanks |