void TestListNumBenchmarking::TestInsertedListItemShowsChangesToTheFollowingListNumbers() { ComparisonContext cContext; CStdString sOriginal = GET_TEST_FILE_PATH("SimpleList001.rtf"); CStdString sModified = GET_TEST_FILE_PATH("SimpleList002.rtf"); assertFileExists(sOriginal); assertFileExists(sModified); assertFileExists(TemplateFile); CStdString sRedline = CGeneral::GetTemporaryFileName(); assertMessage(!sRedline.IsEmpty(),_T("No temp file name - Did General Nuke it?")); CRtfDocumentChainBuilder rtfdcb; rtfdcb.m_Options.SetTemplate(TemplateFile); rtfdcb.m_Options.Flags.m_bWorkshareComparison = false; HRESULT hr = rtfdcb.PerformRTFComparison(AutoInputFileData4Tests(sOriginal), AutoInputFileData4Tests(sModified), AutoOutputFileData4Tests(sRedline), true); assertMessage(SUCCEEDED(hr), _T("Failed to compare the test documents")); assertMessage(rtfdcb.GetSummaryItemCount() == 2, _T("Expect 1 insert and 1 change")); rtfdcb.DeleteChains(); //Let's compare the files the other way around CRtfDocumentChainBuilder rtfdcb2; rtfdcb2.m_Options.SetTemplate(TemplateFile); rtfdcb2.m_Options.Flags.m_bWorkshareComparison = false; hr = rtfdcb2.PerformRTFComparison(AutoInputFileData4Tests(sModified), AutoInputFileData4Tests(sOriginal), AutoOutputFileData4Tests(sRedline), true); assertMessage(SUCCEEDED(hr), _T("Failed to compare the test documents")); assertMessage(rtfdcb.GetSummaryItemCount() == 2, _T("Expect 1 delete and 1 change")); rtfdcb2.DeleteChains(); ::DeleteFile(sRedline); }
void TestListNumBenchmarking::TestSimpleMergedListComparison() { ComparisonContext cContext; CStdString sOriginal = GET_TEST_FILE_PATH("TestSplitOrMergeList001.rtf"); CStdString sModified = GET_TEST_FILE_PATH("TestSplitOrMergeList002.rtf"); assertFileExists(sOriginal); assertFileExists(sModified); assertFileExists(TemplateFile); CStdString sRedline = CGeneral::GetTemporaryFileName(); assertMessage(!sRedline.IsEmpty(),_T("No temp file name - Did General Nuke it?")); CRtfDocumentChainBuilder rtfdcb; Helper_PerformComparisonUpToCompareChainsOnly(rtfdcb, sOriginal, sModified); CChainElement_Rtf* pModifiedChainTracer = rtfdcb.m_pAnchor[1]; pModifiedChainTracer = pModifiedChainTracer->GetNext()->GetNext()->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the first para of interest here")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); assertMessage(pModifiedChainTracer->GetAssociate(), _T(".. with things on the associate chain, 'One level of list.'")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the second para of interest here")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); assertMessage(pModifiedChainTracer->GetAssociate(), _T(".. with things on the associate chain, 'This is the text of the first item.'")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Should continue with inserted text NOT a para")); assertMessage(pModifiedChainTracer->GetRealBridge() == NULL, _T("Should be inserted thus not bridged at all")); CRTF_String* pString = (CRTF_String*) pModifiedChainTracer; CWideString wsTest = pString->GetText(); assertMessage(wsTest == L" ", _T("Strings are decomposed so expect just a space to start with")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Should continue with more inserted text")); assertMessage(pModifiedChainTracer->GetRealBridge() == NULL, _T("Should be inserted thus not bridged at all")); pString = (CRTF_String*) pModifiedChainTracer; wsTest = pString->GetText(); assertMessage(wsTest == L"Merged", _T("Strings are decomposed so expect just the first word here 'Merged'")); for(int i=0; i<5; ++i) { pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Expect 5 more inserted strings")); assertMessage(pModifiedChainTracer->GetRealBridge() == NULL, _T("Expect 5 more inserted strings")); } pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Expect 1 more matched strings")); assertMessage(pModifiedChainTracer->GetRealBridge(), _T("Expect 1 more matched strings")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be a para after the inserted strings")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); // That is probably enough to prove the point rtfdcb.m_Options.UnloadTemplate(); rtfdcb.DeleteChains(); ::DeleteFile(sRedline); }
void TestGlobalMethods::CreateTestDocument(const CStdString& sFileName, const CStdString& sFileNameToUse /* = TEST_DISCOVER_METADATA_DOC */) { assertFileExists(sFileNameToUse); assertTest(TRUE == ::CopyFile(sFileNameToUse, sFileName, FALSE)); assertTest(TRUE == ::SetFileAttributes(sFileName, FILE_ATTRIBUTE_NORMAL)); assertFileExists(sFileName); }
void TestCloseDocument::TestDeletesTempFileOnCloseIfReq() { DocProviderWorker objWorker; WSDocNonCom wsDoc; DocumentID docTarget(DocumentID::GenerateIdFromFilePath(sTestOriginalFileName)); wsDoc.SetDescription(docTarget.GetDescription()); wsDoc.SetLocalFile(docTarget.GetWorkingFile()); assertTest(objWorker.ImportDocument(wsDoc, true) == S_OK); m_wsImportedDoc = wsDoc; assertMessage(SUCCEEDED(objWorker.GetDocument(wsDoc.GetDocId(),NULL,wsDoc)),_T("Failed to get document for testing")); CStdString sTempFile = wsDoc.GetLocalFile(); assertFileExists(sTempFile); assertMessage(SUCCEEDED(objWorker.CloseDocument(wsDoc,NULL)),_T("Failed to Close document successfully")); assertFileNotExists(sTempFile); assertMessage(SUCCEEDED(objWorker.GetDocument(wsDoc.GetDocId(),DF_LOCK,wsDoc)),_T("Failed to get locked document")); sTempFile = wsDoc.GetLocalFile(); assertFileExists(sTempFile); assertMessage(SUCCEEDED(objWorker.CloseDocument(wsDoc,NULL)),_T("Failed to Close document successfully and unlock")); assertFileNotExists(sTempFile); assertMessage(SUCCEEDED(objWorker.GetDocument(wsDoc.GetDocId(),DF_LOCK,wsDoc)),_T("Failed to get locked document")); sTempFile = wsDoc.GetLocalFile(); assertFileExists(sTempFile); assertMessage(SUCCEEDED(objWorker.CloseDocument(wsDoc,DF_UNLOCK_ONLY)),_T("Failed to Close document successfully with unlock only")); assertFileExists(sTempFile); try { assertMessage(SUCCEEDED(objWorker.LockDocumentAsOtherUserForTesting(wsDoc.GetDocId(), _T("Java"), _T("IsCrap"),LOCK_DOCUMENT)),_T("Failed to lock document as other user")); assertMessage(SUCCEEDED(objWorker.GetDocument(wsDoc.GetDocId(),NULL,wsDoc)),_T("Failed to get document for testing")); sTempFile = wsDoc.GetLocalFile(); assertFileExists(sTempFile); assertMessage(SUCCEEDED(objWorker.CloseDocument(wsDoc,NULL)),_T("Failed to Close document successfully")); assertFileNotExists(sTempFile); long lLockStatus = 0; CStdString sLockedBy; assertMessage(SUCCEEDED(objWorker.GetDocumentLockStatus(wsDoc.GetDocId(), lLockStatus, sLockedBy)),_T("Failed get document lock status")); assertMessage(lLockStatus==DOCUMENT_LOCKED_BY_OTHER,_T("Failed to say document still locked by other user")); assertMessage(sLockedBy==_T("Java"),_T("Failed to say document locked by the user we locked it with")); } catch(...) { objWorker.LockDocumentAsOtherUserForTesting(wsDoc.GetDocId(), _T("Java"), _T("IsCrap"),UNLOCK_DOCUMENT); throw; } objWorker.LockDocumentAsOtherUserForTesting(wsDoc.GetDocId(), _T("Java"), _T("IsCrap"),UNLOCK_DOCUMENT); }
void TestListNumBenchmarking::TestListOverrideMerge() { ComparisonContext cContext; CStdString sOriginal = GET_TEST_FILE_PATH("TestListOverrideMerge01.rtf"); CStdString sModified = GET_TEST_FILE_PATH("TestListOverrideMerge02.rtf"); assertFileExists(sOriginal); assertFileExists(sModified); assertFileExists(TemplateFile); CStdString sRedline = CGeneral::GetTemporaryFileName(); assertMessage(!sRedline.IsEmpty(),_T("No temp file name - Did General Nuke it?")); CRtfDocumentChainBuilder rtfdcb; Helper_PerformComparisonUpToCompareChainsOnly(rtfdcb, sOriginal, sModified); CChainElement_Rtf* pModifiedChainTracer = rtfdcb.m_pAnchor[1]; pModifiedChainTracer = pModifiedChainTracer->GetNext()->GetNext()->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the first para of interest here")); CWideString ws; CRTF_ParaMarker *pPara = (CRTF_ParaMarker *)pModifiedChainTracer; pPara->GetText()->GetAllText(ws, false); assertMessage(CStdString(ws.GetData()) == L"ARTICLE I\t", _T("Should be ARTICLE I")); ws.Clear(); pModifiedChainTracer = pModifiedChainTracer->GetNext()->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the next para of interest here")); pPara = (CRTF_ParaMarker *)pModifiedChainTracer; pPara->GetText()->GetAllText(ws, false); assertMessage(CStdString(ws.GetData()) == L"1.2\t", _T("Should be 1.2")); ws.Clear(); pModifiedChainTracer = pModifiedChainTracer->GetNext()->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the next 2 para of interest here")); pPara = (CRTF_ParaMarker *)pModifiedChainTracer; pPara->GetText()->GetAllText(ws, false); assertMessage(CStdString(ws.GetData()) == L"(b)\t", _T("Should be (b)")); ws.Clear(); pModifiedChainTracer = pModifiedChainTracer->GetNext()->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the next 3 para of interest here")); pPara = (CRTF_ParaMarker *)pModifiedChainTracer; pPara->GetText()->GetAllText(ws, false); assertMessage(CStdString(ws.GetData()) == L"(i)\t", _T("Should be (i)")); rtfdcb.DeleteChains(); ::DeleteFile(sRedline); }
void TestGlobalMethods::TestMWSetFileTimesToCurrentSystemTime() { CreateTestDocument(TEST_RESULT_FILE_TIME_DOC); assertFileExists(TEST_RESULT_FILE_TIME_DOC); FILETIME OriginalCreationTime; FILETIME OriginalLastAccessTime; FILETIME OriginalWriteTime; HANDLE hFile = ::CreateFile(TEST_RESULT_FILE_TIME_DOC, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (NULL != hFile) { ::GetFileTime(hFile, &OriginalCreationTime, &OriginalLastAccessTime, &OriginalWriteTime); ::CloseHandle(hFile); hFile = NULL; } ::Sleep(30); ::MWSetFileTimesToCurrentSystemTime(TEST_RESULT_FILE_TIME_DOC); FILETIME CurrentCreationTime; FILETIME CurrentLastAccessTime; FILETIME CurrentWriteTime; hFile = ::CreateFile(TEST_RESULT_FILE_TIME_DOC, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (NULL != hFile) { ::GetFileTime(hFile, &CurrentCreationTime, &CurrentLastAccessTime, &CurrentWriteTime); ::CloseHandle(hFile); hFile = NULL; } assertMessage(0 != ::CompareFileTime(&CurrentCreationTime, &OriginalCreationTime), _T("Creation date time not set correctly")); assertMessage(0 != ::CompareFileTime(&CurrentLastAccessTime, &OriginalLastAccessTime), _T("Last access date time not set correctly")); assertMessage(0 != ::CompareFileTime(&CurrentWriteTime, &OriginalWriteTime), _T("Write date time not set correctly")); assertMessage(0 == ::CompareFileTime(&CurrentCreationTime, &CurrentWriteTime), _T("Creation date time not equal to write time")); }
void CTestLongNameOpen::setUpSuite() { // Does test share already exist? TCHAR szUNCName[MAX_PATH] = {0}; unsigned long ulUNCPathSize = MAX_PATH; GetComputerName(szUNCName, &ulUNCPathSize); sLongUNC_Name.Format(sLongUNC_Name.c_str(), szUNCName); CStdString sUNCShareName; sUNCShareName.Format(UNC_SERVER_PART.c_str(), szUNCName); if (!ShareExistsAndIsWriteable(sUNCShareName)) { // You can't create shares on subst drives in XP using this method ... // That's why it skips some tests on XP NetworkShareHelper nsh; m_bTestShareExists = (0 != nsh.ShareTestFolder(GET_TEST_FILE_PATH(_T("")))); if(!m_bTestShareExists) return; } m_bTestShareExists = (_taccess(sUNCShareName, 00) != -1); CStdString sMsg; sMsg.Format(_T("This machine must have a shared folder called 'TestShare' located at '%s'"), GET_TEST_FILE_PATH(_T("")).c_str()); assertMessageSuite(m_bTestShareExists, sMsg); assertFileExists(sUNCTestDoc); CopyFile(sUNCTestDoc, sLongUNC_Name, false); assertMessageSuite(CGeneral::FileExists(sLongUNC_Name), _T("Didn't managed to copy the test file - do you have a \\testshare network share on this machine? Is it writeable?")); }
void TestSnapshotSaver::TestSave() { const CStdString sSourceFileName = CTestUtils::GetTestFileFolder() + _T("TestApplyChange_BinaryRead\\Synergy24TestDocuments\\FlagForFollowUp.doc"); CStdString sDestFileName = CTestUtils::GetTestFileFolder() + _T("TestApplyChange_BinaryRead\\Synergy24TestDocuments\\rubbish.doc"); ::DeleteFile( sDestFileName ); assertFileNotExists( sDestFileName ); Word::_ApplicationPtr pApp; pApp.CreateInstance( __uuidof( Word::Application ) ); const Word::_DocumentPtr pDocument = pApp->Documents->Open( &_variant_t( sSourceFileName ) ); try { SnapshotSaver snapshotSaver( pDocument ); snapshotSaver.Save( sDestFileName ); } catch(...) { pDocument->Close(); pApp->Quit(); throw; } pDocument->Close(); pApp->Quit(); assertFileExists( sDestFileName ); }
void TestGlobalMethods::TestSetFiletimeFromOLEStats() { CreateTestDocument(TEST_RESULT_SET_FROM_OLE_DOC, TEST_SET_FILETIME_FROM_OLE_DOC); assertFileExists(TEST_RESULT_SET_FROM_OLE_DOC); ::MWSetFileTimesToCurrentSystemTime(TEST_RESULT_SET_FROM_OLE_DOC); FILETIME CurrentCreationTime; FILETIME CurrentModifiedTime; FILETIME CurrentLastAccessTime; HANDLE hFile = ::CreateFile(TEST_RESULT_SET_FROM_OLE_DOC, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(INVALID_HANDLE_VALUE != hFile) { ::GetFileTime(hFile, &CurrentCreationTime, &CurrentLastAccessTime, &CurrentModifiedTime); ::CloseHandle(hFile); hFile = 0; } FILETIME ExpectedOLECreationTime; FILETIME ExpectedOLEModifiedTime; SYSTEMTIME ExpectedOLESystemTime; ExpectedOLESystemTime.wYear = 2004; ExpectedOLESystemTime.wMonth = 5; ExpectedOLESystemTime.wDay = 24; ExpectedOLESystemTime.wDayOfWeek = 1; ExpectedOLESystemTime.wHour = 10; //UTC ExpectedOLESystemTime.wMinute = 37; ExpectedOLESystemTime.wSecond = 0; // Should be 24? ExpectedOLESystemTime.wMilliseconds = 0; assertTest(TRUE == ::SystemTimeToFileTime(&ExpectedOLESystemTime, &ExpectedOLECreationTime)); ExpectedOLESystemTime.wMinute = 38; ExpectedOLESystemTime.wSecond = 0; // Should be 31? assertTest(TRUE == ::SystemTimeToFileTime(&ExpectedOLESystemTime, &ExpectedOLEModifiedTime)); assertMessage(0 != ::CompareFileTime(&CurrentCreationTime, &ExpectedOLECreationTime), _T("Expected creation time to be incorrect (current time)")); assertMessage(0 != ::CompareFileTime(&CurrentModifiedTime, &ExpectedOLEModifiedTime), _T("Expected last modified time to be incorrect (current time)")); SetFiletimeFromOLEStats(TEST_RESULT_SET_FROM_OLE_DOC); hFile = ::CreateFile(TEST_RESULT_SET_FROM_OLE_DOC, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(INVALID_HANDLE_VALUE != hFile) { ::GetFileTime(hFile, &CurrentCreationTime, &CurrentLastAccessTime, &CurrentModifiedTime); ::CloseHandle(hFile); hFile = 0; } CStdString sErr; sErr.Format(_T("Expected a creation time of %s but got %s"), FiletimeAsString(ExpectedOLECreationTime), FiletimeAsString(CurrentCreationTime)); assertMessage(0 == ::CompareFileTime(&CurrentCreationTime, &ExpectedOLECreationTime), sErr.c_str()); sErr.Format(_T("Expected a last modified time of %s but got %s"), FiletimeAsString(ExpectedOLEModifiedTime), FiletimeAsString(CurrentModifiedTime)); assertMessage(0 == ::CompareFileTime(&CurrentModifiedTime, &ExpectedOLEModifiedTime), sErr.c_str()); }
void TestExcelAttachedDocument::TestSaveAs() { ::DeleteFile(TESTRESULT_EXCEL_SAVEAS); const std::wstring wdoc(CT2W(TESTRESULT_EXCEL_SAVEAS)); m_pDocument->SaveAs(wdoc); assertFileExists(TESTRESULT_EXCEL_SAVEAS); ::DeleteFile(TESTRESULT_EXCEL_SAVEAS); }
//A flex term licence is available, but has expired. //Should create a new demo licence, and return Term user profile void TestCheckUser::TestCheckUser_FlexTermExpiredAndDemoExisting() { throw SkipTestException(_T("TODO: TEST DISABLED FOR CHECKIN (Need to work out licensing for combined pes/pro) - RNP 2010-04-14")); //create a brand new demo licence for our test assertFileNotExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); UserProfile::CreateFeatureDemoLicence(_T("ProtectEnterpriseClient"), false); assertFileExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); //testing UserProfile::UserProfileType userProfileType = (UserProfile::UserProfileType)m_lpCheckUser(FEATURE_NAME_SUPPORTED, TEST_PATH_MAKE_ABSOLUTE(_T("Projects\\Licence\\src\\UserProfile.Tests\\TestDocuments\\Expired")), m_showUI); //asserts assertMessage(UserProfile::Term == userProfileType, _T("expected Term")); assertFileExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); //tidyup UserProfile::DeleteFeatureDemoLicence(_T("ProtectEnterpriseClient")); }
//No flex licence is available, but a demo licence already exists. //Should return Term user profile. void TestCheckUser::TestCheckUser_NoFlexAndDemoExisting() { throw SkipTestException(_T("TODO: TEST DISABLED FOR CHECKIN (Need to work out licensing for combined pes/pro) - RNP 2010-04-14")); //create a brand new demo licence for our test assertFileNotExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); UserProfile::CreateFeatureDemoLicence(FEATURE_NAME_SUPPORTED, false); assertFileExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); //testing UserProfile::UserProfileType userProfileType = (UserProfile::UserProfileType)m_lpCheckUser(FEATURE_NAME_SUPPORTED, UserProfile::GetModulePath(), m_showUI); //asserts assertMessage(UserProfile::Term == userProfileType, _T("expected Term")); assertFileExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); //tidyup UserProfile::DeleteFeatureDemoLicence(FEATURE_NAME_SUPPORTED); }
void TestListNumBenchmarking::TestImplicitListNumLevelAfterARealListItem() { ComparisonContext cContext; CStdString sOriginal = GET_TEST_FILE_PATH("MixedListListNum.rtf"); CStdString sModified = GET_TEST_FILE_PATH("MixedListListNum.rtf"); assertFileExists(sOriginal); assertFileExists(sModified); assertFileExists(TemplateFile); CStdString sRedline = CGeneral::GetTemporaryFileName(); assertMessage(!sRedline.IsEmpty(),_T("No temp file name - Did General Nuke it?")); CRtfDocumentChainBuilder rtfdcb; rtfdcb.m_Options.SetTemplate(TemplateFile); rtfdcb.m_Options.Flags.m_bWorkshareComparison = false; HRESULT hr = rtfdcb.PerformRTFComparison(AutoInputFileData4Tests(sOriginal), AutoInputFileData4Tests(sModified), AutoOutputFileData4Tests(sRedline), true); assertMessage(SUCCEEDED(hr), _T("Failed to compare the test documents")); CChainElement_Rtf* pModifiedChainTracer = rtfdcb.m_pAnchor[1]; pModifiedChainTracer = Helper_GetNextListNumField(pModifiedChainTracer); assertMessage(pModifiedChainTracer, _T("Ran out of chain before we found the listnum we wanted")); Helper_VerifyListNumLevelInFieldObject((CRTF_Field*) pModifiedChainTracer, 2); pModifiedChainTracer = Helper_GetNextListNumField(pModifiedChainTracer->GetNext()); assertMessage(pModifiedChainTracer, _T("Ran out of chain before we found the listnum we wanted")); Helper_VerifyNoListNumLevelInFieldObject((CRTF_Field*) pModifiedChainTracer, 2); pModifiedChainTracer = Helper_GetNextListNumField(pModifiedChainTracer->GetNext()); assertMessage(pModifiedChainTracer, _T("Ran out of chain before we found the listnum we wanted")); Helper_VerifyNoListNumLevelInFieldObject((CRTF_Field*) pModifiedChainTracer, 1); rtfdcb.DeleteChains(); }
//A flex term licence is available, but has expired. //Should create a new demo licence, and return Term user profile void TestCheckUser::TestCheckUser_FlexTermExpiredAndCreatesDemo() { //pre-testing asserts - shouldn't already have a users.dat in our path assertFileNotExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); //testing UserProfile::UserProfileType userProfileType = (UserProfile::UserProfileType)m_lpCheckUser(FEATURE_NAME_SUPPORTED, TEST_PATH_MAKE_ABSOLUTE(_T("Projects\\Licence\\src\\UserProfile.Tests\\TestDocuments\\Expired")), m_showUI); //asserts assertMessage(UserProfile::Term == userProfileType, _T("expected UserProfileType::Term")); assertFileExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); //tidyup UserProfile::DeleteFeatureDemoLicence(_T("ProtectEnterpriseClient")); UserProfile::DeleteFeatureDemoLicence(_T("ProtectEnterpriseMobile")); }
void TestCheckUser::TestCheckUser_NoFlexAndCreatesDemo() { //pre-testing asserts - shouldn't already have a users.dat file, or flex .lic files, in our path assertFileNotExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); //testing CStdString filePath(UserProfile::GetAppDataPath()); UserProfile::UserProfileType userProfileType = (UserProfile::UserProfileType)m_lpCheckUser(FEATURE_NAME_SUPPORTED, UserProfile::GetModulePath(), m_showUI); //assert userprofile status is Expired and that we do not have a demo licence file assertMessage(UserProfile::Term == userProfileType, _T("expected Term")); assertFileExists(UserProfile::GetAppDataPath() + _T("\\users.dat")); //tidyup UserProfile::DeleteFeatureDemoLicence(FEATURE_NAME_SUPPORTED); }
void TestGlobalMethods::TestMWCanAutomate() { assertFileExists(TEST_DISCOVER_METADATA_DOC); CWordHelper WordHelper; Word::_ApplicationPtr spApplication = WordHelper.InitializeWord(); assertTest(NULL != spApplication); Word::DocumentsPtr spDocuments = spApplication->Documents; _variant_t vFilename(TEST_DISCOVER_METADATA_DOC); Word::_DocumentPtr spDocument = spDocuments->OpenOld(&vFilename); assertTest(spDocument != 0); assertMessage(!MWCanAutomate(spDocument), _T("Failed to prevent embedded object being automated.")); spApplication->Visible = VARIANT_TRUE; assertMessage(MWCanAutomate(spDocument), _T("Expected to be able to automate word if its visible.")); }
void CTestRTFTablePostProcessor::ReadRTFFromFile(LPCTSTR szFileName) { ERTFToken ec; InputFileData ifd; ifd.AssignFileName(szFileName); RTFInputFile rif(ifd); assertFileExists(szFileName); assertTest(rif.Open()); ec = m_pfileSource->the_RTFParser.ReadFile(&rif, m_pfileSource); assertTest(ec == rtferr_OK); rif.Close(); m_pfileSource->m_iModality = FM_TESTFILE; }
int main() { step("parent: fork"); if (fork()) { step("parent: wait for child to exit"); int status = 0; do wait(&status); while (!WIFEXITED(status)); assertFileExists("parent", FS_ROOT_SOURCE "/dir1"); assertFileDoesNotExist("parent", FS_ROOT_SOURCE "/dir1/file"); assertFileExists("parent", FS_ROOT_SOURCE "/dir2"); assertFileExists("parent", FS_ROOT_SOURCE "/dir2/file"); } else { step("child: create container with separate mnt namespace"); struct slc_create_container_parameters params; initialize_default_fs_root(¶ms.fs_root); slc_create_container(¶ms, 0); step("child: create dir1"); mkdir("dir1", S_IRWXU | S_IRWXG | S_IRWXO); step("child: create dir2"); mkdir("dir2", S_IRWXU | S_IRWXG | S_IRWXO); step("child: create dir2/file"); close(open("dir2/file", O_CREAT)); step("child: mount dir2 over dir1"); mount("dir2", "dir1", NULL, MS_BIND, NULL); assertFileExists("child", "dir1"); assertFileExists("child", "dir1/file"); assertFileExists("child", "dir2"); assertFileExists("child", "dir2/file"); } return 0; }
void CommandLine::initialize( int argc, char **argv) { // first copy the command line string for(int i = 0; i < argc; ++i) { _cmdString += std::string(argv[i], argv[i] + strlen(argv[i])); _cmdString += " "; } int c ; // TODO threads/ processes? while( (c = getopt(argc,argv, "c:df:vhn:w:s:t:R:r:M:C:m:Sq:zxT:")) != EOF) { try { switch(c) { case 'z': { quiet = true; } break; case 'c': // config file { configFileName = std::string(optarg); assertFileExists(configFileName); } break; case 'f': // aln file alnFileName = std::string(optarg); assertFileExists(alnFileName); break; case 'v': // version _onlyPrintVersion = true; break; case 'd': dryRun = true; break; case 'h': // help _onlyPrintHelp = true; break; case 'n': // runid runid = std::string(optarg); break; case 't': // trees -- have that in the config file? treeFile = std::string(optarg); break; case 'w': // working dir workDir = std::string(optarg); break; case 's': // seed seed.v[0] = std::stoi(optarg); break; case 'r': checkpointId = std::string{optarg}; break; case 'q': modelFile = std::string{optarg}; break; case 'm': singleModel = std::string{optarg}; break; case 'S': saveMemorySEV = true; break; case 'M': memoryMode = MemoryMode(std::stoi(optarg)); break; case 'C': chainNumParallel = std::stoi(optarg); break; case 'R': runNumParallel = std::stoi(optarg); break; case 'T': _totalThreads = std::stoi(optarg); break; // case 'x': // readerStride = std::stoi(optarg); // break; case 'x': _hasThreadPinning = false; break; default: { std::cerr << "Encountered unknown command line option -" << char(c) << "\n\nFor an overview of program options, please use -h" << std::endl ; // TODO mpi-finalize stuff exitFunction(-1, true); } } } catch(const std::invalid_argument& ia) { std::cerr << "Invalid argument >" << optarg << "< to option >" << reinterpret_cast<char*>(&c) << "<" << std::endl; exitFunction(-1, true); } } if(_onlyPrintHelp || _onlyPrintVersion) return; if(isYggdrasil && (_totalThreads % (runNumParallel * chainNumParallel)) != 0 ) { std::cerr << "Error: for the threaded version it is currently necessary that the number of threads is a multiple of the product of the number of chains and runs that is executed in parallel." << std::endl; exitFunction(-1, true); } if(runid.compare("") == 0 ) { std::cerr << "please specify a runid with -n runid" << std::endl; exitFunction(-1, true); } if(seed.v[0] != 0 && checkpointId.compare("") != 0 ) { std::cout << std::endl << "You provided a seed and run-id for a restart from a checkpoint.\n" << "Please be aware that the seed will be ignored." << std::endl; } if(checkpointId.compare("") == 0 && seed.v[0] == 0 ) { std::cerr << "please specify a seed via -s seed (must NOT be 0)" << std::endl; exitFunction(-1, true); } if(workDir.compare("") != 0 && not OutputFile::directoryExists(workDir)) { std::cout << std::endl << "Could not find the provided working directory >" << workDir << "<" << std::endl; exitFunction(-1, true); } if(alnFileName.compare("") == 0 ) { std::cerr << "please specify an alignment file via -f file" << std::endl << "You have to transform your NEWICK-style alignment into a binary file using the appropriate parser (see manual)." << std::endl; exitFunction(-1, true); } if(alnFileIsBinary()) { if(singleModel.compare("") != 0 || modelFile.compare("") != 0 ) { std::cout << "Found binary alignment file. Additionally, you provided a model file\n" "(-q) or specified a data type for a single partiton. This information\n" "will be ignored.\n"; modelFile = ""; singleModel = ""; } } else { if(singleModel.compare("") == 0 && ( modelFile.compare("") == 0 || not std::ifstream(modelFile) ) ) { std::cout << "Found a phylip-style alignment file. However, you did not provide a\n" << "model file (see -q, resp. it coul not be found) or a data type specification for a single\n" << "partition (-m). Cannot proceed.\n" ; exitFunction(-1, true); } } if( treeFile.compare("") != 0 && not std::ifstream(treeFile)) { std::cout << "Could not find tree file passed via -t >" << treeFile << "<"<< std::endl; exitFunction(-1, true); } }
void TestListNumBenchmarking::TestListNumberingStaysMonotonicWithTrickyDelete() { ComparisonContext cContext; throw SkipTestException(_T("Disabled while we re-think the Slaughter and May problems")); CStdString sOriginal = GET_TEST_FILE_PATH("TestSplitOrMergeList007.rtf"); CStdString sModified = GET_TEST_FILE_PATH("TestSplitOrMergeList008.rtf"); assertFileExists(sOriginal); assertFileExists(sModified); assertFileExists(TemplateFile); CStdString sRedline = CGeneral::GetTemporaryFileName(); assertMessage(!sRedline.IsEmpty(),_T("No temp file name - Did General Nuke it?")); CRtfDocumentChainBuilder rtfdcb; Helper_PerformComparisonUpToCompareChainsOnly(rtfdcb, sOriginal, sModified); CChainElement_Rtf* pModifiedChainTracer = rtfdcb.m_pAnchor[1]; pModifiedChainTracer = pModifiedChainTracer->GetNext()->GetNext()->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the first parahere")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); assertMessage(pModifiedChainTracer->GetAssociate(), _T(".. with a single full stop on the associate chain")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the second para of interest here")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); assertMessage(pModifiedChainTracer->GetAssociate(), _T(".. with 'Obligations' on the associate chain")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_Marker, _T("Expect a bridged marker in here")); assertMessage(pModifiedChainTracer->GetBridge(), _T("Should be bridged")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Expect a para here")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("'Following' should be matched after the deleted list para")); assertMessage(pModifiedChainTracer->GetRealBridge() != NULL, _T("'Following' should be matched")); CRTF_String* pString = (CRTF_String*) pModifiedChainTracer; CWideString wsTest = pString->GetText(); assertMessage(wsTest == L"Following", _T("Strings are decomposed so should just be 'Following' here")); // now a little one way trip down the associate chain .... pModifiedChainTracer = (CChainElement_Rtf*) pModifiedChainTracer->m_pAssociate; assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Expect a para first")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Expecting the deleted '(A)'")); pString = (CRTF_String*) pModifiedChainTracer; assertMessage(pString->IsListNumberReplacement(), _T("Should be the deleted list number '(A)'")); wsTest = pString->GetText(); assertMessage(wsTest == L"(A)\t", _T("The '(A)' must come before the '(B)'")); for(int i=0; i<6; ++i) { pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Expect 6 more deleted strings")); assertMessage(pModifiedChainTracer->GetRealBridge() == NULL, _T("Expect 6 more deleted strings")); } pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Expect a para after the strings")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Expecting the deleted '(B)'")); pString = (CRTF_String*) pModifiedChainTracer; assertMessage(pString->IsListNumberReplacement(), _T("Should be the deleted list number '(B)'")); wsTest = pString->GetText(); assertMessage(wsTest == L"(B) ", _T("The '(B)' must come after the '(A)'")); rtfdcb.DeleteChains(); ::DeleteFile(sRedline); }
static void verify_tree(size_t limit) { char name1[260]; char name2[260]; size_t i, LOOP_MAX; LOOP_MAX = compute_loop_max(); /* Generate the names we know should be there and verify them. */ for (i = 1; i < LOOP_MAX; i++) { /* Verify a file named "f/abcdef..." */ sprintf(name1, "f/%s", filenames[i]); if (i <= limit) { assertFileExists(name1); assertFileContents(name1, (int)strlen(name1), name1); } sprintf(name2, "l/%s", filenames[i]); if (i + 2 <= limit) { /* Verify hardlink "l/abcdef..." */ assertIsHardlink(name1, name2); /* Verify hardlink "m/abcdef..." */ name2[0] = 'm'; assertIsHardlink(name1, name2); } if (canSymlink()) { /* Verify symlink "s/abcdef..." */ sprintf(name1, "s/%s", filenames[i]); sprintf(name2, "../f/%s", filenames[i]); if (strlen(name2) <= limit) assertIsSymlink(name1, name2); } /* Verify dir "d/abcdef...". */ sprintf(name1, "d/%s", filenames[i]); if (i + 1 <= limit) { /* +1 for trailing slash */ if (assertIsDir(name1, -1)) { /* TODO: opendir/readdir this * directory and make sure * it's empty. */ } } } #if !defined(_WIN32) || defined(__CYGWIN__) { const char *dp; /* Now make sure nothing is there that shouldn't be. */ for (dp = "dflms"; *dp != '\0'; ++dp) { DIR *d; struct dirent *de; char dir[2]; dir[0] = *dp; dir[1] = '\0'; d = opendir(dir); failure("Unable to open dir '%s'", dir); if (!assert(d != NULL)) continue; while ((de = readdir(d)) != NULL) { char *p = de->d_name; if (p[0] == '.') continue; switch(dp[0]) { case 'l': case 'm': case 'd': failure("strlen(p)=%d", strlen(p)); assert(strlen(p) < limit); assertEqualString(p, filenames[strlen(p)]); break; case 'f': case 's': failure("strlen(p)=%d", strlen(p)); assert(strlen(p) < limit + 1); assertEqualString(p, filenames[strlen(p)]); break; default: failure("File %s shouldn't be here", p); assert(0); } } closedir(d); } } #endif }
void TestListNumBenchmarking::TestWhenDeletedListNumbersMayHaveBeenDecomposedDocumentsSwapped() { ComparisonContext cContext; throw SkipTestException(_T("Disabled while we re-think the Slaughter and May problems")); CStdString sOriginal = GET_TEST_FILE_PATH("TestSplitOrMergeList010.rtf"); CStdString sModified = GET_TEST_FILE_PATH("TestSplitOrMergeList009.rtf"); assertFileExists(sOriginal); assertFileExists(sModified); assertFileExists(TemplateFile); CStdString sRedline = CGeneral::GetTemporaryFileName(); assertMessage(!sRedline.IsEmpty(),_T("No temp file name - Did General Nuke it?")); CRtfDocumentChainBuilder rtfdcb; Helper_PerformComparisonUpToCompareChainsOnly(rtfdcb, sOriginal, sModified); CChainElement_Rtf* pModifiedChainTracer = rtfdcb.m_pAnchor[1]; pModifiedChainTracer = pModifiedChainTracer->GetNext()->GetNext()->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the first para of interest here")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); assertMessage(pModifiedChainTracer->GetAssociate(), _T(".. with things on the associate chain, '3.1\tXXXXX'")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_Marker, _T("Expecting a marker inserted between the paras")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the second para of interest here")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); assertMessage(!pModifiedChainTracer->GetAssociate(), _T(".. but with nothing on the associate chain")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("'Twenty' expected to be matched here")); assertMessage(pModifiedChainTracer->GetBridge(), _T("'Twenty' expected to be matched here")); CRTF_String* pString = (CRTF_String*) pModifiedChainTracer; CWideString wsTest = pString->GetText(); assertMessage(wsTest == L"Twenty", _T("'Twenty' expected to be matched here")); for(int i=0; i<6; ++i) { pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Expect 6 more matched strings")); assertMessage(pModifiedChainTracer->GetRealBridge(), _T("Expect 6 more matched strings")); } pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Expected unmatched string")); assertMessage(pModifiedChainTracer->GetRealBridge() == NULL, _T("Expected unmatched string")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Expected unmatched para")); assertMessage(pModifiedChainTracer->GetRealBridge() == NULL, _T("Expected unmatched para")); for(int i=0; i<2; ++i) { pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("Expect 2 unmatched strings")); assertMessage(pModifiedChainTracer->GetRealBridge() == NULL, _T("Expect 2 unmatched strings")); } pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Expected unmatched para")); assertMessage(pModifiedChainTracer->GetRealBridge() == NULL, _T("Expected unmatched para")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_String, _T("'longer' expected to be matched here")); assertMessage(pModifiedChainTracer->GetBridge(), _T("'longer' expected to be matched here")); assertMessage(pModifiedChainTracer->GetAssociate(), _T("... with more on the associate chain")); pString = (CRTF_String*) pModifiedChainTracer; wsTest = pString->GetText(); assertMessage(wsTest == L"longer", _T("'longer' expected to be matched here")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_ParaMarker, _T("Should be the last para")); assertMessage(pModifiedChainTracer->GetBridge(), _T(".. it should be bridged")); pModifiedChainTracer = pModifiedChainTracer->GetNext(); assertMessage(pModifiedChainTracer->GetType() == ROT_Marker, _T("Expecting the end marker")); assertMessage(pModifiedChainTracer->GetBridge(), _T("End marker should be bridged")); assertMessage(!pModifiedChainTracer->GetNext(), _T("There should not be any more chain")); rtfdcb.DeleteChains(); ::DeleteFile(sRedline); }