aboutsummaryrefslogtreecommitdiff
path: root/src/test/net_tests.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2020-11-20 04:36:19 +0100
committerWladimir J. van der Laan <laanwj@protonmail.com>2020-11-20 04:39:37 +0100
commit2878167c18eee9ad440ab3f663d74bf2db254f17 (patch)
tree4c9f92030519cdd2afe3f2ca99d21157419883f3 /src/test/net_tests.cpp
parent0a267f4eb88597f9e3dbd4614c70427e6e41df20 (diff)
parentecc6cf1a3b097b9b5b047282063a0b6779631b83 (diff)
Merge #20000: test: fix creation of "std::string"s with \0s
ecc6cf1a3b097b9b5b047282063a0b6779631b83 test: fix creation of std::string objects with \0s (Vasil Dimov) Pull request description: A string literal `"abc"` contains a terminating `\0`, so that is 4 bytes. There is no need to write `"abc\0"` unless two terminating `\0`s are necessary. `std::string` objects do not internally contain a terminating `\0`, so `std::string("abc")` creates a string with size 3 and is the same as `std::string("abc", 3)`. In `"\01"` the `01` part is interpreted as one number (1) and that is the same as `"\1"` which is a string like `{1, 0}` whereas `"\0z"` is a string like `{0, 'z', 0}`. To create a string like `{0, '1', 0}` one must use `"\0" "1"`. Adjust the tests accordingly. ACKs for top commit: laanwj: ACK ecc6cf1a3b097b9b5b047282063a0b6779631b83 practicalswift: ACK ecc6cf1a3b097b9b5b047282063a0b6779631b83 modulo happily green CI Tree-SHA512: 5eb489e8533a4199a9324b92f7280041552379731ebf7dfee169f70d5458e20e29b36f8bfaee6f201f48ab2b9d1d0fc4bdf8d6e4c58d6102f399cfbea54a219e
Diffstat (limited to 'src/test/net_tests.cpp')
-rw-r--r--src/test/net_tests.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index 37eca8b7ef..b23fec9b95 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -25,6 +25,8 @@
#include <memory>
#include <string>
+using namespace std::literals;
+
class CAddrManSerializationMock : public CAddrMan
{
public:
@@ -106,8 +108,8 @@ BOOST_AUTO_TEST_CASE(caddrdb_read)
BOOST_CHECK(Lookup("250.7.1.1", addr1, 8333, false));
BOOST_CHECK(Lookup("250.7.2.2", addr2, 9999, false));
BOOST_CHECK(Lookup("250.7.3.3", addr3, 9999, false));
- BOOST_CHECK(Lookup(std::string("250.7.3.3", 9), addr3, 9999, false));
- BOOST_CHECK(!Lookup(std::string("250.7.3.3\0example.com", 21), addr3, 9999, false));
+ BOOST_CHECK(Lookup("250.7.3.3"s, addr3, 9999, false));
+ BOOST_CHECK(!Lookup("250.7.3.3\0example.com"s, addr3, 9999, false));
// Add three addresses to new table.
CService source;