aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar kpayson64 <kpayson@google.com>2016-07-13 10:24:22 -0700
committerGravatar GitHub <noreply@github.com>2016-07-13 10:24:22 -0700
commit5820f8c597691acc88afc811eda7c2f4395e12d8 (patch)
tree57faf6e9cd11d24aa3238ee5275d2a174c36a1ea /test
parentd3d739284b3d450e5823387dd13a67ef2932de15 (diff)
parent3e63b4ee7e96ac432227ec7676f9f737c7008b1a (diff)
Merge pull request #7044 from yang-g/slice
Add API to get C slice from C++ Slice.
Diffstat (limited to 'test')
-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