bool TestExtDatetime::test_date_time_set() { Object dt = f_date_create("2006-12-12 12:34:56"); f_date_time_set(dt, 23, 45, 12); VDT(dt, "2006-12-12 23:45:12"); return Count(true); }
bool TestExtClass::test_get_class_constants() { Array constants = f_get_class_constants("test"); VS(constants, CREATE_MAP1("const_foo", "f")); return Count(true); }
void MainFrame::OnTreeSelectionChanged(wxTreeEvent &event) { auto treeItemId = event.GetItem(); auto rootId = dirTree->GetRootItem(); auto currentFileEntry = dynamic_cast<EntryItemData *>(dirTree->GetItemData(treeItemId))->Get(); auto gridPanel = dynamic_cast<wxScrolledWindow *>(splitter->GetWindow2()); if (loadThread) { loadThread->Delete(nullptr, wxTHREAD_WAIT_BLOCK); loadThread = nullptr; } gridPanel->Show(false); auto grid = gridPanel->GetSizer(); grid->Clear(true); std::vector<Entry *> loadEntries; imgButtons.clear(); for (int i = 0; i < currentFileEntry->Count(); ++i) { Entry *childEntry = (*currentFileEntry)[i]; if (childEntry->IsDirectory()) continue; auto ext = childEntry->Name().AfterLast('.').Lower(); if (ext != "jpg" && ext != "jpeg" && ext != "png" && ext != "gif") continue; loadEntries.push_back(childEntry); } for (auto entry : loadEntries) { auto button = new wxButton(gridPanel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); imgButtons.push_back(button); button->Bind(wxEVT_BUTTON, &MainFrame::OnImageButtonClick, this); button->SetClientObject(new EntryItemData(entry)); button->SetMinSize({250, 250}); auto staticText = new wxStaticText(gridPanel, wxID_ANY, entry->Name()); staticText->SetMaxSize({250, 50}); auto btnSizer = new wxBoxSizer(wxVERTICAL); btnSizer->Add(button, 0, wxEXPAND); btnSizer->Add(staticText); grid->Add(btnSizer, 0, wxALL | wxEXPAND, 5); } GetStatusBar()->SetStatusText(wxString::Format("Loading Thumbnail %i of %i", 1, (int)loadEntries.size())); grid->FitInside(gridPanel); gridPanel->Show(true); gridPanel->Scroll(0, 0); gridPanel->Refresh(); gridPanel->Update(); loadThread = new ThumbnailLoadThread(this, loadEntries, currentEntry); loadThread->Run(); threadId = loadThread->GetId(); }
bool TestExtClass::test_class_exists() { VERIFY(f_class_exists("TEst")); return Count(true); }
bool TestExtClass::test_get_class_methods() { Array methods = f_get_class_methods("TEst"); VS(methods[0], "foo"); return Count(true); }
bool TestExtClass::test_get_object_vars() { // TestCodeRun covers this return Count(true); }
bool TestExtClass::test_get_declared_classes() { Array classes = f_get_declared_classes(); VS(f_in_array("test", classes, true), true); return Count(true); }
bool TestExtDatetime::test_timezone_identifiers_list() { //f_var_dump(TimeZone::GetNames()); VERIFY(!TimeZone::GetNames().empty()); return Count(true); }
bool TestExtDatetime::test_timezone_name_from_abbr() { VS(f_timezone_name_from_abbr("CET"), "Europe/Berlin"); VS(f_timezone_name_from_abbr("", 3600, 0), "Europe/Paris"); return Count(true); }
bool TestExtDatetime::test_microtime() { int time_start = f_microtime(true); VERIFY(time_start > 0); return Count(true); }
bool TestExtDatetime::test_timezone_abbreviations_list() { //f_var_dump(TimeZone::GetAbbreviations()); VERIFY(!TimeZone::GetAbbreviations().empty()); return Count(true); }
bool TestExtDatetime::test_gmmktime() { int d = f_gmmktime(0, 0, 0, 1, 1, 1998); VS(f_date("M d Y H:i:s", d), "Dec 31 1997 16:00:00"); VS(f_gmdate("M d Y H:i:s", d), "Jan 01 1998 00:00:00"); return Count(true); }
bool TestExtDatetime::test_date_timezone_get() { Object dt = f_date_create("2008-08-08 12:34:56"); VS(f_timezone_name_get(f_date_timezone_get(dt)), "America/Los_Angeles"); return Count(true); }
bool TestExtDatetime::test_date_timestamp_get() { Object tz = f_timezone_open("America/Los_Angeles"); Object dt = f_date_create("2008-08-08 12:34:56", tz); VS(f_date_timestamp_get(dt), 1218224096); return Count(true); }
bool TestExtClass::test_method_exists() { // TestCodeRun covers this return Count(true); }
bool TestExtDatetime::test_timezone_open() { Object tz = f_timezone_open("Asia/Shanghai"); VS(f_timezone_name_get(tz), "Asia/Shanghai"); return Count(true); }
bool TestExtClass::test_property_exists() { VERIFY(f_property_exists("TEst", "prop")); return Count(true); }
bool TestExtDatetime::test_timezone_version_get() { VS(f_timezone_version_get(), "2011.14"); return Count(true); }
bool TestExtClass::test_call_user_method() { // TestCodeRun covers this return Count(true); }
bool TestExtDatetime::test_checkdate() { VERIFY(f_checkdate(12, 31, 2000)); VERIFY(!f_checkdate(2, 29, 2001)); return Count(true); }
bool TestExtClass::test_get_declared_interfaces() { Array classes = f_get_declared_interfaces(); VS(f_in_array("itestable", classes, true), true); return Count(true); }
bool TestExtDatetime::test_date_create_from_format() { Object dt = f_date_create_from_format("d/m/Y H:i:s", "16/08/2012 00:00:00"); VDT(dt, "2012-08-16 00:00:00"); return Count(true); }
bool TestExtClass::test_interface_exists() { VERIFY(f_interface_exists("iTESTable")); return Count(true); }
/** \brief Add the specified words to this moWords object. * * This function adds words to the existing list of words. * * The new words are appened at the end of the existing * word list. * * The words are separated using the character and * string separators. * * \param[in] words The list of words to append. * * \return The number of words in this moWords object. */ unsigned long moWords::AddWords(const moWCString& words) { moWCString str, *cmp; const mowc::wc_t *s, *start, *seps; long idx, max, skip; bool found, accepts_backslash; if(!f_words.IsEmpty()) { if(!f_char_separators.IsEmpty()) { f_words += f_char_separators[0]; } else if(f_str_separators.Count() != 0) { f_words += dynamic_cast<moWCString *>(f_str_separators.Get(0))[0]; } else { // use a default separator (a space) f_words += " "; } } f_words += words; s = words.Data(); while(*s != '\0') { // start of this new word start = s; found = false; do { skip = 1; // 1. test with strings max = f_str_separators.Count(); idx = 0; while(idx < max) { cmp = dynamic_cast<moWCString *>(f_str_separators.Get(idx)); if(cmp->Compare(s, 0, static_cast<int>(cmp->Length())) == MO_BASE_COMPARE_EQUAL) { // we found a separator found = true; skip = static_cast<long>(cmp->Length()); break; } idx++; } // 2. test with characters (if not found yet) if(!found && !f_char_separators.IsEmpty()) { seps = f_char_separators.Data(); while(*seps != '\0' && !found) { if(*seps == '\\') { seps++; if(*seps == 's') { found = mowc::isspace(*s); seps++; } else { found = *s == mowc::backslash_char(seps); } } else if(*seps == *s) { // we found a separator found = true; break; } else { seps++; } } } // 3. test with the default separators (spaces) if(!found && f_char_separators.IsEmpty() && f_str_separators.IsEmpty() && mowc::isspace(*s)) { // we found the default separator found = true; } // 4. check for quoted information if(!found) { accepts_backslash = false; seps = f_quotes.Data(); while(*seps != '\0') { if(*seps == '\\') { accepts_backslash = true; } else if(*s == *seps) { // we found a quoted part - quoted parts can include separators s++; // skip starting quote while(*s != seps[1] && *s != '\0') { if(accepts_backslash && *s == '\\' && s[1] != '\0') { s++; } s++; } if(*s == '\0') { s--; // make sure the following s++ doesn't make the system crash } break; } seps += 2; // the size of f_quotes is always even } } s++; } while(!found && *s != '\0'); if(found) { s--; // this character is part of the separator, not the word } str = moWCString(start, static_cast<int>(s - start)); if(f_auto_clip) { str = str.Clip(); } if(f_empty_words || !str.IsEmpty()) { // word accepted Insert(new moWCString(str)); } // skip the word separator if(*s != '\0') { s += skip; } } return Count(); }
bool TestExtClass::test_get_class_vars() { Array properties = f_get_class_vars("TEst"); VS(properties, CREATE_MAP1("foo", uninit_null())); return Count(true); }
bool TestExtClass::test_get_parent_class() { // TestCodeRun covers this return Count(true); }
void world_tick(World *world) { Random_Series *rs = &world->random_series; for (U32 i = 0; i < Count(world->dwarves); i++) { Dwarf *dwarf = &world->dwarves[i]; if (!dwarf->id || !dwarf->alive) continue; Location *location = &world->locations[dwarf->location]; dwarf->hunger++; dwarf->sleep++; switch (dwarf->activity) { case Activity_Idle: if (dwarf->sleep > 50) { dwarf_do_activity(world, dwarf, Activity_Sleep); } else if (dwarf->hunger > 50) { dwarf_do_activity(world, dwarf, Activity_Eat); } break; case Activity_Eat: if (location->has_food) { dwarf->hunger -= 3; } else { for (U32 i = 0; i < Count(world->locations); i++) { Location *new_location = &world->locations[i]; if (new_location->id && new_location->has_food) { dwarf->location = new_location->id; break; } } } if (dwarf->hunger < 5) { dwarf_do_activity(world, dwarf, Activity_Idle); } break; case Activity_Sleep: if (location->has_bed) { dwarf->sleep -= 3; } else { for (U32 i = 0; i < Count(world->locations); i++) { Location *new_location = &world->locations[i]; if (new_location->id && new_location->has_bed) { dwarf->location = new_location->id; break; } } } if (dwarf->sleep < 5) { dwarf_do_activity(world, dwarf, Activity_Idle); } break; } // TODO: Support more precision, now the chance is // 1:1000 and 1:1000 = 1:1000*1000 = 1:1000000 if (next_one_in(rs, 1000) && next_one_in(rs, 1000)) { world_post(world, dwarf->id, Post_Death, 0); dwarf->alive = false; } } }
bool TestExtClass::test_is_subclass_of() { // TestCodeRun covers this return Count(true); }
bool TestExtError::test_debug_backtrace() { // better tested by php code return Count(true); }
bool TestExtDatetime::test_date_offset_get() { VS(f_date_offset_get(f_date_create("2006-12-12")), -28800); VS(f_date_offset_get(f_date_create("2008-08-08")), -25200); return Count(true); }