Finished migrating Storage Kit tests to new framework.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@292 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
feae69d2c9
commit
aad997bd6c
42
headers/tools/cppunit/TestApp.h
Normal file
42
headers/tools/cppunit/TestApp.h
Normal file
@ -0,0 +1,42 @@
|
||||
// TestApp.h
|
||||
|
||||
#ifndef _beos_test_app_h_
|
||||
#define _beos_test_app_h_
|
||||
|
||||
#include <Application.h>
|
||||
#include <MessageQueue.h>
|
||||
|
||||
// TestHandler
|
||||
|
||||
class TestHandler : public BHandler {
|
||||
public:
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
BMessageQueue &Queue();
|
||||
|
||||
private:
|
||||
BMessageQueue fQueue;
|
||||
};
|
||||
|
||||
|
||||
// TestApp
|
||||
|
||||
class TestApp : public BApplication {
|
||||
public:
|
||||
TestApp(const char *signature);
|
||||
|
||||
status_t Init();
|
||||
void Terminate();
|
||||
|
||||
virtual void ReadyToRun();
|
||||
|
||||
TestHandler &Handler();
|
||||
|
||||
private:
|
||||
static int32 _AppThreadStart(void *data);
|
||||
|
||||
private:
|
||||
thread_id fAppThread;
|
||||
TestHandler fHandler;
|
||||
};
|
||||
|
||||
#endif // _beos_test_app_h_
|
@ -29,9 +29,6 @@ public:
|
||||
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
||||
void RestoreCWD(const char *alternate = NULL);
|
||||
protected:
|
||||
//! Returns true if the current shell settings allow us to print to standard output.
|
||||
bool BeVerbose();
|
||||
|
||||
bool fValidCWD;
|
||||
char fCurrentWorkingDir[B_PATH_NAME_LENGTH+1];
|
||||
int32 fSubTestNum;
|
||||
|
@ -30,7 +30,8 @@ typedef CppUnit::SynchronizedObject::SynchronizationObject SyncObject;
|
||||
*/
|
||||
class BTestShell {
|
||||
public:
|
||||
BTestShell(const std::string &description = "", SyncObject *syncObject = 0);
|
||||
BTestShell(const std::string &description = "", SyncObject *syncObject = 0);
|
||||
virtual ~BTestShell();
|
||||
|
||||
// This function is used to add the tests for a given kit (as contained
|
||||
// in a BTestSuite object) to the list of available tests. The shell assumes
|
||||
@ -72,11 +73,15 @@ public:
|
||||
// access to verbosity information. Don't rely on it if you don't
|
||||
// have to (and always make sure the pointer it returns isn't NULL
|
||||
// before you try to use it :-).
|
||||
static BTestShell* Shell() { return fGlobalShell; };
|
||||
static BTestShell* GlobalShell() { return fGlobalShell; };
|
||||
|
||||
// Sets the global BTestShell pointer. The BTestShell class does
|
||||
// not assume ownership of the object.
|
||||
static void SetShell(BTestShell *shell) { fGlobalShell = shell; };
|
||||
static void SetGlobalShell(BTestShell *shell) { fGlobalShell = shell; };
|
||||
|
||||
const char* TestDir() const;
|
||||
static const char* GlobalTestDir() { return (fGlobalShell ? fGlobalShell->TestDir() : NULL); };
|
||||
|
||||
|
||||
protected:
|
||||
VerbosityLevel fVerbosityLevel;
|
||||
@ -90,6 +95,7 @@ protected:
|
||||
static BTestShell* fGlobalShell;
|
||||
static const char indent[];
|
||||
bool fListTestsAndExit;
|
||||
BPath *fTestDir;
|
||||
|
||||
//! Prints a brief description of the program.
|
||||
virtual void PrintDescription(int argc, char *argv[]);
|
||||
@ -127,6 +133,10 @@ protected:
|
||||
*/
|
||||
virtual void LoadDynamicSuites();
|
||||
|
||||
//! Sets the current test directory.
|
||||
void UpdateTestDir(char *argv[]);
|
||||
|
||||
|
||||
private:
|
||||
//! Prevents the use of the copy constructor.
|
||||
BTestShell( const BTestShell © );
|
||||
|
@ -1,5 +1,29 @@
|
||||
#include <TestShell.h>
|
||||
#ifndef __beos_test_utils_h__
|
||||
#define __beos_test_utils_h__
|
||||
|
||||
#include <string>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
// Handy defines :-)
|
||||
#define CHK CPPUNIT_ASSERT
|
||||
#define RES DecodeResult
|
||||
|
||||
// Prints out a description of the given status_t
|
||||
// return code to standard out. Helpful for figuring
|
||||
// out just what the R5 libraries are returning.
|
||||
// Returns the same value passed in, so you can
|
||||
// use it inline in tests if necessary.
|
||||
status_t DecodeResult(status_t result);
|
||||
|
||||
// Calls system() with the concatenated string of command and parameter.
|
||||
void ExecCommand(const char *command, const char *parameter);
|
||||
|
||||
// Calls system() with the concatenated string of command, parameter1,
|
||||
// " " and parameter2.
|
||||
void ExecCommand(const char *command, const char *parameter1,
|
||||
const char *parameter2);
|
||||
|
||||
// Calls system() with the given command (kind of silly, but it's consistent :-)
|
||||
void ExecCommand(const char *command);
|
||||
|
||||
#endif // __beos_test_utils_h__
|
||||
|
@ -153,9 +153,6 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
||||
// Try to acquire the semaphore
|
||||
err = acquire_sem_etc(fThreadSem, fThreads.size(), B_RELATIVE_TIMEOUT, 500000);
|
||||
|
||||
// Get a pointer to the current global shell
|
||||
BTestShell *shell = BTestShell::Shell();
|
||||
|
||||
// Empty the UpdateList
|
||||
std::vector<std::string> &list = fObject->AcquireUpdateList();
|
||||
for (std::vector<std::string>::iterator i = list.begin();
|
||||
@ -164,7 +161,7 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
||||
{
|
||||
// Only print to standard out if the current global shell
|
||||
// lets us (or if no global shell is designated).
|
||||
if ((shell && shell->BeVerbose()) || !shell) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
printf("%s", (*i).c_str());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
SubDir OBOS_TOP src add-ons kernel file_systems ;
|
||||
|
||||
SubInclude OBOS_TOP src add-ons kernel file_systems befs ;
|
||||
#SubInclude OBOS_TOP src add-ons kernel file_systems befs ;
|
||||
|
@ -1,4 +1,4 @@
|
||||
SubDir OBOS_TOP src add-ons print drivers ;
|
||||
|
||||
SubInclude OBOS_TOP src add-ons print drivers canon_lips ;
|
||||
SubInclude OBOS_TOP src add-ons print drivers pdf ;
|
||||
#SubInclude OBOS_TOP src add-ons print drivers pdf ;
|
||||
|
@ -6,7 +6,7 @@ SubInclude OBOS_TOP src prefs drivesetup ;
|
||||
SubInclude OBOS_TOP src prefs dun ;
|
||||
SubInclude OBOS_TOP src prefs fonts ;
|
||||
SubInclude OBOS_TOP src prefs keyboard ;
|
||||
SubInclude OBOS_TOP src prefs keymap ;
|
||||
#SubInclude OBOS_TOP src prefs keymap ;
|
||||
SubInclude OBOS_TOP src prefs media ;
|
||||
SubInclude OBOS_TOP src prefs menu ;
|
||||
SubInclude OBOS_TOP src prefs mouse ;
|
||||
|
@ -11,7 +11,7 @@ int main(int argc, char *argv[]) {
|
||||
// ##### Add test suites for statically linked tests here #####
|
||||
// shell.AddTest( "Example", ExampleTest::Suite() );
|
||||
|
||||
BTestShell::SetShell(&shell);
|
||||
BTestShell::SetGlobalShell(&shell);
|
||||
|
||||
// Load our dynamically linked tests
|
||||
|
||||
|
@ -331,7 +331,7 @@ EntryTest::InitTest1Paths(TestEntry &_testEntry, status_t error, bool traverse)
|
||||
{
|
||||
TestEntry *testEntry = &_testEntry;
|
||||
// absolute path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
//printf("%s\n", testEntry->cpath);
|
||||
BEntry entry(testEntry->cpath, traverse);
|
||||
@ -343,7 +343,7 @@ printf("error: %lx (%lx)\n", result, error);
|
||||
examine_entry(entry, testEntry, traverse);
|
||||
}
|
||||
// relative path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
//printf("%s\n", testEntry->cpath);
|
||||
if (chdir(testEntry->super->cpath) == 0) {
|
||||
@ -365,7 +365,7 @@ EntryTest::InitTest1Refs(TestEntry &_testEntry, status_t error, bool traverse)
|
||||
{
|
||||
TestEntry *testEntry = &_testEntry;
|
||||
// absolute path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
//printf("%s\n", testEntry->cpath);
|
||||
BEntry entry(&testEntry->get_ref(), traverse);
|
||||
@ -385,7 +385,7 @@ EntryTest::InitTest1DirPaths(TestEntry &_testEntry, status_t error,
|
||||
{
|
||||
TestEntry *testEntry = &_testEntry;
|
||||
// absolute path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
if (!testEntry->isBad()
|
||||
&& testEntry->path.length() < B_PATH_NAME_LENGTH) {
|
||||
@ -402,7 +402,7 @@ printf("error: %lx (%lx)\n", result, error);
|
||||
}
|
||||
}
|
||||
// relative path (one level)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
if (!testEntry->isBad()
|
||||
&& testEntry->super->path.length() < B_PATH_NAME_LENGTH) {
|
||||
@ -419,7 +419,7 @@ printf("error: %lx (%lx)\n", result, error);
|
||||
}
|
||||
}
|
||||
// relative path (two levels)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
if (!testEntry->super->isBad() && !testEntry->super->super->isBad()) {
|
||||
string entryName = testEntry->super->name + "/" + testEntry->name;
|
||||
@ -442,7 +442,7 @@ void
|
||||
EntryTest::InitTest1()
|
||||
{
|
||||
// 1. default constructor
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry;
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
@ -541,19 +541,19 @@ EntryTest::InitTest1()
|
||||
InitTest1Paths(tooLongDir16, fuzzy_error(B_ERROR, B_NAME_TOO_LONG), true);
|
||||
|
||||
// special cases (root dir)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry("/");
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
}
|
||||
// special cases (fs root dir)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry("/boot");
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
}
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry((const char*)NULL);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_BAD_VALUE );
|
||||
@ -641,7 +641,7 @@ EntryTest::InitTest1()
|
||||
InitTest1Refs(relVeryBadLink3, B_ENTRY_NOT_FOUND, true);
|
||||
InitTest1Refs(relVeryBadLink4, B_ENTRY_NOT_FOUND, true);
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry((const entry_ref*)NULL);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_BAD_VALUE );
|
||||
@ -693,7 +693,7 @@ EntryTest::InitTest1()
|
||||
InitTest1DirPaths(tooLongEntry1, fuzzy_error(E2BIG, B_NAME_TOO_LONG));
|
||||
// OBOS: Fails, because the implementation concatenates the dir and leaf
|
||||
// name.
|
||||
#if !SK_TEST_OBOS_POSIX
|
||||
#if !TEST_OBOS /* !!!POSIX ONLY!!! */
|
||||
InitTest1DirPaths(tooLongDir16, B_OK, true);
|
||||
#endif
|
||||
// traverse
|
||||
@ -741,26 +741,26 @@ EntryTest::InitTest1()
|
||||
InitTest1DirPaths(tooLongEntry1, fuzzy_error(E2BIG, B_NAME_TOO_LONG), true);
|
||||
// OBOS: Fails, because the implementation concatenates the dir and leaf
|
||||
// name.
|
||||
#if !SK_TEST_OBOS_POSIX
|
||||
#if !TEST_OBOS /* !!!POSIX ONLY!!! */
|
||||
InitTest1DirPaths(tooLongDir16, B_OK, true);
|
||||
#endif
|
||||
|
||||
// special cases (root dir)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory dir("/");
|
||||
BEntry entry(&dir, ".");
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
}
|
||||
// special cases (fs root dir)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory dir("/");
|
||||
BEntry entry(&dir, "boot");
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
}
|
||||
// NULL path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory dir("/");
|
||||
BEntry entry(&dir, (const char*)NULL);
|
||||
@ -768,8 +768,8 @@ EntryTest::InitTest1()
|
||||
}
|
||||
// bad args (NULL dir)
|
||||
// R5: crashs
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
chdir("/");
|
||||
BEntry entry((const BDirectory*)NULL, "tmp");
|
||||
@ -778,7 +778,7 @@ EntryTest::InitTest1()
|
||||
}
|
||||
#endif
|
||||
// strange args (badly initialized dir, absolute path)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory dir(badEntry1.cpath);
|
||||
CPPUNIT_ASSERT( dir.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
@ -787,8 +787,8 @@ EntryTest::InitTest1()
|
||||
}
|
||||
// bad args (NULL dir and path)
|
||||
// R5: crashs
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry((const BDirectory*)NULL, (const char*)NULL);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_BAD_VALUE );
|
||||
@ -796,8 +796,8 @@ EntryTest::InitTest1()
|
||||
#endif
|
||||
// bad args(NULL dir, absolute path)
|
||||
// R5: crashs
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry((const BDirectory*)NULL, "/tmp");
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_BAD_VALUE );
|
||||
@ -812,7 +812,7 @@ EntryTest::InitTest2Paths(TestEntry &_testEntry, status_t error, bool traverse)
|
||||
TestEntry *testEntry = &_testEntry;
|
||||
BEntry entry;
|
||||
// absolute path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
//printf("%s\n", testEntry->cpath);
|
||||
status_t result = entry.SetTo(testEntry->cpath, traverse);
|
||||
@ -824,7 +824,7 @@ printf("error: %lx (%lx)\n", result, error);
|
||||
examine_entry(entry, testEntry, traverse);
|
||||
}
|
||||
// relative path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
//printf("%s\n", testEntry->cpath);
|
||||
if (chdir(testEntry->super->cpath) == 0) {
|
||||
@ -847,7 +847,7 @@ EntryTest::InitTest2Refs(TestEntry &_testEntry, status_t error, bool traverse)
|
||||
TestEntry *testEntry = &_testEntry;
|
||||
BEntry entry;
|
||||
// absolute path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
//printf("%s\n", testEntry->cpath);
|
||||
status_t result = entry.SetTo(&testEntry->get_ref(), traverse);
|
||||
@ -868,7 +868,7 @@ EntryTest::InitTest2DirPaths(TestEntry &_testEntry, status_t error,
|
||||
TestEntry *testEntry = &_testEntry;
|
||||
BEntry entry;
|
||||
// absolute path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
if (!testEntry->isBad()
|
||||
&& testEntry->path.length() < B_PATH_NAME_LENGTH) {
|
||||
@ -885,7 +885,7 @@ printf("error: %lx (%lx)\n", result, error);
|
||||
}
|
||||
}
|
||||
// relative path (one level)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
if (!testEntry->isBad()
|
||||
&& testEntry->super->path.length() < B_PATH_NAME_LENGTH) {
|
||||
@ -902,7 +902,7 @@ printf("error: %lx (%lx)\n", result, error);
|
||||
}
|
||||
}
|
||||
// relative path (two levels)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
if (!testEntry->super->isBad() && !testEntry->super->super->isBad()) {
|
||||
string entryName = testEntry->super->name + "/" + testEntry->name;
|
||||
@ -1017,17 +1017,17 @@ EntryTest::InitTest2()
|
||||
// R5: returns B_ERROR instead of B_NAME_TOO_LONG
|
||||
InitTest2Paths(tooLongDir16, fuzzy_error(B_ERROR, B_NAME_TOO_LONG), true);
|
||||
// special cases (root dir)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo("/") == B_OK );
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
entry.Unset();
|
||||
// special cases (fs root dir)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo("/boot") == B_OK );
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
entry.Unset();
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo((const char*)NULL) == B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_BAD_VALUE );
|
||||
entry.Unset();
|
||||
@ -1114,7 +1114,7 @@ EntryTest::InitTest2()
|
||||
InitTest2Refs(relVeryBadLink3, B_ENTRY_NOT_FOUND, true);
|
||||
InitTest2Refs(relVeryBadLink4, B_ENTRY_NOT_FOUND, true);
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo((const entry_ref*)NULL) == B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_BAD_VALUE );
|
||||
entry.Unset();
|
||||
@ -1165,7 +1165,7 @@ EntryTest::InitTest2()
|
||||
InitTest2DirPaths(tooLongEntry1, fuzzy_error(E2BIG, B_NAME_TOO_LONG));
|
||||
// OBOS: Fails, because the implementation concatenates the dir and leaf
|
||||
// name.
|
||||
#if !SK_TEST_OBOS_POSIX
|
||||
#if !TEST_OBOS /* !!!POSIX ONLY!!! */
|
||||
InitTest2DirPaths(tooLongDir16, B_OK, true);
|
||||
#endif
|
||||
// traverse
|
||||
@ -1213,11 +1213,11 @@ EntryTest::InitTest2()
|
||||
InitTest2DirPaths(tooLongEntry1, fuzzy_error(E2BIG, B_NAME_TOO_LONG), true);
|
||||
// OBOS: Fails, because the implementation concatenates the dir and leaf
|
||||
// name.
|
||||
#if !SK_TEST_OBOS_POSIX
|
||||
#if !TEST_OBOS /* !!!POSIX ONLY!!! */
|
||||
InitTest2DirPaths(tooLongDir16, B_OK, true);
|
||||
#endif
|
||||
// special cases (root dir)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory dir("/");
|
||||
CPPUNIT_ASSERT( entry.SetTo(&dir, ".") == B_OK );
|
||||
@ -1225,7 +1225,7 @@ EntryTest::InitTest2()
|
||||
entry.Unset();
|
||||
}
|
||||
// special cases (fs root dir)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory dir("/");
|
||||
CPPUNIT_ASSERT( entry.SetTo(&dir, "boot") == B_OK );
|
||||
@ -1233,7 +1233,7 @@ EntryTest::InitTest2()
|
||||
entry.Unset();
|
||||
}
|
||||
// NULL path
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory dir("/");
|
||||
CPPUNIT_ASSERT( entry.SetTo(&dir, (const char*)NULL) == B_OK );
|
||||
@ -1242,8 +1242,8 @@ EntryTest::InitTest2()
|
||||
}
|
||||
// bad args (NULL dir)
|
||||
// R5: crashs
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
chdir("/");
|
||||
CPPUNIT_ASSERT( entry.SetTo((const BDirectory*)NULL, "tmp")
|
||||
@ -1254,7 +1254,7 @@ EntryTest::InitTest2()
|
||||
}
|
||||
#endif
|
||||
// strange args (badly initialized dir, absolute path)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory dir(badEntry1.cpath);
|
||||
CPPUNIT_ASSERT( dir.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
@ -1263,8 +1263,8 @@ EntryTest::InitTest2()
|
||||
}
|
||||
// bad args (NULL dir and path)
|
||||
// R5: crashs
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
CPPUNIT_ASSERT( entry.SetTo((const BDirectory*)NULL, (const char*)NULL)
|
||||
== B_BAD_VALUE );
|
||||
@ -1274,8 +1274,8 @@ EntryTest::InitTest2()
|
||||
#endif
|
||||
// bad args(NULL dir, absolute path)
|
||||
// R5: crashs
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
CPPUNIT_ASSERT( entry.SetTo((const BDirectory*)NULL, "/tmp")
|
||||
== B_BAD_VALUE );
|
||||
@ -1296,17 +1296,17 @@ EntryTest::SpecialGetCasesTest()
|
||||
BEntry entry;
|
||||
// 1. Exists()
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( entry.Exists() == false );
|
||||
entry.Unset();
|
||||
// badly initialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(badEntry1.cpath) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( entry.Exists() == false );
|
||||
entry.Unset();
|
||||
// root
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo("/") == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Exists() == true );
|
||||
entry.Unset();
|
||||
@ -1314,20 +1314,20 @@ EntryTest::SpecialGetCasesTest()
|
||||
// 2. GetPath()
|
||||
BPath path;
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( entry.GetPath(&path) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// badly initialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(badEntry1.cpath) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( entry.GetPath(&path) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// too long pathname
|
||||
// OBOS: Fails, because the implementation concatenates the dir and leaf
|
||||
// name.
|
||||
#if !SK_TEST_OBOS_POSIX
|
||||
nextSubTest();
|
||||
#if !TEST_OBOS /* !!!POSIX ONLY!!! */
|
||||
NextSubTest();
|
||||
BDirectory dir(tooLongDir16.super->super->cpath);
|
||||
string entryName = tooLongDir16.super->name + "/" + tooLongDir16.name;
|
||||
CPPUNIT_ASSERT( entry.SetTo(&dir, entryName.c_str()) == B_OK );
|
||||
@ -1339,12 +1339,12 @@ EntryTest::SpecialGetCasesTest()
|
||||
// 3. GetName()
|
||||
char name[B_FILE_NAME_LENGTH + 1];
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( entry.GetName(name) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// badly initialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(badEntry1.cpath) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( entry.GetName(name) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
@ -1352,17 +1352,17 @@ EntryTest::SpecialGetCasesTest()
|
||||
// 4. GetParent(BEntry *)
|
||||
BEntry parentEntry;
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( entry.GetParent(&parentEntry) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// badly initialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(badEntry1.cpath) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( entry.GetParent(&parentEntry) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// parent of root dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo("/") == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetParent(&parentEntry) == B_ENTRY_NOT_FOUND );
|
||||
entry.Unset();
|
||||
@ -1370,17 +1370,17 @@ EntryTest::SpecialGetCasesTest()
|
||||
// 5. GetParent(BDirectory *)
|
||||
BDirectory parentDir;
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( entry.GetParent(&parentDir) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// badly initialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(badEntry1.cpath) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( entry.GetParent(&parentDir) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// parent of root dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo("/") == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetParent(&parentDir) == B_ENTRY_NOT_FOUND );
|
||||
entry.Unset();
|
||||
@ -1388,17 +1388,17 @@ EntryTest::SpecialGetCasesTest()
|
||||
// 6. GetRef()
|
||||
entry_ref ref, ref2;
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( entry.GetRef(&ref) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// badly initialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(badEntry1.cpath) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( entry.GetRef(&ref) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// ref for root dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo("/") == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetRef(&ref) == B_OK );
|
||||
entry.Unset();
|
||||
@ -1410,7 +1410,7 @@ EntryTest::RenameTestEntry(TestEntry *testEntry, TestEntry *newTestEntry,
|
||||
string newName, bool existing, bool clobber,
|
||||
status_t error, uint32 kind)
|
||||
{
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BEntry entry;
|
||||
BDirectory dir;
|
||||
// get all the names
|
||||
@ -1565,7 +1565,7 @@ EntryTest::RenameTest()
|
||||
RenameTestLink(&file2, &file3, true, false, B_FILE_EXISTS);
|
||||
|
||||
// try to clobber a non-empty directory
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CreateFile(file3.cpath);
|
||||
CPPUNIT_ASSERT( entry.SetTo(file3.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Rename(dir1.cpath, true) == B_DIRECTORY_NOT_EMPTY );
|
||||
@ -1575,7 +1575,7 @@ EntryTest::RenameTest()
|
||||
entry.Unset();
|
||||
dir.Unset();
|
||||
// clobber an empty directory
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CreateFile(file3.cpath);
|
||||
CPPUNIT_ASSERT( entry.SetTo(file3.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Rename(subDir1.cpath, true) == B_OK );
|
||||
@ -1585,30 +1585,30 @@ EntryTest::RenameTest()
|
||||
entry.Unset();
|
||||
dir.Unset();
|
||||
// abstract entry
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(file2.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Rename(file4.cname) == B_ENTRY_NOT_FOUND );
|
||||
entry.Unset();
|
||||
dir.Unset();
|
||||
// uninitialized entry
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( entry.Rename(file4.cpath) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
dir.Unset();
|
||||
// badly initialized entry
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(badEntry1.cpath) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( entry.Rename(file4.cpath) == B_NO_INIT );
|
||||
entry.Unset();
|
||||
dir.Unset();
|
||||
// Verify attempts to rename root
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BEntry root("/");
|
||||
CPPUNIT_ASSERT( root.Rename("/", false) == B_FILE_EXISTS );
|
||||
CPPUNIT_ASSERT( root.Rename("/", true) == B_NOT_ALLOWED );
|
||||
// Verify abstract entries
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BEntry abstract(abstractEntry1.cpath);
|
||||
CPPUNIT_ASSERT( abstract.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( !abstract.Exists() );
|
||||
@ -1617,7 +1617,7 @@ EntryTest::RenameTest()
|
||||
CPPUNIT_ASSERT( abstract.Rename("/DoesntMatter") == B_CROSS_DEVICE_LINK );
|
||||
CPPUNIT_ASSERT( abstract.Rename("/DontMatter", true) == B_CROSS_DEVICE_LINK );
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(file1.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( equals(entry.Rename(NULL, false), B_FILE_EXISTS,
|
||||
B_BAD_VALUE) );
|
||||
@ -1631,7 +1631,7 @@ EntryTest::MoveToTestEntry(TestEntry *testEntry, TestEntry *testDir,
|
||||
string newName, bool existing, bool clobber,
|
||||
status_t error, uint32 kind)
|
||||
{
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BEntry entry;
|
||||
BDirectory dir;
|
||||
// get all the names
|
||||
@ -1888,7 +1888,7 @@ EntryTest::MoveToTest()
|
||||
dir.Unset();
|
||||
// bad args (NULL dir)
|
||||
// R5: crashs
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CreateFile(file2.cpath);
|
||||
CPPUNIT_ASSERT( entry.SetTo(file2.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.MoveTo(NULL, file3.cpath) == B_BAD_VALUE );
|
||||
@ -1912,41 +1912,41 @@ EntryTest::RemoveTest()
|
||||
{
|
||||
BEntry entry;
|
||||
// file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(file1.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Remove() == B_OK );
|
||||
CPPUNIT_ASSERT( !PingFile(file1.cpath) );
|
||||
entry.Unset();
|
||||
// symlink
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(absFileLink1.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Remove() == B_OK );
|
||||
CPPUNIT_ASSERT( !PingLink(absFileLink1.cpath) );
|
||||
entry.Unset();
|
||||
// empty dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(subDir1.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Remove() == B_OK );
|
||||
CPPUNIT_ASSERT( !PingDir(subDir1.cpath) );
|
||||
entry.Unset();
|
||||
// non-empty dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(dir1.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Remove() == B_DIRECTORY_NOT_EMPTY );
|
||||
CPPUNIT_ASSERT( PingDir(dir1.cpath) );
|
||||
entry.Unset();
|
||||
// abstract entry
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(abstractEntry1.cpath) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.Remove() == B_ENTRY_NOT_FOUND );
|
||||
entry.Unset();
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( entry.Remove() == B_NO_INIT );
|
||||
entry.Unset();
|
||||
// badly initialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(badEntry1.cpath) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( entry.Remove() == B_NO_INIT );
|
||||
entry.Unset();
|
||||
@ -1976,7 +1976,7 @@ void
|
||||
EntryTest::ComparisonTest()
|
||||
{
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry;
|
||||
BEntry entry2;
|
||||
@ -1986,7 +1986,7 @@ EntryTest::ComparisonTest()
|
||||
CPPUNIT_ASSERT( !(entry2 != entry) );
|
||||
}
|
||||
// initialized + uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(file1.cpath);
|
||||
BEntry entry2;
|
||||
@ -2017,7 +2017,7 @@ EntryTest::ComparisonTest()
|
||||
};
|
||||
int32 testEntryCount = sizeof(testEntries) / sizeof(TestEntry*);
|
||||
for (int32 i = 0; i < testEntryCount; i++) {
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestEntry *testEntry = testEntries[i];
|
||||
TestEntry *traversedTestEntry = resolve_link(testEntry);
|
||||
BEntry entry(testEntry->cpath);
|
||||
@ -2045,7 +2045,7 @@ EntryTest::AssignmentTest()
|
||||
{
|
||||
// 1. copy constructor
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry;
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
@ -2068,7 +2068,7 @@ EntryTest::AssignmentTest()
|
||||
};
|
||||
int32 testEntryCount = sizeof(testEntries) / sizeof(TestEntry*);
|
||||
for (int32 i = 0; i < testEntryCount; i++) {
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestEntry *testEntry = testEntries[i];
|
||||
BEntry entry(testEntry->cpath);
|
||||
BEntry entry2(entry);
|
||||
@ -2080,7 +2080,7 @@ EntryTest::AssignmentTest()
|
||||
|
||||
// 2. assignment operator
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry;
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
@ -2090,7 +2090,7 @@ EntryTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( equals(entry2.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
CPPUNIT_ASSERT( entry == entry2 );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry;
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
@ -2102,7 +2102,7 @@ EntryTest::AssignmentTest()
|
||||
}
|
||||
// initialized
|
||||
for (int32 i = 0; i < testEntryCount; i++) {
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestEntry *testEntry = testEntries[i];
|
||||
BEntry entry(testEntry->cpath);
|
||||
BEntry entry2;
|
||||
@ -2167,7 +2167,7 @@ EntryTest::CFunctionsTest()
|
||||
};
|
||||
int32 testEntryCount = sizeof(testEntries) / sizeof(TestEntry*);
|
||||
for (int32 i = 0; i < testEntryCount; i++) {
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestEntry *testEntry = testEntries[i];
|
||||
const char *path = testEntry->cpath;
|
||||
entry_ref ref;
|
||||
@ -2205,7 +2205,7 @@ EntryTest::CFunctionsTest()
|
||||
}
|
||||
}
|
||||
// root dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
entry_ref ref, ref2;
|
||||
CPPUNIT_ASSERT( get_ref_for_path("/", &ref) == B_OK );
|
||||
CPPUNIT_ASSERT( get_entry_ref_for_entry("/", ".", &ref2) == B_OK );
|
||||
@ -2214,7 +2214,7 @@ EntryTest::CFunctionsTest()
|
||||
CPPUNIT_ASSERT( strcmp(ref.name, ref2.name) == 0 );
|
||||
CPPUNIT_ASSERT( ref == ref2 );
|
||||
// fs root dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( get_ref_for_path("/boot", &ref) == B_OK );
|
||||
CPPUNIT_ASSERT( get_entry_ref_for_entry("/", "boot", &ref2) == B_OK );
|
||||
CPPUNIT_ASSERT( ref.device == ref2.device );
|
||||
@ -2222,7 +2222,7 @@ EntryTest::CFunctionsTest()
|
||||
CPPUNIT_ASSERT( strcmp(ref.name, ref2.name) == 0 );
|
||||
CPPUNIT_ASSERT( ref == ref2 );
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
ref = entry_ref();
|
||||
ref2 = entry_ref();
|
||||
CPPUNIT_ASSERT( ref == ref2 );
|
||||
@ -2670,3 +2670,7 @@ resolve_link(TestEntry *entry)
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -3,11 +3,9 @@
|
||||
#ifndef __sk_entry_test_h__
|
||||
#define __sk_entry_test_h__
|
||||
|
||||
#include <TestUtils.h>
|
||||
#include "StatableTest.h"
|
||||
|
||||
#include "StorageKitTester.h"
|
||||
#include "TestUtils.h"
|
||||
|
||||
class BEntry;
|
||||
struct TestEntry;
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <TestShell.h>
|
||||
|
||||
#include "StorageKitTester.h" // For "shell" global variable
|
||||
#include "FileTest.h"
|
||||
|
||||
// Suite
|
||||
@ -87,13 +87,13 @@ FileTest::InitTest1()
|
||||
void testAll() const
|
||||
{
|
||||
for (int32 i = 0; i < initTestCasesCount; i++) {
|
||||
if (shell.BeVerbose()) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
printf("[%ld]", i);
|
||||
fflush(stdout);
|
||||
}
|
||||
test(initTestCases[i]);
|
||||
}
|
||||
if (shell.BeVerbose())
|
||||
if (BTestShell::GlobalBeVerbose())
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
@ -196,13 +196,13 @@ FileTest::InitTest2()
|
||||
void testAll() const
|
||||
{
|
||||
for (int32 i = 0; i < initTestCasesCount; i++) {
|
||||
if (shell.BeVerbose()) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
printf("[%ld]", i);
|
||||
fflush(stdout);
|
||||
}
|
||||
test(initTestCases[i]);
|
||||
}
|
||||
if (shell.BeVerbose())
|
||||
if (BTestShell::GlobalBeVerbose())
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
@ -310,31 +310,31 @@ FileTest::InitTest2()
|
||||
void
|
||||
FileTest::RWAbleTest()
|
||||
{
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file;
|
||||
CPPUNIT_ASSERT( file.IsReadable() == false );
|
||||
CPPUNIT_ASSERT( file.IsWritable() == false );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.IsReadable() == true );
|
||||
CPPUNIT_ASSERT( file.IsWritable() == false );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_WRITE_ONLY);
|
||||
CPPUNIT_ASSERT( file.IsReadable() == false );
|
||||
CPPUNIT_ASSERT( file.IsWritable() == true );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.IsReadable() == true );
|
||||
CPPUNIT_ASSERT( file.IsWritable() == true );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(nonExistingFilename, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.IsReadable() == false );
|
||||
@ -347,7 +347,7 @@ void
|
||||
FileTest::RWTest()
|
||||
{
|
||||
// read/write an uninitialized BFile
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BFile file;
|
||||
char buffer[10];
|
||||
CPPUNIT_ASSERT( file.Read(buffer, sizeof(buffer)) < 0 );
|
||||
@ -356,7 +356,7 @@ FileTest::RWTest()
|
||||
CPPUNIT_ASSERT( file.WriteAt(0, buffer, sizeof(buffer)) < 0 );
|
||||
file.Unset();
|
||||
// read/write an file opened for writing/reading only
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(existingFilename, B_WRITE_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.Read(buffer, sizeof(buffer)) < 0 );
|
||||
@ -367,14 +367,14 @@ FileTest::RWTest()
|
||||
CPPUNIT_ASSERT( file.WriteAt(0, buffer, sizeof(buffer)) < 0 );
|
||||
file.Unset();
|
||||
// read from an empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(existingFilename, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.Read(buffer, sizeof(buffer)) == 0 );
|
||||
CPPUNIT_ASSERT( file.ReadAt(0, buffer, sizeof(buffer)) == 0 );
|
||||
file.Unset();
|
||||
// read from past an empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(existingFilename, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.Seek(10, SEEK_SET) == 10 );
|
||||
@ -383,7 +383,7 @@ FileTest::RWTest()
|
||||
file.Unset();
|
||||
// create a new empty file and write some data into it, then
|
||||
// read the file and check the data
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
char writeBuffer[256];
|
||||
@ -406,7 +406,7 @@ FileTest::RWTest()
|
||||
file.Unset();
|
||||
execCommand(string("rm -f ") + testFilename1);
|
||||
// same procedure, just using ReadAt()/WriteAt()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.WriteAt(80, writeBuffer + 80, 50) == 50 );
|
||||
@ -431,7 +431,7 @@ FileTest::RWTest()
|
||||
file.Unset();
|
||||
execCommand(string("rm -f ") + testFilename1);
|
||||
// write past the end of a file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.Seek(128, SEEK_SET) == 128 );
|
||||
@ -440,7 +440,7 @@ FileTest::RWTest()
|
||||
file.Unset();
|
||||
// open the file with B_OPEN_AT_END flag, Write() some data to it, close
|
||||
// and re-open it to check the file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_WRITE_ONLY | B_OPEN_AT_END);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
for (int32 i = 0; i < 256; i++)
|
||||
@ -457,7 +457,7 @@ FileTest::RWTest()
|
||||
file.Unset();
|
||||
// open the file with B_OPEN_AT_END flag, WriteAt() some data to it, close
|
||||
// and re-open it to check the file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_WRITE_ONLY | B_OPEN_AT_END);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
for (int32 i = 0; i < 256; i++)
|
||||
@ -471,7 +471,7 @@ FileTest::RWTest()
|
||||
CPPUNIT_ASSERT( readBuffer[i] == 42 );
|
||||
file.Unset();
|
||||
// open the file with B_OPEN_AT_END flag, ReadAt() some data
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_READ_ONLY | B_OPEN_AT_END);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
for (int32 i = 0; i < 256; i++)
|
||||
@ -484,7 +484,7 @@ FileTest::RWTest()
|
||||
CPPUNIT_ASSERT( readBuffer[i] == 42 );
|
||||
file.Unset();
|
||||
// same procedure, just using Seek() and Read()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_READ_ONLY | B_OPEN_AT_END);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
for (int32 i = 0; i < 256; i++)
|
||||
@ -506,14 +506,14 @@ void
|
||||
FileTest::PositionTest()
|
||||
{
|
||||
// unitialized file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BFile file;
|
||||
CPPUNIT_ASSERT( file.Position() == B_FILE_ERROR );
|
||||
CPPUNIT_ASSERT( file.Seek(10, SEEK_SET) == B_FILE_ERROR );
|
||||
CPPUNIT_ASSERT( file.Seek(10, SEEK_END) == B_FILE_ERROR );
|
||||
CPPUNIT_ASSERT( file.Seek(10, SEEK_CUR) == B_FILE_ERROR );
|
||||
// open new file, write some bytes to it and seek a bit around
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.Position() == 0 );
|
||||
@ -533,7 +533,7 @@ FileTest::PositionTest()
|
||||
// means, that all write()s append their data at the end. The behavior
|
||||
// of Seek() and Position() is a bit unclear for this case.
|
||||
/*
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_READ_ONLY | B_OPEN_AT_END);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.Position() == 256 );
|
||||
@ -553,13 +553,13 @@ void
|
||||
FileTest::SizeTest()
|
||||
{
|
||||
// unitialized file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BFile file;
|
||||
off_t size;
|
||||
CPPUNIT_ASSERT( file.GetSize(&size) != B_OK );
|
||||
CPPUNIT_ASSERT( file.SetSize(100) != B_OK );
|
||||
// read only file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_READ_ONLY | B_CREATE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.GetSize(&size) == B_OK );
|
||||
@ -569,7 +569,7 @@ FileTest::SizeTest()
|
||||
CPPUNIT_ASSERT( size == 100 );
|
||||
file.Unset();
|
||||
// shorten existing file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_WRITE_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.GetSize(&size) == B_OK );
|
||||
@ -579,7 +579,7 @@ FileTest::SizeTest()
|
||||
CPPUNIT_ASSERT( size == 73 );
|
||||
file.Unset();
|
||||
// enlarge existing file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.GetSize(&size) == B_OK );
|
||||
@ -589,7 +589,7 @@ FileTest::SizeTest()
|
||||
CPPUNIT_ASSERT( size == 147 );
|
||||
file.Unset();
|
||||
// erase existing file (read only)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_READ_ONLY | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.GetSize(&size) == B_OK );
|
||||
@ -599,7 +599,7 @@ FileTest::SizeTest()
|
||||
CPPUNIT_ASSERT( size == 132 );
|
||||
file.Unset();
|
||||
// erase existing file (write only)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_WRITE_ONLY | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.GetSize(&size) == B_OK );
|
||||
@ -609,7 +609,7 @@ FileTest::SizeTest()
|
||||
CPPUNIT_ASSERT( size == 93 );
|
||||
file.Unset();
|
||||
// erase existing file using SetSize()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
file.SetTo(testFilename1, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( file.GetSize(&size) == B_OK );
|
||||
@ -627,7 +627,7 @@ FileTest::AssignmentTest()
|
||||
{
|
||||
// copy constructor
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file;
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_NO_INIT );
|
||||
@ -636,7 +636,7 @@ FileTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( equals(file2.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
}
|
||||
// existing file, different open modes
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -645,7 +645,7 @@ FileTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( file2.IsReadable() == true );
|
||||
CPPUNIT_ASSERT( file2.IsWritable() == false );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_WRITE_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -654,7 +654,7 @@ FileTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( file2.IsReadable() == false );
|
||||
CPPUNIT_ASSERT( file2.IsWritable() == true );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -665,7 +665,7 @@ FileTest::AssignmentTest()
|
||||
}
|
||||
// assignment operator
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file;
|
||||
BFile file2;
|
||||
@ -673,7 +673,7 @@ FileTest::AssignmentTest()
|
||||
// R5 returns B_BAD_VALUE instead of B_NO_INIT
|
||||
CPPUNIT_ASSERT( equals(file2.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file;
|
||||
BFile file2(existingFilename, B_READ_ONLY);
|
||||
@ -683,7 +683,7 @@ FileTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( equals(file2.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
}
|
||||
// existing file, different open modes
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -693,7 +693,7 @@ FileTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( file2.IsReadable() == true );
|
||||
CPPUNIT_ASSERT( file2.IsWritable() == false );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_WRITE_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -703,7 +703,7 @@ FileTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( file2.IsReadable() == false );
|
||||
CPPUNIT_ASSERT( file2.IsWritable() == true );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(existingFilename, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -766,3 +766,13 @@ const FileTest::InitTestCase FileTest::initTestCases[] = {
|
||||
const int32 FileTest::initTestCasesCount
|
||||
= sizeof(FileTest::initTestCases) / sizeof(FileTest::InitTestCase);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <Path.h>
|
||||
#include <Volume.h>
|
||||
|
||||
#include "StorageKitTester.h"
|
||||
|
||||
|
||||
const directory_which directories[] = {
|
||||
@ -363,30 +362,30 @@ void
|
||||
FindDirectoryTest::Test()
|
||||
{
|
||||
// /boot
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
dev_t device = dev_for_path("/boot");
|
||||
CPPUNIT_ASSERT( device > 0 );
|
||||
TestDirectories(device);
|
||||
// /dev
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
device = dev_for_path("/dev");
|
||||
CPPUNIT_ASSERT( device > 0 );
|
||||
TestDirectories(device);
|
||||
// /
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
device = dev_for_path("/");
|
||||
CPPUNIT_ASSERT( device > 0 );
|
||||
TestDirectories(device);
|
||||
// test image
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
device = dev_for_path(testMountPoint);
|
||||
CPPUNIT_ASSERT( device > 0 );
|
||||
TestDirectories(device);
|
||||
// invalid device ID
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestDirectories(-1);
|
||||
// NULL BVolume
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
for (int32 i = 0; i < directoryCount; i++) {
|
||||
BPath path;
|
||||
BPath path2;
|
||||
@ -397,7 +396,7 @@ FindDirectoryTest::Test()
|
||||
CPPUNIT_ASSERT( path == path2 );
|
||||
}
|
||||
// no such volume
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
device = 213;
|
||||
fs_info info;
|
||||
while (fs_stat_dev(device, &info) == 0)
|
||||
@ -417,19 +416,23 @@ FindDirectoryTest::Test()
|
||||
}
|
||||
// bad args
|
||||
// R5: crashes
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
device = dev_for_path("/boot");
|
||||
CPPUNIT_ASSERT( device > 0 );
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CPPUNIT_ASSERT( find_directory(B_BEOS_DIRECTORY, NULL, false, NULL)
|
||||
== B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( find_directory(B_BEOS_DIRECTORY, device, false, NULL, 50)
|
||||
== B_BAD_VALUE );
|
||||
#endif
|
||||
// small buffer
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
char path3[7];
|
||||
CPPUNIT_ASSERT( find_directory(B_BEOS_DIRECTORY, device, false, path3, 7)
|
||||
== E2BIG );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,25 +1,21 @@
|
||||
SubDir OBOS_TOP src tests kits storage ;
|
||||
|
||||
# EntryTest.cpp
|
||||
# FileTest.cpp
|
||||
# FindDirectoryTest.cpp
|
||||
# MimeTypeTest.cpp
|
||||
# PathTest.cpp
|
||||
# QueryTest.cpp
|
||||
# ResourcesTest.cpp
|
||||
# ResourceStringsTest.cpp
|
||||
# StatableTest.cpp
|
||||
# SymLinkTest.cpp
|
||||
# TestApp.cpp
|
||||
|
||||
CommonTestLib libstoragetest.so
|
||||
: StorageKitTestAddon.cpp
|
||||
BasicTest.cpp
|
||||
DirectoryTest.cpp
|
||||
EntryTest.cpp
|
||||
FindDirectoryTest.cpp
|
||||
FileTest.cpp
|
||||
MimeTypeTest.cpp
|
||||
NodeTest.cpp
|
||||
PathTest.cpp
|
||||
QueryTest.cpp
|
||||
ResourcesTest.cpp
|
||||
ResourceStringsTest.cpp
|
||||
StatableTest.cpp
|
||||
TestUtils.cpp
|
||||
SymLinkTest.cpp
|
||||
: <$(SOURCE_GRIST)>libstorage.so be stdc++.r4
|
||||
: be stdc++.r4
|
||||
: storage
|
||||
@ -39,7 +35,7 @@ CommonTestLib libstoragetest.so
|
||||
# To run the tests some test files must be around.
|
||||
{
|
||||
local resdir = <storage!kit!test!files>resources ;
|
||||
MakeLocate $(resdir) : [ on libstoragetest.so return $(LOCATE[1]) ] ;
|
||||
MakeLocate $(resdir) : [ on UnitTester return $(LOCATE[1]) ] ;
|
||||
RelSymLink $(resdir) : [ FDirName $(SUBDIR) resources ] ;
|
||||
DEPENDS libstoragetest.so : $(resdir) ;
|
||||
}
|
||||
|
@ -23,10 +23,9 @@
|
||||
#include <StorageKit.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
#include "StorageKitTester.h"
|
||||
#include "TestApp.h"
|
||||
#include "TestUtils.h"
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <TestApp.h>
|
||||
#include <TestUtils.h>
|
||||
|
||||
// MIME database directories
|
||||
static const char *testDir = "/tmp/mimeTestDir";
|
||||
@ -107,7 +106,7 @@ void FillWithMimeTypes(ContainerAdapter &container, BMessage &typeMessage, const
|
||||
// Suite
|
||||
CppUnit::Test*
|
||||
MimeTypeTest::Suite() {
|
||||
StorageKit::TestSuite *suite = new StorageKit::TestSuite();
|
||||
CppUnit::TestSuite *suite = new CppUnit::TestSuite();
|
||||
typedef CppUnit::TestCaller<MimeTypeTest> TC;
|
||||
|
||||
// Tyler
|
||||
@ -465,7 +464,7 @@ MimeTypeTest::AppHintTest() {
|
||||
CHK(entry2.InitCheck() == B_OK);
|
||||
CHK(entry2.GetRef(&appRef2) == B_OK);
|
||||
// Uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime;
|
||||
entry_ref ref;
|
||||
@ -474,7 +473,7 @@ MimeTypeTest::AppHintTest() {
|
||||
CHK(mime.SetAppHint(&ref) != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// NULL params
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
BMimeType mime(testType);
|
||||
@ -491,7 +490,7 @@ MimeTypeTest::AppHintTest() {
|
||||
CHK(mime.SetAppHint(NULL) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
}
|
||||
// Non-installed type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
BMimeType mime(testType);
|
||||
@ -508,7 +507,7 @@ MimeTypeTest::AppHintTest() {
|
||||
CHK(ref == appRef);
|
||||
}
|
||||
// Installed Type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
BMimeType mime(testType);
|
||||
@ -532,7 +531,7 @@ MimeTypeTest::AppHintTest() {
|
||||
CHK(ref != appRef);
|
||||
}
|
||||
// Installed Type, invalid entry_ref
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref(-1, -1, NULL);
|
||||
BMimeType mime(testType);
|
||||
@ -547,7 +546,7 @@ MimeTypeTest::AppHintTest() {
|
||||
CHK(mime.SetAppHint(&ref) != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// Installed Type, fake/invalid entry_ref
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref(0, 0, "__this_ought_not_exist__");
|
||||
BMimeType mime(testType);
|
||||
@ -562,7 +561,7 @@ MimeTypeTest::AppHintTest() {
|
||||
CHK(mime.SetAppHint(&ref) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
}
|
||||
// Installed Type, abstract entry_ref
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref fakeRef;
|
||||
entry_ref ref;
|
||||
@ -644,7 +643,7 @@ MimeTypeTest::AttrInfoTest() {
|
||||
CHK(msg2 == msg3);
|
||||
|
||||
// Uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime;
|
||||
BMessage msg;
|
||||
@ -655,7 +654,7 @@ MimeTypeTest::AttrInfoTest() {
|
||||
}
|
||||
|
||||
// NULL params
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
BMessage msg;
|
||||
@ -669,22 +668,22 @@ MimeTypeTest::AttrInfoTest() {
|
||||
CHK(!mime.IsInstalled());
|
||||
CHK(mime.GetAttrInfo(NULL) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
CHK(!mime.IsInstalled());
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(RES(mime.SetAttrInfo(NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
|
||||
// Installed
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(mime.Install() == B_OK);
|
||||
CHK(mime.IsInstalled());
|
||||
CHK(mime.GetAttrInfo(NULL) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(RES(mime.SetAttrInfo(NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
}
|
||||
|
||||
// Improperly formatted BMessages
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg(WHAT);
|
||||
BMimeType mime(testType);
|
||||
@ -711,7 +710,7 @@ MimeTypeTest::AttrInfoTest() {
|
||||
}
|
||||
|
||||
// Set() with improperly formatted message
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg(WHAT);
|
||||
BMimeType mime(testType);
|
||||
@ -738,7 +737,7 @@ MimeTypeTest::AttrInfoTest() {
|
||||
}
|
||||
|
||||
// Set() with empty message
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
BMessage msgEmpty(WHAT);
|
||||
@ -761,7 +760,7 @@ MimeTypeTest::AttrInfoTest() {
|
||||
}
|
||||
|
||||
// Set() with extra attributes in message
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
BMessage msg(WHAT);
|
||||
@ -792,13 +791,13 @@ MimeTypeTest::AttrInfoTest() {
|
||||
CHK(msg != msg1);
|
||||
|
||||
// Get(extra)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(mime.GetAttrInfo(&msgExtraGet) == B_OK);
|
||||
CHK(msgExtraGet == msgExtraSet);
|
||||
CHK(msgExtraGet != msg1);
|
||||
|
||||
// Get(extra and then some)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(msgExtraGet.AddInt32("more_extras", 101112) == B_OK);
|
||||
msgExtraGet.RemoveName(typeField); // Clear "type" fields to be fair, since SFE() just adds another
|
||||
CHK(mime.GetAttrInfo(&msgExtraGet) == B_OK); // Reinitializes result (clearing extra fields)
|
||||
@ -807,7 +806,7 @@ MimeTypeTest::AttrInfoTest() {
|
||||
|
||||
}
|
||||
// Normal Function (Non-installed type)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
BMessage msg(WHAT);
|
||||
@ -829,7 +828,7 @@ MimeTypeTest::AttrInfoTest() {
|
||||
}
|
||||
|
||||
// Normal Function
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg(WHAT);
|
||||
BMimeType mime(testType);
|
||||
@ -855,7 +854,7 @@ MimeTypeTest::AttrInfoTest() {
|
||||
CHK(msg != msg2);
|
||||
|
||||
// Followup Set()/Get()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(msg.MakeEmpty() == B_OK);
|
||||
msg1.RemoveName(typeField); // Clear "type" fields, since SFE() just adds another
|
||||
msg2.RemoveName(typeField);
|
||||
@ -869,13 +868,13 @@ MimeTypeTest::AttrInfoTest() {
|
||||
CHK(msg == msg2);
|
||||
|
||||
// Clear
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(msg.MakeEmpty() == B_OK);
|
||||
msg1.RemoveName(typeField); // Clear "type" fields, since SFE() just adds another
|
||||
msg2.RemoveName(typeField);
|
||||
CHK(msg != msg1);
|
||||
CHK(msg != msg2);
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(RES(mime.SetAttrInfo(NULL)) == B_OK); // R5 == CRASH! despite what one might think should happen
|
||||
CHK(RES(mime.GetAttrInfo(&msg)) != B_OK);
|
||||
CHK(msg1.AddString(typeField, testType) == B_OK); // Add in "type" fields as GFE() does
|
||||
@ -913,7 +912,7 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
CHK(msg2 == msg3);
|
||||
|
||||
// Uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg(WHAT);
|
||||
BMimeType mime;
|
||||
@ -923,7 +922,7 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
CHK(mime.SetFileExtensions(&msg) != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// NULL params
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg(WHAT);
|
||||
BMimeType mime(testType);
|
||||
@ -936,7 +935,7 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
// Not installed
|
||||
CHK(mime.GetFileExtensions(NULL) != B_OK); // R5 == B_BAD_VALUE
|
||||
CHK(!mime.IsInstalled());
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(RES(mime.SetFileExtensions(NULL)) == B_OK); // R5 == CRASH!
|
||||
CHK(mime.IsInstalled());
|
||||
CHK(RES(mime.GetFileExtensions(&msg)) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
@ -950,7 +949,7 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
#endif
|
||||
}
|
||||
// Set() with empty message
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
BMessage msgEmpty(WHAT);
|
||||
@ -972,7 +971,7 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
CHK(msg == msgEmpty);
|
||||
}
|
||||
// Set() with extra attributes in message
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
BMessage msg(WHAT);
|
||||
@ -1003,13 +1002,13 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
CHK(msg != msg1);
|
||||
|
||||
// Get(extra)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(mime.GetFileExtensions(&msgExtraGet) == B_OK);
|
||||
CHK(msgExtraGet == msgExtraSet);
|
||||
CHK(msgExtraGet != msg1);
|
||||
|
||||
// Get(extra and then some)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(msgExtraGet.AddInt32("more_extras", 101112) == B_OK);
|
||||
msgExtraGet.RemoveName(typeField); // Clear "type" fields to be fair, since SFE() just adds another
|
||||
CHK(mime.GetFileExtensions(&msgExtraGet) == B_OK); // Reinitializes result (clearing extra fields)
|
||||
@ -1018,7 +1017,7 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
|
||||
}
|
||||
// Normal function
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg(WHAT);
|
||||
BMimeType mime(testType);
|
||||
@ -1043,7 +1042,7 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
CHK(msg != msg2);
|
||||
|
||||
// Followup Set()/Get()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(msg.MakeEmpty() == B_OK);
|
||||
msg1.RemoveName(typeField); // Clear "type" fields, since SFE() just adds another
|
||||
msg2.RemoveName(typeField);
|
||||
@ -1057,13 +1056,13 @@ MimeTypeTest::FileExtensionsTest() {
|
||||
CHK(msg == msg2);
|
||||
|
||||
// Clear
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(msg.MakeEmpty() == B_OK);
|
||||
msg1.RemoveName(typeField); // Clear "type" fields, since SFE() just adds another
|
||||
msg2.RemoveName(typeField);
|
||||
CHK(msg != msg1);
|
||||
CHK(msg != msg2);
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(RES(mime.SetFileExtensions(NULL)) == B_OK); // R5 == CRASH! despite what the BeBook says
|
||||
CHK(RES(mime.GetFileExtensions(&msg)) != B_OK);
|
||||
CHK(msg1.AddString(typeField, testType) == B_OK); // Add in "type" fields as GFE() does
|
||||
@ -1081,7 +1080,7 @@ void
|
||||
MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
BBitmap *bmp = helper.TempBitmap();
|
||||
// Unitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime;
|
||||
CHK(mime.InitCheck() == B_NO_INIT);
|
||||
@ -1089,7 +1088,7 @@ MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
CHK(helper.SetIcon(mime, bmp) != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// Non-installed type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1106,7 +1105,7 @@ MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
CHK(*bmp == *helper.Bitmap1());
|
||||
}
|
||||
// NULL params
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1129,7 +1128,7 @@ MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
CHK(helper.GetIcon(mime, bmp) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
}
|
||||
// Invalid Bitmap Size (small -- 10x10)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1157,7 +1156,7 @@ MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
CHK(helper.GetIcon(mime, &testBmp) != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// Invalid Bitmap Size (large -- 100x100)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1185,7 +1184,7 @@ MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
CHK(helper.GetIcon(mime, &testBmp) != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// Invalid Bitmap Color Depth
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1198,7 +1197,7 @@ MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
// Init Test Bitmap
|
||||
BBitmap testBmp(helper.BitmapBounds(), B_RGBA32);
|
||||
// Test Set()
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
fill_bitmap(testBmp, 4);
|
||||
CHK(testBmp != *helper.Bitmap1());
|
||||
CHK(RES(helper.SetIcon(mime, helper.Bitmap1())) == B_OK);
|
||||
@ -1212,7 +1211,7 @@ MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
CHK(*bmp != testBmp);
|
||||
#endif
|
||||
// Test Get()
|
||||
#if SK_TEST_R5
|
||||
#if TEST_R5
|
||||
fill_bitmap(testBmp, 3);
|
||||
CHK(helper.SetIcon(mime, helper.Bitmap1()) == B_OK);
|
||||
CHK(helper.GetIcon(mime, &testBmp) == B_OK); // R5 == B_OK, but testBmp is not actually modified
|
||||
@ -1220,7 +1219,7 @@ MimeTypeTest::IconTest(IconHelper &helper) {
|
||||
#endif
|
||||
}
|
||||
// Normal Function
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1255,7 +1254,7 @@ MimeTypeTest::IconForTypeTest(IconForTypeHelper &helper) {
|
||||
BBitmap *bmp = helper.TempBitmap();
|
||||
|
||||
// Invalid MIME string
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1273,7 +1272,7 @@ MimeTypeTest::IconForTypeTest(IconForTypeHelper &helper) {
|
||||
CHK(*bmp != *helper.Bitmap1());
|
||||
}
|
||||
// NULL MIME string (just like calling respective {Get,Set}Icon() function)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1343,39 +1342,39 @@ MimeTypeTest::InstalledTypesTest() {
|
||||
// NULL params
|
||||
{
|
||||
BMessage msg;
|
||||
nextSubTest();
|
||||
#if !SK_TEST_R5
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::GetInstalledTypes(NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
nextSubTest();
|
||||
#if !SK_TEST_R5
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::GetInstalledTypes("text", NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(BMimeType::GetInstalledTypes(NULL, &msg) == B_OK); // Same as GetInstalledTypes(&msg)
|
||||
nextSubTest();
|
||||
#if !SK_TEST_R5
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::GetInstalledTypes(NULL, NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
nextSubTest();
|
||||
#if !SK_TEST_R5
|
||||
NextSubTest();
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::GetInstalledSupertypes(NULL)) != B_OK); // R5 == CRASH!!!
|
||||
#endif
|
||||
}
|
||||
// Invalid supertype param to GetInstalledTypes(char *super, BMessage*)
|
||||
{
|
||||
BMessage msg;
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(!BMimeType::IsValid(testTypeSuperInvalid));
|
||||
CHK(BMimeType::GetInstalledTypes(testTypeSuperInvalid, &msg) != B_OK); // R5 == B_BAD_VALUE
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(BMimeType::IsValid(testTypeSuperValid));
|
||||
CHK(BMimeType::GetInstalledTypes(testTypeSuperValid, &msg) != B_OK); // R5 == B_ENTRY_NOT_FOUND
|
||||
}
|
||||
// Normal Function -- GetInstalledTypes(BMessage*)
|
||||
// This test gets the list of installed types, then iterates through
|
||||
// the actual database directory listings and verifies they're identical.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg;
|
||||
|
||||
@ -1472,7 +1471,7 @@ MimeTypeTest::InstalledTypesTest() {
|
||||
// Normal Function -- GetInstalledSupertypes()/GetInstalledTypes(char*,BMessage*)
|
||||
// This test gets the list of installed super types, then iterates through
|
||||
// the actual database directory listings and verifies they're identical.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg;
|
||||
|
||||
@ -1619,7 +1618,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
||||
char str[B_MIME_TYPE_LENGTH+1];
|
||||
|
||||
// Uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime;
|
||||
CPPUNIT_ASSERT(mime.InitCheck() == B_NO_INIT);
|
||||
@ -1627,7 +1626,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
||||
CPPUNIT_ASSERT((mime.*setDescr)(str) != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// Non-installed type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1643,9 +1642,9 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
||||
CHK(strcmp(str, testDescr) == 0);
|
||||
}
|
||||
// Non-installed type, NULL params
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
#if !SK_TEST_R5 // NOTE: These tests crash for R5::LongDescription calls but not for R5::ShortDescription
|
||||
#if !TEST_R5 // NOTE: These tests crash for R5::LongDescription calls but not for R5::ShortDescription
|
||||
// calls. Considering the general instability exihibited by most R5 calls when passed
|
||||
// NULL pointers, however, I wouldn't suggest it, and thus they aren't even tested here.
|
||||
BMimeType mime(testType);
|
||||
@ -1666,7 +1665,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
||||
#endif
|
||||
}
|
||||
// Installed type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1688,7 +1687,7 @@ MimeTypeTest::DescriptionTest(GetDescriptionFunc getDescr, SetDescriptionFunc se
|
||||
CHK(strcmp(str, testDescr2) == 0);
|
||||
}
|
||||
// Installed Type, Description Too Long
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
CHK(strlen(longDescr) > (B_MIME_TYPE_LENGTH+1));
|
||||
BMimeType mime(testType);
|
||||
@ -1719,7 +1718,7 @@ MimeTypeTest::PreferredAppTest() {
|
||||
sprintf(str, "%s", testSig);
|
||||
|
||||
// Uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime;
|
||||
CPPUNIT_ASSERT(mime.InitCheck() == B_NO_INIT);
|
||||
@ -1727,7 +1726,7 @@ MimeTypeTest::PreferredAppTest() {
|
||||
CPPUNIT_ASSERT(mime.SetPreferredApp(str) != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// Non-installed type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1743,7 +1742,7 @@ MimeTypeTest::PreferredAppTest() {
|
||||
CHK(strcmp(str, testSig) == 0);
|
||||
}
|
||||
// Non-installed type, NULL params
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1758,7 +1757,7 @@ MimeTypeTest::PreferredAppTest() {
|
||||
CHK(mime.GetPreferredApp(str) == B_ENTRY_NOT_FOUND);
|
||||
}
|
||||
// Installed type, NULL params
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1773,7 +1772,7 @@ MimeTypeTest::PreferredAppTest() {
|
||||
CHK(mime.GetPreferredApp(NULL) != B_OK); // R5 == B_BAD_ADDRESS
|
||||
}
|
||||
// Installed type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testType);
|
||||
CHK(mime.InitCheck() == B_OK);
|
||||
@ -1795,7 +1794,7 @@ MimeTypeTest::PreferredAppTest() {
|
||||
CHK(strcmp(str, testSig2) == 0);
|
||||
}
|
||||
// Installed Type, Signature Too Long
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
CHK(strlen(longDescr) > (B_MIME_TYPE_LENGTH+1));
|
||||
BMimeType mime(testType);
|
||||
@ -1866,7 +1865,7 @@ type_exists(const char *type, const char *databaseDir) {
|
||||
void
|
||||
MimeTypeTest::InstallDeleteTest() {
|
||||
// Uninitialzized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime;
|
||||
CHK(mime.InitCheck() == B_NO_INIT);
|
||||
@ -1875,7 +1874,7 @@ MimeTypeTest::InstallDeleteTest() {
|
||||
CHK(mime.Delete() != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// Invalid Type String
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType mime(testTypeInvalid);
|
||||
CHK(mime.InitCheck() != B_OK); // R5 == B_BAD_VALUE
|
||||
@ -1884,7 +1883,7 @@ MimeTypeTest::InstallDeleteTest() {
|
||||
CHK(mime.Delete() != B_OK); // R5 == B_BAD_VALUE
|
||||
}
|
||||
// Normal function
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
remove_type(testType);
|
||||
BMimeType mime(testType);
|
||||
@ -1895,7 +1894,7 @@ MimeTypeTest::InstallDeleteTest() {
|
||||
CHK(mime.Install() == B_OK);
|
||||
CHK(type_exists(testType));
|
||||
CHK(mime.IsInstalled());
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(mime.Install() != B_OK); // We ought to return something standard and logical here
|
||||
#endif
|
||||
CHK(mime.Delete() == B_OK);
|
||||
@ -1987,7 +1986,7 @@ MimeTypeTest::SupportingAppsTest() {
|
||||
CHK(mime.GetSupportingApps(&msg) == B_OK);
|
||||
msg.PrintToStream();
|
||||
} */
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
std::queue<std::string> typeList; // Stores all installed MIME types
|
||||
std::queue<std::string> appList; // Stores all installed application subtypes
|
||||
@ -2021,16 +2020,16 @@ MimeTypeTest::SupportingAppsTest() {
|
||||
void
|
||||
MimeTypeTest::WildcardAppsTest() {
|
||||
// NULL param
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
#if SK_TEST_R5
|
||||
#if TEST_R5
|
||||
CHK(BMimeType::GetWildcardApps(NULL) == B_OK); // R5 == B_OK (???)
|
||||
#else
|
||||
CHK(RES(BMimeType::GetWildcardApps(NULL)) != B_OK); // Personally I think we ought to return B_BAD_VALUE
|
||||
#endif
|
||||
}
|
||||
// Normal function (compare to BMimeType("application/octet-stream").GetSupportingApps())
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMessage msg1, msg2;
|
||||
CHK(BMimeType::GetWildcardApps(&msg1) == B_OK);
|
||||
@ -2080,7 +2079,7 @@ MimeTypeTest::InitTest()
|
||||
init_long_types(notTooLongType, tooLongType);
|
||||
|
||||
// default constructor
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.InitCheck() == B_NO_INIT);
|
||||
@ -2092,7 +2091,7 @@ MimeTypeTest::InitTest()
|
||||
|
||||
// BMimeType(const char *)
|
||||
// valid type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type(validType);
|
||||
CHK(type.InitCheck() == B_OK);
|
||||
@ -2102,7 +2101,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// invalid type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type(invalidType);
|
||||
CHK(type.InitCheck() == B_BAD_VALUE);
|
||||
@ -2112,7 +2111,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// long, but not too long type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type(notTooLongType);
|
||||
CHK(type.InitCheck() == B_OK);
|
||||
@ -2122,7 +2121,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// too long type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type(tooLongType);
|
||||
CHK(type.InitCheck() == B_BAD_VALUE);
|
||||
@ -2134,7 +2133,7 @@ MimeTypeTest::InitTest()
|
||||
|
||||
// SetTo()
|
||||
// valid type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.SetTo(validType) == B_OK);
|
||||
@ -2145,7 +2144,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// invalid type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.SetTo(invalidType) == B_BAD_VALUE);
|
||||
@ -2156,7 +2155,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// long, but not too long type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.SetTo(notTooLongType) == B_OK);
|
||||
@ -2167,7 +2166,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// too long type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.SetTo(tooLongType) == B_BAD_VALUE);
|
||||
@ -2180,7 +2179,7 @@ MimeTypeTest::InitTest()
|
||||
|
||||
// SetType()
|
||||
// valid type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.SetType(validType) == B_OK);
|
||||
@ -2191,7 +2190,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// invalid type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.SetType(invalidType) == B_BAD_VALUE);
|
||||
@ -2202,7 +2201,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// long, but not too long type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.SetType(notTooLongType) == B_OK);
|
||||
@ -2213,7 +2212,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(type.Type() == NULL);
|
||||
}
|
||||
// too long type
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type;
|
||||
CHK(type.SetType(tooLongType) == B_BAD_VALUE);
|
||||
@ -2225,7 +2224,7 @@ MimeTypeTest::InitTest()
|
||||
}
|
||||
|
||||
// reinitialization
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type(validType);
|
||||
CHK(type.InitCheck() == B_OK);
|
||||
@ -2235,7 +2234,7 @@ MimeTypeTest::InitTest()
|
||||
CHK(string(type.Type()) == validType2);
|
||||
}
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type(NULL);
|
||||
CHK(type.Type() == NULL);
|
||||
@ -2339,7 +2338,7 @@ MimeTypeTest::StringTest()
|
||||
int32 testCount = sizeof(tests) / sizeof(mime_type_test);
|
||||
// test loop
|
||||
for (int32 i = 0; i < testCount; i++) {
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
mime_type_test &test = tests[i];
|
||||
BMimeType type(test.type);
|
||||
CHK(type.InitCheck() == test.error);
|
||||
@ -2400,11 +2399,11 @@ MimeTypeTest::StringTest()
|
||||
}
|
||||
}
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BMimeType type("image/gif");
|
||||
// R5: crashes when passing NULL
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(BMimeType::IsValid(NULL) == false);
|
||||
CHK(type.GetSupertype(NULL) == B_BAD_VALUE);
|
||||
CHK(type.Contains(NULL) == false);
|
||||
@ -2495,7 +2494,7 @@ MimeTypeTest::MonitoringTest()
|
||||
// * change something, check message queue (empty)
|
||||
|
||||
CHK(fApplication != NULL);
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
// StartWatching()
|
||||
BMessenger target(&fApplication->Handler(), fApplication);
|
||||
CHK(BMimeType::StartWatching(target) == B_OK);
|
||||
@ -2557,7 +2556,7 @@ MimeTypeTest::MonitoringTest()
|
||||
}
|
||||
|
||||
// set the same values once again
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
// icon
|
||||
CHK(type.SetIcon(iconHelperLarge.Bitmap1(), B_LARGE_ICON) == B_OK);
|
||||
CHK(type.SetIcon(iconHelperMini.Bitmap1(), B_MINI_ICON) == B_OK);
|
||||
@ -2602,7 +2601,7 @@ MimeTypeTest::MonitoringTest()
|
||||
}
|
||||
|
||||
// set different values
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
// icon
|
||||
CHK(type.SetIcon(iconHelperLarge.Bitmap2(), B_LARGE_ICON) == B_OK);
|
||||
CHK(type.SetIcon(iconHelperMini.Bitmap2(), B_MINI_ICON) == B_OK);
|
||||
@ -2691,7 +2690,7 @@ MimeTypeTest::MonitoringTest()
|
||||
|
||||
// bad args
|
||||
// StopWatching() another target
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
// install
|
||||
CHK(type.InitCheck() == B_OK);
|
||||
CHK(type.IsInstalled() == false);
|
||||
@ -2702,11 +2701,11 @@ MimeTypeTest::MonitoringTest()
|
||||
BMessenger target3("application/does-not_exist");
|
||||
CHK(target3.IsValid() == false);
|
||||
// R5: An invalid messenger is fine for any reason?!
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(RES(BMimeType::StartWatching(target3)) == B_BAD_VALUE);
|
||||
#endif
|
||||
CHK(BMimeType::StartWatching(target) == B_OK);
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(BMimeType::StopWatching(target3) == B_BAD_VALUE);
|
||||
#endif
|
||||
CHK(BMimeType::StopWatching(target2) == B_BAD_VALUE);
|
||||
@ -2837,7 +2836,7 @@ MimeTypeTest::UpdateMimeInfoTest()
|
||||
// * Updating all files is not tested as it takes too long.
|
||||
|
||||
// individual files
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
execCommand(string("mkdir ") + testDir + "/subdir1 "
|
||||
+ testDir + "/subdir2 "
|
||||
+ testDir + "/subdir2/subsubdir1");
|
||||
@ -2904,7 +2903,7 @@ printf("%s <-> %s\n", type.String(), file.type.c_str());
|
||||
#endif // 0
|
||||
|
||||
// directory
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
// create
|
||||
for (int32 i = 0; i < fileCount; i++) {
|
||||
MimeInfoTestFile &file = files[i];
|
||||
@ -2944,7 +2943,7 @@ printf("%s <-> %s\n", type.String(), file.type.c_str());
|
||||
}
|
||||
|
||||
// bad args: non-existing file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BEntry entry(files[0].name.c_str());
|
||||
CHK(entry.InitCheck() == B_OK);
|
||||
CHK(entry.Exists() == false);
|
||||
@ -3107,7 +3106,7 @@ MimeTypeTest::CreateAppMetaMimeTest()
|
||||
// * Updating all apps is not tested as it takes too long.
|
||||
|
||||
// attributes and resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
execCommand(string("mkdir ") + testDir + "/subdir1 "
|
||||
+ testDir + "/subdir2 "
|
||||
+ testDir + "/subdir2/subsubdir1");
|
||||
@ -3134,7 +3133,7 @@ MimeTypeTest::CreateAppMetaMimeTest()
|
||||
}
|
||||
|
||||
// attributes only
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
for (int32 i = 0; i < fileCount; i++) {
|
||||
// create file, create_app_meta_mime()
|
||||
AppMimeTestFile &file = files[i];
|
||||
@ -3148,7 +3147,7 @@ MimeTypeTest::CreateAppMetaMimeTest()
|
||||
}
|
||||
|
||||
// resources only
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
for (int32 i = 0; i < fileCount; i++) {
|
||||
// create file, create_app_meta_mime()
|
||||
AppMimeTestFile &file = files[i];
|
||||
@ -3243,7 +3242,7 @@ MimeTypeTest::CreateAppMetaMimeTest()
|
||||
#endif // 0
|
||||
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
// no signature
|
||||
CHK(files[0].Create(false, false) == B_OK);
|
||||
CHK(create_app_meta_mime(files[0].name.c_str(), false, true, false)
|
||||
@ -3294,7 +3293,7 @@ MimeTypeTest::GetDeviceIconTest()
|
||||
};
|
||||
const int testCaseCount = sizeof(testCases) / sizeof(test_case);
|
||||
for (int32 i = 0; i < testCaseCount; i++) {
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
test_case &testCase = testCases[i];
|
||||
// get device name from path name
|
||||
fs_info info;
|
||||
@ -3318,7 +3317,7 @@ MimeTypeTest::GetDeviceIconTest()
|
||||
CheckIconData(deviceName, size, buffer);
|
||||
// bad args: NULL buffer
|
||||
// R5: Wanna see KDL? Here you go...
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(get_device_icon(deviceName, NULL, size) == B_BAD_VALUE);
|
||||
#endif
|
||||
} else
|
||||
@ -3424,7 +3423,7 @@ MimeTypeTest::SnifferRuleTest()
|
||||
CHK(type.SetTo(testType) == B_OK);
|
||||
CHK(type.Install() == B_OK);
|
||||
for (int32 i = 0; i < testCaseCount; i++) {
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
test_case &testCase = testCases[i];
|
||||
BString parseError;
|
||||
status_t error = BMimeType::CheckSnifferRule(testCase.rule,
|
||||
@ -3445,19 +3444,19 @@ printf("error: %s\n", parseError.String());
|
||||
}
|
||||
|
||||
// bad args: NULL rule/result string
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BString parseError;
|
||||
CHK(BMimeType::CheckSnifferRule("0.0 ('')", NULL)
|
||||
== B_BAD_MIME_SNIFFER_RULE);
|
||||
// R5: crashes when passing a NULL rule/result buffer.
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CHK(BMimeType::CheckSnifferRule(NULL, &parseError) == B_BAD_VALUE);
|
||||
CHK(BMimeType::CheckSnifferRule(NULL, NULL) == B_BAD_VALUE);
|
||||
CHK(type.GetSnifferRule(NULL) == B_BAD_VALUE);
|
||||
#endif
|
||||
|
||||
// NULL rule to SetSnifferRule unsets the attribute
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CHK(type.IsInstalled() == true);
|
||||
CHK(type.SetSnifferRule(NULL) == B_OK);
|
||||
BString rule;
|
||||
@ -3595,7 +3594,7 @@ MimeTypeTest::SniffingTest()
|
||||
};
|
||||
int fileCount = sizeof(files) / sizeof(SniffingTestFile);
|
||||
for (int32 i = 0; i < fileCount; i++) {
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
SniffingTestFile &file = files[i];
|
||||
const char *filename = file.name.c_str();
|
||||
//printf("file: %s\n", filename);
|
||||
@ -3636,7 +3635,7 @@ printf("type: %s, should be: %s\n", type.Type(), realType);
|
||||
|
||||
// GuessMimeType(const ref*,), invalid/abstract entry
|
||||
{
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
const char *filename = (string(testDir) + "/file100.cpp").c_str();
|
||||
BMimeType type;
|
||||
entry_ref ref;
|
||||
@ -3650,7 +3649,7 @@ printf("type: %s, should be: %s\n", type.Type(), realType);
|
||||
|
||||
// bad args
|
||||
{
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
SniffingTestFile &file = files[0];
|
||||
CHK(file.Create() == B_OK);
|
||||
const char *filename = file.name.c_str();
|
||||
@ -3759,3 +3758,7 @@ printf("type: %s, should be: %s\n", type.Type(), realType);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -72,3 +72,7 @@ private:
|
||||
|
||||
|
||||
#endif // __sk_mime_type_test_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <TestUtils.h>
|
||||
#include <NodeTest.h>
|
||||
|
||||
#include <errno.h>
|
||||
@ -18,7 +19,6 @@
|
||||
#include <String.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
#include "TestUtils.h"
|
||||
|
||||
// == for attr_info
|
||||
static
|
||||
|
@ -105,7 +105,7 @@ NodeTest::AddBaseClassTests(const char *prefix, CppUnit::TestSuite *suite)
|
||||
suite->addTest( new TC(p + "BNode::AttrDir Test", &NodeTest::AttrDirTest) );
|
||||
suite->addTest( new TC(p + "BNode::Attr Test", &NodeTest::AttrTest) );
|
||||
suite->addTest( new TC(p + "BNode::AttrRename Test"
|
||||
#if SK_TEST_R5
|
||||
#if TEST_R5
|
||||
" (NOTE: test not actually performed with R5 libraries)"
|
||||
#endif
|
||||
, &NodeTest::AttrRenameTest) );
|
||||
@ -114,7 +114,7 @@ NodeTest::AddBaseClassTests(const char *prefix, CppUnit::TestSuite *suite)
|
||||
suite->addTest( new TC(p + "BNode::Sync Test", &NodeTest::SyncTest) );
|
||||
suite->addTest( new TC(p + "BNode::Dup Test", &NodeTest::DupTest) );
|
||||
suite->addTest( new TC(p + "BNode::Lock Test"
|
||||
#if SK_TEST_OBOS_POSIX
|
||||
#if TEST_OBOS /* !!!POSIX ONLY!!! */
|
||||
" (NOTE: test not actually performed with OpenBeOS Posix libraries)"
|
||||
#endif
|
||||
, &NodeTest::LockTest) );
|
||||
@ -122,3 +122,7 @@ NodeTest::AddBaseClassTests(const char *prefix, CppUnit::TestSuite *suite)
|
||||
|
||||
|
||||
#endif // __sk_node_test_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -18,15 +18,14 @@
|
||||
#include <Query.h>
|
||||
#include <String.h>
|
||||
#include <Volume.h>
|
||||
#include "StorageKitTester.h"
|
||||
#include "TestApp.h"
|
||||
#include "TestUtils.h"
|
||||
#include <TestApp.h>
|
||||
#include <TestUtils.h>
|
||||
|
||||
// Query
|
||||
|
||||
class Query : public BQuery {
|
||||
public:
|
||||
#if SK_TEST_R5
|
||||
#if TEST_R5
|
||||
status_t PushValue(int32 value) { PushInt32(value); return B_OK; }
|
||||
status_t PushValue(uint32 value) { PushUInt32(value); return B_OK; }
|
||||
status_t PushValue(int64 value) { PushInt64(value); return B_OK; }
|
||||
@ -659,7 +658,7 @@ TestOperator(query_op op)
|
||||
TestPredicate(OpNode(op, new AttributeNode("attribute"), NULL), B_OK,
|
||||
B_NO_INIT);
|
||||
// R5: crashs when pushing B_CONTAINS/B_BEGINS/ENDS_WITH on an empty stack
|
||||
#if SK_TEST_R5
|
||||
#if TEST_R5
|
||||
if (op < B_CONTAINS || op > B_ENDS_WITH)
|
||||
#endif
|
||||
TestPredicate(OpNode(op, NULL, NULL), B_OK, B_NO_INIT);
|
||||
@ -677,7 +676,7 @@ QueryTest::PredicateTest()
|
||||
// * Push*()
|
||||
// * Set/GetPredicate(), PredicateLength()
|
||||
// empty predicate
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
char buffer[1024];
|
||||
{
|
||||
Query query;
|
||||
@ -690,12 +689,12 @@ QueryTest::PredicateTest()
|
||||
== B_NO_INIT );
|
||||
}
|
||||
// one element predicates
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestPredicate(Int32Node(42));
|
||||
TestPredicate(UInt32Node(42));
|
||||
TestPredicate(Int64Node(42));
|
||||
// R5: buggy PushUInt64() implementation.
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
TestPredicate(UInt64Node(42));
|
||||
#endif
|
||||
TestPredicate(FloatNode(42));
|
||||
@ -711,7 +710,7 @@ QueryTest::PredicateTest()
|
||||
TestPredicate(DateNode("invalid date"), B_BAD_VALUE);
|
||||
TestPredicate(AttributeNode("some attribute"));
|
||||
// operators
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestOperator(B_EQ);
|
||||
TestOperator(B_GT);
|
||||
TestOperator(B_GE);
|
||||
@ -733,7 +732,7 @@ QueryTest::PredicateTest()
|
||||
TestPredicate(OpNode(B_NOT, NULL), B_OK, B_NO_INIT);
|
||||
}
|
||||
// well formed, legal predicate
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestPredicate(OpNode(B_AND,
|
||||
new OpNode(B_CONTAINS,
|
||||
new AttributeNode("attribute"),
|
||||
@ -754,7 +753,7 @@ QueryTest::PredicateTest()
|
||||
)
|
||||
));
|
||||
// well formed, illegal predicate
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestPredicate(OpNode(B_EQ,
|
||||
new StringNode("hello"),
|
||||
new OpNode(B_LE,
|
||||
@ -768,7 +767,7 @@ QueryTest::PredicateTest()
|
||||
// ill formed predicates
|
||||
// Some have already been tested in TestOperator, so we only test a few
|
||||
// special ones.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
TestPredicate(ListNode(new Int32Node(42), new StringNode("hello!")),
|
||||
B_OK, B_NO_INIT);
|
||||
TestPredicate(OpNode(B_EQ,
|
||||
@ -776,7 +775,7 @@ QueryTest::PredicateTest()
|
||||
new OpNode(B_NOT, NULL)
|
||||
), B_OK, B_NO_INIT);
|
||||
// precedence Push*() over SetPredicate()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
OpNode predicate1(B_CONTAINS,
|
||||
@ -792,7 +791,7 @@ QueryTest::PredicateTest()
|
||||
CPPUNIT_ASSERT( predicate == predicate1.toString() );
|
||||
}
|
||||
// GetPredicate() clears the stack
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
OpNode predicate1(B_CONTAINS,
|
||||
@ -810,7 +809,7 @@ QueryTest::PredicateTest()
|
||||
CPPUNIT_ASSERT( predicate == predicate2.toString() );
|
||||
}
|
||||
// PredicateLength() clears the stack
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
OpNode predicate1(B_CONTAINS,
|
||||
@ -828,7 +827,7 @@ QueryTest::PredicateTest()
|
||||
CPPUNIT_ASSERT( predicate == predicate2.toString() );
|
||||
}
|
||||
// SetPredicate(), Push*() fail after Fetch()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -840,7 +839,7 @@ QueryTest::PredicateTest()
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExistEither\"")
|
||||
== B_NOT_ALLOWED );
|
||||
// R5: Push*()ing a new predicate does work, though it doesn't make any sense
|
||||
#if SK_TEST_R5
|
||||
#if TEST_R5
|
||||
CPPUNIT_ASSERT( query.PushDate("20 May 2002") == B_OK );
|
||||
CPPUNIT_ASSERT( query.PushValue((int32)42) == B_OK );
|
||||
CPPUNIT_ASSERT( query.PushValue((uint32)42) == B_OK );
|
||||
@ -866,8 +865,8 @@ QueryTest::PredicateTest()
|
||||
}
|
||||
// SetPredicate(): bad args
|
||||
// R5: crashes when passing NULL to Set/GetPredicate()
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate(NULL) == B_BAD_VALUE );
|
||||
@ -888,15 +887,15 @@ QueryTest::ParameterTest()
|
||||
|
||||
// SetVolume(), TargetDevice()
|
||||
// uninitialized BQuery
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BQuery query;
|
||||
CPPUNIT_ASSERT( query.TargetDevice() == B_ERROR );
|
||||
}
|
||||
// NULL volume
|
||||
// R5: crashs when passing a NULL BVolume
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
BQuery query;
|
||||
CPPUNIT_ASSERT( query.SetVolume(NULL) == B_BAD_VALUE );
|
||||
@ -904,7 +903,7 @@ QueryTest::ParameterTest()
|
||||
}
|
||||
#endif
|
||||
// invalid volume
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BQuery query;
|
||||
BVolume volume(-2);
|
||||
@ -913,7 +912,7 @@ QueryTest::ParameterTest()
|
||||
CPPUNIT_ASSERT( query.TargetDevice() == B_ERROR );
|
||||
}
|
||||
// valid volume
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BQuery query;
|
||||
dev_t device = dev_for_path("/boot");
|
||||
@ -925,13 +924,13 @@ QueryTest::ParameterTest()
|
||||
|
||||
// SetTarget(), IsLive()
|
||||
// uninitialized BQuery
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BQuery query;
|
||||
CPPUNIT_ASSERT( query.IsLive() == false );
|
||||
}
|
||||
// uninitialized BMessenger
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BQuery query;
|
||||
BMessenger messenger;
|
||||
@ -940,7 +939,7 @@ QueryTest::ParameterTest()
|
||||
CPPUNIT_ASSERT( query.IsLive() == false );
|
||||
}
|
||||
// valid BMessenger
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BQuery query;
|
||||
BMessenger messenger(&fApplication->Handler());
|
||||
@ -950,7 +949,7 @@ QueryTest::ParameterTest()
|
||||
}
|
||||
|
||||
// SetVolume/Target() fail after Fetch()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -966,7 +965,7 @@ QueryTest::ParameterTest()
|
||||
}
|
||||
|
||||
// Fetch() fails without a valid volume set
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -1102,13 +1101,13 @@ QueryTest::FetchTest()
|
||||
|
||||
// Fetch()
|
||||
// uninitialized BQuery
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.Fetch() == B_NO_INIT );
|
||||
}
|
||||
// incompletely initialized BQuery (no predicate)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
BVolume volume(dev_for_path("/boot"));
|
||||
@ -1117,7 +1116,7 @@ QueryTest::FetchTest()
|
||||
CPPUNIT_ASSERT( query.Fetch() == B_NO_INIT );
|
||||
}
|
||||
// incompletely initialized BQuery (no volume)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -1125,7 +1124,7 @@ QueryTest::FetchTest()
|
||||
CPPUNIT_ASSERT( query.Fetch() == B_NO_INIT );
|
||||
}
|
||||
// incompletely initialized BQuery (invalid predicate)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"&&")
|
||||
@ -1136,7 +1135,7 @@ QueryTest::FetchTest()
|
||||
CPPUNIT_ASSERT( query.Fetch() == B_BAD_VALUE );
|
||||
}
|
||||
// initialized BQuery, Fetch() twice
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -1152,7 +1151,7 @@ QueryTest::FetchTest()
|
||||
fVolumeCreated = true;
|
||||
create_test_entries(allTestEntries, allTestEntryCount);
|
||||
// ... all files
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
QueryTestEntry *entries[] = {
|
||||
&file11, &file12, &file21, &file22, &file31, &file32, &file1,
|
||||
@ -1163,7 +1162,7 @@ QueryTest::FetchTest()
|
||||
entryCount);
|
||||
}
|
||||
// ... all entries containing a "l"
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
QueryTestEntry *entries[] = {
|
||||
&file11, &file12, &link11, &file21, &file22, &link21, &file31,
|
||||
@ -1174,7 +1173,7 @@ QueryTest::FetchTest()
|
||||
entryCount);
|
||||
}
|
||||
// ... all entries ending on "2"
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
QueryTestEntry *entries[] = {
|
||||
&subdir12, &file12, &dir2, &subdir22, &file22, &subdir32, &file32,
|
||||
@ -1187,13 +1186,13 @@ QueryTest::FetchTest()
|
||||
|
||||
// Clear()
|
||||
// uninitialized BQuery
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.Clear() == B_OK );
|
||||
}
|
||||
// initialized BQuery, Fetch(), Clear(), Fetch()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -1206,7 +1205,7 @@ QueryTest::FetchTest()
|
||||
CPPUNIT_ASSERT( query.Fetch() == B_NO_INIT );
|
||||
}
|
||||
// initialized BQuery, Fetch(), Clear(), re-init, Fetch()
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -1225,7 +1224,7 @@ QueryTest::FetchTest()
|
||||
|
||||
// BEntryList interface:
|
||||
// empty queries
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -1244,7 +1243,7 @@ QueryTest::FetchTest()
|
||||
CPPUNIT_ASSERT( query.GetNextDirents(ents, bufSize, 1) == 0 );
|
||||
}
|
||||
// uninitialized queries
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
BEntry entry;
|
||||
@ -1258,7 +1257,7 @@ QueryTest::FetchTest()
|
||||
== B_FILE_ERROR );
|
||||
}
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"ThisShouldNotExist\"")
|
||||
@ -1269,7 +1268,7 @@ QueryTest::FetchTest()
|
||||
CPPUNIT_ASSERT( query.Fetch() == B_OK );
|
||||
size_t bufSize = (sizeof(dirent) + B_FILE_NAME_LENGTH) * 10;
|
||||
// R5: crashs when passing a NULL BEntry or entry_ref
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CPPUNIT_ASSERT( query.GetNextEntry(NULL) == B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( query.GetNextRef(NULL) == B_BAD_VALUE );
|
||||
#endif
|
||||
@ -1380,7 +1379,7 @@ QueryTest::LiveTest()
|
||||
BMessenger target(&fApplication->Handler());
|
||||
|
||||
// empty query, add some files, remove some files
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
CPPUNIT_ASSERT( query.SetPredicate("name=\"*Argh\"")
|
||||
@ -1414,7 +1413,7 @@ QueryTest::LiveTest()
|
||||
RemoveLiveEntries(entries, entryCount, queryEntries, queryEntryCount);
|
||||
}
|
||||
// non-empty query, add some files, remove some files
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
Query query;
|
||||
TestSet testSet;
|
||||
@ -1461,3 +1460,7 @@ QueryTest::LiveTest()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -46,3 +46,7 @@ private:
|
||||
};
|
||||
|
||||
#endif // __sk_query_test_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -17,8 +17,7 @@
|
||||
#include <ResourceStrings.h>
|
||||
#include <String.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
#include "StorageKitTester.h"
|
||||
#include <TestShell.h>
|
||||
|
||||
|
||||
static const char *testDir = "/tmp/testDir";
|
||||
@ -186,7 +185,7 @@ void
|
||||
ResourceStringsTest::setUp()
|
||||
{
|
||||
BasicTest::setUp();
|
||||
string resourcesTestDir(shell.TestDir());
|
||||
string resourcesTestDir(BTestShell::GlobalTestDir());
|
||||
resourcesTestDir += "/resources";
|
||||
execCommand(string("mkdir ") + testDir
|
||||
+ " ; cp " + resourcesTestDir + "/" + x86ResName + " "
|
||||
@ -235,7 +234,7 @@ void
|
||||
ResourceStringsTest::InitTest1()
|
||||
{
|
||||
// default constructor
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResourceStrings resourceStrings;
|
||||
CPPUNIT_ASSERT( resourceStrings.InitCheck() == B_OK );
|
||||
@ -244,7 +243,7 @@ ResourceStringsTest::InitTest1()
|
||||
== B_ENTRY_NOT_FOUND );
|
||||
}
|
||||
// application file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = get_app_ref();
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -254,7 +253,7 @@ ResourceStringsTest::InitTest1()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// x86 resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(x86ResFile, &ref) == B_OK );
|
||||
@ -265,7 +264,7 @@ ResourceStringsTest::InitTest1()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// ppc resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(ppcResFile, &ref) == B_OK );
|
||||
@ -276,7 +275,7 @@ ResourceStringsTest::InitTest1()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// ELF executable
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(elfFile, &ref) == B_OK );
|
||||
@ -287,7 +286,7 @@ ResourceStringsTest::InitTest1()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// PEF executable
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(pefFile, &ref) == B_OK );
|
||||
@ -298,7 +297,7 @@ ResourceStringsTest::InitTest1()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// test file 1
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(testFile1, &ref) == B_OK );
|
||||
@ -309,7 +308,7 @@ ResourceStringsTest::InitTest1()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// test file 2
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(testFile1, &ref) == B_OK );
|
||||
@ -320,7 +319,7 @@ ResourceStringsTest::InitTest1()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(emptyFile, &ref) == B_OK );
|
||||
@ -331,7 +330,7 @@ ResourceStringsTest::InitTest1()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// non-resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(noResFile, &ref) == B_OK );
|
||||
@ -343,7 +342,7 @@ ResourceStringsTest::InitTest1()
|
||||
B_IO_ERROR) );
|
||||
}
|
||||
// non-existing file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(noSuchFile, &ref) == B_OK );
|
||||
@ -355,8 +354,8 @@ ResourceStringsTest::InitTest1()
|
||||
}
|
||||
// bad args (GetStringFile)
|
||||
// R5: crashes
|
||||
#if !SK_TEST_R5
|
||||
nextSubTest();
|
||||
#if !TEST_R5
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(testFile1, &ref) == B_OK );
|
||||
@ -372,7 +371,7 @@ void
|
||||
ResourceStringsTest::InitTest2()
|
||||
{
|
||||
// application file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = get_app_ref();
|
||||
BResourceStrings resourceStrings;
|
||||
@ -383,7 +382,7 @@ ResourceStringsTest::InitTest2()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// x86 resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(x86ResFile, &ref) == B_OK );
|
||||
@ -395,7 +394,7 @@ ResourceStringsTest::InitTest2()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// ppc resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(ppcResFile, &ref) == B_OK );
|
||||
@ -407,7 +406,7 @@ ResourceStringsTest::InitTest2()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// ELF executable
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(elfFile, &ref) == B_OK );
|
||||
@ -419,7 +418,7 @@ ResourceStringsTest::InitTest2()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// PEF executable
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(pefFile, &ref) == B_OK );
|
||||
@ -431,7 +430,7 @@ ResourceStringsTest::InitTest2()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// test file 1
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(testFile1, &ref) == B_OK );
|
||||
@ -443,7 +442,7 @@ ResourceStringsTest::InitTest2()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// test file 2
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(testFile1, &ref) == B_OK );
|
||||
@ -455,7 +454,7 @@ ResourceStringsTest::InitTest2()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(emptyFile, &ref) == B_OK );
|
||||
@ -467,7 +466,7 @@ ResourceStringsTest::InitTest2()
|
||||
CPPUNIT_ASSERT( BEntry(&ref, true) == BEntry(&ref2, true) );
|
||||
}
|
||||
// non-resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(noResFile, &ref) == B_OK );
|
||||
@ -481,7 +480,7 @@ ResourceStringsTest::InitTest2()
|
||||
B_IO_ERROR) );
|
||||
}
|
||||
// non-existing file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( get_ref_for_path(noSuchFile, &ref) == B_OK );
|
||||
@ -494,7 +493,7 @@ ResourceStringsTest::InitTest2()
|
||||
== B_ENTRY_NOT_FOUND );
|
||||
}
|
||||
// NULL ref -> app file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResourceStrings resourceStrings;
|
||||
CPPUNIT_ASSERT( resourceStrings.SetStringFile(NULL) == B_OK );
|
||||
@ -527,7 +526,7 @@ void
|
||||
ResourceStringsTest::FindStringTest()
|
||||
{
|
||||
// app file (default constructor)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResourceStrings resourceStrings;
|
||||
CPPUNIT_ASSERT( resourceStrings.InitCheck() == B_OK );
|
||||
@ -542,7 +541,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, false);
|
||||
}
|
||||
// app file (explicitely)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = get_app_ref();
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -558,7 +557,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, false);
|
||||
}
|
||||
// test file 1
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(testFile1);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -574,7 +573,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, false);
|
||||
}
|
||||
// test file 2
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(testFile2);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -590,7 +589,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, false);
|
||||
}
|
||||
// x86 resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(x86ResFile);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -606,7 +605,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, true);
|
||||
}
|
||||
// ppc resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(ppcResFile);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -622,7 +621,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, true);
|
||||
}
|
||||
// ELF executable
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(elfFile);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -638,7 +637,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, true);
|
||||
}
|
||||
// PEF executable
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(pefFile);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -654,7 +653,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, true);
|
||||
}
|
||||
// empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(emptyFile);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -670,7 +669,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, false);
|
||||
}
|
||||
// non-resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(noResFile);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -687,7 +686,7 @@ ResourceStringsTest::FindStringTest()
|
||||
::FindStringTest(resourceStrings, testResource1, false);
|
||||
}
|
||||
// non-existing file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
entry_ref ref = ref_for(noSuchFile);
|
||||
BResourceStrings resourceStrings(ref);
|
||||
@ -704,3 +703,7 @@ ResourceStringsTest::FindStringTest()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -45,3 +45,7 @@ public:
|
||||
|
||||
|
||||
#endif // __sk_resource_strings_test_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include <Resources.h>
|
||||
#include <String.h>
|
||||
#include <TypeConstants.h>
|
||||
#include <TestShell.h>
|
||||
|
||||
#include "StorageKitTester.h"
|
||||
|
||||
static const char *testDir = "/tmp/testDir";
|
||||
static const char *x86ResFile = "/tmp/testDir/x86.rsrc";
|
||||
@ -196,7 +196,7 @@ void
|
||||
ResourcesTest::setUp()
|
||||
{
|
||||
BasicTest::setUp();
|
||||
BString unescapedTestDir(shell.TestDir());
|
||||
BString unescapedTestDir(BTestShell::GlobalTestDir());
|
||||
unescapedTestDir.CharacterEscape(" \t\n!\"'`$&()?*+{}[]<>|", '\\');
|
||||
string resourcesTestDir(unescapedTestDir.String());
|
||||
resourcesTestDir += "/resources";
|
||||
@ -227,7 +227,7 @@ ResourcesTest::InitTest()
|
||||
{
|
||||
// 1. existing files, read only
|
||||
// x86 resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
@ -235,7 +235,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// ppc resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(ppcResFile, B_READ_ONLY);
|
||||
@ -243,7 +243,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// ELF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(elfFile, B_READ_ONLY);
|
||||
@ -251,7 +251,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// ELF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(elfNoResFile, B_READ_ONLY);
|
||||
@ -259,7 +259,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// PEF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(pefFile, B_READ_ONLY);
|
||||
@ -267,7 +267,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// PEF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(pefNoResFile, B_READ_ONLY);
|
||||
@ -275,7 +275,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(emptyFile, B_READ_ONLY);
|
||||
@ -283,7 +283,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// non-resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(noResFile, B_READ_ONLY);
|
||||
@ -294,7 +294,7 @@ ResourcesTest::InitTest()
|
||||
|
||||
// 2. existing files, read only, clobber
|
||||
// x86 resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
@ -302,7 +302,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, true) == B_OK );
|
||||
}
|
||||
// ppc resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(ppcResFile, B_READ_ONLY);
|
||||
@ -310,7 +310,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, true) == B_OK );
|
||||
}
|
||||
// ELF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(elfFile, B_READ_ONLY);
|
||||
@ -318,7 +318,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, true) == B_OK );
|
||||
}
|
||||
// ELF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(elfNoResFile, B_READ_ONLY);
|
||||
@ -326,7 +326,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, true) == B_OK );
|
||||
}
|
||||
// PEF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(pefFile, B_READ_ONLY);
|
||||
@ -334,7 +334,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, true) == B_OK );
|
||||
}
|
||||
// PEF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(pefNoResFile, B_READ_ONLY);
|
||||
@ -342,7 +342,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, true) == B_OK );
|
||||
}
|
||||
// empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(emptyFile, B_READ_ONLY);
|
||||
@ -350,7 +350,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, true) == B_OK );
|
||||
}
|
||||
// non-resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(noResFile, B_READ_ONLY);
|
||||
@ -360,7 +360,7 @@ ResourcesTest::InitTest()
|
||||
|
||||
// 3. existing files, read/write
|
||||
// x86 resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(x86ResFile, B_READ_WRITE);
|
||||
@ -368,7 +368,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// ppc resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(ppcResFile, B_READ_WRITE);
|
||||
@ -376,7 +376,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// ELF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(elfFile, B_READ_WRITE);
|
||||
@ -384,7 +384,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// ELF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(elfNoResFile, B_READ_WRITE);
|
||||
@ -392,7 +392,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// PEF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(pefFile, B_READ_WRITE);
|
||||
@ -400,7 +400,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// PEF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(pefNoResFile, B_READ_WRITE);
|
||||
@ -408,7 +408,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(emptyFile, B_READ_WRITE);
|
||||
@ -416,7 +416,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
}
|
||||
// non-resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(noResFile, B_READ_WRITE);
|
||||
@ -427,7 +427,7 @@ ResourcesTest::InitTest()
|
||||
|
||||
// 4. existing files, read/write, clobber
|
||||
// x86 resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(x86ResFile, B_READ_WRITE);
|
||||
@ -436,7 +436,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_OK );
|
||||
}
|
||||
// ppc resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(ppcResFile, B_READ_WRITE);
|
||||
@ -445,7 +445,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_OK );
|
||||
}
|
||||
// ELF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(elfFile, B_READ_WRITE);
|
||||
@ -454,7 +454,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_OK );
|
||||
}
|
||||
// ELF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(elfNoResFile, B_READ_WRITE);
|
||||
@ -463,7 +463,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_OK );
|
||||
}
|
||||
// PEF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(pefFile, B_READ_WRITE);
|
||||
@ -472,7 +472,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_OK );
|
||||
}
|
||||
// PEF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(pefNoResFile, B_READ_WRITE);
|
||||
@ -481,7 +481,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_OK );
|
||||
}
|
||||
// empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(emptyFile, B_READ_WRITE);
|
||||
@ -490,7 +490,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_OK );
|
||||
}
|
||||
// non-resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(noResFile, B_READ_WRITE);
|
||||
@ -500,7 +500,7 @@ ResourcesTest::InitTest()
|
||||
|
||||
// 5. bad args
|
||||
// uninitialized file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file;
|
||||
@ -508,7 +508,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_NO_INIT );
|
||||
}
|
||||
// badly initialized file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(noSuchFile, B_READ_ONLY);
|
||||
@ -516,7 +516,7 @@ ResourcesTest::InitTest()
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_ENTRY_NOT_FOUND );
|
||||
}
|
||||
// NULL file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
// R5: A NULL file is B_OK!
|
||||
@ -708,7 +708,7 @@ ResourcesTest::ReadTest()
|
||||
|
||||
// 1. basic tests
|
||||
// x86 resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -721,7 +721,7 @@ ResourcesTest::ReadTest()
|
||||
ReadResTest(resources, testResource5, false);
|
||||
}
|
||||
// ppc resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(ppcResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -734,7 +734,7 @@ ResourcesTest::ReadTest()
|
||||
ReadResTest(resources, testResource5, false);
|
||||
}
|
||||
// ELF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(elfFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -747,7 +747,7 @@ ResourcesTest::ReadTest()
|
||||
ReadResTest(resources, testResource5, false);
|
||||
}
|
||||
// ELF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(elfNoResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -760,7 +760,7 @@ ResourcesTest::ReadTest()
|
||||
ReadResTest(resources, testResource5, false);
|
||||
}
|
||||
// PEF binary containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(pefFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -773,7 +773,7 @@ ResourcesTest::ReadTest()
|
||||
ReadResTest(resources, testResource5, false);
|
||||
}
|
||||
// PEF binary not containing resources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(pefNoResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -788,7 +788,7 @@ ResourcesTest::ReadTest()
|
||||
|
||||
// 2. PreloadResource()
|
||||
// Hard to test: just preload all and check, if it still works.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -808,7 +808,7 @@ ResourcesTest::ReadTest()
|
||||
ReadResTest(resources, testResource5, false);
|
||||
}
|
||||
// uninitialized BResources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
// int32 type
|
||||
@ -819,7 +819,7 @@ ResourcesTest::ReadTest()
|
||||
|
||||
// 3. the index versions of GetResourceInfo()
|
||||
// index only
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -852,7 +852,7 @@ ResourcesTest::ReadTest()
|
||||
&name, &length) == false );
|
||||
}
|
||||
// type and index
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(x86ResFile, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -892,7 +892,7 @@ ResourcesTest::ReadTest()
|
||||
|
||||
// 4. error cases
|
||||
// non-resource file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(noResFile, B_READ_ONLY);
|
||||
@ -902,7 +902,7 @@ ResourcesTest::ReadTest()
|
||||
ReadBadResTest(resources, testResource1);
|
||||
}
|
||||
// uninitialized file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file;
|
||||
@ -911,7 +911,7 @@ ResourcesTest::ReadTest()
|
||||
ReadBadResTest(resources, testResource1);
|
||||
}
|
||||
// badly initialized file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file(noSuchFile, B_READ_ONLY);
|
||||
@ -920,7 +920,7 @@ ResourcesTest::ReadTest()
|
||||
ReadBadResTest(resources, testResource1);
|
||||
}
|
||||
// NULL file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
// R5: A NULL file is B_OK!
|
||||
@ -929,7 +929,7 @@ ResourcesTest::ReadTest()
|
||||
ReadBadResTest(resources, testResource1);
|
||||
}
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1087,7 +1087,7 @@ void
|
||||
ResourcesTest::SyncTest()
|
||||
{
|
||||
// Sync() is not easy to test. We just check its return value for now.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
execCommand(string("cp ") + x86ResFile + " " + testFile1);
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE);
|
||||
@ -1108,7 +1108,7 @@ ResourcesTest::SyncTest()
|
||||
}
|
||||
// error cases
|
||||
// read only file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1117,13 +1117,13 @@ ResourcesTest::SyncTest()
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_NOT_ALLOWED );
|
||||
}
|
||||
// uninitialized BResources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
CPPUNIT_ASSERT( resources.Sync() == B_NO_INIT );
|
||||
}
|
||||
// badly initialized BResources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(noSuchFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
@ -1138,7 +1138,7 @@ void
|
||||
ResourcesTest::MergeTest()
|
||||
{
|
||||
// empty file, merge with resources from another file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1154,7 +1154,7 @@ ResourcesTest::MergeTest()
|
||||
}
|
||||
// empty file, add some resources first and then merge with resources
|
||||
// from another file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1175,7 +1175,7 @@ ResourcesTest::MergeTest()
|
||||
}
|
||||
// error cases
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1186,13 +1186,13 @@ ResourcesTest::MergeTest()
|
||||
CPPUNIT_ASSERT( resources.MergeFrom(&file2) == B_IO_ERROR );
|
||||
// NULL file
|
||||
// R5: crashs
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CPPUNIT_ASSERT( resources.MergeFrom(NULL) == B_BAD_VALUE );
|
||||
#endif
|
||||
}
|
||||
// uninitialized BResources
|
||||
// R5: returns B_OK!
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
BFile file2(x86ResFile, B_READ_ONLY);
|
||||
@ -1200,7 +1200,7 @@ ResourcesTest::MergeTest()
|
||||
}
|
||||
// badly initialized BResources
|
||||
// R5: returns B_OK!
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(noSuchFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
@ -1216,7 +1216,7 @@ void
|
||||
ResourcesTest::WriteToTest()
|
||||
{
|
||||
// take a file with resources and write them to an empty file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1229,7 +1229,7 @@ ResourcesTest::WriteToTest()
|
||||
}
|
||||
// take a file with resources and write them to an non-empty non-resource
|
||||
// file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1241,7 +1241,7 @@ ResourcesTest::WriteToTest()
|
||||
CPPUNIT_ASSERT( resources.File() == file2 );
|
||||
}
|
||||
// take a file with resources and write them to an ELF file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
execCommand(string("cp ") + elfNoResFile + " " + testFile1);
|
||||
{
|
||||
BFile file(x86ResFile, B_READ_ONLY);
|
||||
@ -1254,7 +1254,7 @@ ResourcesTest::WriteToTest()
|
||||
CPPUNIT_ASSERT( resources.File() == file2 );
|
||||
}
|
||||
// empty file, add a resource, write it to another file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile2, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1274,7 +1274,7 @@ ResourcesTest::WriteToTest()
|
||||
CPPUNIT_ASSERT( fileSize == 0 );
|
||||
}
|
||||
// uninitialized BResources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
execCommand(string("cp ") + elfNoResFile + " " + testFile1);
|
||||
{
|
||||
BResources resources;
|
||||
@ -1285,13 +1285,13 @@ ResourcesTest::WriteToTest()
|
||||
}
|
||||
// bad args: NULL file
|
||||
// R5: crashs
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile2, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
BResources resources;
|
||||
CPPUNIT_ASSERT( resources.SetTo(&file, false) == B_OK );
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CPPUNIT_ASSERT( resources.WriteTo(NULL) == B_BAD_VALUE);
|
||||
#endif
|
||||
}
|
||||
@ -1309,7 +1309,7 @@ ResourcesTest::AddRemoveTest()
|
||||
// Start with an empty file, add all the resources of our x86 resource
|
||||
// file and compare the two bytewise.
|
||||
// This does of course only work on x86 machines.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1328,7 +1328,7 @@ ResourcesTest::AddRemoveTest()
|
||||
}
|
||||
// Now remove all resources and compare the file with an empty resource
|
||||
// file.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1353,7 +1353,7 @@ ResourcesTest::AddRemoveTest()
|
||||
CompareFiles(file1, file2);
|
||||
}
|
||||
// Same file, use the other remove version.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
execCommand(string("cp ") + x86ResFile + " " + testFile1);
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE);
|
||||
@ -1379,7 +1379,7 @@ ResourcesTest::AddRemoveTest()
|
||||
CompareFiles(file1, file2);
|
||||
}
|
||||
// some arbitrary adding and removing...
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1401,7 +1401,7 @@ ResourcesTest::AddRemoveTest()
|
||||
RemoveResource(resources, resourceSet, testResource4, false);
|
||||
}
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1414,7 +1414,7 @@ ResourcesTest::AddRemoveTest()
|
||||
"Hey!") == B_BAD_VALUE );
|
||||
}
|
||||
// uninitialized BResources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
const ResourceInfo &info = testResource1;
|
||||
@ -1431,7 +1431,7 @@ ResourcesTest::ReadWriteTest()
|
||||
// ReadResource() has already been tested in ReadTest(). Thus we focus on
|
||||
// WriteResource().
|
||||
// Open a file and write a little bit into one of its resources.
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
execCommand(string("cp ") + x86ResFile + " " + testFile1);
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE);
|
||||
@ -1498,7 +1498,7 @@ ResourcesTest::ReadWriteTest()
|
||||
}
|
||||
// error cases
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BFile file(testFile1, B_READ_WRITE);
|
||||
CPPUNIT_ASSERT( file.InitCheck() == B_OK );
|
||||
@ -1517,7 +1517,7 @@ ResourcesTest::ReadWriteTest()
|
||||
== B_BAD_VALUE );
|
||||
}
|
||||
// uninitialized BResources
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BResources resources;
|
||||
const ResourceInfo &info = testResource1;
|
||||
@ -1529,3 +1529,7 @@ ResourcesTest::ReadWriteTest()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -37,3 +37,7 @@ public:
|
||||
|
||||
|
||||
#endif // __sk_resources_test_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,17 +2,33 @@
|
||||
#include <TestSuiteAddon.h>
|
||||
|
||||
// ##### Include headers for your tests here #####
|
||||
#include <DirectoryTest.h>
|
||||
#include <NodeTest.h>
|
||||
#include <PathTest.h>
|
||||
#include "DirectoryTest.h"
|
||||
#include "EntryTest.h"
|
||||
#include "FileTest.h"
|
||||
#include "FindDirectoryTest.h"
|
||||
#include "MimeTypeTest.h"
|
||||
#include "NodeTest.h"
|
||||
#include "PathTest.h"
|
||||
#include "QueryTest.h"
|
||||
#include "ResourcesTest.h"
|
||||
#include "ResourceStringsTest.h"
|
||||
#include "SymLinkTest.h"
|
||||
|
||||
BTestSuite* getTestSuite() {
|
||||
BTestSuite *suite = new BTestSuite("Storage");
|
||||
|
||||
// ##### Add test suites for statically linked tests here #####
|
||||
// ##### Add test suites here #####
|
||||
suite->addTest("BDirectory", DirectoryTest::Suite());
|
||||
suite->addTest("BEntry", EntryTest::Suite());
|
||||
suite->addTest("BFile", FileTest::Suite());
|
||||
suite->addTest("BMimeType", MimeTypeTest::Suite());
|
||||
suite->addTest("BNode", NodeTest::Suite());
|
||||
suite->addTest("BPath", PathTest::Suite());
|
||||
suite->addTest("BQuery", QueryTest::Suite());
|
||||
suite->addTest("BResources", ResourcesTest::Suite());
|
||||
suite->addTest("BResourceStrings", ResourceStringsTest::Suite());
|
||||
suite->addTest("BSymLink", SymLinkTest::Suite());
|
||||
suite->addTest("FindDirectory", FindDirectoryTest::Suite());
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <Path.h>
|
||||
#include <SymLink.h>
|
||||
|
||||
#include "StorageKitTester.h"
|
||||
#include "SymLinkTest.h"
|
||||
|
||||
// Suite
|
||||
@ -102,76 +101,76 @@ SymLinkTest::InitTest1()
|
||||
const char *nonExistingSuper = nonExistingSuperDirname;
|
||||
const char *nonExistingRel = nonExistingRelDirname;
|
||||
// 1. default constructor
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link;
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NO_INIT );
|
||||
}
|
||||
|
||||
// 2. BSymLink(const char*)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(fileLink);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(nonExisting);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link((const char *)NULL);
|
||||
CPPUNIT_ASSERT( equals(link.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link("");
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(existingFile);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(existingDir);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(tooLongEntryname);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NAME_TOO_LONG );
|
||||
}
|
||||
|
||||
// 3. BSymLink(const BEntry*)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(dirLink);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
BSymLink link(&entry);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(nonExisting);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
BSymLink link(&entry);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link((BEntry *)NULL);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry;
|
||||
BSymLink link(&entry);
|
||||
CPPUNIT_ASSERT( equals(link.InitCheck(), B_BAD_ADDRESS, B_BAD_VALUE) );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(existingFile);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
@ -179,7 +178,7 @@ SymLinkTest::InitTest1()
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(existingDir);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
@ -187,7 +186,7 @@ SymLinkTest::InitTest1()
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(tooLongEntryname);
|
||||
// R5 returns E2BIG instead of B_NAME_TOO_LONG
|
||||
@ -197,7 +196,7 @@ SymLinkTest::InitTest1()
|
||||
}
|
||||
|
||||
// 4. BSymLink(const entry_ref*)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(dirLink);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
@ -206,7 +205,7 @@ SymLinkTest::InitTest1()
|
||||
BSymLink link(&ref);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(nonExisting);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
@ -215,12 +214,12 @@ SymLinkTest::InitTest1()
|
||||
BSymLink link(&ref);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link((entry_ref *)NULL);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(existingFile);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
@ -229,7 +228,7 @@ SymLinkTest::InitTest1()
|
||||
BSymLink link(&ref);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BEntry entry(existingDir);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
@ -240,73 +239,73 @@ SymLinkTest::InitTest1()
|
||||
}
|
||||
|
||||
// 5. BSymLink(const BDirectory*, const char*)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(dirSuperLink);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
BSymLink link(&pathDir, dirRelLink);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(dirSuperLink);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
BSymLink link(&pathDir, dirLink);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(nonExistingSuper);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
BSymLink link(&pathDir, nonExistingRel);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link((BDirectory *)NULL, (const char *)NULL);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link((BDirectory *)NULL, dirLink);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(dirSuperLink);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
BSymLink link(&pathDir, (const char *)NULL);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(dirSuperLink);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
BSymLink link(&pathDir, "");
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(existingSuperFile);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
BSymLink link(&pathDir, existingRelFile);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(existingSuperDir);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
BSymLink link(&pathDir, existingRelDir);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(tooLongSuperEntryname);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
BSymLink link(&pathDir, tooLongRelEntryname);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NAME_TOO_LONG );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BDirectory pathDir(fileSuperDirname);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
@ -334,68 +333,68 @@ SymLinkTest::InitTest2()
|
||||
const char *nonExistingRel = nonExistingRelDirname;
|
||||
BSymLink link;
|
||||
// 2. BSymLink(const char*)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(fileLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(nonExisting) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( equals(link.SetTo((const char *)NULL), B_BAD_VALUE,
|
||||
B_NO_INIT) );
|
||||
CPPUNIT_ASSERT( equals(link.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo("") == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(existingFile) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(existingDir) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(tooLongEntryname) == B_NAME_TOO_LONG );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NAME_TOO_LONG );
|
||||
|
||||
// 3. BSymLink(const BEntry*)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BEntry entry(dirLink);
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&entry) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(nonExisting) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&entry) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo((BEntry *)NULL) == B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
entry.Unset();
|
||||
CPPUNIT_ASSERT( entry.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( equals(link.SetTo(&entry), B_BAD_ADDRESS, B_BAD_VALUE) );
|
||||
CPPUNIT_ASSERT( equals(link.InitCheck(), B_BAD_ADDRESS, B_BAD_VALUE) );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(existingFile) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&entry) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(existingDir) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&entry) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
// R5 returns E2BIG instead of B_NAME_TOO_LONG
|
||||
CPPUNIT_ASSERT( equals(entry.SetTo(tooLongEntryname), E2BIG,
|
||||
B_NAME_TOO_LONG) );
|
||||
@ -403,88 +402,88 @@ SymLinkTest::InitTest2()
|
||||
CPPUNIT_ASSERT( equals(link.InitCheck(), B_BAD_ADDRESS, B_BAD_VALUE) );
|
||||
|
||||
// 4. BSymLink(const entry_ref*)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(dirLink) == B_OK );
|
||||
entry_ref ref;
|
||||
CPPUNIT_ASSERT( entry.GetRef(&ref) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&ref) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(nonExisting) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetRef(&ref) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&ref) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo((entry_ref *)NULL) == B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(existingFile) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetRef(&ref) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&ref) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(existingDir) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetRef(&ref) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&ref) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
|
||||
// 5. BSymLink(const BDirectory*, const char*)
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BDirectory pathDir(dirSuperLink);
|
||||
CPPUNIT_ASSERT( pathDir.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, dirRelLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( pathDir.SetTo(dirSuperLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, dirLink) == B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( pathDir.SetTo(nonExistingSuper) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, nonExistingRel) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo((BDirectory *)NULL, (const char *)NULL)
|
||||
== B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo((BDirectory *)NULL, dirLink) == B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( pathDir.SetTo(dirSuperLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, (const char *)NULL) == B_BAD_VALUE );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_BAD_VALUE );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( pathDir.SetTo(dirSuperLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, "") == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( pathDir.SetTo(existingSuperFile) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, existingRelFile) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( pathDir.SetTo(existingSuperDir) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, existingRelDir) == B_OK );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( pathDir.SetTo(tooLongSuperEntryname) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, tooLongRelEntryname)
|
||||
== B_NAME_TOO_LONG );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NAME_TOO_LONG );
|
||||
//
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( pathDir.SetTo(fileSuperDirname) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(&pathDir, fileRelDirname) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_ENTRY_NOT_FOUND );
|
||||
@ -506,59 +505,59 @@ SymLinkTest::ReadLinkTest()
|
||||
char buffer[B_PATH_NAME_LENGTH + 1];
|
||||
// uninitialized
|
||||
// R5: returns B_BAD_ADDRESS instead of (as doc'ed) B_FILE_ERROR
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( equals(link.ReadLink(buffer, sizeof(buffer)),
|
||||
B_BAD_ADDRESS, B_FILE_ERROR) );
|
||||
// existing dir link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.ReadLink(buffer, sizeof(buffer))
|
||||
== (ssize_t)strlen(existingDir) );
|
||||
CPPUNIT_ASSERT( strcmp(buffer, existingDir) == 0 );
|
||||
// existing file link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(fileLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.ReadLink(buffer, sizeof(buffer))
|
||||
== (ssize_t)strlen(existingFile) );
|
||||
CPPUNIT_ASSERT( strcmp(buffer, existingFile) == 0 );
|
||||
// existing cyclic link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(cyclicLink1) == B_OK );
|
||||
CPPUNIT_ASSERT( link.ReadLink(buffer, sizeof(buffer))
|
||||
== (ssize_t)strlen(cyclicLink2) );
|
||||
CPPUNIT_ASSERT( strcmp(buffer, cyclicLink2) == 0 );
|
||||
// existing link to non-existing entry
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(badLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.ReadLink(buffer, sizeof(buffer))
|
||||
== (ssize_t)strlen(nonExisting) );
|
||||
CPPUNIT_ASSERT( strcmp(buffer, nonExisting) == 0 );
|
||||
// non-existing link
|
||||
// R5: returns B_BAD_ADDRESS instead of (as doc'ed) B_FILE_ERROR
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(nonExisting) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( equals(link.ReadLink(buffer, sizeof(buffer)),
|
||||
B_BAD_ADDRESS, B_FILE_ERROR) );
|
||||
// dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(existingDir) == B_OK );
|
||||
CPPUNIT_ASSERT( link.ReadLink(buffer, sizeof(buffer)) == B_BAD_VALUE );
|
||||
// file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(existingFile) == B_OK );
|
||||
CPPUNIT_ASSERT( link.ReadLink(buffer, sizeof(buffer)) == B_BAD_VALUE );
|
||||
// small buffer
|
||||
// R5: returns the size of the contents, not the number of bytes copied
|
||||
// OBOS: ... so do we
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
char smallBuffer[2];
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.ReadLink(smallBuffer, sizeof(smallBuffer))
|
||||
== (ssize_t)strlen(dirLink) );
|
||||
CPPUNIT_ASSERT( strncmp(smallBuffer, existingDir, sizeof(smallBuffer)) == 0 );
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(fileLink) == B_OK );
|
||||
CPPUNIT_ASSERT( equals(link.ReadLink(NULL, sizeof(buffer)), B_BAD_ADDRESS,
|
||||
B_BAD_VALUE) );
|
||||
@ -583,14 +582,14 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
BPath path;
|
||||
// 1. MakeLinkedPath(const char*, BPath*)
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( equals(link.MakeLinkedPath("/boot", &path), B_BAD_ADDRESS,
|
||||
B_FILE_ERROR) );
|
||||
link.Unset();
|
||||
path.Unset();
|
||||
// existing absolute dir link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath("/boot", &path)
|
||||
== (ssize_t)strlen(existingDir) );
|
||||
@ -599,7 +598,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
link.Unset();
|
||||
path.Unset();
|
||||
// existing absolute file link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(fileLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath("/boot", &path)
|
||||
== (ssize_t)strlen(existingFile) );
|
||||
@ -608,7 +607,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
link.Unset();
|
||||
path.Unset();
|
||||
// existing absolute cyclic link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(cyclicLink1) == B_OK );
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath("/boot", &path)
|
||||
== (ssize_t)strlen(cyclicLink2) );
|
||||
@ -617,7 +616,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
link.Unset();
|
||||
path.Unset();
|
||||
// existing relative dir link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
BEntry entry;
|
||||
BPath entryPath;
|
||||
CPPUNIT_ASSERT( entry.SetTo(existingDir) == B_OK );
|
||||
@ -632,7 +631,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
entry.Unset();
|
||||
entryPath.Unset();
|
||||
// existing relative file link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(existingFile) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetPath(&entryPath) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(relFileLink) == B_OK );
|
||||
@ -645,16 +644,16 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
entry.Unset();
|
||||
entryPath.Unset();
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
// R5: crashs, when passing a NULL path
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath("/boot", NULL) == B_BAD_VALUE );
|
||||
#endif
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath((const char*)NULL, &path)
|
||||
== B_BAD_VALUE );
|
||||
// R5: crashs, when passing a NULL path
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath((const char*)NULL, NULL)
|
||||
== B_BAD_VALUE );
|
||||
#endif
|
||||
@ -663,7 +662,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
|
||||
// 2. MakeLinkedPath(const BDirectory*, BPath*)
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
link.Unset();
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NO_INIT );
|
||||
BDirectory dir;
|
||||
@ -674,7 +673,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
path.Unset();
|
||||
dir.Unset();
|
||||
// existing absolute dir link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( dir.SetTo("/boot") == B_OK);
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath(&dir, &path)
|
||||
@ -685,7 +684,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
path.Unset();
|
||||
dir.Unset();
|
||||
// existing absolute file link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(fileLink) == B_OK );
|
||||
CPPUNIT_ASSERT( dir.SetTo("/boot") == B_OK);
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath(&dir, &path)
|
||||
@ -696,7 +695,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
path.Unset();
|
||||
dir.Unset();
|
||||
// existing absolute cyclic link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(cyclicLink1) == B_OK );
|
||||
CPPUNIT_ASSERT( dir.SetTo("/boot") == B_OK);
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath(&dir, &path)
|
||||
@ -707,7 +706,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
path.Unset();
|
||||
dir.Unset();
|
||||
// existing relative dir link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(existingDir) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetPath(&entryPath) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(relDirLink) == B_OK );
|
||||
@ -722,7 +721,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
entry.Unset();
|
||||
entryPath.Unset();
|
||||
// existing relative file link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( entry.SetTo(existingFile) == B_OK );
|
||||
CPPUNIT_ASSERT( entry.GetPath(&entryPath) == B_OK );
|
||||
CPPUNIT_ASSERT( link.SetTo(relFileLink) == B_OK );
|
||||
@ -737,7 +736,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
entry.Unset();
|
||||
entryPath.Unset();
|
||||
// absolute link, uninitialized dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( dir.InitCheck() == B_NO_INIT);
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath(&dir, &path)
|
||||
@ -745,7 +744,7 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
CPPUNIT_ASSERT( path.InitCheck() == B_OK );
|
||||
CPPUNIT_ASSERT( string(existingDir) == path.Path() );
|
||||
// absolute link, badly initialized dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( dir.SetTo(nonExisting) == B_ENTRY_NOT_FOUND);
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath(&dir, &path)
|
||||
@ -756,14 +755,14 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
path.Unset();
|
||||
dir.Unset();
|
||||
// relative link, uninitialized dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(relDirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( dir.InitCheck() == B_NO_INIT);
|
||||
CPPUNIT_ASSERT( equals(link.MakeLinkedPath(&dir, &path), B_NO_INIT,
|
||||
B_BAD_VALUE) );
|
||||
link.Unset();
|
||||
// relative link, badly initialized dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(relDirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( dir.SetTo(nonExisting) == B_ENTRY_NOT_FOUND);
|
||||
CPPUNIT_ASSERT( equals(link.MakeLinkedPath(&dir, &path), B_NO_INIT,
|
||||
@ -772,18 +771,18 @@ SymLinkTest::MakeLinkedPathTest()
|
||||
path.Unset();
|
||||
dir.Unset();
|
||||
// bad args
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( dir.SetTo("/boot") == B_OK);
|
||||
// R5: crashs, when passing a NULL path
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath(&dir, NULL) == B_BAD_VALUE );
|
||||
#endif
|
||||
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath((const BDirectory*)NULL, &path)
|
||||
== B_BAD_VALUE );
|
||||
// R5: crashs, when passing a NULL path
|
||||
#if !SK_TEST_R5
|
||||
#if !TEST_R5
|
||||
CPPUNIT_ASSERT( link.MakeLinkedPath((const BDirectory*)NULL, NULL)
|
||||
== B_BAD_VALUE );
|
||||
#endif
|
||||
@ -803,32 +802,32 @@ SymLinkTest::IsAbsoluteTest()
|
||||
const char *nonExisting = nonExistingDirname;
|
||||
BSymLink link;
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NO_INIT );
|
||||
CPPUNIT_ASSERT( link.IsAbsolute() == false );
|
||||
link.Unset();
|
||||
// existing absolute dir link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(dirLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.IsAbsolute() == true );
|
||||
link.Unset();
|
||||
// existing relative file link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(relFileLink) == B_OK );
|
||||
CPPUNIT_ASSERT( link.IsAbsolute() == false );
|
||||
link.Unset();
|
||||
// non-existing link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(nonExisting) == B_ENTRY_NOT_FOUND );
|
||||
CPPUNIT_ASSERT( link.IsAbsolute() == false );
|
||||
link.Unset();
|
||||
// dir
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(existingDir) == B_OK );
|
||||
CPPUNIT_ASSERT( link.IsAbsolute() == false );
|
||||
link.Unset();
|
||||
// file
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT( link.SetTo(existingFile) == B_OK );
|
||||
CPPUNIT_ASSERT( link.IsAbsolute() == false );
|
||||
link.Unset();
|
||||
@ -842,7 +841,7 @@ SymLinkTest::AssignmentTest()
|
||||
const char *fileLink = fileLinkname;
|
||||
// 1. copy constructor
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link;
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_NO_INIT );
|
||||
@ -851,7 +850,7 @@ SymLinkTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( equals(link2.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
}
|
||||
// existing dir link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(dirLink);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
@ -859,7 +858,7 @@ SymLinkTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( link2.InitCheck() == B_OK );
|
||||
}
|
||||
// existing file link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(fileLink);
|
||||
CPPUNIT_ASSERT( link.InitCheck() == B_OK );
|
||||
@ -869,7 +868,7 @@ SymLinkTest::AssignmentTest()
|
||||
|
||||
// 2. assignment operator
|
||||
// uninitialized
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link;
|
||||
BSymLink link2;
|
||||
@ -877,7 +876,7 @@ SymLinkTest::AssignmentTest()
|
||||
// R5 returns B_BAD_VALUE instead of B_NO_INIT
|
||||
CPPUNIT_ASSERT( equals(link2.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
}
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link;
|
||||
BSymLink link2(dirLink);
|
||||
@ -886,7 +885,7 @@ SymLinkTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( equals(link2.InitCheck(), B_BAD_VALUE, B_NO_INIT) );
|
||||
}
|
||||
// existing dir link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(dirLink);
|
||||
BSymLink link2;
|
||||
@ -894,7 +893,7 @@ SymLinkTest::AssignmentTest()
|
||||
CPPUNIT_ASSERT( link2.InitCheck() == B_OK );
|
||||
}
|
||||
// existing file link
|
||||
nextSubTest();
|
||||
NextSubTest();
|
||||
{
|
||||
BSymLink link(fileLink);
|
||||
BSymLink link2;
|
||||
@ -904,3 +903,7 @@ SymLinkTest::AssignmentTest()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -36,3 +36,7 @@ public:
|
||||
};
|
||||
|
||||
#endif // __sk_sym_link_test_h__
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -15,10 +15,12 @@ rule CppUnitLibrary
|
||||
|
||||
CppUnitLibrary
|
||||
SemaphoreSyncObject.cpp
|
||||
TestApp.cpp
|
||||
TestCase.cpp
|
||||
TestListener.cpp
|
||||
TestShell.cpp
|
||||
TestSuite.cpp
|
||||
TestUtils.cpp
|
||||
ThreadedTestCase.cpp
|
||||
cppunit/Asserter.cpp
|
||||
cppunit/CompilerOutputter.cpp
|
||||
|
89
src/tools/cppunit/TestApp.cpp
Normal file
89
src/tools/cppunit/TestApp.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
// TestApp.cpp
|
||||
|
||||
#include <TestApp.h>
|
||||
|
||||
// TestHandler
|
||||
|
||||
// MessageReceived
|
||||
void
|
||||
TestHandler::MessageReceived(BMessage *message)
|
||||
{
|
||||
// clone and push it
|
||||
BMessage *clone = new BMessage(*message);
|
||||
fQueue.Lock();
|
||||
fQueue.AddMessage(clone);
|
||||
fQueue.Unlock();
|
||||
}
|
||||
|
||||
// Queue
|
||||
BMessageQueue &
|
||||
TestHandler::Queue()
|
||||
{
|
||||
return fQueue;
|
||||
}
|
||||
|
||||
|
||||
// TestApp
|
||||
|
||||
// constructor
|
||||
TestApp::TestApp(const char *signature)
|
||||
: BApplication(signature),
|
||||
fAppThread(B_ERROR),
|
||||
fHandler()
|
||||
{
|
||||
AddHandler(&fHandler);
|
||||
Unlock();
|
||||
}
|
||||
|
||||
// Init
|
||||
status_t
|
||||
TestApp::Init()
|
||||
{
|
||||
status_t error = B_OK;
|
||||
fAppThread = spawn_thread(&_AppThreadStart, "query app",
|
||||
B_NORMAL_PRIORITY, this);
|
||||
if (fAppThread < 0)
|
||||
error = fAppThread;
|
||||
else {
|
||||
error = resume_thread(fAppThread);
|
||||
if (error != B_OK)
|
||||
kill_thread(fAppThread);
|
||||
}
|
||||
if (error != B_OK)
|
||||
fAppThread = B_ERROR;
|
||||
return error;
|
||||
}
|
||||
|
||||
// Terminate
|
||||
void
|
||||
TestApp::Terminate()
|
||||
{
|
||||
PostMessage(B_QUIT_REQUESTED, this);
|
||||
int32 result;
|
||||
wait_for_thread(fAppThread, &result);
|
||||
}
|
||||
|
||||
// ReadyToRun
|
||||
void
|
||||
TestApp::ReadyToRun()
|
||||
{
|
||||
}
|
||||
|
||||
// Handler
|
||||
TestHandler &
|
||||
TestApp::Handler()
|
||||
{
|
||||
return fHandler;
|
||||
}
|
||||
|
||||
// _AppThreadStart
|
||||
int32
|
||||
TestApp::_AppThreadStart(void *data)
|
||||
{
|
||||
if (TestApp *app = (TestApp*)data) {
|
||||
app->Lock();
|
||||
app->Run();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ BTestCase::tearDown() {
|
||||
|
||||
void
|
||||
BTestCase::NextSubTest() {
|
||||
if (BeVerbose()) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
printf("[%ld]", fSubTestNum++);
|
||||
fflush(stdout);
|
||||
}
|
||||
@ -26,13 +26,13 @@ BTestCase::NextSubTest() {
|
||||
|
||||
void
|
||||
BTestCase::NextSubTestBlock() {
|
||||
if (BeVerbose())
|
||||
if (BTestShell::GlobalBeVerbose())
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void
|
||||
BTestCase::Outputf(const char *str, ...) {
|
||||
if (BeVerbose()) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
va_list args;
|
||||
va_start(args, str);
|
||||
vprintf(str, args);
|
||||
@ -60,8 +60,3 @@ BTestCase::RestoreCWD(const char *alternate) {
|
||||
chdir(alternate);
|
||||
}
|
||||
|
||||
bool
|
||||
BTestCase::BeVerbose() {
|
||||
BTestShell *shell = BTestShell::Shell();
|
||||
return ((shell && shell->BeVerbose()) || !shell);
|
||||
}
|
||||
|
@ -23,9 +23,15 @@ BTestShell::BTestShell(const std::string &description, SyncObject *syncObject)
|
||||
, fDescription(description)
|
||||
, fTestResults(syncObject)
|
||||
, fListTestsAndExit(false)
|
||||
, fTestDir(NULL)
|
||||
{
|
||||
};
|
||||
|
||||
BTestShell::~BTestShell() {
|
||||
delete fTestDir;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BTestShell::AddSuite(BTestSuite *suite) {
|
||||
if (suite) {
|
||||
@ -95,6 +101,9 @@ BTestShell::LoadSuitesFrom(BDirectory *libDir) {
|
||||
|
||||
int
|
||||
BTestShell::Run(int argc, char *argv[]) {
|
||||
// Make note of which directory we started in
|
||||
UpdateTestDir(argv);
|
||||
|
||||
// Parse the command line args
|
||||
if (!ProcessArguments(argc, argv))
|
||||
return 0;
|
||||
@ -154,6 +163,11 @@ BTestShell::Verbosity() const {
|
||||
return fVerbosityLevel;
|
||||
}
|
||||
|
||||
const char*
|
||||
BTestShell::TestDir() const {
|
||||
return (fTestDir ? fTestDir->Path() : NULL);
|
||||
}
|
||||
|
||||
void
|
||||
BTestShell::PrintDescription(int argc, char *argv[]) {
|
||||
cout << endl << fDescription;
|
||||
@ -253,8 +267,8 @@ BTestShell::InitOutput() {
|
||||
cout << "Tests" << endl;
|
||||
cout << "------------------------------------------------------------------------------" << endl;
|
||||
fTestResults.addListener(new BTestListener);
|
||||
fTestResults.addListener(&fResultsCollector);
|
||||
}
|
||||
fTestResults.addListener(&fResultsCollector);
|
||||
}
|
||||
|
||||
void
|
||||
@ -319,3 +333,16 @@ BTestShell::LoadDynamicSuites() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BTestShell::UpdateTestDir(char *argv[]) {
|
||||
BPath path(argv[0]);
|
||||
if (path.InitCheck() == B_OK) {
|
||||
delete fTestDir;
|
||||
fTestDir = new BPath();
|
||||
if (path.GetParent(fTestDir) != B_OK)
|
||||
cout << "Couldn't get test dir." << endl;
|
||||
} else
|
||||
cout << "Couldn't find the path to the test app." << endl;
|
||||
}
|
||||
|
||||
|
199
src/tools/cppunit/TestUtils.cpp
Normal file
199
src/tools/cppunit/TestUtils.cpp
Normal file
@ -0,0 +1,199 @@
|
||||
// TestUtils.cpp
|
||||
|
||||
#include <TestUtils.h>
|
||||
#include <TestShell.h>
|
||||
|
||||
status_t DecodeResult(status_t result) {
|
||||
if (!BTestShell::GlobalBeVerbose())
|
||||
return result;
|
||||
|
||||
std::string str;
|
||||
switch (result) {
|
||||
|
||||
case B_OK:
|
||||
str = "B_OK";
|
||||
break;
|
||||
|
||||
case B_ERROR:
|
||||
str = "B_ERROR";
|
||||
break;
|
||||
|
||||
|
||||
// Storage Kit Errors
|
||||
case B_FILE_ERROR:
|
||||
str = "B_FILE_ERROR";
|
||||
break;
|
||||
|
||||
case B_FILE_NOT_FOUND:
|
||||
str = "B_FILE_NOT_FOUND";
|
||||
break;
|
||||
|
||||
case B_FILE_EXISTS:
|
||||
str = "B_FILE_EXISTS";
|
||||
break;
|
||||
|
||||
case B_ENTRY_NOT_FOUND:
|
||||
str = "B_ENTRY_NOT_FOUND";
|
||||
break;
|
||||
|
||||
case B_NAME_TOO_LONG:
|
||||
str = "B_NAME_TOO_LONG";
|
||||
break;
|
||||
|
||||
case B_DIRECTORY_NOT_EMPTY:
|
||||
str = "B_DIRECTORY_NOT_EMPTY";
|
||||
break;
|
||||
|
||||
case B_DEVICE_FULL:
|
||||
str = "B_DEVICE_FULL";
|
||||
break;
|
||||
|
||||
case B_READ_ONLY_DEVICE:
|
||||
str = "B_READ_ONLY_DEVICE";
|
||||
break;
|
||||
|
||||
case B_IS_A_DIRECTORY:
|
||||
str = "B_IS_A_DIRECTORY";
|
||||
break;
|
||||
|
||||
case B_NO_MORE_FDS:
|
||||
str = "B_NO_MORE_FDS";
|
||||
break;
|
||||
|
||||
case B_CROSS_DEVICE_LINK:
|
||||
str = "B_CROSS_DEVICE_LINK";
|
||||
break;
|
||||
|
||||
case B_LINK_LIMIT:
|
||||
str = "B_LINK_LIMIT";
|
||||
break;
|
||||
|
||||
case B_BUSTED_PIPE:
|
||||
str = "B_BUSTED_PIPE";
|
||||
break;
|
||||
|
||||
case B_UNSUPPORTED:
|
||||
str = "B_UNSUPPORTED";
|
||||
break;
|
||||
|
||||
case B_PARTITION_TOO_SMALL:
|
||||
str = "B_PARTITION_TOO_SMALL";
|
||||
break;
|
||||
|
||||
|
||||
// General Errors
|
||||
case B_NO_MEMORY:
|
||||
str = "B_NO_MEMORY";
|
||||
break;
|
||||
|
||||
case B_IO_ERROR:
|
||||
str = "B_IO_ERROR";
|
||||
break;
|
||||
|
||||
case B_PERMISSION_DENIED:
|
||||
str = "B_PERMISSION_DENIED";
|
||||
break;
|
||||
|
||||
case B_BAD_INDEX:
|
||||
str = "B_BAD_INDEX";
|
||||
break;
|
||||
|
||||
case B_BAD_TYPE:
|
||||
str = "B_BAD_TYPE";
|
||||
break;
|
||||
|
||||
case B_BAD_VALUE:
|
||||
str = "B_BAD_VALUE";
|
||||
break;
|
||||
|
||||
case B_MISMATCHED_VALUES:
|
||||
str = "B_MISMATCHED_VALUES";
|
||||
break;
|
||||
|
||||
case B_NAME_NOT_FOUND:
|
||||
str = "B_NAME_NOT_FOUND";
|
||||
break;
|
||||
|
||||
case B_NAME_IN_USE:
|
||||
str = "B_NAME_IN_USE";
|
||||
break;
|
||||
|
||||
case B_TIMED_OUT:
|
||||
str = "B_TIMED_OUT";
|
||||
break;
|
||||
|
||||
case B_INTERRUPTED:
|
||||
str = "B_INTERRUPTED";
|
||||
break;
|
||||
|
||||
case B_WOULD_BLOCK:
|
||||
str = "B_WOULD_BLOCK";
|
||||
break;
|
||||
|
||||
case B_CANCELED:
|
||||
str = "B_CANCELED";
|
||||
break;
|
||||
|
||||
case B_NO_INIT:
|
||||
str = "B_NO_INIT";
|
||||
break;
|
||||
|
||||
case B_BUSY:
|
||||
str = "B_BUSY";
|
||||
break;
|
||||
|
||||
case B_NOT_ALLOWED:
|
||||
str = "B_NOT_ALLOWED";
|
||||
break;
|
||||
|
||||
|
||||
// Kernel Errors
|
||||
case B_BAD_ADDRESS:
|
||||
str = "B_BAD_ADDRESS";
|
||||
break;
|
||||
|
||||
// OS Errors
|
||||
case B_BAD_PORT_ID:
|
||||
str = "B_BAD_PORT_ID";
|
||||
break;
|
||||
|
||||
// Anything Else
|
||||
default:
|
||||
str = "??????????";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
cout << endl << "DecodeResult() -- " "0x" << hex << result << " (" << dec << result << ") == " << str << endl;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ExecCommand(const char *command) {
|
||||
if (command)
|
||||
system(command);
|
||||
}
|
||||
|
||||
void ExecCommand(const char *command, const char *parameter) {
|
||||
if (command && parameter) {
|
||||
char *cmdLine = new char[strlen(command) + strlen(parameter) + 1];
|
||||
strcpy(cmdLine, command);
|
||||
strcat(cmdLine, parameter);
|
||||
system(cmdLine);
|
||||
delete[] cmdLine;
|
||||
}
|
||||
}
|
||||
|
||||
void ExecCommand(const char *command, const char *parameter1,
|
||||
const char *parameter2) {
|
||||
if (command && parameter1 && parameter2) {
|
||||
char *cmdLine = new char[strlen(command) + strlen(parameter1)
|
||||
+ 1 + strlen(parameter2) + 1];
|
||||
strcpy(cmdLine, command);
|
||||
strcat(cmdLine, parameter1);
|
||||
strcat(cmdLine, " ");
|
||||
strcat(cmdLine, parameter2);
|
||||
system(cmdLine);
|
||||
delete[] cmdLine;
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#include <TestShell.h>
|
||||
#include <ThreadedTestCase.h>
|
||||
#include <Autolock.h>
|
||||
#include <stdio.h>
|
||||
@ -48,7 +49,7 @@ BThreadedTestCase::NextSubTest() {
|
||||
|
||||
void
|
||||
BThreadedTestCase::Outputf(const char *str, ...) {
|
||||
if (BeVerbose()) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
// Figure out if this is a multithreaded test or not
|
||||
thread_id id = find_thread(NULL);
|
||||
bool isSingleThreaded;
|
||||
|
Loading…
Reference in New Issue
Block a user