diff options
Diffstat (limited to 'vespalib/src/tests')
84 files changed, 179 insertions, 469 deletions
diff --git a/vespalib/src/tests/bits/.gitignore b/vespalib/src/tests/bits/.gitignore deleted file mode 100644 index b5330fc2580..00000000000 --- a/vespalib/src/tests/bits/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -bits_test -vespalib_bits_test_app diff --git a/vespalib/src/tests/bits/CMakeLists.txt b/vespalib/src/tests/bits/CMakeLists.txt deleted file mode 100644 index 3ba0c6afc1c..00000000000 --- a/vespalib/src/tests/bits/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_bits_test_app TEST - SOURCES - bits_test.cpp - DEPENDS - vespalib - GTest::gtest -) -vespa_add_test(NAME vespalib_bits_test_app COMMAND vespalib_bits_test_app) diff --git a/vespalib/src/tests/crc/.gitignore b/vespalib/src/tests/crc/.gitignore deleted file mode 100644 index cd64c20e0a4..00000000000 --- a/vespalib/src/tests/crc/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -crc_test -vespalib_crc_test_app diff --git a/vespalib/src/tests/crc/CMakeLists.txt b/vespalib/src/tests/crc/CMakeLists.txt deleted file mode 100644 index a7de5d1fa7a..00000000000 --- a/vespalib/src/tests/crc/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_crc_test_app TEST - SOURCES - crc_test.cpp - DEPENDS - vespalib - GTest::gtest -) -vespa_add_test(NAME vespalib_crc_test_app COMMAND vespalib_crc_test_app boost) diff --git a/vespalib/src/tests/crypto/CMakeLists.txt b/vespalib/src/tests/crypto/CMakeLists.txt deleted file mode 100644 index 0da9b6db1f0..00000000000 --- a/vespalib/src/tests/crypto/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_crypto_crypto_test_app TEST - SOURCES - crypto_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_crypto_crypto_test_app COMMAND vespalib_crypto_crypto_test_app) - diff --git a/vespalib/src/tests/eventbarrier/.gitignore b/vespalib/src/tests/eventbarrier/.gitignore deleted file mode 100644 index 89007477b2a..00000000000 --- a/vespalib/src/tests/eventbarrier/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -eventbarrier_test -vespalib_eventbarrier_test_app diff --git a/vespalib/src/tests/eventbarrier/CMakeLists.txt b/vespalib/src/tests/eventbarrier/CMakeLists.txt deleted file mode 100644 index e4ee14a1ed7..00000000000 --- a/vespalib/src/tests/eventbarrier/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_eventbarrier_test_app TEST - SOURCES - eventbarrier.cpp - DEPENDS - vespalib - GTest::gtest -) -vespa_add_test(NAME vespalib_eventbarrier_test_app COMMAND vespalib_eventbarrier_test_app) diff --git a/vespalib/src/tests/execution_profiler/execution_profiler_test.cpp b/vespalib/src/tests/execution_profiler/execution_profiler_test.cpp index 9c31e2dd46a..dd7ba04b281 100644 --- a/vespalib/src/tests/execution_profiler/execution_profiler_test.cpp +++ b/vespalib/src/tests/execution_profiler/execution_profiler_test.cpp @@ -228,7 +228,7 @@ TEST(ExecutionProfilerTest, flat_profiling_does_not_report_tasks_with_count_0) { EXPECT_EQ(slime["profiler"].asString().make_string(), "flat"); EXPECT_EQ(slime["topn"].asLong(), 2); EXPECT_EQ(slime["roots"].entries(), 1); - EXPECT_EQ(slime["roots"][0]["name"].asString().make_stringref(), "baz"); + EXPECT_EQ(slime["roots"][0]["name"].asString().make_stringview(), "baz"); EXPECT_EQ(slime["roots"][0]["count"].asLong(), 1); } diff --git a/vespalib/src/tests/io/fileutil/fileutiltest.cpp b/vespalib/src/tests/io/fileutil/fileutiltest.cpp index 51b755e1668..a1831c8e415 100644 --- a/vespalib/src/tests/io/fileutil/fileutiltest.cpp +++ b/vespalib/src/tests/io/fileutil/fileutiltest.cpp @@ -211,7 +211,7 @@ TEST("require that vespalib::dirname works") TEST("require that vespalib::getOpenErrorString works") { - stringref dirName = "mydir"; + std::string_view dirName = "mydir"; std::filesystem::remove_all(std::filesystem::path(dirName)); std::filesystem::create_directory(std::filesystem::path(dirName)); { diff --git a/vespalib/src/tests/json/.gitignore b/vespalib/src/tests/json/.gitignore deleted file mode 100644 index 9918fbce6e8..00000000000 --- a/vespalib/src/tests/json/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vespalib_json_test_app diff --git a/vespalib/src/tests/json/CMakeLists.txt b/vespalib/src/tests/json/CMakeLists.txt deleted file mode 100644 index 89471e18d74..00000000000 --- a/vespalib/src/tests/json/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_json_test_app TEST - SOURCES - json.cpp - DEPENDS - vespalib - GTest::gtest -) -vespa_add_test(NAME vespalib_json_test_app COMMAND vespalib_json_test_app boost) diff --git a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp index ed20dd6bcf4..937891fb1e4 100644 --- a/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp +++ b/vespalib/src/tests/net/tls/auto_reloading_tls_crypto_engine/auto_reloading_tls_crypto_engine_test.cpp @@ -85,7 +85,7 @@ PhL9XBnJJfzvG5GKXIK/iZgFuYkCIFLp+SIQ5Nc1+NzrU2ii/mkzCgC4N/nOWu9H 88OP2wnm -----END CERTIFICATE-----)"; -void write_file(vespalib::stringref path, vespalib::stringref data) { +void write_file(std::string_view path, std::string_view data) { File f(path); f.open(File::CREATE | File::TRUNC); f.write(data.data(), data.size(), 0); diff --git a/vespalib/src/tests/net/tls/direct_buffer_bio/direct_buffer_bio_test.cpp b/vespalib/src/tests/net/tls/direct_buffer_bio/direct_buffer_bio_test.cpp index c70470f95dd..b87db151e82 100644 --- a/vespalib/src/tests/net/tls/direct_buffer_bio/direct_buffer_bio_test.cpp +++ b/vespalib/src/tests/net/tls/direct_buffer_bio/direct_buffer_bio_test.cpp @@ -43,7 +43,7 @@ TEST_F("Mutable BIO_write writes to associated buffer", Fixture) { vespalib::string to_write = "hello world!"; int ret = ::BIO_write(f.mutable_bio.get(), to_write.data(), static_cast<int>(to_write.size())); EXPECT_EQUAL(static_cast<int>(to_write.size()), ret); - EXPECT_EQUAL(to_write, vespalib::stringref(f.tmp_buf.data(), to_write.size())); + EXPECT_EQUAL(to_write, std::string_view(f.tmp_buf.data(), to_write.size())); EXPECT_EQUAL(static_cast<int>(to_write.size()), BIO_pending(f.mutable_bio.get())); } @@ -61,7 +61,7 @@ TEST_F("Mutable BIO_write moves write cursor per invocation", Fixture) { ASSERT_EQUAL(4, ret); EXPECT_EQUAL(12, BIO_pending(f.mutable_bio.get())); - EXPECT_EQUAL(to_write, vespalib::stringref(f.tmp_buf.data(), to_write.size())); + EXPECT_EQUAL(to_write, std::string_view(f.tmp_buf.data(), to_write.size())); } TEST_F("Const BIO_read reads from associated buffer", Fixture) { @@ -72,7 +72,7 @@ TEST_F("Const BIO_read reads from associated buffer", Fixture) { EXPECT_EQUAL(static_cast<int>(to_read.size()), ret); EXPECT_EQUAL(ret, static_cast<int>(to_read.size())); - EXPECT_EQUAL(to_read, vespalib::stringref(f.tmp_buf.data(), to_read.size())); + EXPECT_EQUAL(to_read, std::string_view(f.tmp_buf.data(), to_read.size())); } TEST_F("Const BIO_read moves read cursor per invocation", Fixture) { @@ -90,7 +90,7 @@ TEST_F("Const BIO_read moves read cursor per invocation", Fixture) { ASSERT_EQUAL(6, ret); EXPECT_EQUAL(0, BIO_pending(f.const_bio.get())); - EXPECT_EQUAL(to_read, vespalib::stringref(f.tmp_buf.data(), to_read.size())); + EXPECT_EQUAL(to_read, std::string_view(f.tmp_buf.data(), to_read.size())); } TEST_F("Const BIO read EOF returns -1 by default and sets BIO retry flag", Fixture) { diff --git a/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp b/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp index 0912afde250..585339e7b57 100644 --- a/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp +++ b/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp @@ -59,9 +59,9 @@ void print_decode_result(const char* mode, const DecodeResult& res) { decode_state_to_str(res.state)); } -TransportSecurityOptions ts_from_pems(vespalib::stringref ca_certs_pem, - vespalib::stringref cert_chain_pem, - vespalib::stringref private_key_pem) +TransportSecurityOptions ts_from_pems(std::string_view ca_certs_pem, + std::string_view cert_chain_pem, + std::string_view private_key_pem) { auto ts_builder = TransportSecurityOptions::Params(). ca_certs_pem(ca_certs_pem). @@ -128,7 +128,7 @@ struct Fixture { return create_openssl_codec(ctx, mode, SocketSpec::invalid); } - static EncodeResult do_encode(CryptoCodec& codec, Output& buffer, vespalib::stringref plaintext) { + static EncodeResult do_encode(CryptoCodec& codec, Output& buffer, std::string_view plaintext) { auto out = buffer.reserve(codec.min_encode_buffer_size()); auto enc_res = codec.encode(plaintext.data(), plaintext.size(), out.data, out.size); buffer.commit(enc_res.bytes_produced); @@ -146,13 +146,13 @@ struct Fixture { return enc_res; } - EncodeResult client_encode(vespalib::stringref plaintext) { + EncodeResult client_encode(std::string_view plaintext) { auto res = do_encode(*client, client_to_server, plaintext); print_encode_result("client", res); return res; } - EncodeResult server_encode(vespalib::stringref plaintext) { + EncodeResult server_encode(std::string_view plaintext) { auto res = do_encode(*server, server_to_client, plaintext); print_encode_result("server", res); return res; diff --git a/vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp b/vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp index b80151e9ccf..7070e4136e5 100644 --- a/vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp +++ b/vespalib/src/tests/net/tls/policy_checking_certificate_verifier/policy_checking_certificate_verifier_test.cpp @@ -8,22 +8,22 @@ using namespace vespalib; using namespace vespalib::net::tls; -bool dns_glob_matches(vespalib::stringref pattern, vespalib::stringref string_to_check) { +bool dns_glob_matches(std::string_view pattern, std::string_view string_to_check) { auto glob = CredentialMatchPattern::create_from_dns_glob(pattern); return glob->matches(string_to_check); } -bool uri_glob_matches(vespalib::stringref pattern, vespalib::stringref string_to_check) { +bool uri_glob_matches(std::string_view pattern, std::string_view string_to_check) { auto glob = CredentialMatchPattern::create_from_uri_glob(pattern); return glob->matches(string_to_check); } -void verify_all_glob_types_match(vespalib::stringref pattern, vespalib::stringref string_to_check) { +void verify_all_glob_types_match(std::string_view pattern, std::string_view string_to_check) { EXPECT_TRUE(dns_glob_matches(pattern, string_to_check)); EXPECT_TRUE(uri_glob_matches(pattern, string_to_check)); } -void verify_all_glob_types_mismatch(vespalib::stringref pattern, vespalib::stringref string_to_check) { +void verify_all_glob_types_mismatch(std::string_view pattern, std::string_view string_to_check) { EXPECT_FALSE(dns_glob_matches(pattern, string_to_check)); EXPECT_FALSE(uri_glob_matches(pattern, string_to_check)); } @@ -117,7 +117,7 @@ PeerCredentials creds_with_uri_sans(std::vector<vespalib::string> uri_sans) { return creds; } -PeerCredentials creds_with_cn(vespalib::stringref cn) { +PeerCredentials creds_with_cn(std::string_view cn) { PeerCredentials creds; creds.common_name = cn; return creds; diff --git a/vespalib/src/tests/nexus/CMakeLists.txt b/vespalib/src/tests/nexus/CMakeLists.txt deleted file mode 100644 index 1cc0e8d31fd..00000000000 --- a/vespalib/src/tests/nexus/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_nexus_test_app TEST - SOURCES - nexus_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_nexus_test_app COMMAND vespalib_nexus_test_app) diff --git a/vespalib/src/tests/objects/nbostream/nbostream_test.cpp b/vespalib/src/tests/objects/nbostream/nbostream_test.cpp index 91c83656353..b8b12d508a2 100644 --- a/vespalib/src/tests/objects/nbostream/nbostream_test.cpp +++ b/vespalib/src/tests/objects/nbostream/nbostream_test.cpp @@ -195,9 +195,9 @@ TEST_F("Test serializing c string", Fixture) EXPECT_EQUAL(exp, f._stream); } -TEST_F("Test serializing stringref", Fixture) +TEST_F("Test serializing std::string_view", Fixture) { - vespalib::stringref val("Hello"); + std::string_view val("Hello"); ExpBuffer exp({ 0x00, 0x00, 0x00, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f }); f._stream << val; EXPECT_EQUAL(exp, f._stream); diff --git a/vespalib/src/tests/objects/objectdump/objectdump.cpp b/vespalib/src/tests/objects/objectdump/objectdump.cpp index f2f4920c37b..e5497d73e69 100644 --- a/vespalib/src/tests/objects/objectdump/objectdump.cpp +++ b/vespalib/src/tests/objects/objectdump/objectdump.cpp @@ -41,7 +41,7 @@ struct Bar : public Base float _float; double _double; vespalib::string _string; - Bar() : _bool(true), _int8(-1), _uint8(1), _int16(-2), _uint16(2), + Bar() noexcept : _bool(true), _int8(-1), _uint8(1), _int16(-2), _uint16(2), _int32(-4), _uint32(4), _int64(-8), _uint64(8), _float(2.5), _double(2.75), _string("bla bla") {} @@ -76,20 +76,20 @@ struct Foo : public Base std::vector<IdentifiablePtr<Base> > _list2; Foo(); - ~Foo(); + ~Foo() override; Foo *clone() const override { return new Foo(*this); } void visitMembers(ObjectVisitor &v) const override; }; -Foo::~Foo() { } +Foo::~Foo() = default; Foo::Foo() : _objMember(), _objMember2(), _objPtr(0), _list(), _list2() { - _list.push_back(Bar()); - _list.push_back(Bar()); - _list.push_back(Bar()); - _list2.push_back(Bar()); - _list2.push_back(Baz()); + _list.emplace_back(); + _list.emplace_back(); + _list.emplace_back(); + _list2.emplace_back(Bar()); + _list2.emplace_back(Baz()); } void diff --git a/vespalib/src/tests/portal/portal_test.cpp b/vespalib/src/tests/portal/portal_test.cpp index e5a6cc1572b..7657f5a65d9 100644 --- a/vespalib/src/tests/portal/portal_test.cpp +++ b/vespalib/src/tests/portal/portal_test.cpp @@ -32,7 +32,7 @@ vespalib::string do_http(int port, CryptoEngine::SP crypto, const vespalib::stri vespalib::string result; ssize_t res = conn->read(buf, sizeof(buf)); while (res > 0) { - result.append(vespalib::stringref(buf, res)); + result.append(std::string_view(buf, res)); res = conn->read(buf, sizeof(buf)); } ASSERT_EQUAL(res, 0); diff --git a/vespalib/src/tests/printable/.gitignore b/vespalib/src/tests/printable/.gitignore deleted file mode 100644 index e001a281449..00000000000 --- a/vespalib/src/tests/printable/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -printabletest -vespalib_printabletest_app diff --git a/vespalib/src/tests/printable/CMakeLists.txt b/vespalib/src/tests/printable/CMakeLists.txt deleted file mode 100644 index 4781e9b8f54..00000000000 --- a/vespalib/src/tests/printable/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_printabletest_app TEST - SOURCES - printabletest.cpp - DEPENDS - vespalib - GTest::gtest -) -vespa_add_test(NAME vespalib_printabletest_app COMMAND vespalib_printabletest_app) diff --git a/vespalib/src/tests/random/CMakeLists.txt b/vespalib/src/tests/random/CMakeLists.txt index 75d9ce75f1a..e79944f69ef 100644 --- a/vespalib/src/tests/random/CMakeLists.txt +++ b/vespalib/src/tests/random/CMakeLists.txt @@ -1,12 +1,4 @@ # Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_random_test_app TEST - SOURCES - random_test.cpp - DEPENDS - vespalib - GTest::gtest -) -vespa_add_test(NAME vespalib_random_test_app COMMAND vespalib_random_test_app) vespa_add_executable(vespalib_friendfinder_test_app SOURCES friendfinder.cpp diff --git a/vespalib/src/tests/ref_counted/CMakeLists.txt b/vespalib/src/tests/ref_counted/CMakeLists.txt deleted file mode 100644 index bbbcd7db67b..00000000000 --- a/vespalib/src/tests/ref_counted/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_ref_counted_test_app TEST - SOURCES - ref_counted_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_ref_counted_test_app COMMAND vespalib_ref_counted_test_app) diff --git a/vespalib/src/tests/require/CMakeLists.txt b/vespalib/src/tests/require/CMakeLists.txt deleted file mode 100644 index d4f2b305006..00000000000 --- a/vespalib/src/tests/require/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_require_test_app TEST - SOURCES - require_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_require_test_app COMMAND vespalib_require_test_app) diff --git a/vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp b/vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp index ef13421a6ec..230bdbc87a6 100644 --- a/vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp +++ b/vespalib/src/tests/sequencedtaskexecutor/adaptive_sequenced_executor_test.cpp @@ -64,7 +64,7 @@ public: } }; -vespalib::stringref ZERO("0"); +std::string_view ZERO("0"); TEST_F("testExecute", Fixture) { std::shared_ptr<TestObj> tv(std::make_shared<TestObj>()); @@ -133,7 +133,7 @@ TEST_F("require that task with same string component id are serialized", Fixture namespace { -int detectSerializeFailure(Fixture &f, vespalib::stringref altComponentId, int tryLimit) +int detectSerializeFailure(Fixture &f, std::string_view altComponentId, int tryLimit) { int tryCnt = 0; for (tryCnt = 0; tryCnt < tryLimit; ++tryCnt) { diff --git a/vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp b/vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp index beed490c214..7943371c6b0 100644 --- a/vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp +++ b/vespalib/src/tests/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp @@ -72,7 +72,7 @@ public: } }; -vespalib::stringref ZERO("0"); +std::string_view ZERO("0"); TEST_F("testExecute", Fixture) { std::shared_ptr<TestObj> tv(std::make_shared<TestObj>()); @@ -159,7 +159,7 @@ TEST_F("require that task with same string component id are serialized", Fixture namespace { int -detectSerializeFailure(Fixture &f, vespalib::stringref altComponentId, int tryLimit) +detectSerializeFailure(Fixture &f, std::string_view altComponentId, int tryLimit) { int tryCnt = 0; for (tryCnt = 0; tryCnt < tryLimit; ++tryCnt) { diff --git a/vespalib/src/tests/sharedptr/.gitignore b/vespalib/src/tests/sharedptr/.gitignore deleted file mode 100644 index d6ea42f40fb..00000000000 --- a/vespalib/src/tests/sharedptr/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.depend -Makefile -ptrholder_test -sharedptr_test -vespalib_ptrholder_test_app diff --git a/vespalib/src/tests/sharedptr/CMakeLists.txt b/vespalib/src/tests/sharedptr/CMakeLists.txt deleted file mode 100644 index 6e038ed31c5..00000000000 --- a/vespalib/src/tests/sharedptr/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_ptrholder_test_app TEST - SOURCES - ptrholder.cpp - DEPENDS - vespalib - GTest::gtest -) -vespa_add_test(NAME vespalib_ptrholder_test_app COMMAND vespalib_ptrholder_test_app) diff --git a/vespalib/src/tests/slime/are_equal/slime_are_equal_test.cpp b/vespalib/src/tests/slime/are_equal/slime_are_equal_test.cpp index 4751d51958a..07509524775 100644 --- a/vespalib/src/tests/slime/are_equal/slime_are_equal_test.cpp +++ b/vespalib/src/tests/slime/are_equal/slime_are_equal_test.cpp @@ -13,7 +13,7 @@ using namespace vespalib::slime::convenience; using vespalib::make_string_short::fmt; using vespalib::slime::NIX; -using Path = std::vector<std::variant<size_t,vespalib::stringref>>; +using Path = std::vector<std::variant<size_t,std::string_view>>; using Hook = std::function<bool(const Path &, const Inspector &, const Inspector &)>; using vespalib::slime::Inspector; @@ -92,7 +92,7 @@ vespalib::string path_to_str(const Path &path) { } std::visit(vespalib::overload{ [&str](size_t value)noexcept{ str.append(fmt("%zu", value)); }, - [&str](vespalib::stringref value)noexcept{ str.append(value); }}, item); + [&str](std::string_view value)noexcept{ str.append(value); }}, item); } str.append("]"); return str; diff --git a/vespalib/src/tests/small_vector/CMakeLists.txt b/vespalib/src/tests/small_vector/CMakeLists.txt deleted file mode 100644 index f40a708402d..00000000000 --- a/vespalib/src/tests/small_vector/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_small_vector_test_app TEST - SOURCES - small_vector_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_small_vector_test_app COMMAND vespalib_small_vector_test_app) diff --git a/vespalib/src/tests/state_server/state_server_test.cpp b/vespalib/src/tests/state_server/state_server_test.cpp index 18dc54188ef..5c27f585d8d 100644 --- a/vespalib/src/tests/state_server/state_server_test.cpp +++ b/vespalib/src/tests/state_server/state_server_test.cpp @@ -57,7 +57,7 @@ get_body_and_content_type(const JsonGetHandler &handler, net::ConnectionAuthContext dummy_ctx(net::tls::PeerCredentials(), net::tls::CapabilitySet::all()); auto res = handler.get(host, path, params, dummy_ctx); if (res.ok()) { - return {res.payload(), res.content_type()}; + return {vespalib::string(res.payload()), vespalib::string(res.content_type())}; } return {}; } diff --git a/vespalib/src/tests/stllike/asciistream_test.cpp b/vespalib/src/tests/stllike/asciistream_test.cpp index cd710c0adb4..048e6ab3fee 100644 --- a/vespalib/src/tests/stllike/asciistream_test.cpp +++ b/vespalib/src/tests/stllike/asciistream_test.cpp @@ -20,7 +20,7 @@ verifyBothWays(T value, const char * expected, const vespalib::string& label) SCOPED_TRACE(label); asciistream os; os << value; - EXPECT_EQ(os.str(), string(expected)); + EXPECT_EQ(os.view(), string(expected)); EXPECT_EQ(os.size(), strlen(expected)); { T v; @@ -48,7 +48,7 @@ verify(T first, T second, const char * firstResult, const char * secondResult, c std::ostringstream ss; os << first; ss << first; - EXPECT_EQ(os.str(), string(firstResult)); + EXPECT_EQ(os.view(), string(firstResult)); EXPECT_EQ(os.size(), strlen(firstResult)); EXPECT_EQ(ss.str().size(), strlen(firstResult)); EXPECT_EQ(strcmp(ss.str().c_str(), firstResult), 0); @@ -102,7 +102,7 @@ TEST(AsciistreamTest, test_illegal_numbers) float f(0); EXPECT_THROW(is >> f, IllegalArgumentException); EXPECT_EQ(40u, is.size()); - vespalib::string tmp = is.str(); + std::string_view tmp = is.view(); is << "e" << tmp; EXPECT_EQ(81u, is.size()); double d(0); @@ -153,33 +153,33 @@ TEST(AsciistreamTest, test_copy_construct) asciistream os; os << "test1"; asciistream os2(os); - EXPECT_EQ(os.str(), os2.str()); + EXPECT_EQ(os.view(), os2.view()); os2 << " test2"; - EXPECT_FALSE(os.str() == os2.str()); + EXPECT_FALSE(os.view() == os2.view()); asciistream os3(os); os3 = os2; - EXPECT_EQ(os2.str(), os3.str()); + EXPECT_EQ(os2.view(), os3.view()); os.swap(os2); - EXPECT_EQ(os.str(), os3.str()); - EXPECT_FALSE(os3.str() == os2.str()); + EXPECT_EQ(os.view(), os3.view()); + EXPECT_FALSE(os3.view() == os2.view()); os.swap(os2); - EXPECT_TRUE(os3.str() == os2.str()); + EXPECT_TRUE(os3.view() == os2.view()); } TEST(AsciistreamTest, test_move_is_well_defined) { asciistream read_only("hello world"); asciistream dest(std::move(read_only)); - EXPECT_EQ("hello world", dest.str()); + EXPECT_EQ("hello world", dest.view()); read_only = asciistream("a string long enough to not be short string optimized"); dest = std::move(read_only); - EXPECT_EQ("a string long enough to not be short string optimized", dest.str()); + EXPECT_EQ("a string long enough to not be short string optimized", dest.view()); asciistream written_src; written_src << "a foo walks into a bar"; dest = std::move(written_src); - EXPECT_EQ("a foo walks into a bar", dest.str()); + EXPECT_EQ("a foo walks into a bar", dest.view()); } TEST(AsciistreamTest, test_integer_manip) @@ -220,7 +220,7 @@ TEST(AsciistreamTest, test_integer_manip) // Also test that number base is restored OK after ptr print os << dec << ' ' << fooptr << ' ' << 1234; ss << std::dec << ' ' << fooptr << ' ' << 1234; - EXPECT_EQ(std::string("10 10 a b 12 0b1010 0x1badbadc0ffee 1234"), os.str()); + EXPECT_EQ(std::string("10 10 a b 12 0b1010 0x1badbadc0ffee 1234"), os.view()); EXPECT_EQ(std::string("10 10 a b 12 0x1badbadc0ffee 1234"), ss.str()); int i = 0; @@ -230,7 +230,7 @@ TEST(AsciistreamTest, test_integer_manip) std_istr >> i; EXPECT_EQ(1234, i); - stringref firstfour(digits, 4); + std::string_view firstfour(digits, 4); asciistream istr(firstfour); istr >> i; EXPECT_EQ(1234, i); @@ -319,7 +319,7 @@ TEST(AsciistreamTest, test_string) { asciistream oss; oss << ss << vs; - EXPECT_EQ("aa", oss.str()); + EXPECT_EQ("aa", oss.view()); } { std::istringstream iss("b c"); @@ -400,7 +400,7 @@ TEST(AsciistreamTest, test_get_line) mystream << format; \ if (precision > 0) mystream << asciistream::Precision(precision); \ mystream << value; \ - EXPECT_EQ(expected, mystream.str()); \ + EXPECT_EQ(expected, mystream.view()); \ } TEST(AsciistreamTest, test_double) diff --git a/vespalib/src/tests/stllike/string_test.cpp b/vespalib/src/tests/stllike/string_test.cpp index 509c71b1641..41beee508d3 100644 --- a/vespalib/src/tests/stllike/string_test.cpp +++ b/vespalib/src/tests/stllike/string_test.cpp @@ -291,7 +291,7 @@ TEST("testString") { EXPECT_EQUAL(3u, s.rfind("ab")); } { - stringref s("abcabca"); + std::string_view s("abcabca"); EXPECT_EQUAL(string::npos, s.find('g')); EXPECT_EQUAL(string::npos, s.rfind('g')); EXPECT_EQUAL(0u, s.find('a')); @@ -302,26 +302,27 @@ TEST("testString") { EXPECT_EQUAL(5u, s.rfind("ca")); EXPECT_EQUAL(0u, s.find("ab")); EXPECT_EQUAL(3u, s.rfind("ab")); - stringref s2("abc"); + std::string_view s2("abc"); EXPECT_EQUAL(2u, s2.rfind('c')); EXPECT_EQUAL(1u, s2.rfind('b')); EXPECT_EQUAL(0u, s2.rfind('a')); EXPECT_EQUAL(string::npos, s2.rfind('d')); } - EXPECT_EQUAL("a" + stringref("b"), string("ab")); + EXPECT_EQUAL("a" + std::string_view("b"), string("ab")); EXPECT_EQUAL("a" + string("b"), string("ab")); EXPECT_EQUAL(string("a") + string("b"), string("ab")); - EXPECT_EQUAL(string("a") + stringref("b"), string("ab")); + EXPECT_EQUAL(string("a") + std::string_view("b"), string("ab")); EXPECT_EQUAL(string("a") + "b", string("ab")); - EXPECT_EQUAL(stringref("a") + stringref("b"), string("ab")); + EXPECT_EQUAL(std::string_view("a") + std::string_view("b"), string("ab")); // Test std::string conversion of empty string - stringref sref; + std::string_view sref; std::string stdString(sref); - EXPECT_TRUE(strcmp("", sref.data()) == 0); + EXPECT_EQUAL(nullptr, sref.data()); + EXPECT_TRUE(strcmp("", stdString.data()) == 0); stdString = "abc"; - stringref sref2(stdString); + std::string_view sref2(stdString); EXPECT_TRUE(stdString.c_str() == sref2.data()); EXPECT_TRUE(stdString == sref2); EXPECT_TRUE(sref2 == stdString); @@ -338,7 +339,7 @@ TEST("testString") { } { EXPECT_EQUAL(string("abc"), string("abcd", 3)); - EXPECT_EQUAL(string("abc"), string(stringref("abc"))); + EXPECT_EQUAL(string("abc"), string(std::string_view("abc"))); } { string s("abc"); @@ -350,7 +351,7 @@ TEST("testString") { EXPECT_EQUAL(string("c"), s.substr(2)); } { - stringref s("abc"); + std::string_view s("abc"); EXPECT_EQUAL(string("a"), s.substr(0,1)); EXPECT_EQUAL(string("b"), s.substr(1,1)); EXPECT_EQUAL(string("c"), s.substr(2,1)); @@ -461,10 +462,10 @@ TEST("test that small_string::pop_back works") { } -TEST("test that operator<() works with stringref versus string") { - vespalib::stringref sra("a"); +TEST("test that operator<() works with std::string_view versus string") { + std::string_view sra("a"); vespalib::string sa("a"); - vespalib::stringref srb("b"); + std::string_view srb("b"); vespalib::string sb("b"); EXPECT_FALSE(sra < sra); EXPECT_FALSE(sra < sa); @@ -498,9 +499,9 @@ TEST("starts_with has expected semantics for small_string") { EXPECT_FALSE(a.starts_with("oobar")); } -TEST("starts_with has expected semantics for stringref") { +TEST("starts_with has expected semantics for std::string_view") { vespalib::string a("foobar"); - vespalib::stringref ar(a); + std::string_view ar(a); EXPECT_TRUE(ar.starts_with("")); EXPECT_TRUE(ar.starts_with("foo")); EXPECT_TRUE(ar.starts_with("foobar")); diff --git a/vespalib/src/tests/time/CMakeLists.txt b/vespalib/src/tests/time/CMakeLists.txt index c4d22cc5b45..bcc0d8fc772 100644 --- a/vespalib/src/tests/time/CMakeLists.txt +++ b/vespalib/src/tests/time/CMakeLists.txt @@ -6,11 +6,3 @@ vespa_add_executable(vespalib_time_box_test_app TEST vespalib ) vespa_add_test(NAME vespalib_time_box_test_app COMMAND vespalib_time_box_test_app) -vespa_add_executable(vespalib_time_test_app TEST - SOURCES - time_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_time_test_app COMMAND vespalib_time_test_app) diff --git a/vespalib/src/tests/typify/CMakeLists.txt b/vespalib/src/tests/typify/CMakeLists.txt deleted file mode 100644 index d95c9fecd78..00000000000 --- a/vespalib/src/tests/typify/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_typify_test_app TEST - SOURCES - typify_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_typify_test_app COMMAND vespalib_typify_test_app) diff --git a/vespalib/src/tests/util/CMakeLists.txt b/vespalib/src/tests/util/CMakeLists.txt new file mode 100644 index 00000000000..fef048cc99c --- /dev/null +++ b/vespalib/src/tests/util/CMakeLists.txt @@ -0,0 +1,42 @@ +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +# Runner for unit tests written in gtest. +# NOTE: All new test classes should be added here. +vespa_add_executable(vespalib_util_gtest_runner_test_app TEST + SOURCES + gtest_runner.cpp + bfloat16_test.cpp + bits_test.cpp + cgroup_resource_limits_test.cpp + crc_test.cpp + crypto_test.cpp + eventbarrier.cpp + file_area_freelist_test.cpp + generation_hold_list_test.cpp + generationhandler_test.cpp + json.cpp + issue_test.cpp + memory_trap_test.cpp + mmap_file_allocator_factory_test.cpp + mmap_file_allocator_test.cpp + nexus_test.cpp + printabletest.cpp + ptrholder.cpp + random_test.cpp + rcuvector_test.cpp + ref_counted_test.cpp + require_test.cpp + size_literals_test.cpp + small_vector_test.cpp + static_string_test.cpp + string_escape_test.cpp + time_test.cpp + typify_test.cpp + xmlserializabletest.cpp + DEPENDS + vespalib + onnxruntime + GTest::GTest +) + +vespa_add_test( NAME vespalib_util_gtest_runner_test_app COMMAND vespalib_util_gtest_runner_test_app) diff --git a/vespalib/src/tests/util/bfloat16/CMakeLists.txt b/vespalib/src/tests/util/bfloat16/CMakeLists.txt deleted file mode 100644 index 72d6c8720d6..00000000000 --- a/vespalib/src/tests/util/bfloat16/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -if(EXISTS /opt/vespa-deps/include/onnxruntime/onnxruntime_cxx_api.h) -vespa_add_executable(vespalib_bfloat16_test_app TEST - SOURCES - bfloat16_test.cpp - DEPENDS - vespalib - onnxruntime - GTest::GTest -) -vespa_add_test(NAME vespalib_bfloat16_test_app COMMAND vespalib_bfloat16_test_app) -endif() diff --git a/vespalib/src/tests/util/bfloat16/bfloat16_test.cpp b/vespalib/src/tests/util/bfloat16_test.cpp index 196c5f98c9e..8b21cbad309 100644 --- a/vespalib/src/tests/util/bfloat16/bfloat16_test.cpp +++ b/vespalib/src/tests/util/bfloat16_test.cpp @@ -219,5 +219,3 @@ TEST(OnnxBFloat16Test, has_same_encoding) { printf("floats that are NaN in both vespalib and onnx: %d (0x%04x)\n", nan_count, nan_count); printf("total count (OK + NaN): %d (0x%04x)\n", ok_count + nan_count, ok_count + nan_count); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/bits/bits_test.cpp b/vespalib/src/tests/util/bits_test.cpp index 6b01b2cd63a..4132627a412 100644 --- a/vespalib/src/tests/bits/bits_test.cpp +++ b/vespalib/src/tests/util/bits_test.cpp @@ -56,5 +56,3 @@ void BitsTest::testBuffer() Bits::reverse(&a, sizeof(a)); EXPECT_EQ(a, b); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/cgroup_resource_limits/CMakeLists.txt b/vespalib/src/tests/util/cgroup_resource_limits/CMakeLists.txt deleted file mode 100644 index d7e99fcde29..00000000000 --- a/vespalib/src/tests/util/cgroup_resource_limits/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_cgroup_resource_limits_test_app TEST - SOURCES - cgroup_resource_limits_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_cgroup_resource_limits_test_app COMMAND vespalib_cgroup_resource_limits_test_app) diff --git a/vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp b/vespalib/src/tests/util/cgroup_resource_limits_test.cpp index 38e8467ff35..2528c56d211 100644 --- a/vespalib/src/tests/util/cgroup_resource_limits/cgroup_resource_limits_test.cpp +++ b/vespalib/src/tests/util/cgroup_resource_limits_test.cpp @@ -12,15 +12,16 @@ class CGroupResourceLimitsTest : public ::testing::Test protected: CGroupResourceLimitsTest(); ~CGroupResourceLimitsTest(); - void check_limits(const std::string &name, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit); + void check_limits(std::string_view name, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit); }; CGroupResourceLimitsTest::CGroupResourceLimitsTest() = default; CGroupResourceLimitsTest::~CGroupResourceLimitsTest() = default; void -CGroupResourceLimitsTest::check_limits(const std::string &base, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit) +CGroupResourceLimitsTest::check_limits(std::string_view subdir, const std::optional<uint64_t>& memory_limit, const std::optional<uint32_t>& cpu_limit) { + std::string base = "cgroup_resource_limits/" + subdir; auto src_base = TEST_PATH(base); CGroupResourceLimits cg_limits(src_base + "/cgroup", src_base + "/self"); EXPECT_EQ(memory_limit, cg_limits.get_memory_limit()); @@ -73,5 +74,3 @@ TEST_F(CGroupResourceLimitsTest, cgroup_v2_container) } } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/crc/crc_test.cpp b/vespalib/src/tests/util/crc_test.cpp index 82ad8b4c013..c9cec0a4ad5 100644 --- a/vespalib/src/tests/crc/crc_test.cpp +++ b/vespalib/src/tests/util/crc_test.cpp @@ -1,8 +1,8 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/util/crc.h> -#include <vespa/vespalib/gtest/gtest.h> #include <vector> +#include <vespa/vespalib/gtest/gtest.h> using namespace vespalib; @@ -28,7 +28,7 @@ TEST(FCrcTest, test_correctness) TEST(CrcTest, benchmark) { constexpr size_t bufSz = 1024; - constexpr size_t numRep = 1000 * 1000; + constexpr size_t numRep = 100 * 1000; std::vector<char> a(numRep+bufSz); for(size_t i(0), m(a.size()); i < m; i++) { a[i] = i&0xff; @@ -42,5 +42,3 @@ TEST(CrcTest, benchmark) } printf("sum = %x\n", sum); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/crypto/crypto_test.cpp b/vespalib/src/tests/util/crypto_test.cpp index ed70414fbde..4cad16a7d63 100644 --- a/vespalib/src/tests/crypto/crypto_test.cpp +++ b/vespalib/src/tests/util/crypto_test.cpp @@ -33,5 +33,3 @@ TEST(CryptoTest, generated_x509_certificate_can_be_exported_to_pem_format) { } } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/eventbarrier/eventbarrier.cpp b/vespalib/src/tests/util/eventbarrier.cpp index 31db0e61fe7..a54f039fb00 100644 --- a/vespalib/src/tests/eventbarrier/eventbarrier.cpp +++ b/vespalib/src/tests/util/eventbarrier.cpp @@ -171,5 +171,3 @@ TEST(EventBarriarTest, test_reorder) EXPECT_EQ(eb.countEvents(), 0u); EXPECT_EQ(eb.countBarriers(), 0u); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/file_area_freelist/CMakeLists.txt b/vespalib/src/tests/util/file_area_freelist/CMakeLists.txt deleted file mode 100644 index 30303eaed21..00000000000 --- a/vespalib/src/tests/util/file_area_freelist/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_file_area_freelist_test_app TEST - SOURCES - file_area_freelist_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_file_area_freelist_test_app COMMAND vespalib_file_area_freelist_test_app) diff --git a/vespalib/src/tests/util/file_area_freelist/file_area_freelist_test.cpp b/vespalib/src/tests/util/file_area_freelist_test.cpp index 470680e0f8f..90161b76d49 100644 --- a/vespalib/src/tests/util/file_area_freelist/file_area_freelist_test.cpp +++ b/vespalib/src/tests/util/file_area_freelist_test.cpp @@ -97,6 +97,3 @@ TEST_F(FileAreaFreeListTest, can_use_part_of_free_area) EXPECT_EQ(5, _freelist.alloc(1)); EXPECT_EQ(bad_offset, _freelist.alloc(1)); } - - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/generation_hold_list/CMakeLists.txt b/vespalib/src/tests/util/generation_hold_list/CMakeLists.txt deleted file mode 100644 index bf607a6fec6..00000000000 --- a/vespalib/src/tests/util/generation_hold_list/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_generation_hold_list_test_app TEST - SOURCES - generation_hold_list_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_generation_hold_list_test_app COMMAND vespalib_generation_hold_list_test_app) diff --git a/vespalib/src/tests/util/generation_hold_list/generation_hold_list_test.cpp b/vespalib/src/tests/util/generation_hold_list_test.cpp index 2d8da961433..e7bbe40856d 100644 --- a/vespalib/src/tests/util/generation_hold_list/generation_hold_list_test.cpp +++ b/vespalib/src/tests/util/generation_hold_list_test.cpp @@ -91,5 +91,3 @@ TEST_F(IntHoldListTest, reclaim_all_calls_callback_for_all_elements) assert_reclaim_all({3, 5}); assert_reclaim_all({}); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/generationhandler/.gitignore b/vespalib/src/tests/util/generationhandler/.gitignore deleted file mode 100644 index c98a32727d9..00000000000 --- a/vespalib/src/tests/util/generationhandler/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -generationhandler_test -vespalib_generationhandler_test_app diff --git a/vespalib/src/tests/util/generationhandler/CMakeLists.txt b/vespalib/src/tests/util/generationhandler/CMakeLists.txt deleted file mode 100644 index 10cb0b00060..00000000000 --- a/vespalib/src/tests/util/generationhandler/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_generationhandler_test_app TEST - SOURCES - generationhandler_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_generationhandler_test_app COMMAND vespalib_generationhandler_test_app) diff --git a/vespalib/src/tests/util/generationhandler/generationhandler_test.cpp b/vespalib/src/tests/util/generationhandler_test.cpp index 383a46fbef9..5b2a69f95ea 100644 --- a/vespalib/src/tests/util/generationhandler/generationhandler_test.cpp +++ b/vespalib/src/tests/util/generationhandler_test.cpp @@ -133,5 +133,3 @@ TEST_F(GenerationHandlerTest, require_that_generation_can_grow_large) } } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/gtest_runner.cpp b/vespalib/src/tests/util/gtest_runner.cpp new file mode 100644 index 00000000000..c2e1d07b60c --- /dev/null +++ b/vespalib/src/tests/util/gtest_runner.cpp @@ -0,0 +1,8 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include <vespa/vespalib/gtest/gtest.h> + +#include <vespa/log/log.h> +LOG_SETUP("vespalib_util_gtest_runner"); + +GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/issue/issue_test.cpp b/vespalib/src/tests/util/issue_test.cpp index 366c7a64df9..f2a3622156c 100644 --- a/vespalib/src/tests/issue/issue_test.cpp +++ b/vespalib/src/tests/util/issue_test.cpp @@ -83,5 +83,3 @@ TEST(IssueTest, alternative_report_functions) { } EXPECT_EQ(my_handler.list, make_list({"str", "fmt_msg_7", "exception"})); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/json/json.cpp b/vespalib/src/tests/util/json.cpp index 024d9045cc1..f661ba7c7ef 100644 --- a/vespalib/src/tests/json/json.cpp +++ b/vespalib/src/tests/util/json.cpp @@ -1,9 +1,9 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/util/jsonstream.h> #include <vespa/vespalib/util/jsonexception.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/gtest/gtest.h> using namespace vespalib; @@ -14,77 +14,77 @@ TEST(JSONTest, test_json_writer_values) { // bool js.appendBool(true); - EXPECT_EQ(js.toString(), "true"); + EXPECT_EQ(js.view(), "true"); js.clear().appendBool(false); - EXPECT_EQ(js.toString(), "false"); + EXPECT_EQ(js.view(), "false"); } { // double js.clear().appendDouble(1234.5678); - EXPECT_EQ(js.toString(), "1234.5678"); + EXPECT_EQ(js.view(), "1234.5678"); js.clear().appendDouble(-1234.5678); - EXPECT_EQ(js.toString(), "-1234.5678"); + EXPECT_EQ(js.view(), "-1234.5678"); js.clear().appendDouble(0.0); - EXPECT_EQ(js.toString(), "0.0"); + EXPECT_EQ(js.view(), "0.0"); js.clear().appendDouble(0.00000000012345678912356789123456789); - EXPECT_EQ(js.toString(), "1.234567891235679e-10"); + EXPECT_EQ(js.view(), "1.234567891235679e-10"); js.clear().appendDouble(std::numeric_limits<double>::max()); - EXPECT_EQ(js.toString(), "1.797693134862316e+308"); + EXPECT_EQ(js.view(), "1.797693134862316e+308"); js.clear().appendDouble(std::numeric_limits<double>::min()); - EXPECT_EQ(js.toString(), "2.225073858507201e-308"); + EXPECT_EQ(js.view(), "2.225073858507201e-308"); js.clear().appendDouble(1.0 * (uint64_t(1) << 53)); - EXPECT_EQ(js.toString(), "9007199254740992.0"); + EXPECT_EQ(js.view(), "9007199254740992.0"); js.clear().appendDouble(1000); - EXPECT_EQ(js.toString(), "1000.0"); + EXPECT_EQ(js.view(), "1000.0"); } { // float js.clear().appendFloat(1234.5678f); - EXPECT_EQ(js.toString(), "1234.5677"); + EXPECT_EQ(js.view(), "1234.5677"); js.clear().appendFloat(-1234.5678f); - EXPECT_EQ(js.toString(), "-1234.5677"); + EXPECT_EQ(js.view(), "-1234.5677"); js.clear().appendFloat(0.0f); - EXPECT_EQ(js.toString(), "0.0"); + EXPECT_EQ(js.view(), "0.0"); js.clear().appendFloat(0.00000000012345678912356789123456789f); - EXPECT_EQ(js.toString(), "1.2345679e-10"); + EXPECT_EQ(js.view(), "1.2345679e-10"); js.clear().appendFloat(std::numeric_limits<float>::max()); - EXPECT_EQ(js.toString(), "3.4028235e+38"); + EXPECT_EQ(js.view(), "3.4028235e+38"); js.clear().appendFloat(std::numeric_limits<float>::min()); - EXPECT_EQ(js.toString(), "1.1754944e-38"); + EXPECT_EQ(js.view(), "1.1754944e-38"); js.clear().appendFloat(1.0 * (uint64_t(1) << 24)); - EXPECT_EQ(js.toString(), "16777216.0"); + EXPECT_EQ(js.view(), "16777216.0"); js.clear().appendFloat(1000); - EXPECT_EQ(js.toString(), "1000.0"); + EXPECT_EQ(js.view(), "1000.0"); } { // long js.clear().appendInt64(4294967296ll); - EXPECT_EQ(js.toString(), "4294967296"); + EXPECT_EQ(js.view(), "4294967296"); js.clear().appendInt64(-4294967296ll); - EXPECT_EQ(js.toString(), "-4294967296"); + EXPECT_EQ(js.view(), "-4294967296"); } { // string js.clear().appendString("string"); - EXPECT_EQ(js.toString(), "\"string\""); + EXPECT_EQ(js.view(), "\"string\""); } { // NULL js.clear().appendNull(); - EXPECT_EQ(js.toString(), "null"); + EXPECT_EQ(js.view(), "null"); } { // quote js.clear().appendString("x\"y"); - EXPECT_EQ(js.toString(), "\"x\\\"y\""); + EXPECT_EQ(js.view(), "\"x\\\"y\""); js.clear().appendString("x\\y"); - EXPECT_EQ(js.toString(), "\"x\\\\y\""); + EXPECT_EQ(js.view(), "\"x\\\\y\""); js.clear().appendString("x/y"); - EXPECT_EQ(js.toString(), "\"x/y\""); + EXPECT_EQ(js.view(), "\"x/y\""); js.clear().appendString("x\by"); - EXPECT_EQ(js.toString(), "\"x\\by\""); + EXPECT_EQ(js.view(), "\"x\\by\""); js.clear().appendString("x\fy"); - EXPECT_EQ(js.toString(), "\"x\\fy\""); + EXPECT_EQ(js.view(), "\"x\\fy\""); js.clear().appendString("x\ny"); - EXPECT_EQ(js.toString(), "\"x\\ny\""); + EXPECT_EQ(js.view(), "\"x\\ny\""); js.clear().appendString("x\ry"); - EXPECT_EQ(js.toString(), "\"x\\ry\""); + EXPECT_EQ(js.view(), "\"x\\ry\""); js.clear().appendString("x\ty"); - EXPECT_EQ(js.toString(), "\"x\\ty\""); + EXPECT_EQ(js.view(), "\"x\\ty\""); } } @@ -94,15 +94,15 @@ TEST(JSONTest, test_json_writer_object) { // single pair js.beginObject().appendKey("k1").appendInt64(1l).endObject(); - EXPECT_EQ(js.toString(), "{\"k1\":1}"); + EXPECT_EQ(js.view(), "{\"k1\":1}"); } { // multiple pairs js.clear().beginObject().appendKey("k1").appendInt64(1l).appendKey("k2").appendInt64(2l).endObject(); - EXPECT_EQ(js.toString(), "{\"k1\":1,\"k2\":2}"); + EXPECT_EQ(js.view(), "{\"k1\":1,\"k2\":2}"); } { // object in object js.clear().beginObject().appendKey("k1").beginObject().appendKey("k1.1").appendInt64(11l).endObject().endObject(); - EXPECT_EQ(js.toString(), "{\"k1\":{\"k1.1\":11}}"); + EXPECT_EQ(js.view(), "{\"k1\":{\"k1.1\":11}}"); } { // object in object (multiple pairs) js.clear().beginObject(). @@ -117,19 +117,19 @@ TEST(JSONTest, test_json_writer_object) appendKey("k2.2").appendInt64(22l). endObject(). endObject(); - EXPECT_EQ(js.toString(), "{\"k1\":{\"k1.1\":11,\"k1.2\":12},\"k2\":{\"k2.1\":21,\"k2.2\":22}}"); + EXPECT_EQ(js.view(), "{\"k1\":{\"k1.1\":11,\"k1.2\":12},\"k2\":{\"k2.1\":21,\"k2.2\":22}}"); } { // array in object js.clear().beginObject().appendKey("k1"). beginArray().appendInt64(1l).appendInt64(2l).endArray().endObject(); - EXPECT_EQ(js.toString(), "{\"k1\":[1,2]}"); + EXPECT_EQ(js.view(), "{\"k1\":[1,2]}"); } { // array in object (multiple pairs) js.clear().beginObject(). appendKey("k1").beginArray().appendInt64(1l).appendInt64(2l).endArray(). appendKey("k2").beginArray().appendInt64(3l).appendInt64(4l).endArray(). endObject(); - EXPECT_EQ(js.toString(), "{\"k1\":[1,2],\"k2\":[3,4]}"); + EXPECT_EQ(js.view(), "{\"k1\":[1,2],\"k2\":[3,4]}"); } } @@ -139,35 +139,35 @@ TEST(JSONTest, test_json_writer_array) { // single element js.beginArray().appendInt64(1l).endArray(); - EXPECT_EQ(js.toString(), "[1]"); + EXPECT_EQ(js.view(), "[1]"); } { // multiple elements js.clear().beginArray().appendInt64(1l).appendInt64(2l).endArray(); - EXPECT_EQ(js.toString(), "[1,2]"); + EXPECT_EQ(js.view(), "[1,2]"); } { // array in array js.clear().beginArray().beginArray().appendInt64(1l).endArray().endArray(); - EXPECT_EQ(js.toString(), "[[1]]"); + EXPECT_EQ(js.view(), "[[1]]"); } { // array in array (multiple elements) js.clear().beginArray(). beginArray().appendInt64(1l).appendInt64(2l).endArray(). beginArray().appendInt64(3l).appendInt64(4l).endArray(). endArray(); - EXPECT_EQ(js.toString(), "[[1,2],[3,4]]"); + EXPECT_EQ(js.view(), "[[1,2],[3,4]]"); } { // object in array js.clear().beginArray(). beginObject().appendKey("k1").appendInt64(1l).endObject(). endArray(); - EXPECT_EQ(js.toString(), "[{\"k1\":1}]"); + EXPECT_EQ(js.view(), "[{\"k1\":1}]"); } { // object in array (multiple elements) js.clear().beginArray(). beginObject().appendKey("k1").appendInt64(1l).appendKey("k2").appendInt64(2l).endObject(). beginObject().appendKey("k3").appendInt64(3l).appendKey("k4").appendInt64(4l).endObject(). endArray(); - EXPECT_EQ(js.toString(), "[{\"k1\":1,\"k2\":2},{\"k3\":3,\"k4\":4}]"); + EXPECT_EQ(js.view(), "[{\"k1\":1,\"k2\":2},{\"k3\":3,\"k4\":4}]"); } } @@ -249,7 +249,7 @@ TEST(JSONTest, test_json_writer_complex) js.endArray(); } js.endObject(); - EXPECT_EQ(js.toString(), "{\"k1\":{\"k1.1\":1,\"k1.2\":[2,3]},\"k2\":{\"k2.1\":{\"k2.1.1\":4,\"k2.1.2\":[5,6]}},\"k3\":[{\"k3.1\":7,\"k3.2\":[8,9]},{\"k3.1\":10,\"k3.2\":[11,12]}]}"); + EXPECT_EQ(js.view(), "{\"k1\":{\"k1.1\":1,\"k1.2\":[2,3]},\"k2\":{\"k2.1\":{\"k2.1.1\":4,\"k2.1.2\":[5,6]}},\"k3\":[{\"k3.1\":7,\"k3.2\":[8,9]},{\"k3.1\":10,\"k3.2\":[11,12]}]}"); } namespace { @@ -291,7 +291,7 @@ TEST(JSONTest, test_json_stream) Builder b; b.build(stream); stream.finalize(); - EXPECT_EQ(as.str(), "{\"k1\":{\"k1.1\":1,\"k1.2\":[2,3]},\"k2\":{\"k2.1\":{\"k2.1.1\":4,\"k2.1.2\":[5,6]}},\"k3\":[{\"k3.1\":-7,\"k3.2\":[-8,-9]},{\"k3.1\":10,\"k3.2\":[11,12]}]}"); + EXPECT_EQ(as.view(), "{\"k1\":{\"k1.1\":1,\"k1.2\":[2,3]},\"k2\":{\"k2.1\":{\"k2.1.1\":4,\"k2.1.2\":[5,6]}},\"k3\":[{\"k3.1\":-7,\"k3.2\":[-8,-9]},{\"k3.1\":10,\"k3.2\":[11,12]}]}"); } TEST(JSONTest, test_json_stream_errors) @@ -426,6 +426,3 @@ TEST(JSONTest, test_json_stream_state_reporting) << End(); EXPECT_EQ("Current: Finalized", stream.getJsonStreamState()); } - -GTEST_MAIN_RUN_ALL_TESTS() - diff --git a/vespalib/src/tests/util/md5/md5_test.cpp b/vespalib/src/tests/util/md5/md5_test.cpp index ce48aeb5c7c..a1b0c1ce311 100644 --- a/vespalib/src/tests/util/md5/md5_test.cpp +++ b/vespalib/src/tests/util/md5/md5_test.cpp @@ -6,7 +6,7 @@ namespace vespalib { -string md5_hash_of(stringref buffer) { +string md5_hash_of(std::string_view buffer) { unsigned char hash_out[16]; // Always 128 bits. fastc_md5sum(buffer.data(), buffer.size(), hash_out); asciistream os; diff --git a/vespalib/src/tests/util/memory_trap/CMakeLists.txt b/vespalib/src/tests/util/memory_trap/CMakeLists.txt deleted file mode 100644 index cc38296a928..00000000000 --- a/vespalib/src/tests/util/memory_trap/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_util_memory_trap_test_app TEST - SOURCES - memory_trap_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_util_memory_trap_test_app COMMAND vespalib_util_memory_trap_test_app) diff --git a/vespalib/src/tests/util/memory_trap/memory_trap_test.cpp b/vespalib/src/tests/util/memory_trap_test.cpp index a220e81f3a3..d963792e857 100644 --- a/vespalib/src/tests/util/memory_trap/memory_trap_test.cpp +++ b/vespalib/src/tests/util/memory_trap_test.cpp @@ -57,5 +57,3 @@ TEST_F(MemoryTrapTest, read_from_hw_backed_trap_crashes_process) { do_not_optimize_away(dummy); // never reached },""); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/mmap_file_allocator/.gitignore b/vespalib/src/tests/util/mmap_file_allocator/.gitignore deleted file mode 100644 index a18e9aac589..00000000000 --- a/vespalib/src/tests/util/mmap_file_allocator/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap-file-allocator-factory-dir diff --git a/vespalib/src/tests/util/mmap_file_allocator/CMakeLists.txt b/vespalib/src/tests/util/mmap_file_allocator/CMakeLists.txt deleted file mode 100644 index c671b4df572..00000000000 --- a/vespalib/src/tests/util/mmap_file_allocator/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_mmap_file_allocator_test_app TEST - SOURCES - mmap_file_allocator_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_mmap_file_allocator_test_app COMMAND vespalib_mmap_file_allocator_test_app) diff --git a/vespalib/src/tests/util/mmap_file_allocator_factory/.gitignore b/vespalib/src/tests/util/mmap_file_allocator_factory/.gitignore deleted file mode 100644 index a18e9aac589..00000000000 --- a/vespalib/src/tests/util/mmap_file_allocator_factory/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap-file-allocator-factory-dir diff --git a/vespalib/src/tests/util/mmap_file_allocator_factory/CMakeLists.txt b/vespalib/src/tests/util/mmap_file_allocator_factory/CMakeLists.txt deleted file mode 100644 index 03fbd04821b..00000000000 --- a/vespalib/src/tests/util/mmap_file_allocator_factory/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_mmap_file_allocator_factory_test_app TEST - SOURCES - mmap_file_allocator_factory_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_mmap_file_allocator_factory_test_app COMMAND vespalib_mmap_file_allocator_factory_test_app) diff --git a/vespalib/src/tests/util/mmap_file_allocator_factory/mmap_file_allocator_factory_test.cpp b/vespalib/src/tests/util/mmap_file_allocator_factory_test.cpp index bda19a143d3..394ecd2df27 100644 --- a/vespalib/src/tests/util/mmap_file_allocator_factory/mmap_file_allocator_factory_test.cpp +++ b/vespalib/src/tests/util/mmap_file_allocator_factory_test.cpp @@ -46,5 +46,3 @@ TEST(MmapFileAllocatorFactoryTest, nonempty_dir_gives_allocator) MmapFileAllocatorFactory::instance().setup(""); std::filesystem::remove_all(std::filesystem::path(basedir)); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp b/vespalib/src/tests/util/mmap_file_allocator_test.cpp index cf6227de4db..e986c976643 100644 --- a/vespalib/src/tests/util/mmap_file_allocator/mmap_file_allocator_test.cpp +++ b/vespalib/src/tests/util/mmap_file_allocator_test.cpp @@ -129,5 +129,3 @@ TEST_P(MmapFileAllocatorTest, reuse_file_offset_works) EXPECT_EQ(0, memcmp(buf.data, world.c_str(), world.size() + 1)); } } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/nexus/nexus_test.cpp b/vespalib/src/tests/util/nexus_test.cpp index 2bf52cf448e..27559216a1a 100644 --- a/vespalib/src/tests/nexus/nexus_test.cpp +++ b/vespalib/src/tests/util/nexus_test.cpp @@ -83,5 +83,3 @@ TEST(NexusTest, example_multi_threaded_unit_test) { EXPECT_EQ(a, 5); EXPECT_EQ(b, 7); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/printable/printabletest.cpp b/vespalib/src/tests/util/printabletest.cpp index 5b6c0058bf0..b3f35ee1d5e 100644 --- a/vespalib/src/tests/printable/printabletest.cpp +++ b/vespalib/src/tests/util/printabletest.cpp @@ -1,8 +1,8 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/util/printable.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/gtest/gtest.h> struct Foo : public vespalib::Printable { int val; @@ -108,7 +108,7 @@ TEST(PrintableTest, test_ascii_variant) { vespalib::asciistream as; as << foo; - EXPECT_EQ("19", as.str()); + EXPECT_EQ("19", as.view()); std::ostringstream ost; ost << foo; @@ -123,12 +123,10 @@ TEST(PrintableTest, test_ascii_variant) { vespalib::asciistream as; as << bar; - EXPECT_EQ("3", as.str()); + EXPECT_EQ("3", as.view()); std::ostringstream ost; ost << bar; EXPECT_EQ("3", ost.str()); } } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/sharedptr/ptrholder.cpp b/vespalib/src/tests/util/ptrholder.cpp index e6d1710247b..cd8cd50509a 100644 --- a/vespalib/src/tests/sharedptr/ptrholder.cpp +++ b/vespalib/src/tests/util/ptrholder.cpp @@ -74,5 +74,3 @@ TEST(PtrHolderTest, test_simple) EXPECT_TRUE(data.ctorCnt == 2); EXPECT_TRUE(data.dtorCnt == 2); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/random/random_test.cpp b/vespalib/src/tests/util/random_test.cpp index 34b4e3d0389..49ce3931b53 100644 --- a/vespalib/src/tests/random/random_test.cpp +++ b/vespalib/src/tests/util/random_test.cpp @@ -1,7 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/util/random.h> +#include <vespa/vespalib/gtest/gtest.h> using namespace vespalib; @@ -133,5 +133,3 @@ TEST(RandoMTest, test_normal_distribution) EXPECT_TRUE(buckets[10] > buckets[0]); EXPECT_TRUE(buckets[90] > buckets[100]); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/rcuvector/.gitignore b/vespalib/src/tests/util/rcuvector/.gitignore deleted file mode 100644 index 2c1661a8461..00000000000 --- a/vespalib/src/tests/util/rcuvector/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.depend -Makefile -rcuvector_test -vespalib_rcuvector_test_app - diff --git a/vespalib/src/tests/util/rcuvector/CMakeLists.txt b/vespalib/src/tests/util/rcuvector/CMakeLists.txt deleted file mode 100644 index ddc572ca825..00000000000 --- a/vespalib/src/tests/util/rcuvector/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_rcuvector_test_app TEST - SOURCES - rcuvector_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_rcuvector_test_app COMMAND vespalib_rcuvector_test_app) diff --git a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp b/vespalib/src/tests/util/rcuvector_test.cpp index 134c697bd3f..28b8bcdad06 100644 --- a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp +++ b/vespalib/src/tests/util/rcuvector_test.cpp @@ -516,5 +516,3 @@ TEST(RcuVectorTest, single_writer_four_readers) StressFixture f; f.run_test(20000, 4); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/ref_counted/ref_counted_test.cpp b/vespalib/src/tests/util/ref_counted_test.cpp index eb85f7b55f9..d3469dad3c9 100644 --- a/vespalib/src/tests/ref_counted/ref_counted_test.cpp +++ b/vespalib/src/tests/util/ref_counted_test.cpp @@ -264,5 +264,3 @@ TEST(RefCountedTest, with_threads) { gate.countDown(); pool.join(); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/require/require_test.cpp b/vespalib/src/tests/util/require_test.cpp index 3acfa940a12..8ad8c225f08 100644 --- a/vespalib/src/tests/require/require_test.cpp +++ b/vespalib/src/tests/util/require_test.cpp @@ -168,7 +168,3 @@ TEST(RequireTest, explicit_require_failure) { } }, E); } - -//----------------------------------------------------------------------------- - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/size_literals/CMakeLists.txt b/vespalib/src/tests/util/size_literals/CMakeLists.txt deleted file mode 100644 index 0c32d81482c..00000000000 --- a/vespalib/src/tests/util/size_literals/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_size_literals_test_app TEST - SOURCES - size_literals_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_size_literals_test_app COMMAND vespalib_size_literals_test_app) diff --git a/vespalib/src/tests/util/size_literals/size_literals_test.cpp b/vespalib/src/tests/util/size_literals_test.cpp index 93a0ee5cdb7..8356ebc0351 100644 --- a/vespalib/src/tests/util/size_literals/size_literals_test.cpp +++ b/vespalib/src/tests/util/size_literals_test.cpp @@ -37,5 +37,3 @@ TEST(SizeLiteralsTest, simple_usage) EXPECT_TRUE(is_size_t(v42g)); EXPECT_TRUE(is_size_t(v42t)); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/small_vector/small_vector_test.cpp b/vespalib/src/tests/util/small_vector_test.cpp index 8924fe64eb9..0ef4091bd0c 100644 --- a/vespalib/src/tests/small_vector/small_vector_test.cpp +++ b/vespalib/src/tests/util/small_vector_test.cpp @@ -1,9 +1,9 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/util/small_vector.h> -#include <vespa/vespalib/gtest/gtest.h> #include <vector> #include <map> +#include <vespa/vespalib/gtest/gtest.h> using namespace vespalib; @@ -288,5 +288,3 @@ TEST(SmallVectorTest, pop_back) { } EXPECT_EQ(my_cnt, 0); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/static_string/CMakeLists.txt b/vespalib/src/tests/util/static_string/CMakeLists.txt deleted file mode 100644 index 508466d4c73..00000000000 --- a/vespalib/src/tests/util/static_string/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_static_string_test_app TEST - SOURCES - static_string_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_static_string_test_app COMMAND vespalib_static_string_test_app) diff --git a/vespalib/src/tests/util/static_string/static_string_test.cpp b/vespalib/src/tests/util/static_string_test.cpp index daaf7c0dae8..e5d9356e4dc 100644 --- a/vespalib/src/tests/util/static_string/static_string_test.cpp +++ b/vespalib/src/tests/util/static_string_test.cpp @@ -13,9 +13,9 @@ TEST(StaticStringViewTest, simple_usage) { static_assert(std::same_as<decltype(value),StaticStringView>); auto a_ref = value.ref(); auto a_view = value.view(); - static_assert(std::same_as<decltype(a_ref),vespalib::stringref>); + static_assert(std::same_as<decltype(a_ref),std::string_view>); static_assert(std::same_as<decltype(a_view),std::string_view>); - vespalib::stringref ref = value; + std::string_view ref = value; std::string_view view = value; EXPECT_EQ(a_ref, expect); EXPECT_EQ(a_view, expect_std); @@ -30,5 +30,3 @@ TEST(StaticStringViewTest, with_null_byte) { std::string expect("foo\0bar", 7); EXPECT_EQ(value.view(), expect); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/util/string_escape/CMakeLists.txt b/vespalib/src/tests/util/string_escape/CMakeLists.txt deleted file mode 100644 index 86885fc66ef..00000000000 --- a/vespalib/src/tests/util/string_escape/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_util_string_escape_test_app TEST - SOURCES - string_escape_test.cpp - DEPENDS - vespalib - GTest::GTest -) -vespa_add_test(NAME vespalib_util_string_escape_test_app COMMAND vespalib_util_string_escape_test_app) diff --git a/vespalib/src/tests/util/string_escape/string_escape_test.cpp b/vespalib/src/tests/util/string_escape_test.cpp index 313fc5eac60..aba139cd74a 100644 --- a/vespalib/src/tests/util/string_escape/string_escape_test.cpp +++ b/vespalib/src/tests/util/string_escape_test.cpp @@ -19,7 +19,7 @@ TEST(StringEscapeTest, xml_attribute_regular_chars_are_not_escaped) { TEST(StringEscapeTest, control_characters_are_escaped_in_attributes) { EXPECT_EQ(xml_attribute_escaped("\n"), " "); EXPECT_EQ(xml_attribute_escaped("\r"), " "); - EXPECT_EQ(xml_attribute_escaped(stringref("\x00", 1)), "�"); // Can't just invoke strlen with null byte :) + EXPECT_EQ(xml_attribute_escaped(std::string_view("\x00", 1)), "�"); // Can't just invoke strlen with null byte :) EXPECT_EQ(xml_attribute_escaped("\x1f"), ""); } @@ -37,8 +37,6 @@ TEST(StringEscapeTest, xml_content_regular_chars_are_not_escaped) { TEST(StringEscapeTest, control_characters_are_escaped_in_content) { EXPECT_EQ(xml_content_escaped("\r"), " "); - EXPECT_EQ(xml_content_escaped(stringref("\x00", 1)), "�"); + EXPECT_EQ(xml_content_escaped(std::string_view("\x00", 1)), "�"); EXPECT_EQ(xml_content_escaped("\x1f"), ""); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/time/time_test.cpp b/vespalib/src/tests/util/time_test.cpp index e86d712e64c..7adbab21cbc 100644 --- a/vespalib/src/tests/time/time_test.cpp +++ b/vespalib/src/tests/util/time_test.cpp @@ -104,5 +104,3 @@ TEST(TimeTest, saturated_add_with_overflow) { EXPECT_EQ(saturated_add(future, duration::max()), steady_time::max()); EXPECT_EQ(saturated_add(past, duration::min()), steady_time::min()); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/typify/typify_test.cpp b/vespalib/src/tests/util/typify_test.cpp index 38cbf06a6ec..c463731a701 100644 --- a/vespalib/src/tests/typify/typify_test.cpp +++ b/vespalib/src/tests/util/typify_test.cpp @@ -120,5 +120,3 @@ TEST(TypifyTest, typify_invoke_can_return_object_reference) { EXPECT_NE(&s1, &s2); EXPECT_EQ(&s2, &s3); } - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/xmlserializable/xmlserializabletest.cpp b/vespalib/src/tests/util/xmlserializabletest.cpp index 3a6b933491a..f7ceec236e7 100644 --- a/vespalib/src/tests/xmlserializable/xmlserializabletest.cpp +++ b/vespalib/src/tests/util/xmlserializabletest.cpp @@ -1,7 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/util/xmlstream.h> +#include <vespa/vespalib/gtest/gtest.h> namespace vespalib { @@ -132,5 +132,3 @@ TEST(XmlSerializableTest, test_indent) } } // vespalib - -GTEST_MAIN_RUN_ALL_TESTS() diff --git a/vespalib/src/tests/xmlserializable/.gitignore b/vespalib/src/tests/xmlserializable/.gitignore deleted file mode 100644 index 8573da1cd93..00000000000 --- a/vespalib/src/tests/xmlserializable/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*_test -.depend -Makefile -vespalib_xmlserializable_test_app diff --git a/vespalib/src/tests/xmlserializable/CMakeLists.txt b/vespalib/src/tests/xmlserializable/CMakeLists.txt deleted file mode 100644 index 4bd28a668a0..00000000000 --- a/vespalib/src/tests/xmlserializable/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_xmlserializable_test_app TEST - SOURCES - xmlserializabletest.cpp - DEPENDS - vespalib - GTest::gtest -) -vespa_add_test(NAME vespalib_xmlserializable_test_app COMMAND vespalib_xmlserializable_test_app) |