Re: [Cppunit-devel] newbie question: create tests from input file
Brought to you by:
blep
|
From: CppUnit d. m. l. <cpp...@li...> - 2007-02-25 09:04:38
|
I usually put the test creation logic in a new subclass of TestSuite, =
which add tests to itself.=20
----- Original Message -----=20
From: CppUnit development mailing list=20
To: cpp...@li...=20
Sent: Wednesday, February 21, 2007 9:52 AM
Subject: [Cppunit-devel] newbie question: create tests from input file
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:=20
StrTest.h:
class StrTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(StrTest);
CPPUNIT_TEST(testOpen);
CPPUNIT_TEST_SUITE_END();
public:
void testOpen() {
string line;=20
yutString errStr;
=20
ifstream dbFile("forbiddenList.txt");
if (dbFile.is_open())
{
while (!dbFile.eof())
{
getline(dbFile, line);=20
cout << line << endl;
if (!line.empty())
CPPUNIT_ASSERT(isValidString(line, errStr) =3D=3D =
true);
...
strTest.cc:
int main() {
CppUnit::TextUi::TestRunner runner;=20
runner.addTest(StrTest::suite());
runner.run();
}
Thanks
-------------------------------------------------------------------------=
-----
=
-------------------------------------------------------------------------=
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=3Djoin.php&p=3Dsourceforge&CID=3D=
DEVDEV
-------------------------------------------------------------------------=
-----
_______________________________________________
Cppunit-devel mailing list
Cpp...@li...
https://lists.sourceforge.net/lists/listinfo/cppunit-devel
|