proxygen
LogNameTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (LogName, canonicalize)
 
 TEST (LogName, getParent)
 
 TEST (LogName, hash)
 
 TEST (LogName, cmp)
 

Function Documentation

TEST ( LogName  ,
canonicalize   
)

Definition at line 21 of file LogNameTest.cpp.

References folly::LogName::canonicalize(), and EXPECT_EQ.

21  {
22  EXPECT_EQ("", LogName::canonicalize("."));
23  EXPECT_EQ("", LogName::canonicalize("..."));
24  EXPECT_EQ("", LogName::canonicalize("/"));
25  EXPECT_EQ("", LogName::canonicalize("\\"));
26  EXPECT_EQ("", LogName::canonicalize(".//..\\\\./"));
27  EXPECT_EQ("foo.bar", LogName::canonicalize(".foo..bar."));
28  EXPECT_EQ("a.b.c", LogName::canonicalize("a.b.c"));
29  EXPECT_EQ("a.b.c", LogName::canonicalize("a/b/c"));
30  EXPECT_EQ("a.b.c", LogName::canonicalize("a/b/c/"));
31  EXPECT_EQ("a.b.c", LogName::canonicalize("a..b.c..."));
32  EXPECT_EQ("a.b.c", LogName::canonicalize("....a.b.c"));
33  EXPECT_EQ("a.b.c", LogName::canonicalize("a.b.c...."));
34  EXPECT_EQ("a.b.c", LogName::canonicalize("////a.b.c"));
35  EXPECT_EQ("a.b.c", LogName::canonicalize("a.b.c////"));
36  EXPECT_EQ("a.b.c", LogName::canonicalize("/a.b.//.c/"));
37 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( LogName  ,
getParent   
)

Definition at line 39 of file LogNameTest.cpp.

References EXPECT_EQ, and folly::LogName::getParent().

39  {
40  EXPECT_EQ("", LogName::getParent("foo"));
41  EXPECT_EQ("", LogName::getParent(".foo"));
42  EXPECT_EQ("foo", LogName::getParent("foo.bar"));
43  EXPECT_EQ("foo", LogName::getParent("foo/bar"));
44  EXPECT_EQ("foo", LogName::getParent("foo\\bar"));
45  EXPECT_EQ("foo", LogName::getParent("foo\\bar/"));
46  EXPECT_EQ("foo", LogName::getParent("foo\\bar\\"));
47  EXPECT_EQ("foo..bar", LogName::getParent("foo..bar..test"));
48  EXPECT_EQ("..foo..bar", LogName::getParent("..foo..bar..test.."));
49 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( LogName  ,
hash   
)

Definition at line 51 of file LogNameTest.cpp.

References EXPECT_EQ, EXPECT_NE, and folly::LogName::hash().

51  {
52  EXPECT_EQ(LogName::hash("foo"), LogName::hash("foo."));
53  EXPECT_EQ(LogName::hash(".foo..bar"), LogName::hash("foo.bar..."));
54  EXPECT_EQ(LogName::hash("a.b.c..d."), LogName::hash("..a.b.c.d."));
55  EXPECT_EQ(LogName::hash("a.b.c.d"), LogName::hash("/a/b/c/d/"));
56  EXPECT_EQ(LogName::hash("a.b.c.d"), LogName::hash("a\\b\\c/d/"));
57  EXPECT_EQ(LogName::hash(""), LogName::hash("."));
58  EXPECT_EQ(LogName::hash(""), LogName::hash("//"));
59  EXPECT_EQ(LogName::hash(""), LogName::hash("\\"));
60  EXPECT_EQ(LogName::hash(""), LogName::hash("...."));
61 
62  // Hashes for different category names should generally be different.
63  // This is not strictly required. This test is mainly to ensure that the
64  // code does not just hash all inputs to the same value.
65  EXPECT_NE(LogName::hash("foo"), LogName::hash("bar"));
66  EXPECT_NE(LogName::hash("a.b.c"), LogName::hash("abc"));
67 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
TEST ( LogName  ,
cmp   
)

Definition at line 69 of file LogNameTest.cpp.

References folly::LogName::cmp(), EXPECT_EQ, EXPECT_GT, and EXPECT_LT.

69  {
70  EXPECT_EQ(0, LogName::cmp("foo", "foo."));
71  EXPECT_EQ(0, LogName::cmp("foo", "foo/"));
72  EXPECT_EQ(0, LogName::cmp(".foo..bar", "foo.bar..."));
73  EXPECT_EQ(0, LogName::cmp(".foo.bar", "foo...bar..."));
74  EXPECT_EQ(0, LogName::cmp("a.b.c..d.", "..a.b.c.d."));
75  EXPECT_EQ(0, LogName::cmp("a.b.c..d.", "\\/a.b/c/d."));
76  EXPECT_EQ(0, LogName::cmp("", "."));
77  EXPECT_EQ(0, LogName::cmp("", "...."));
78 
79  EXPECT_GT(LogName::cmp("foo", "bar"), 0);
80  EXPECT_LT(LogName::cmp("a.b.c", "abc"), 0);
81  EXPECT_LT(LogName::cmp("a...b.c", "a.bc"), 0);
82  EXPECT_GT(LogName::cmp("a...b.z", "a.b.c"), 0);
83  EXPECT_LT(LogName::cmp(".foo.bar", "foobar..."), 0);
84  EXPECT_GT(LogName::cmp("foobar", ".foo...bar"), 0);
85 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_LT(val1, val2)
Definition: gtest.h:1930
#define EXPECT_GT(val1, val2)
Definition: gtest.h:1934