#include "test.h"

#include <base/windows.h>

#include <gtest/gtest.h>

#if defined(CONF_FAMILY_WINDOWS)

TEST(ArgumentsToWide, SingleArgumentNoQuotes)
{
	const char *apArguments[] = {"change_map ctf5"};
	std::wstring Result = windows_args_to_wide(apArguments, std::size(apArguments));
	EXPECT_EQ(Result, LR"("change_map ctf5")");
}

TEST(ArgumentsToWide, SingleArgumentWithQuotes)
{
	const char *apArguments[] = {"change_map \"ctf5\""};
	std::wstring Result = windows_args_to_wide(apArguments, std::size(apArguments));
	EXPECT_EQ(Result, L"\"change_map \\\"ctf5\\\"\"");
}

TEST(ArgumentsToWide, MultipleArguments)
{
	const char *apArguments[] = {"change_map ctf5", "sv_register 0"};
	std::wstring Result = windows_args_to_wide(apArguments, std::size(apArguments));
	EXPECT_EQ(Result, LR"("change_map ctf5" "sv_register 0")");
}

TEST(ArgumentsToWide, SingleArgumentWithSlashes)
{
	const char *apArguments[] = {R"(sv_name te\st)"};
	std::wstring Result = windows_args_to_wide(apArguments, std::size(apArguments));
	EXPECT_EQ(Result, L"\"sv_name te\\st\"");
}

TEST(ArgumentsToWide, MultipleArgumentsWithSlashesAndQuotes)
{
	const char *apArguments[] = {R"(sv_name "te\\st")", R"(sv_motd "fo\\o")"};
	std::wstring Result = windows_args_to_wide(apArguments, std::size(apArguments));
	EXPECT_EQ(Result, L"\"sv_name \\\"te\\\\st\\\"\" \"sv_motd \\\"fo\\\\o\\\"\"");
}

TEST(ArgumentsToWide, MultipleArgumentsWithEndSlash)
{
	const char *apArguments[] = {R"(sv_name "te\\st\\")", R"(sv_motd foo\)"};
	std::wstring Result = windows_args_to_wide(apArguments, std::size(apArguments));
	EXPECT_EQ(Result, L"\"sv_name \\\"te\\\\st\\\\\\\\\\\"\" \"sv_motd foo\\\\\"");
}

#endif
