Пример #1
0
    void insertItem(const char* testFileName, const int expectedResult, 
                    const char* expectedOutName, const char* forceFileName = NULL) {

        FileData file = createFileData(testFileName);
        if (forceFileName) {
            WString wname;
            StringBuffer tmp(forceFileName);
            wname = tmp;
            file.setName(wname.c_str());
        }

        // Create a SyncItem containing the OMA file data
        SyncItem item(TEXT("test1"));
        char* data = file.format();
        item.setData(data, (long)strlen(data));
        delete [] data;

        int ret = fmss->insertItem(item);

        // TESTS
        CPPUNIT_ASSERT_MESSAGE("wrong status returned", ret == expectedResult);
        if (fmss->isErrorCode(ret)) {
            return;
        }
        StringBuffer outKey;
        outKey.convert(item.getKey());
        CPPUNIT_ASSERT_MESSAGE("wrong item's key returned", outKey == expectedOutName);

        StringBuffer outFile(outputDir);
        outFile.append(expectedOutName);
        CPPUNIT_ASSERT_MESSAGE("output file not found", fileExists(outFile.c_str()) );

        char* outContent = NULL;
        size_t outLen;
        readFile(outFile.c_str(), &outContent, &outLen, true);
        CPPUNIT_ASSERT( (int)outLen == file.getSize() );
        delete [] outContent;
    }
Пример #2
0
BOOL isSizeFilter::include(FileData &file) const
{
    return file.getSize() == size;
}