proxygen
DemangleTest.cpp File Reference

Go to the source code of this file.

Classes

struct  folly_test::ThisIsAVeryLongStructureName
 

Namespaces

 folly_test
 

Functions

 TEST (Demangle, strlcpy)
 

Function Documentation

TEST ( Demangle  ,
strlcpy   
)

Definition at line 89 of file DemangleTest.cpp.

References EXPECT_EQ, string, and folly::strlcpy().

89  {
90  char buf[6];
91 
92  EXPECT_EQ(3, folly::strlcpy(buf, "abc", 6));
93  EXPECT_EQ('\0', buf[3]);
94  EXPECT_EQ("abc", std::string(buf));
95 
96  EXPECT_EQ(7, folly::strlcpy(buf, "abcdefg", 3));
97  EXPECT_EQ('\0', buf[2]);
98  EXPECT_EQ("ab", std::string(buf));
99 
100  const char* big_string = "abcdefghijklmnop";
101 
102  EXPECT_EQ(strlen(big_string), folly::strlcpy(buf, big_string, sizeof(buf)));
103  EXPECT_EQ('\0', buf[5]);
104  EXPECT_EQ("abcde", std::string(buf));
105 
106  buf[0] = 'z';
107  EXPECT_EQ(strlen(big_string), folly::strlcpy(buf, big_string, 0));
108  EXPECT_EQ('z', buf[0]); // unchanged, size = 0
109 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
size_t strlcpy(char *dest, const char *const src, size_t size)
Definition: Demangle.cpp:121
const char * string
Definition: Conv.cpp:212