TEST(SwitchAny, usesDefaultCase) { boost::any a; int result = switchAny<int>(a, defaultCase([] { return 1; }) ); EXPECT_EQ(1, result); }
TEST(SwitchAny, skipsEmptyCaseForNonEmpty) { boost::any a = 1; int result = switchAny<int>(a, emptyCase([] { return 2; }), defaultCase([] { return 1; }) ); EXPECT_EQ(1, result); }
TEST(SwitchAny, usesEmptyCaseForEmpty) { boost::any a; int result = switchAny<int>(a, emptyCase([] { return 2; }), defaultCase([] { return 1; }) ); EXPECT_EQ(2, result); }
TEST(SwitchAny, canDeduceArgument) { boost::any a = 3; int result = switchAny<int>(a, typeCase_([](int& i) { return i; }), emptyCase([] { return 2; }), defaultCase([] { return 1; }) ); EXPECT_EQ(3, result); }
TEST(SwitchAny, orderIndependent) { boost::any a = 3; int result = switchAny<int>(a, emptyCase([] { return 2; }), defaultCase([] { return 1; }), typeCase<int>([](const int& i) { return i; }) ); EXPECT_EQ(3, result); }
TEST(SwitchAny, usesTypedCaseForFull) { boost::any a = 3; int result = switchAny<int>(a, typeCase<int>([](int& i) { return i; }), emptyCase([] { return 2; }), defaultCase([] { return 1; }) ); EXPECT_EQ(3, result); }
TEST(SwitchAny, worksForConst) { boost::any a = 3; const boost::any& ra = a; int result = switchAny<int>(ra, typeCase<int>([](const int& i) { return i; }), emptyCase([] { return 2; }), defaultCase([] { return 1; }) ); EXPECT_EQ(3, result); }
void LSSNetworkHandler::inMessage(std::string pMessage, int pSocket){ std::string command = Tokenizer::getCommandSpace(pMessage, 1); std::string param = Tokenizer::getParameters(pMessage); if (command == "connect"){ connect(pSocket, param); } else if (command == "startClient"){ outMessage( std::to_string(LssOperations::newSession()) , pSocket); } else if (command == "format"){ format(pSocket, param); } else if (command == "isAlive"){ isAlive(pSocket, param); }else if (command == "readBlock"){ readBlock(pSocket, param); } else if (command == "writeBlock"){ writeBlock(pSocket, param); } else if (command == "getSize"){ getSize(pSocket, param); } else if (command == "disconnect"){ disconnectClient(); }else if (command == "writeBytes"){ writeBytes(pSocket, param); } else if (command == "readBytes"){ readBytes(pSocket, param); } else { defaultCase(pSocket, command); } }