proxygen
UTF8StringTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (UTF8StringPiece, valid_utf8)
 
 TEST (UTF8StringPiece, valid_suffix)
 
 TEST (UTF8StringPiece, empty_mid_codepoint)
 
 TEST (UTF8StringPiece, invalid_mid_codepoint)
 
 TEST (UTF8StringPiece, valid_implicit_conversion)
 

Variables

const folly::StringPiece kTestUTF8 = u8"This is \U0001F602 stuff!"
 

Function Documentation

TEST ( UTF8StringPiece  ,
valid_utf8   
)

Definition at line 28 of file UTF8StringTest.cpp.

References EXPECT_EQ, and kTestUTF8.

28  {
30  UTF8StringPiece utf8 = sp;
31  // utf8.size() not available since it's not a random-access range
32  EXPECT_EQ(16, utf8.walk_size());
33 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const folly::StringPiece kTestUTF8
TEST ( UTF8StringPiece  ,
valid_suffix   
)

Definition at line 35 of file UTF8StringTest.cpp.

References EXPECT_EQ, and folly::Range< Iter >::subpiece().

35  {
37  EXPECT_EQ(8, utf8.walk_size());
38 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const folly::StringPiece kTestUTF8
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
TEST ( UTF8StringPiece  ,
empty_mid_codepoint   
)

Definition at line 40 of file UTF8StringTest.cpp.

References EXPECT_EQ, and folly::Range< Iter >::subpiece().

40  {
41  UTF8StringPiece utf8 = kTestUTF8.subpiece(9, 0); // okay since it's empty
42  EXPECT_EQ(0, utf8.walk_size());
43 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const folly::StringPiece kTestUTF8
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
TEST ( UTF8StringPiece  ,
invalid_mid_codepoint   
)

Definition at line 45 of file UTF8StringTest.cpp.

References EXPECT_THROW, and folly::Range< Iter >::subpiece().

45  {
46  EXPECT_THROW(UTF8StringPiece(kTestUTF8.subpiece(9, 1)), std::out_of_range);
47 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
UTF8Range< const char * > UTF8StringPiece
Definition: UTF8String.h:46
const folly::StringPiece kTestUTF8
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
TEST ( UTF8StringPiece  ,
valid_implicit_conversion   
)

Definition at line 49 of file UTF8StringTest.cpp.

References EXPECT_EQ, and string.

49  {
50  std::string input = u8"\U0001F602\U0001F602\U0001F602";
51  auto checkImplicitCtor = [](UTF8StringPiece implicitCtor) {
52  return implicitCtor.walk_size();
53  };
54  EXPECT_EQ(3, checkImplicitCtor(input));
55 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const char * string
Definition: Conv.cpp:212

Variable Documentation

const folly::StringPiece kTestUTF8 = u8"This is \U0001F602 stuff!"

Definition at line 26 of file UTF8StringTest.cpp.

Referenced by TEST().