Esempio n. 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
    }