From 4a7fe355da8efddec055943d7770619efe80cb03 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 2 Dec 2020 17:35:00 +0000 Subject: Make it compatible with c++2a --- document/src/tests/documentselectparsertest.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'document') diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp index 30b2bfbb1b4..7e8e3796aaf 100644 --- a/document/src/tests/documentselectparsertest.cpp +++ b/document/src/tests/documentselectparsertest.cpp @@ -37,8 +37,8 @@ protected: ~DocumentSelectParserTest(); Document::SP createDoc( - const std::string& doctype, const std::string& id, uint32_t hint, - double hfloat, const std::string& hstr, const std::string& cstr, + vespalib::stringref doctype, vespalib::stringref id, uint32_t hint, + double hfloat, vespalib::stringref hstr, vespalib::stringref cstr, uint64_t hlong = 0); DocumentUpdate::SP createUpdate( @@ -105,8 +105,8 @@ void DocumentSelectParserTest::SetUp() } Document::SP DocumentSelectParserTest::createDoc( - const std::string& doctype, const std::string& id, uint32_t hint, - double hfloat, const std::string& hstr, const std::string& cstr, + vespalib::stringref doctype, vespalib::stringref id, uint32_t hint, + double hfloat, vespalib::stringref hstr, vespalib::stringref cstr, uint64_t hlong) { const DocumentType* type = _repo->getDocumentType(doctype); @@ -117,8 +117,8 @@ Document::SP DocumentSelectParserTest::createDoc( doc->setValue(doc->getField("headerlongval"), LongFieldValue(hlong)); } doc->setValue(doc->getField("hfloatval"), FloatFieldValue(hfloat)); - doc->setValue(doc->getField("hstringval"), StringFieldValue(hstr.c_str())); - doc->setValue(doc->getField("content"), StringFieldValue(cstr.c_str())); + doc->setValue(doc->getField("hstringval"), StringFieldValue(hstr)); + doc->setValue(doc->getField("content"), StringFieldValue(cstr)); return doc; } @@ -1232,10 +1232,19 @@ TEST_F(DocumentSelectParserTest, testDocumentIdsInRemoves) PARSE("testdoctype1 and testdoctype1.headerval == 0", DocumentId("id:ns:testdoctype1::1"), Invalid); } +namespace { + +const char * +bad_cast_from_u8(const char8_t *p) { + return reinterpret_cast(p); +} + +} + TEST_F(DocumentSelectParserTest, testUtf8) { createDocs(); - std::string utf8name(u8"H\u00e5kon"); + vespalib::string utf8name = bad_cast_from_u8(u8"H\u00e5kon"); EXPECT_EQ(size_t(6), utf8name.size()); /// \todo TODO (was warning): UTF8 test for glob/regex support in selection language disabled. Known not to work -- cgit v1.2.3