16 #include <gtest/gtest.h>
26 char* ptr =
const_cast<char*
>(str.c_str());
31 TEST(StringValueTest, TestCompare) {
32 string empty_str =
"";
33 string str1_str(
"\0", 1);
34 string str2_str(
"\0xy", 3);
35 string str3_str =
"abc";
36 string str4_str(
"abc\0def", 7);
37 string str5_str =
"abcdef";
38 string str6_str =
"xyz";
39 string str7_str(
"xyz\0", 4);
41 string str8_str(
"yyyyyyyyyyyyyyyy\0yyyyyyyyyyyyyyyyyy", 35);
42 string str9_str(
"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy", 34);
43 string char0_str(
"hi", 2);
44 string char1_str(
"hi ", 4);
45 string char2_str(
" hi ", 5);
46 string char3_str(
"12345", 5);
47 string char4_str(
" ", 1);
48 string char5_str(
"", 0);
51 const int NUM_CHARS = 6;
70 EXPECT_TRUE(svs[i].Eq(svs[j])) <<
"i=" << i <<
" j=" << j;
71 EXPECT_FALSE(svs[i].Ne(svs[j])) <<
"i=" << i <<
" j=" << j;
72 EXPECT_FALSE(svs[i].Lt(svs[j])) <<
"i=" << i <<
" j=" << j;
73 EXPECT_FALSE(svs[i].Gt(svs[j])) <<
"i=" << i <<
" j=" << j;
74 EXPECT_TRUE(svs[i].Le(svs[j])) <<
"i=" << i <<
" j=" << j;
75 EXPECT_TRUE(svs[i].Ge(svs[j])) <<
"i=" << i <<
" j=" << j;
76 EXPECT_TRUE(svs[i].Compare(svs[j]) == 0) <<
"i=" << i <<
" j=" << j;
79 EXPECT_FALSE(svs[i].Eq(svs[j])) <<
"i=" << i <<
" j=" << j;
80 EXPECT_TRUE(svs[i].Ne(svs[j])) <<
"i=" << i <<
" j=" << j;
81 EXPECT_TRUE(svs[i].Lt(svs[j])) <<
"i=" << i <<
" j=" << j;
82 EXPECT_FALSE(svs[i].Gt(svs[j])) <<
"i=" << i <<
" j=" << j;
83 EXPECT_TRUE(svs[i].Le(svs[j])) <<
"i=" << i <<
" j=" << j;
84 EXPECT_FALSE(svs[i].Gt(svs[j])) <<
"i=" << i <<
" j=" << j;
85 EXPECT_TRUE(svs[i].Compare(svs[j]) < 0) <<
"i=" << i <<
" j=" << j;
88 EXPECT_FALSE(svs[i].Eq(svs[j])) <<
"i=" << i <<
" j=" << j;
89 EXPECT_TRUE(svs[i].Ne(svs[j])) <<
"i=" << i <<
" j=" << j;
90 EXPECT_FALSE(svs[i].Lt(svs[j])) <<
"i=" << i <<
" j=" << j;
91 EXPECT_TRUE(svs[i].Gt(svs[j])) <<
"i=" << i <<
" j=" << j;
92 EXPECT_FALSE(svs[i].Le(svs[j])) <<
"i=" << i <<
" j=" << j;
93 EXPECT_TRUE(svs[i].Gt(svs[j])) <<
"i=" << i <<
" j=" << j;
94 EXPECT_TRUE(svs[i].Compare(svs[j]) > 0) <<
"i=" << i <<
" j=" << j;
115 EXPECT_EQ(chars[3].ptr[4],
' ');
116 EXPECT_EQ(chars[3].ptr[3],
'4');
121 int main(
int argc,
char **argv) {
122 ::testing::InitGoogleTest(&argc, argv);
124 return RUN_ALL_TESTS();
StringValue FromStdString(const string &str)
static void PadWithSpaces(char *cptr, int64_t cptr_len, int64_t num_chars)
static const int NUM_STRINGS
static int64_t UnpaddedCharLength(const char *cptr, int64_t len)
Returns number of characters in a char array (ignores trailing spaces)
int main(int argc, char **argv)
static void Init()
Initialize CpuInfo.