HomePhabricator

test: fix creation of std::string objects with \0s

Description

test: fix creation of std::string objects with \0s

Summary:
A string literal "abc" contains a terminating \0, so that is 4
bytes. There is no need to write "abc\0" unless two terminating
\0s 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.

This is a backport of core#20000

Test Plan: ninja check

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10808

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on Sep 23 2020, 06:40
PiRKCommitted on Jan 11 2022, 12:33
PiRKPushed on Jan 11 2022, 12:33
Reviewer
Restricted Project
Differential Revision
D10808: test: fix creation of std::string objects with \0s
Parents
rABC734651c14c05: docs/descriptors.md: Remove hardened marker in the path after xpub
Branches
Unknown
Tags
Unknown