void post_executor_test(int time_taken) { test_t * test = test_current(g_test_runner); test->time_taken = time_taken; if (test->is_failure) { g_test_runner->total_success--; g_test_runner->total_failures++; } print_test_result(); }
void print_test_result() { test_t *test = test_current(g_test_runner); string_t color = NULL; if (!test->is_failure) { g_test_reporter->print_description_success(test, ""); } else { g_test_reporter->print_description_failure(test, g_test_runner->total_failures, ""); } }
//int main(int argc, const char * const argv[]) { int main(int, const char * const *) { static const char* test[4] = { "\\u304D\\u3085\\u3046\\u0000", "\\u30AD\\u30E6\\u30A6\\u0000", "\\u304D\\u3086\\u3046\\u0000", "\\u30AD\\u30E5\\u30A6\\u0000" }; #if 0 static const char* test2[4] = { "dbc\\u0000", "cbc\\u0000", "bbc\\u0000", "abc\\u0000" }; #endif static UChar uTest[4][5]; static uint8_t keys[4][32]; uint32_t i = 0; for(i = 0; i<4; i++) { u_unescape(test[i], uTest[i], 5); } printArray("Before current", uTest, 4); test_current(uTest, 4, 5, keys); printArray("After current", uTest, 4); printKeys("Current keys", keys, 4); for(i = 0; i<4; i++) { u_unescape(test[i], uTest[i], 5); } printArray("Before legacy", uTest, 4); test_legacy(uTest, 4, 5, keys); printArray("After legacy", uTest, 4); printKeys("Legacy keys", keys, 4); return 0; }
int main(int argc, char*argv[]) { #ifndef COMMON_INITS1 cfg.init("bedlab.cfg"); Vec2i windowsize; Vec2i screen_resolution = { int(VideoMode::getDesktopMode().width), int(VideoMode::getDesktopMode().height) }; if (cfg.getvar<int>("auto_winsize")) { auto winscale_which = cfg.getstr("winscale_which"); auto window_scale = cfg.getvar<Vec2>(winscale_which); windowsize = Vec2i(scal(Vec2(screen_resolution), window_scale)); } else { windowsize = cfg.getvar<Vec2i>("windowsize"); } winsize = Vec2(windowsize); UI.init_console(); // ALWAYS AFTER SO IT CAN GET WINDOW SIZE wincenter = 0.5f*Vec2(windowsize); Vec2i windowpos; VideoMode::getDesktopMode().height; if (cfg.getvar<int>("stick_left")) { windowpos = Vec2i( screen_resolution.x - windowsize.x - 10, screen_resolution.y - windowsize.y - 40 ); } else windowpos = (Vec2i(5, 25)); sf::RenderWindow window(sf::VideoMode(windowsize.x, windowsize.y), "bedlab!", 7 //,sf::ContextSettings(0, 0, 1) ); window.setFramerateLimit(cfg.getvar<int>("fps_max")); frame_duration = 1.0f / cfg.getvar<int>("fps_max"); window.setPosition(windowpos); vector<string> keys; auto choice = cfg.getstr("app"); // show_keys(cfg.getstr("app"), keys); #endif // COMMON_INITS1 #ifndef COMMON_INITS2 // we don't have a class/interface/struct with data, everything is local to this function, like a classic stack that all programs are anyway. // Texture cursor_tx; // if (!cursor_tx.loadFromFile(cfg.getstr("cursor"))) // cout << "did not load cursor" << endl; // Sprite cursor; // cursor.setTexture(cursor_tx); // cursor.setOrigin(3, 3); CircleShape cursor = mkcircle({ 0,0 }, Color::Transparent, 3, 1); Color background = cfg.getvar<Color>("background"); window.setMouseCursorVisible(false); Vec2 mpos; bool leftclicked = false, rightclicked = false; // view and zoom View view, ui_view; ui_view = view = window.getDefaultView(); float zoomlevel = 1; Vec2 mpos_abs; float frame_duration = 1.0f / cfg.getvar<int>("fps_max"); float smaller_size = 0.95*min(windowsize.y, windowsize.x); auto all_pt_mult = cfg.getvar<float>("all_pt_mult"); all_pt_size = all_pt_mult * smaller_size; //Transform transf; //transf_glob.translate(smaller_size*0.1, smaller_size*0.5); transf_glob.translate(smaller_size*0.02, smaller_size*0.02); transf_glob.scale(Vec2(smaller_size, smaller_size)); //transf_glob = transf; glob_vert_single = VertexArray(Lines); #endif // COMMON_INITS2 #ifndef COMMON_INITS3 bool point_text = cfg.getvar<int>("street_gen_point_text"); bool alternate_font = cfg.getvar<int>("alternate_font"); glob_vert = vector<VertexArray>(10, VertexArray(LineStrip)); string bar_font; Vec2 barsize; auto winscale_which = cfg.getstr("winscale_which"); if (winscale_which == "winscale_smallest" || winscale_which == "winscale_laptop") { bar_font = UI.small_font;; barsize = { 40,7 }; } else if (winscale_which == "winscale_largest" || winscale_which == "winscale_large") { bar_font = UI.default_font; barsize = { 100,15 }; } else { bar_font = UI.default_font; barsize = { 100,15 }; } //dip_bars dbars(UI.fonts["unaligned"], UI.fontsizes[UI.default_font], { 100,15 }); dip_bars dbars(UI.fonts[bar_font], UI.fontsizes[UI.default_font], barsize, { 1,1 }); // tests in lambdas map<string, function<void(void)>> test_lambdas; VertexArray grid(Lines); auto make_grid = [&](float resolution) { // dummy grid grid.clear(); Color col(64, 64, 64, 32); // glob_vert = vector<VertexArray>(10, VertexArray(Lines)); for (int i = 0; i <= int(resolution); ++i) for (int j = 0; j <= int(resolution); ++j) { grid.append(Vertex(tr(Vec2(i / resolution, 0)), col)); grid.append(Vertex(tr(Vec2(i / resolution, 1)), col)); grid.append(Vertex(tr(Vec2(0, i / resolution)), col)); grid.append(Vertex(tr(Vec2(1, i / resolution)), col)); } }; // actual tests diag_draw ddraw; function<void(void)> test_current = [&] {msg("no test configured"); }; auto street_gen_test = cfg.getstr("street_gen_test"); if (test_lambdas.count(street_gen_test)) { test_current = test_lambdas[street_gen_test]; msgm("ok, using test", street_gen_test); test_current(); } else { msg("invalid test choice string thing bing ding king ping ring sing wing wing"); } #endif // COMMON_INITS3 // █████████████████████ APP ACTUAL █████████████████████ // █████████████████████ callbacks █████████████████████ #ifndef LOOP_LAMBDAS draw = [&]() { window.setView(view); //////////////// OBJECTS THAT CAN ZOOMED //////////////// window.draw(grid); window.draw(glob_vert_single); for (auto&a : glob_pts)window.draw(a); for (auto&a : glob_rects)window.draw(a); for (auto&a : glob_vert)window.draw(a); if (point_text) for (auto&a : glob_texts)window.draw(a); ddraw.draw(window); // UI draw, AFTER ui view and BEFORE other draw window.setView(ui_view); //////////////// OBJECTS THAT CANNOT ZOOMED, MEANING UI //////////////// dbars.draw(window); //br.drawwithtext(window); UI.draw(window); window.draw(cursor); }; update = [&]() { }; treatkeyevent = [&](Keyboard::Key k) { switch (k) { case Keyboard::E: break; case Keyboard::T: point_text ^= 1; break; case Keyboard::Q: break; case Keyboard::BackSpace: glob_pts.clear(); glob_texts.clear(); glob_rects.clear(); glob_vert.clear(); break; case Keyboard::Space: break; case Keyboard::S: screenshot(window); break; case Keyboard::Num1: case Keyboard::Num2: case Keyboard::Num3: case Keyboard::Num4: case Keyboard::Num5: break; } }; mousemoved = [&](Vec2 pos) { dbars.mouse_moved(mpos); cursor.setPosition(pos); if (leftclicked); }; mouseclick = [&](sf::Mouse::Button button) { if (button == Mouse::Button::Left) leftclicked = true; if (button == Mouse::Button::Right) rightclicked = true; if (button == Mouse::Button::Left) { dbars.mouse_click(mpos); //test_search(); //test_inter(); } if (button == Mouse::Button::Right) { //test_inter(); } }; mouserelease = [&](sf::Mouse::Button button) { if (button == Mouse::Button::Left) leftclicked = false; if (button == Mouse::Button::Right) rightclicked = false; dbars.mouse_release(); test_current(); }; loop = [&]() { while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { switch (event.type) { case sf::Event::KeyPressed: if (event.key.code == sf::Keyboard::Escape) window.close(); treatkeyevent(event.key.code); break; case sf::Event::Closed: window.close(); break; case sf::Event::MouseButtonPressed: mouseclick(event.mouseButton.button); break; case sf::Event::MouseButtonReleased: mouserelease(event.mouseButton.button); break; case sf::Event::MouseMoved: mpos = Vec2(event.mouseMove.x, event.mouseMove.y); mpos_abs = window.mapPixelToCoords(Vec2i(mpos), view); mousemoved(mpos); break; default: treatotherevent(event); break; } } window.clear(background); update(); draw(); //static bool once = true; //if (once) { // screenshot(window); // once = false; //} window.display(); } }; treatotherevent = [&](Event&e) { if (e.type == Event::MouseWheelMoved && e.mouseWheel.delta) { mpos_abs = window.mapPixelToCoords(Vec2i(mpos), view); //view = window.getView(); if (e.mouseWheel.delta < 0) { zoomlevel *= 2.f; view.setSize(view.getSize()*2.f); view.setCenter(interp(mpos_abs, view.getCenter(), 2.f)); //view.setCenter(interp(mpos_abs, view.getCenter(), 2.f)); } if (e.mouseWheel.delta > 0) { zoomlevel *= 0.5; view.setSize(view.getSize()*.5f); view.setCenter(.5f*(view.getCenter() + mpos_abs)); //view.setCenter(.5f*(view.getCenter() + mpos_abs)); } window.setView(view); } }; #endif // LOOP_LAMBDAS loop(); }
void post_executor_pending(string_t description) { test_t * test = test_current(g_test_runner); g_test_reporter->print_description_pending(test, ""); }