Exemple #1
0
    void TestSetFilename(void)
    {
        // Check that only file name is changed.
        m_path->SetFilename(L"new.file");
#if defined(WIN32)
        CPPUNIT_ASSERT(m_path->Get() == L"some\\path\\new.file");
#else
        CPPUNIT_ASSERT(m_path->Get() == L"some/path/new.file");
#endif
        m_path->SetFilename(L"");
        // Check that empty filename removes filename...
        CPPUNIT_ASSERT(m_path->GetFilename() == L"");
        // ...but not directory
#if defined(WIN32)
        CPPUNIT_ASSERT(m_path->GetDirectory() == L"some\\path\\");
#else
        CPPUNIT_ASSERT(m_path->GetDirectory() == L"some/path/");
#endif

        // Check correct exception thrown when adding folder separators in file name.
        SCXUNIT_RESET_ASSERTION();
        CPPUNIT_ASSERT_THROW(m_path->SetFilename(L"not/valid"), SCXCoreLib::SCXInvalidArgumentException);
        SCXUNIT_ASSERTIONS_FAILED(2); // both in append function and in SCXInvalidArgumentException constructor
        CPPUNIT_ASSERT_THROW(m_path->SetFilename(L"not\\valid"), SCXCoreLib::SCXInvalidArgumentException);
        SCXUNIT_ASSERTIONS_FAILED(2); // both in append function and in SCXInvalidArgumentException constructor
    }
Exemple #2
0
    void TestAssign(void)
    {
        SCXCoreLib::SCXFilePath fp = *m_path;

        // Check may assign to itself.
        CPPUNIT_ASSERT_NO_THROW(*m_path = *m_path);
        // Check content after assign operation is equal.
        CPPUNIT_ASSERT(fp.Get() == m_path->Get());
    }
Exemple #3
0
    void TestCompare(void)
    {
        SCXCoreLib::SCXFilePath fp1 = *m_path;
        SCXCoreLib::SCXFilePath fp2 = m_path->Get();
        SCXCoreLib::SCXFilePath fp3 = *m_directory;
        SCXCoreLib::SCXFilePath fp4 = *m_file;

        // Check compare operators to match content.
        CPPUNIT_ASSERT(fp1 == fp2);
        CPPUNIT_ASSERT(fp3 == *m_directory);
        CPPUNIT_ASSERT(fp4 == *m_file);
        CPPUNIT_ASSERT(fp1 != fp3);
        CPPUNIT_ASSERT(fp1 != fp4);
        CPPUNIT_ASSERT(fp3 != fp4);
    }
Exemple #4
0
    void TestAppendDirectory(void)
    {
        // Test appending to empty folder.
        m_file->AppendDirectory(L"/some\\append/");
        // Test appending folder without trailing folder separator.
        m_directory->AppendDirectory(L"some_append");
        // Test removing starting folder separators and adding trailing folder separator.
        m_path->AppendDirectory(L"/some/append");
#if defined(WIN32)
        CPPUNIT_ASSERT(m_file->Get() == L"\\some\\append\\file");
        CPPUNIT_ASSERT(m_directory->Get() == L"dir\\some_append\\");
        CPPUNIT_ASSERT(m_path->Get() == L"some\\path\\some\\append\\file.ext");
#else
        CPPUNIT_ASSERT(m_file->Get() == L"/some/append/file");
        CPPUNIT_ASSERT(m_directory->Get() == L"dir/some_append/");
        CPPUNIT_ASSERT(m_path->Get() == L"some/path/some/append/file.ext");
#endif
    }