diff options
author | Vikram Gaur <vikramgaur@google.com> | 2022-03-19 19:20:37 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-19 19:20:37 +0000 |
commit | b236eac8909a38197232dda5ec452a282aa6ef24 (patch) | |
tree | 5cf6e6aed510f5de8e63831619b71c7f71f374ea | |
parent | 182cc59382fbb8e7fd21c1c44c218eb51366bec4 (diff) | |
parent | 2d799b0dffd31681fa0be3ef83a0c50248bc4096 (diff) | |
download | libcppbor-b236eac8909a38197232dda5ec452a282aa6ef24.tar.gz |
Fixed minor bugs in libcppbor. am: 237ccfe4c3 am: 2d799b0dff
Original change: https://android-review.googlesource.com/c/platform/external/libcppbor/+/2032574
Change-Id: I2610e139bed4c28d4e577677d8b674580ded6933
-rw-r--r-- | src/cppbor.cpp | 5 | ||||
-rw-r--r-- | tests/cppbor_test.cpp | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/cppbor.cpp b/src/cppbor.cpp index 0e9c939..5c9827f 100644 --- a/src/cppbor.cpp +++ b/src/cppbor.cpp @@ -132,9 +132,8 @@ bool prettyPrintInternal(const Item* item, string& out, size_t indent, size_t ma const ViewBstr* viewBstr = item->asViewBstr(); assert(viewBstr != nullptr); - std::basic_string_view view = viewBstr->view(); - valueData = view.data(); - valueSize = view.size(); + valueData = viewBstr->view().data(); + valueSize = viewBstr->view().size(); } if (valueSize > maxBStrSize) { diff --git a/tests/cppbor_test.cpp b/tests/cppbor_test.cpp index ebdcc02..7756387 100644 --- a/tests/cppbor_test.cpp +++ b/tests/cppbor_test.cpp @@ -944,7 +944,7 @@ TEST(ConvertTest, ViewTstr) { TEST(ConvertTest, ViewBstr) { array<uint8_t, 3> vec{0x23, 0x24, 0x22}; - basic_string_view sv(vec.data(), vec.size()); + basic_string_view<uint8_t> sv(vec.data(), vec.size()); unique_ptr<Item> item = details::makeItem(ViewBstr(sv)); EXPECT_EQ(BSTR, item->type()); @@ -1081,7 +1081,7 @@ TEST(CloningTest, ViewTstr) { TEST(CloningTest, ViewBstr) { array<uint8_t, 5> vec{1, 2, 3, 255, 0}; - basic_string_view sv(vec.data(), vec.size()); + basic_string_view<uint8_t> sv(vec.data(), vec.size()); ViewBstr item(sv); auto clone = item.clone(); EXPECT_EQ(clone->type(), BSTR); @@ -1707,11 +1707,14 @@ TEST(FullParserTest, ViewTstr) { } TEST(FullParserTest, ViewBstr) { - ViewBstr val("\x00\x01\x02"s); + const std::string strVal = "\x00\x01\x02"s; + const ViewBstr val(strVal); + EXPECT_EQ(val.toString(), "\x43\x00\x01\x02"s); auto enc = val.encode(); auto [item, pos, message] = parseWithViews(enc.data(), enc.size()); EXPECT_THAT(item, MatchesItem(val)); + EXPECT_EQ(hexDump(item->toString()), hexDump(val.toString())); } TEST(FullParserTest, ReservedAdditionalInformation) { |