int testGetSharesForParticipants(PFC &pfc) { int errors = 0; ENHDEBUG("Creating instances"); std::string expr = op_OR + "(1, " + op_AND + "(2,3,4), " + op_AND + "(2,5), " + op_AND + "(4,5))"; shared_ptr<BLAccessPolicy> policy = make_shared<BLAccessPolicy>(expr, 5); BLSS testScheme(policy, pfc.order(), pfc); ENHDEBUG("Creating shares"); ShareTuple s1a(1, 0, "1a"); ShareTuple s1b(1, 0, "1b"); ShareTuple s2a(2, 0, "2a"); ShareTuple s3a(3, 0, "3a"); ShareTuple s3b(3, 0, "3b"); ShareTuple s3c(3, 0, "3c"); ShareTuple s4a(4, 0, "4a"); ShareTuple s5a(5, 0, "5a"); vector<ShareTuple> shares; shares.push_back(s1a); shares.push_back(s1b); shares.push_back(s2a); shares.push_back(s3a); shares.push_back(s3b); shares.push_back(s3c); shares.push_back(s4a); shares.push_back(s5a); vector<int> parts313; vector<int> parts276; vector<int> parts45; parts313.push_back(3); parts313.push_back(1); parts313.push_back(3); parts276.push_back(2); parts276.push_back(7); parts276.push_back(6); parts45.push_back(4); parts45.push_back(5); vector<ShareTuple> verif313; vector<ShareTuple> verif276; vector<ShareTuple> verif45; verif313.push_back(s1a); verif313.push_back(s1b); verif313.push_back(s3a); verif313.push_back(s3b); verif313.push_back(s3c); verif276.push_back(s2a); verif45.push_back(s4a); verif45.push_back(s5a); std::string base = "testGetSharesForParticipants - "; ENHDEBUG("Calling diagnosis"); DEBUG("call 1"); vector<ShareTuple> returnedShares = SecretSharing::getSharesForParticipants(parts313, shares); test_diagnosis(base + "[313]", returnedShares == verif313, errors); DEBUG("call 2"); returnedShares = SecretSharing::getSharesForParticipants(parts276, shares); test_diagnosis(base + "[276]", returnedShares == verif276, errors); DEBUG("call 3"); returnedShares = SecretSharing::getSharesForParticipants(parts45, shares); test_diagnosis(base + "[45]", returnedShares == verif45, errors); ENHDEBUG("Finished diagnosis"); return errors; }
void SDL_Window::_handleSDLKeyEvent(Window::KeyEventType type, SDL_Keycode keysym, unsigned int unicode) { april::Key akeysym = AK_UNKNOWN; #define _s2a(sdlk, ak) case sdlk: akeysym = ak; break; #define _s2a_u0(sdlk, ak) case sdlk: akeysym = ak; unicode = 0; break; #define s2a(sdlk, ak) _s2a(SDLK_ ## sdlk, AK_ ## ak) #define s2a_u0(sdlk, ak) _s2a_u0(SDLK_ ## sdlk, AK_ ## ak) #define sea(key) s2a(key, key) #define sea_u0(key) s2a_u0(key, key) switch (keysym) { // control character keys s2a(BACKSPACE, BACK); #ifdef __APPLE__ s2a_u0(DELETE, DELETE); #else case SDLK_DELETE: akeysym = AK_DELETE; //sea(DELETE); #endif sea(TAB) sea(RETURN); s2a(KP_ENTER, RETURN); // control keys above cursor keys s2a(PAGEUP, PRIOR); s2a(PAGEDOWN, NEXT); sea(HOME); sea(END); sea(INSERT); // delete already defined under control chars // this is because on mac sdl, delete == backspace // for some reason // cursor keys sea_u0(LEFT); sea_u0(RIGHT); sea_u0(UP); sea_u0(DOWN); // space sea(SPACE); // function keys sea_u0(F1); sea_u0(F2); sea_u0(F3); sea_u0(F4); sea_u0(F5); sea_u0(F6); sea_u0(F7); sea_u0(F8); sea_u0(F9); sea_u0(F10); sea_u0(F11); sea_u0(F12); s2a(ESCAPE, ESCAPE); // keypad keys s2a(KP_0, NUMPAD0); s2a(KP_1, NUMPAD1); s2a(KP_2, NUMPAD2); s2a(KP_3, NUMPAD3); s2a(KP_4, NUMPAD4); s2a(KP_5, NUMPAD5); s2a(KP_6, NUMPAD6); s2a(KP_7, NUMPAD7); s2a(KP_8, NUMPAD8); s2a(KP_9, NUMPAD9); s2a(LCTRL, LCONTROL); s2a(RCTRL, RCONTROL); s2a(LALT, LMENU); s2a(RALT, RMENU); s2a(LGUI, LCOMMAND); // TODO - check if this is ok in SDL 2 s2a(RGUI, RCOMMAND); // TODO - check if this is ok in SDL 2 s2a(LSHIFT, LSHIFT); s2a(RSHIFT, RSHIFT); default: break; } // number keys if (keysym >= '0' && keysym <= '9') { akeysym = (Key)keysym; } // letters if (keysym >= 'a' && keysym <= 'z') // sdl letter keys are small ASCII letters { akeysym = (Key)(keysym - 32); // april letter keys are capital ASCII letters } if (akeysym == AK_LCONTROL || akeysym == AK_RCONTROL) { if (type == KEY_DOWN) { this->scrollHorizontal = true; } else if (type == KEY_UP) { this->scrollHorizontal = false; } } Window::handleKeyEvent(type, akeysym, 0); }