void CounterTest::testExecute() { DataContainer data = m_operator->getOutputData(Counter::OUTPUT); CPPUNIT_ASSERT_EQUAL(UInt32(0), ReadAccess(data).get<UInt32>()); m_operator->clearOutputData(Counter::OUTPUT); data = m_operator->getOutputData(Counter::OUTPUT); CPPUNIT_ASSERT_EQUAL(UInt32(1), ReadAccess(data).get<UInt32>()); m_operator->deactivate(); m_operator->activate(); data = m_operator->getOutputData(Counter::OUTPUT); CPPUNIT_ASSERT_EQUAL(UInt32(0), ReadAccess(data).get<UInt32>()); }
int main(int argc, char *argv[]) { if (!MainInit(argc, argv)) { printf("Error: %s\n", GetTranslation("Init failed, aborting")); return 1; } // Init if (!(MainWin = initscr())) throwerror(false, "Could not init ncurses"); if (!(CDKScreen = initCDKScreen(MainWin))) throwerror(false, "Could not init CDK"); initCDKColor(); if ((InstallInfo.dest_dir_type == DEST_DEFAULT) && !ReadAccess(InstallInfo.dest_dir)) throwerror(true, CreateText("This installer will install files to the following directory:\n%s\n" "However you don't have read permissions to this directory\n" "Please restart the installer as a user who does or as the root user", InstallInfo.dest_dir.c_str())); int i=0; while(Functions[i]) { if (Functions[i]()) i++; else { if (YesNoBox(GetTranslation("This will abort the installation\nAre you sure?"))) break; } } EndProg(); return 0; }
// In case dir does not exist, it will search for the first valid top directory std::string GetFirstValidDir(const std::string &dir) { if ((dir[0] == '/') && (dir.length() == 1)) return dir; // Root dir given std::string subdir = dir; if (!subdir.compare(0, 2, "~/")) { const char *env = getenv("HOME"); if (env) subdir.replace(0, 1, env); } MakeAbsolute(subdir); if (ReadAccess(subdir)) return subdir; // Remove trailing / if (subdir[subdir.length()-1] == '/') subdir.erase(subdir.length()-1, 1); TSTLStrSize pos; do { pos = subdir.rfind('/'); assert(pos != std::string::npos); if (pos == std::string::npos) { // Shouldn't happen return subdir; } else if (pos == 0) // Reached the root dir('/') return "/"; subdir.erase(pos); } while (!ReadAccess(subdir)); return subdir; }
// Incase dir does not exist, it will search for the first valid top directory std::string GetFirstValidDir(const std::string &dir) { if ((dir[0] == '/') && (dir.length() == 1)) return dir; // Root dir given std::string subdir = dir; if (dir[0] != '/') // No absolute path given { std::string curdir = GetCWD(); subdir.insert(0, curdir + std::string("/")); } if (ReadAccess(subdir)) return subdir; // Remove trailing / if (subdir[subdir.length()-1] == '/') subdir.erase(subdir.length()-1, 1); TSTLStrSize pos; do { pos = subdir.rfind('/'); assert(pos != std::string::npos); if (pos == std::string::npos) { // Shouldn't happen return subdir; } else if (pos == 0) // Reached the root dir('/') return "/"; subdir.erase(pos); } while (!ReadAccess(subdir)); return subdir; }