proxygen
json_pointer_test.cpp File Reference

Go to the source code of this file.

Classes

class  JsonPointerTest
 

Functions

 TEST_F (JsonPointerTest, ValidPointers)
 
 TEST_F (JsonPointerTest, InvalidPointers)
 
 TEST_F (JsonPointerTest, IsPrefixTo)
 

Function Documentation

TEST_F ( JsonPointerTest  ,
ValidPointers   
)

Definition at line 26 of file json_pointer_test.cpp.

References testing::ElementsAreArray(), EXPECT_THAT, parse(), and tokens.

26  {
29  ElementsAreArray(std::vector<std::string>{}));
32  json_pointer::parse("/1/2/3").tokens(),
33  ElementsAreArray({"1", "2", "3"}));
35  json_pointer::parse("/~0~1/~0/10").tokens(),
36  ElementsAreArray({"~/", "~", "10"}));
37 }
size_t parse(const char *buf, size_t len)
Definition: test.c:1591
internal::ElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
#define EXPECT_THAT(value, matcher)
static const char tokens[256]
Definition: http_parser.c:184
TEST_F ( JsonPointerTest  ,
InvalidPointers   
)

Definition at line 39 of file json_pointer_test.cpp.

References folly::pushmi::operators::error(), and EXPECT_EQ.

39  {
40  EXPECT_EQ(
41  json_pointer::parse_error::invalid_first_character,
42  json_pointer::try_parse("a").error());
43  EXPECT_EQ(
44  json_pointer::parse_error::invalid_escape_sequence,
45  json_pointer::try_parse("/~").error());
46  EXPECT_EQ(
47  json_pointer::parse_error::invalid_escape_sequence,
48  json_pointer::try_parse("/~x").error());
49 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
TEST_F ( JsonPointerTest  ,
IsPrefixTo   
)

Definition at line 51 of file json_pointer_test.cpp.

References EXPECT_FALSE, EXPECT_TRUE, and parse().

51  {
53  json_pointer::parse("/a/b").is_prefix_of(json_pointer::parse("/a/b/c")));
55  json_pointer::parse("/a/b").is_prefix_of(json_pointer::parse("/a/d/e")));
57  json_pointer::parse("/a/b/c").is_prefix_of(json_pointer::parse("/a/b")));
58 }
size_t parse(const char *buf, size_t len)
Definition: test.c:1591
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862