Fabcoin Core  0.16.2
P2P Digital Currency
core.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
23 #include <boost/test/unit_test.hpp>
24 #include <libdevcore/CommonIO.h>
25 #include <libdevcore/Log.h>
27 
28 using namespace dev::test;
29 
31 
33 {
34  cnote << "bytesRef copyTo and toString...";
35  dev::bytes originalSequence = dev::fromHex("0102030405060708091011121314151617181920212223242526272829303132");
36  dev::bytesRef out(&originalSequence.at(0), 32);
37  dev::h256 hash32("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347");
38  hash32.ref().copyTo(out);
39 
40  BOOST_CHECK_MESSAGE(out.size() == 32, "Error wrong result size when h256::ref().copyTo(dev::bytesRef out)");
41  BOOST_CHECK_MESSAGE(out.toBytes() == originalSequence, "Error when h256::ref().copyTo(dev::bytesRef out)");
42 }
43 
45 {
46  BOOST_CHECK(dev::isHex("0x"));
47  BOOST_CHECK(dev::isHex("0xA"));
48  BOOST_CHECK(dev::isHex("0xAB"));
49  BOOST_CHECK(dev::isHex("0x0AA"));
50  BOOST_CHECK(!dev::isHex("0x0Ag"));
51  BOOST_CHECK(!dev::isHex("0Ag"));
52  BOOST_CHECK(!dev::isHex(" "));
53  BOOST_CHECK(dev::isHex("aa"));
54  BOOST_CHECK(dev::isHex("003"));
55 }
56 
A modifiable reference to an existing object or vector in memory.
Definition: vector_ref.h:20
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
Definition: CommonData.cpp:99
bool isHex(std::string const &_s) noexcept
std::vector< byte > bytes
Definition: Common.h:75
BOOST_AUTO_TEST_CASE(rndCode)
Definition: fuzzHelper.cpp:409
#define cnote
Definition: Log.h:303
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
Helper functions to work with json::spirit and test files.
#define BOOST_CHECK(expr)
Definition: object.cpp:17