Esempio n. 1
0
void FileTests::testExistNotExist()
{
	// Test pre-condition
	CPPUNIT_ASSERT(!exists("nonExistentFile"));

	// Attempt to open a file known not to exist
#ifndef _WIN32
	File doesntExist("testdir/nonExistentFile");
#else
	File doesntExist("testdir\\nonExistentFile");
#endif

	CPPUNIT_ASSERT(!doesntExist.isValid());

	// Attempt to open a file known to exist
#ifndef _WIN32
	CPPUNIT_ASSERT(!system("echo someStuff > testdir/existingFile"));
#else
	CPPUNIT_ASSERT(!system("echo someStuff > testdir\\existingFile"));
#endif
	CPPUNIT_ASSERT(exists("existingFile"));

#ifndef _WIN32
	File exists("testdir/existingFile");
#else
	File exists("testdir\\existingFile");
#endif

	CPPUNIT_ASSERT(exists.isValid());
}
Esempio n. 2
0
void FileTests::testCreateNotCreate()
{
	// Test pre-condition
	CPPUNIT_ASSERT(!exists("nonExistentFile"));
	CPPUNIT_ASSERT(!exists("nonExistentFile2"));

	// Attempt to open a file known not to exist
#ifndef _WIN32
	File doesntExist("testdir/nonExistentFile", true, true, false);
#else
	File doesntExist("testdir\\nonExistentFile", true, true, false);
#endif

	CPPUNIT_ASSERT(!doesntExist.isValid());
	CPPUNIT_ASSERT(!exists("nonExistentFile"));

	// Attempt to open a file known not to exist in create mode
#ifndef _WIN32
	File willBeCreated("testdir/nonExistentFile2", true, true, true);
#else
	File willBeCreated("testdir\\nonExistentFile2", true, true, true);
#endif

	CPPUNIT_ASSERT(willBeCreated.isValid());
	CPPUNIT_ASSERT(exists("nonExistentFile2"));
}
Esempio n. 3
0
void test_a_dbtoken::should_fail_to_open_nonexistant_tokens()
{
	DBToken doesntExist("testdir","doesntExist");

	CPPUNIT_ASSERT(!doesntExist.isValid());
}