aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-06-22 23:30:00 -0700
committerGravatar yang-g <yangg@google.com>2015-06-22 23:30:00 -0700
commitb1bbc8764db510547ac2b98168e86ee84c3d234b (patch)
tree97839b8d6b1df167ca530be05fecb93ee83be221 /test/cpp
parent89c5a5623377e7d4d253c7a304bc726357c6ef0e (diff)
proper init const char *
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/util/byte_buffer_test.cc24
-rw-r--r--test/cpp/util/slice_test.cc4
2 files changed, 14 insertions, 14 deletions
diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc
index 8ad2fad505..13eb49730a 100644
--- a/test/cpp/util/byte_buffer_test.cc
+++ b/test/cpp/util/byte_buffer_test.cc
@@ -43,21 +43,21 @@
namespace grpc {
namespace {
+const char* kContent1 = "hello xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+const char* kContent2 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world";
+
class ByteBufferTest : public ::testing::Test {
- protected:
- const char* kContent1_ = "hello xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
- const char* kContent2_ = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world";
};
TEST_F(ByteBufferTest, CreateFromSingleSlice) {
- gpr_slice hello = gpr_slice_from_copied_string(kContent1_);
+ gpr_slice hello = gpr_slice_from_copied_string(kContent1);
Slice s(hello, Slice::STEAL_REF);
ByteBuffer buffer(&s, 1);
}
TEST_F(ByteBufferTest, CreateFromVector) {
- gpr_slice hello = gpr_slice_from_copied_string(kContent1_);
- gpr_slice world = gpr_slice_from_copied_string(kContent2_);
+ gpr_slice hello = gpr_slice_from_copied_string(kContent1);
+ gpr_slice world = gpr_slice_from_copied_string(kContent2);
std::vector<Slice> slices;
slices.push_back(Slice(hello, Slice::STEAL_REF));
slices.push_back(Slice(world, Slice::STEAL_REF));
@@ -65,20 +65,20 @@ TEST_F(ByteBufferTest, CreateFromVector) {
}
TEST_F(ByteBufferTest, Clear) {
- gpr_slice hello = gpr_slice_from_copied_string(kContent1_);
+ gpr_slice hello = gpr_slice_from_copied_string(kContent1);
Slice s(hello, Slice::STEAL_REF);
ByteBuffer buffer(&s, 1);
buffer.Clear();
}
TEST_F(ByteBufferTest, Length) {
- gpr_slice hello = gpr_slice_from_copied_string(kContent1_);
- gpr_slice world = gpr_slice_from_copied_string(kContent2_);
+ gpr_slice hello = gpr_slice_from_copied_string(kContent1);
+ gpr_slice world = gpr_slice_from_copied_string(kContent2);
std::vector<Slice> slices;
slices.push_back(Slice(hello, Slice::STEAL_REF));
slices.push_back(Slice(world, Slice::STEAL_REF));
ByteBuffer buffer(&slices[0], 2);
- EXPECT_EQ(strlen(kContent1_) + strlen(kContent2_), buffer.Length());
+ EXPECT_EQ(strlen(kContent1) + strlen(kContent2), buffer.Length());
}
bool SliceEqual(const Slice& a, gpr_slice b) {
@@ -94,8 +94,8 @@ bool SliceEqual(const Slice& a, gpr_slice b) {
}
TEST_F(ByteBufferTest, Dump) {
- gpr_slice hello = gpr_slice_from_copied_string(kContent1_);
- gpr_slice world = gpr_slice_from_copied_string(kContent2_);
+ gpr_slice hello = gpr_slice_from_copied_string(kContent1);
+ gpr_slice world = gpr_slice_from_copied_string(kContent2);
std::vector<Slice> slices;
slices.push_back(Slice(hello, Slice::STEAL_REF));
slices.push_back(Slice(world, Slice::STEAL_REF));
diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc
index 36ffeb66bd..eb328490e1 100644
--- a/test/cpp/util/slice_test.cc
+++ b/test/cpp/util/slice_test.cc
@@ -39,6 +39,8 @@
namespace grpc {
namespace {
+const char* kContent = "hello xxxxxxxxxxxxxxxxxxxx world";
+
class SliceTest : public ::testing::Test {
protected:
void CheckSlice(const Slice& s, const grpc::string& content) {
@@ -46,8 +48,6 @@ class SliceTest : public ::testing::Test {
EXPECT_EQ(content,
grpc::string(reinterpret_cast<const char*>(s.begin()), s.size()));
}
-
- const char* kContent = "hello xxxxxxxxxxxxxxxxxxxx world";
};
TEST_F(SliceTest, Steal) {