Add tests for native GetFileOwner

This commit is contained in:
Andrew Schwartzmeyer committed 2016-07-13 15:46:25 -07:00
1 parent e6d3cbcce0
commit f3328fec5c
2 files changed
+33

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
add_subdirectory(googletest)
add_executable(psl-native-test
test-getfileowner.cpp
test-locale.cpp
test-getcurrentprocessid.cpp
test-getusername.cpp
@@ -0,0 +1,32 @@
//! @file test-getfileowner.cpp
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
//! @brief Tests GetFileOwner
#include <gtest/gtest.h>
#include <errno.h>
#include <unistd.h>
#include "getfileowner.h"
using namespace std;
//! Test fixture for GetFileOwner
class GetFileOwnerTest : public ::testing::Test
{
};
TEST_F(GetFileOwnerTest, CanGetOwnerOfRoot)
{
ASSERT_STREQ(GetFileOwner("/"), "root");
}
TEST_F(GetFileOwnerTest, CannotGetOwnerOfFakeFile)
{
EXPECT_STREQ(GetFileOwner("SomeMadeUpFileNameThatDoesNotExist"), NULL);
EXPECT_EQ(errno, ERROR_FILE_NOT_FOUND);
}
TEST_F(GetFileOwnerTest, ReturnsNullForNullInput)
{
EXPECT_STREQ(GetFileOwner(NULL), NULL);
EXPECT_EQ(errno, ERROR_INVALID_PARAMETER);
}