Files
PowerShell/tests/test-getcomputername.cpp
T

27 lines
659 B
C++
Raw Normal View History

#include <gtest/gtest.h>
#include "getcomputername.h"
TEST(GetComputerName,simple)
2015-04-06 09:57:16 -07:00
{
char hostname[HOST_NAME_MAX];
std::string hostnameFunctionTest;
2015-04-06 09:57:16 -07:00
DWORD hostSize = HOST_NAME_MAX;
BOOL getComputerName = GetComputerName(&hostnameFunctionTest[0], &hostSize);
2015-04-06 09:57:16 -07:00
BOOL host = gethostname(hostname, sizeof hostname);
2015-04-06 09:57:16 -07:00
if(host == 0)
{
host = TRUE;
2015-04-06 09:57:16 -07:00
}
else
{
host = FALSE;
2015-04-06 09:57:16 -07:00
}
std::string hostnameString(hostname);
std::string hostnameStringTest(&hostnameFunctionTest[0]);
2015-04-06 09:57:16 -07:00
ASSERT_TRUE(getComputerName == TRUE);
ASSERT_EQ(host,TRUE);
ASSERT_EQ(hostnameString,hostnameStringTest);
}