Ejemplo n.º 1
0
int main(int argc, char** argv)
{
	// set global variable g_testDirectory
	setTestDirectory();
	// the following statement will be printed at beginning of job
	// and before a death test
//	printf("Test directory: %s.\n", (*g_testDirectory).c_str());
	// parse command line BEFORE InitGoogleTest
	bool useTersePrinter = true;	// ALWAYS true (for testing only)
	bool useTerseOutput = false;	// option for terse (true) or all (false)
	bool useColor = true;
	bool noClose = false;
	for (int i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--terse_output") == 0)
			useTerseOutput = true;
		else if (strcmp(argv[i], "--no_close") == 0)
			noClose = true;
		else if (strcmp(argv[i], "--gtest_color=no") == 0)
			useColor = false;
	}
	// do this after parsing the command line but before changing printer
	testing::InitGoogleTest(&argc, argv);
	// change to TersePrinter
	if (useTersePrinter)
	{
		UnitTest& unit_test = *UnitTest::GetInstance();
		testing::TestEventListeners& listeners = unit_test.listeners();
		delete listeners.Release(listeners.default_result_printer());
		listeners.Append(new TersePrinter(useTerseOutput, useColor));
	}
	// Begin unit testing.
	// The default options file is renamed to avoid errors in testing.
	createTestDirectory(getTestDirectory());
	renameDefaultOptionsFile();
	int retval = RUN_ALL_TESTS();
	restoreDefaultOptionsFile();
	// Print verification if terse_printer.
	// Verify that all tests were run. This can occur if a source file
	// is missing from the project. The UnitTest reflection API in
	// example 9 will not work here because of user modifications.
	if (g_isI18nTest)
		// Change the following value to the number of tests (within 20).
		TersePrinter::PrintTestTotals(40, __FILE__, __LINE__);
	else
		// Change the following value to the number of tests (within 20).
		TersePrinter::PrintTestTotals(140, __FILE__, __LINE__);
	if (g_isI18nTest)
		printI18nMessage();
#ifdef _WIN32
	printf("%c", '\n');
#endif
	// end of unit testing
	removeTestDirectory(getTestDirectory());
	if (noClose)			// command line option
		systemPause();

	return retval;
}
Ejemplo n.º 2
0
void JobTest::moveDirectoryToOtherPartition()
{
    kdDebug() << k_funcinfo << endl;
    const QString src = homeTmpDir() + "dirFromHome";
    const QString dest = otherTmpDir() + "dirFromHome_moved";
    createTestDirectory(src);
    moveLocalDirectory(src, dest);
}
Ejemplo n.º 3
0
void JobTest::copyDirectoryToSamePartition()
{
    kdDebug() << k_funcinfo << endl;
    const QString src = homeTmpDir() + "dirFromHome";
    const QString dest = homeTmpDir() + "dirFromHome_copied";
    createTestDirectory(src);
    copyLocalDirectory(src, dest);
}
Ejemplo n.º 4
0
void JobTest::copyDirectoryToExistingDirectory()
{
    kdDebug() << k_funcinfo << endl;
    // just the same as copyDirectoryToSamePartition, but it means that
    // this time dest exists.
    const QString src = homeTmpDir() + "dirFromHome";
    const QString dest = homeTmpDir() + "dirFromHome_copied";
    createTestDirectory(src);
    copyLocalDirectory(src, dest, AlreadyExists);
}
Ejemplo n.º 5
0
string createLocaleDirectory(wstring subDirectory)
// create a directory in the language of the current locale
// the locale must be set before calling this function
{
	string subdir = convertToMultiByte(subDirectory);
	string dirpath  = getTestDirectory() + subdir;
	standardizePath(subdir);
	// create directory
	createTestDirectory(dirpath);
	return subdir;
}
Ejemplo n.º 6
0
void JobTest::copyDirectoryToOtherPartition()
{
    kdDebug() << k_funcinfo << endl;
    const QString src = homeTmpDir() + "dirFromHome";
    const QString dest = otherTmpDir() + "dirFromHome_copied";
    // src is already created by copyDirectoryToSamePartition()
    // so this is just in case someone calls this method only
    if(!QFile::exists(src))
        createTestDirectory(src);
    copyLocalDirectory(src, dest);
}
Ejemplo n.º 7
0
		void SetUp() override
		{
			createTestDirectory();
		}