Files
haiku-beta6/src/tools/cppunit/TestCase.cpp
T
Tyler Dauwalder 6c3b4a051f Added code to honor BTestShell::Verbosity() levels when outputting
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@232 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-07-15 06:50:13 +00:00

52 lines
1.1 KiB
C++

#include <TestCase.h>
#include <TestShell.h>
#include <unistd.h>
#include <stdio.h>
BTestCase::BTestCase(std::string name)
: CppUnit::TestCase(name)
, fValidCWD(false)
, fSubTestNum(0)
{
}
void
BTestCase::tearDown() {
NextSubTestBlock();
}
void
BTestCase::NextSubTest() {
BTestShell *shell = BTestShell::Shell();
if (shell && shell->BeVerbose()) {
printf("[%ld]", fSubTestNum++);
fflush(stdout);
}
}
void
BTestCase::NextSubTestBlock() {
BTestShell *shell = BTestShell::Shell();
if (shell && shell->BeVerbose())
printf("\n");
}
/*! To return to the last saved working directory, call RestoreCWD(). */
void
BTestCase::SaveCWD() {
fValidCWD = getcwd(fCurrentWorkingDir, B_PATH_NAME_LENGTH);
}
/* If SaveCWD() has not been called and an alternate
directory is specified by alternate, the current working directory is
changed to alternate. If alternate is null, the current working directory
is not modified.
*/
void
BTestCase::RestoreCWD(const char *alternate) {
if (fValidCWD)
chdir(fCurrentWorkingDir);
else if (alternate != NULL)
chdir(alternate);
}