changed spacing and using std::string instead of TCHAR

This commit is contained in:
Aaron Katz
2015-04-09 15:16:37 -07:00
parent 03eae4653a
commit 0245ab771e
2 changed files with 13 additions and 14 deletions
+6 -6
View File
@@ -3,10 +3,10 @@
BOOL GetComputerName(LPTSTR name, LPDWORD len)
{
int host = gethostname(name, HOST_NAME_MAX);
if(host == 0)
{
return TRUE;
}
return FALSE;
int host = gethostname(name, HOST_NAME_MAX);
if(host == 0)
{
return TRUE;
}
return FALSE;
}
+7 -8
View File
@@ -4,25 +4,24 @@
TEST(GetComputerName,simple)
{
char hostname[HOST_NAME_MAX];
TCHAR hostnameFunctionTest[HOST_NAME_MAX];
std::string hostnameFunctionTest;
DWORD hostSize = HOST_NAME_MAX;
BOOL getComputerName = GetComputerName(hostnameFunctionTest, &hostSize);
BOOL getComputerName = GetComputerName(&hostnameFunctionTest[0], &hostSize);
BOOL host = gethostname(hostname, sizeof hostname);
if(host == 0)
{
host = TRUE;
host = TRUE;
}
else
{
host = FALSE;
host = FALSE;
}
std::string hostnameSting(hostname);
std::string hostnameStingTest(hostnameFunctionTest);
std::string hostnameString(hostname);
std::string hostnameStringTest(&hostnameFunctionTest[0]);
ASSERT_TRUE(getComputerName == TRUE);
ASSERT_EQ(host,TRUE);
ASSERT_EQ(hostnameSting,hostnameFunctionTest);
ASSERT_EQ(hostnameString,hostnameStringTest);
}