Ejemplo n.º 1
0
TEST(SwitchAny, usesDefaultCase)
{
	boost::any a;
	int result = switchAny<int>(a,
		defaultCase([] { return 1; })
	);
	EXPECT_EQ(1, result);
}
Ejemplo n.º 2
0
TEST(SwitchAny, skipsEmptyCaseForNonEmpty)
{
	boost::any a = 1;
	int result = switchAny<int>(a,
		emptyCase([] { return 2; }),
		defaultCase([] { return 1; })
	);
	EXPECT_EQ(1, result);
}
Ejemplo n.º 3
0
TEST(SwitchAny, usesEmptyCaseForEmpty)
{
	boost::any a;
	int result = switchAny<int>(a,
		emptyCase([] { return 2; }),
		defaultCase([] { return 1; })
	);
	EXPECT_EQ(2, result);
}
Ejemplo n.º 4
0
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);
}
Ejemplo n.º 5
0
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);
}
Ejemplo n.º 6
0
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);
}
Ejemplo n.º 7
0
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);
}
Ejemplo n.º 8
0
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);

	}
}