2015-08-13 09:47:10 -07:00
|
|
|
//! @file test-getcomputername.cpp
|
2015-10-27 15:33:25 -07:00
|
|
|
//! @author George Fleming <v-geflem@microsoft.com>
|
|
|
|
|
//! @brief Unit tests for GetComputerName
|
2015-04-03 10:22:05 -07:00
|
|
|
|
2015-08-13 09:47:10 -07:00
|
|
|
#include <string>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
#include "getcomputername.h"
|
|
|
|
|
|
|
|
|
|
//! Test fixture for GetComputerNameTest
|
2015-08-13 10:53:09 -07:00
|
|
|
class GetComputerNameTest : public ::testing::Test
|
|
|
|
|
{
|
2015-08-04 14:38:53 -07:00
|
|
|
protected:
|
2015-10-27 09:19:41 -07:00
|
|
|
char expectedComputerName[HOST_NAME_MAX];
|
2015-08-04 14:38:53 -07:00
|
|
|
|
|
|
|
|
//Get expected result from using linux call
|
2015-08-13 10:53:09 -07:00
|
|
|
GetComputerNameTest()
|
2015-08-17 17:02:40 -07:00
|
|
|
{
|
2015-10-27 09:19:41 -07:00
|
|
|
BOOL ret = gethostname(expectedComputerName, HOST_NAME_MAX);
|
2015-08-21 09:55:39 -07:00
|
|
|
EXPECT_EQ(0, ret);
|
2015-08-04 14:38:53 -07:00
|
|
|
}
|
|
|
|
|
};
|
2015-04-03 10:22:05 -07:00
|
|
|
|
2015-10-27 15:33:25 -07:00
|
|
|
TEST_F(GetComputerNameTest, ValidateLinuxGetHostnameSystemCall)
|
2015-08-13 10:53:09 -07:00
|
|
|
{
|
2015-10-27 10:48:31 -07:00
|
|
|
ASSERT_STREQ(GetComputerName(), expectedComputerName);
|
2015-07-30 12:47:10 -07:00
|
|
|
}
|