mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
The UTF-8 char* is marshaled to a UTF-16 string automatically. It must be allocated on the heap as the CLR will free the returned memory. This removes entire classes of possible errors, greatly reducing the code complexity and number of tests.
28 lines
568 B
C++
28 lines
568 B
C++
//! @file test-getusername.cpp
|
|
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
|
|
//! @brief Unit tests for GetUserName
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <unistd.h>
|
|
#include <gtest/gtest.h>
|
|
#include <unicode/unistr.h>
|
|
#include <pwd.h>
|
|
#include "getusername.h"
|
|
|
|
//! Test fixture for GetUserName
|
|
class GetUserNameTest : public ::testing::Test
|
|
{
|
|
protected:
|
|
std::string UserName;
|
|
|
|
GetUserNameTest(): UserName(std::string(getpwuid(geteuid())->pw_name))
|
|
{
|
|
}
|
|
};
|
|
|
|
TEST_F(GetUserNameTest, Success)
|
|
{
|
|
ASSERT_EQ(GetUserName(), UserName);
|
|
}
|