aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/util
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2016-06-24 11:57:07 -0700
committerGravatar yang-g <yangg@google.com>2016-06-24 11:59:35 -0700
commita324c4fea63840eb06dadb4f0d920226b034404e (patch)
tree8b51c4ae9ae07720fc5f8cc4c9566f448186ee40 /test/cpp/util
parentd605b63383678313aaf3a6a3be7d8f9fc7ca67e9 (diff)
Add API to get c slice from c++ Slice.
Diffstat (limited to 'test/cpp/util')
-rw-r--r--test/cpp/util/slice_test.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc
index de7ff031ab..45799ae157 100644
--- a/test/cpp/util/slice_test.cc
+++ b/test/cpp/util/slice_test.cc
@@ -68,6 +68,16 @@ TEST_F(SliceTest, Empty) {
CheckSlice(empty_slice, "");
}
+TEST_F(SliceTest, Cslice) {
+ gpr_slice s = gpr_slice_from_copied_string(kContent);
+ Slice spp(s, Slice::STEAL_REF);
+ CheckSlice(spp, kContent);
+ gpr_slice c_slice = spp.c_slice();
+ EXPECT_EQ(GPR_SLICE_START_PTR(s), GPR_SLICE_START_PTR(c_slice));
+ EXPECT_EQ(GPR_SLICE_END_PTR(s), GPR_SLICE_END_PTR(c_slice));
+ gpr_slice_unref(c_slice);
+}
+
} // namespace
} // namespace grpc