mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
deprecate using namespace std
test: updat filereader test deprecate namespace std deprecate namespace std deprecate namespace std deprecate namespace std deprecate namespace std deprecate namespace std deprecate namespace std deprecate namespace std deprecated std namespace deprecated std namespace deprecated std namespace deprecated std namespace deprecated std namespace deprecated std namespace deprecated std namespace deprecated std namespace deprecated std namespace depecrate namespace std deprecated namespace std check ci clean line Co-authored-by: Nikola Matić <nikola.matic@ethereum.org> purge line pure line deprecate std deprecate std deprecate std deprecate std deprecate std deprecate deprecate std bye namespace
This commit is contained in:
committed by
Nikola Matic
co-authored by
Nikola Matić
parent
df03f1412d
commit
b3230b0bdc
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
@@ -47,7 +46,7 @@ BOOST_AUTO_TEST_CASE(calculate)
|
||||
BOOST_CHECK_THROW(getChecksummedAddress("0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaeK"), InvalidAddress);
|
||||
|
||||
// the official test suite from EIP-55
|
||||
vector<string> cases {
|
||||
std::vector<std::string> cases {
|
||||
// all upper case
|
||||
"0x52908400098527886E0F7030069857D2E4169EE7",
|
||||
"0x8617E340B3D01FA5F11F306F4090FD50E238070D",
|
||||
@@ -103,10 +102,10 @@ BOOST_AUTO_TEST_CASE(homocaps_valid)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(homocaps_invalid)
|
||||
{
|
||||
string upper = "0x00AA0000000012400000000DDEEFF000000000BB";
|
||||
std::string upper = "0x00AA0000000012400000000DDEEFF000000000BB";
|
||||
BOOST_CHECK(passesAddressChecksum(upper, false));
|
||||
BOOST_CHECK(!passesAddressChecksum(upper, true));
|
||||
string lower = "0x11aa000000000000000d00cc00000000000000bb";
|
||||
std::string lower = "0x11aa000000000000000d00cc00000000000000bb";
|
||||
BOOST_CHECK(passesAddressChecksum(lower, false));
|
||||
BOOST_CHECK(!passesAddressChecksum(lower, true));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
// TODO: Fix Boost...
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::test;
|
||||
|
||||
#define TEST_CASE_NAME (boost::unit_test::framework::current_test_case().p_name)
|
||||
@@ -68,31 +67,31 @@ BOOST_AUTO_TEST_CASE(readFileAsString_symlink)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(readUntilEnd_no_ending_newline)
|
||||
{
|
||||
istringstream inputStream("ABC\ndef");
|
||||
std::istringstream inputStream("ABC\ndef");
|
||||
BOOST_TEST(readUntilEnd(inputStream) == "ABC\ndef");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(readUntilEnd_with_ending_newline)
|
||||
{
|
||||
istringstream inputStream("ABC\ndef\n");
|
||||
std::istringstream inputStream("ABC\ndef\n");
|
||||
BOOST_TEST(readUntilEnd(inputStream) == "ABC\ndef\n");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(readUntilEnd_cr_lf_newline)
|
||||
{
|
||||
istringstream inputStream("ABC\r\ndef");
|
||||
std::istringstream inputStream("ABC\r\ndef");
|
||||
BOOST_TEST(readUntilEnd(inputStream) == "ABC\r\ndef");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(readUntilEnd_empty)
|
||||
{
|
||||
istringstream inputStream("");
|
||||
std::istringstream inputStream("");
|
||||
BOOST_TEST(readUntilEnd(inputStream) == "");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(readBytes_past_end)
|
||||
{
|
||||
istringstream inputStream("abc");
|
||||
std::istringstream inputStream("abc");
|
||||
BOOST_CHECK_EQUAL(readBytes(inputStream, 0), "");
|
||||
BOOST_CHECK_EQUAL(readBytes(inputStream, 1), "a");
|
||||
BOOST_CHECK_EQUAL(readBytes(inputStream, 20), "bc");
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
@@ -37,16 +36,16 @@ BOOST_AUTO_TEST_CASE(test_small)
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58({}), "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58("x"), "QmULKig5Fxrs2sC4qt9nNduucXfb92AFYQ6Hi3YRqDmrYC");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58("Solidity\n"), "QmSsm9M7PQRBnyiz1smizk8hZw3URfk8fSeHzeTo3oZidS");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(string(200ul, char(0))), "QmSXR1N23uWzsANi8wpxMPw5dmmhqBVUAb4hUrHVLpNaMr");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(string(10250ul, char(0))), "QmVJJBB3gKKBWYC9QTywpH8ZL1bDeTDJ17B63Af5kino9i");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(string(100000ul, char(0))), "QmYgKa25YqEGpQmmZtPPFMNK3kpqqneHk6nMSEUYryEX1C");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(string(121071ul, char(0))), "QmdMdRshQmqvyc92N82r7AKYdUF5FRh4DJo6GtrmEk3wgj");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(std::string(200ul, char(0))), "QmSXR1N23uWzsANi8wpxMPw5dmmhqBVUAb4hUrHVLpNaMr");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(std::string(10250ul, char(0))), "QmVJJBB3gKKBWYC9QTywpH8ZL1bDeTDJ17B63Af5kino9i");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(std::string(100000ul, char(0))), "QmYgKa25YqEGpQmmZtPPFMNK3kpqqneHk6nMSEUYryEX1C");
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(std::string(121071ul, char(0))), "QmdMdRshQmqvyc92N82r7AKYdUF5FRh4DJo6GtrmEk3wgj");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_medium)
|
||||
{
|
||||
size_t length = 131071;
|
||||
string data;
|
||||
std::string data;
|
||||
data.resize(length, 0);
|
||||
BOOST_REQUIRE_EQUAL(data.size(), length);
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(data), "QmSxYSToKHsPqqRdRnsM9gmr3EYS6dakhVaHgbFdgYQWi6");
|
||||
@@ -55,7 +54,7 @@ BOOST_AUTO_TEST_CASE(test_medium)
|
||||
BOOST_AUTO_TEST_CASE(test_largest_unchunked)
|
||||
{
|
||||
size_t length = 1024 * 256 - 1;
|
||||
string data;
|
||||
std::string data;
|
||||
data.resize(length, 0);
|
||||
BOOST_REQUIRE_EQUAL(data.size(), length);
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(data), "QmbNDspMkzkMFKyS3eCJGedG7GWRQHSCzJCZLjxP7wyVAx");
|
||||
@@ -64,7 +63,7 @@ BOOST_AUTO_TEST_CASE(test_largest_unchunked)
|
||||
BOOST_AUTO_TEST_CASE(test_smallest_chunked)
|
||||
{
|
||||
size_t length = 1024 * 256 + 1;
|
||||
string data;
|
||||
std::string data;
|
||||
data.resize(length, 0);
|
||||
BOOST_REQUIRE_EQUAL(data.size(), length);
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(data), "QmbVuw4C4vcmVKqxoWtgDVobvcHrSn51qsmQmyxjk4sB2Q");
|
||||
@@ -73,7 +72,7 @@ BOOST_AUTO_TEST_CASE(test_smallest_chunked)
|
||||
BOOST_AUTO_TEST_CASE(test_large)
|
||||
{
|
||||
size_t length = 1310710;
|
||||
string data;
|
||||
std::string data;
|
||||
data.resize(length, 0);
|
||||
BOOST_REQUIRE_EQUAL(data.size(), length);
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(data), "QmNg7BJo8gEMDK8yGQbHEwPtycesnE6FUULX5iVd5TAL9f");
|
||||
@@ -82,7 +81,7 @@ BOOST_AUTO_TEST_CASE(test_large)
|
||||
BOOST_AUTO_TEST_CASE(test_largest_one_level)
|
||||
{
|
||||
size_t length = 45613056; // 1024 * 256 * 174;
|
||||
string data;
|
||||
std::string data;
|
||||
data.resize(length, 0);
|
||||
BOOST_REQUIRE_EQUAL(data.size(), length);
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(data), "QmY4HSz1oVGdUzb8poVYPLsoqBZjH6LZrtgnme9wWn2Qko");
|
||||
@@ -91,7 +90,7 @@ BOOST_AUTO_TEST_CASE(test_largest_one_level)
|
||||
BOOST_AUTO_TEST_CASE(test_smallest_multi_level)
|
||||
{
|
||||
size_t length = 45613057; // 1024 * 256 * 174 + 1;
|
||||
string data;
|
||||
std::string data;
|
||||
data.resize(length, 0);
|
||||
BOOST_REQUIRE_EQUAL(data.size(), length);
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(data), "QmehMASWcBsX7VcEQqs6rpR5AHoBfKyBVEgmkJHjpPg8jq");
|
||||
@@ -100,7 +99,7 @@ BOOST_AUTO_TEST_CASE(test_smallest_multi_level)
|
||||
BOOST_AUTO_TEST_CASE(test_multi_level_tree)
|
||||
{
|
||||
size_t length = 46661632;
|
||||
string data;
|
||||
std::string data;
|
||||
data.resize(length, 0);
|
||||
BOOST_REQUIRE_EQUAL(data.size(), length);
|
||||
BOOST_CHECK_EQUAL(ipfsHashBase58(data), "QmaTb1sT9hrSXJLmf8bxJ9NuwndiHuMLsgNLgkS2eXu3Xj");
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
@@ -34,61 +33,61 @@ BOOST_AUTO_TEST_SUITE(IterateReplacing, *boost::unit_test::label("nooptions"))
|
||||
|
||||
BOOST_AUTO_TEST_CASE(no_replacement)
|
||||
{
|
||||
vector<string> v{"abc", "def", "ghi"};
|
||||
function<std::optional<vector<string>>(string&)> f = [](string&) -> std::optional<vector<string>> { return {}; };
|
||||
std::vector<std::string> v{"abc", "def", "ghi"};
|
||||
std::function<std::optional<std::vector<std::string>>(std::string&)> f = [](std::string&) -> std::optional<std::vector<std::string>> { return {}; };
|
||||
iterateReplacing(v, f);
|
||||
vector<string> expectation{"abc", "def", "ghi"};
|
||||
std::vector<std::string> expectation{"abc", "def", "ghi"};
|
||||
BOOST_CHECK(v == expectation);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(empty_input)
|
||||
{
|
||||
vector<string> v;
|
||||
function<std::optional<vector<string>>(string&)> f = [](string&) -> std::optional<vector<string>> { return {}; };
|
||||
std::vector<std::string> v;
|
||||
std::function<std::optional<std::vector<std::string>>(std::string&)> f = [](std::string&) -> std::optional<std::vector<std::string>> { return {}; };
|
||||
iterateReplacing(v, f);
|
||||
vector<string> expectation;
|
||||
std::vector<std::string> expectation;
|
||||
BOOST_CHECK(v == expectation);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(delete_some)
|
||||
{
|
||||
vector<string> v{"abc", "def", "ghi"};
|
||||
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
|
||||
std::vector<std::string> v{"abc", "def", "ghi"};
|
||||
std::function<std::optional<std::vector<std::string>>(std::string&)> f = [](std::string& _s) -> std::optional<std::vector<std::string>> {
|
||||
if (_s == "def")
|
||||
return vector<string>();
|
||||
return std::vector<std::string>();
|
||||
else
|
||||
return {};
|
||||
};
|
||||
iterateReplacing(v, f);
|
||||
vector<string> expectation{"abc", "ghi"};
|
||||
std::vector<std::string> expectation{"abc", "ghi"};
|
||||
BOOST_CHECK(v == expectation);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(inject_some_start)
|
||||
{
|
||||
vector<string> v{"abc", "def", "ghi"};
|
||||
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
|
||||
std::vector<std::string> v{"abc", "def", "ghi"};
|
||||
std::function<std::optional<std::vector<std::string>>(std::string&)> f = [](std::string& _s) -> std::optional<std::vector<std::string>> {
|
||||
if (_s == "abc")
|
||||
return vector<string>{"x", "y"};
|
||||
return std::vector<std::string>{"x", "y"};
|
||||
else
|
||||
return {};
|
||||
};
|
||||
iterateReplacing(v, f);
|
||||
vector<string> expectation{"x", "y", "def", "ghi"};
|
||||
std::vector<std::string> expectation{"x", "y", "def", "ghi"};
|
||||
BOOST_CHECK(v == expectation);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(inject_some_end)
|
||||
{
|
||||
vector<string> v{"abc", "def", "ghi"};
|
||||
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
|
||||
std::vector<std::string> v{"abc", "def", "ghi"};
|
||||
std::function<std::optional<std::vector<std::string>>(std::string&)> f = [](std::string& _s) -> std::optional<std::vector<std::string>> {
|
||||
if (_s == "ghi")
|
||||
return vector<string>{"x", "y"};
|
||||
return std::vector<std::string>{"x", "y"};
|
||||
else
|
||||
return {};
|
||||
};
|
||||
iterateReplacing(v, f);
|
||||
vector<string> expectation{"abc", "def", "x", "y"};
|
||||
std::vector<std::string> expectation{"abc", "def", "x", "y"};
|
||||
BOOST_CHECK(v == expectation);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
@@ -35,7 +34,7 @@ BOOST_AUTO_TEST_SUITE(JsonTest, *boost::unit_test::label("nooptions"))
|
||||
|
||||
BOOST_AUTO_TEST_CASE(json_types)
|
||||
{
|
||||
auto check = [](Json::Value value, string const& expectation) {
|
||||
auto check = [](Json::Value value, std::string const& expectation) {
|
||||
BOOST_CHECK(jsonCompactPrint(value) == expectation);
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
@@ -75,7 +74,7 @@ BOOST_AUTO_TEST_CASE(test_dldistance)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_alternatives_list)
|
||||
{
|
||||
vector<string> strings;
|
||||
std::vector<std::string> strings;
|
||||
BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "");
|
||||
strings.emplace_back("a");
|
||||
BOOST_CHECK_EQUAL(quotedAlternativesList(strings), "\"a\"");
|
||||
@@ -89,20 +88,20 @@ BOOST_AUTO_TEST_CASE(test_alternatives_list)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_human_readable_join)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({})), "");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"})), "a");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"})), "a, b");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"})), "a, b, c");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({})), "");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a"})), "a");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a", "b"})), "a, b");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a", "b", "c"})), "a, b, c");
|
||||
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({}), "; "), "");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"}), "; "), "a");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"}), "; "), "a; b");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"}), "; "), "a; b; c");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({}), "; "), "");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a"}), "; "), "a");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a", "b"}), "; "), "a; b");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a", "b", "c"}), "; "), "a; b; c");
|
||||
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({}), "; ", " or "), "");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a"}), "; ", " or "), "a");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b"}), "; ", " or "), "a or b");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(vector<string>({"a", "b", "c"}), "; ", " or "), "a; b or c");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({}), "; ", " or "), "");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a"}), "; ", " or "), "a");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a", "b"}), "; ", " or "), "a or b");
|
||||
BOOST_CHECK_EQUAL(joinHumanReadable(std::vector<std::string>({"a", "b", "c"}), "; ", " or "), "a; b or c");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_format_number_readable)
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
@@ -37,12 +36,12 @@ BOOST_AUTO_TEST_SUITE(SwarmHash, *boost::unit_test::label("nooptions"))
|
||||
namespace
|
||||
{
|
||||
|
||||
string bzzr0HashHex(string const& _input)
|
||||
std::string bzzr0HashHex(std::string const& _input)
|
||||
{
|
||||
return toHex(bzzr0Hash(_input).asBytes());
|
||||
}
|
||||
|
||||
string bzzr1HashHex(bytes const& _input)
|
||||
std::string bzzr1HashHex(bytes const& _input)
|
||||
{
|
||||
return toHex(bzzr1Hash(_input).asBytes());
|
||||
}
|
||||
@@ -59,17 +58,17 @@ bytes sequence(size_t _length)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_zeros)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string()), string("011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x1000 - 1, 0)), string("32f0faabc4265ac238cd945087133ce3d7e9bb2e536053a812b5373c54043adb"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x1000, 0)), string("411dd45de7246e94589ff5888362c41e85bd3e582a92d0fda8f0e90b76439bec"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x1000 + 1, 0)), string("69754a0098432bbc2e84fe1205276870748a61a065ab6ef44d6a2e7b13ce044d"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x2000 - 1, 0)), string("69ad3c581043404f775ffa8d6f1b25ad4a9ee812971190e90209c0966116a321"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x2000, 0)), string("f00222373ff82d0a178dc6271c78953e9c88f74130a52d401f5ec51475f63c43"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x2000 + 1, 0)), string("86d6773e79e02fd8145ee1aedba89ace0c15f2566db1249654000039a9a134bf"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x80000, 0)), string("cc0854fe2c6b98e920d5c14b1a88e6d4223e55b8f78883f60939aa2485e361bf"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x80020, 0)), string("ee9ffca246e70d3704740ba4df450fa6988d14a1c2439c7e734c7a77a4eb6fd3"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(0x800020, 0)), string("78b90b20c90559fb904535181a7c28929ea2f30a2329dbc25232de579709f12f"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string(2095104, 0)), string("a9958184589fc11b4027a4c233e777ebe2e99c66f96b74aef2a0638a94dd5439"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string()), std::string("011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x1000 - 1, 0)), std::string("32f0faabc4265ac238cd945087133ce3d7e9bb2e536053a812b5373c54043adb"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x1000, 0)), std::string("411dd45de7246e94589ff5888362c41e85bd3e582a92d0fda8f0e90b76439bec"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x1000 + 1, 0)), std::string("69754a0098432bbc2e84fe1205276870748a61a065ab6ef44d6a2e7b13ce044d"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x2000 - 1, 0)), std::string("69ad3c581043404f775ffa8d6f1b25ad4a9ee812971190e90209c0966116a321"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x2000, 0)), std::string("f00222373ff82d0a178dc6271c78953e9c88f74130a52d401f5ec51475f63c43"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x2000 + 1, 0)), std::string("86d6773e79e02fd8145ee1aedba89ace0c15f2566db1249654000039a9a134bf"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x80000, 0)), std::string("cc0854fe2c6b98e920d5c14b1a88e6d4223e55b8f78883f60939aa2485e361bf"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x80020, 0)), std::string("ee9ffca246e70d3704740ba4df450fa6988d14a1c2439c7e734c7a77a4eb6fd3"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(0x800020, 0)), std::string("78b90b20c90559fb904535181a7c28929ea2f30a2329dbc25232de579709f12f"));
|
||||
BOOST_CHECK_EQUAL(bzzr0HashHex(std::string(2095104, 0)), std::string("a9958184589fc11b4027a4c233e777ebe2e99c66f96b74aef2a0638a94dd5439"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bzz_hash_short)
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::test_tools;
|
||||
|
||||
namespace solidity::util::test
|
||||
@@ -58,8 +57,8 @@ BOOST_AUTO_TEST_CASE(TemporaryDirectory_should_delete_its_directory_even_if_not_
|
||||
BOOST_TEST(boost::filesystem::is_directory(dirPath));
|
||||
|
||||
{
|
||||
ofstream tmpFile((dirPath / "test-file.txt").string());
|
||||
tmpFile << "Delete me!" << endl;
|
||||
std::ofstream tmpFile((dirPath / "test-file.txt").string());
|
||||
tmpFile << "Delete me!" << std::endl;
|
||||
}
|
||||
soltestAssert(boost::filesystem::is_regular_file(dirPath / "test-file.txt"), "");
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
@@ -35,13 +34,13 @@ BOOST_AUTO_TEST_SUITE(UTF8, *boost::unit_test::label("nooptions"))
|
||||
|
||||
namespace {
|
||||
|
||||
bool isValidUTF8(string const& _value)
|
||||
bool isValidUTF8(std::string const& _value)
|
||||
{
|
||||
size_t pos;
|
||||
return validateUTF8(asString(fromHex(_value)), pos);
|
||||
}
|
||||
|
||||
bool isInvalidUTF8(string const& _value, size_t _expectedPos)
|
||||
bool isInvalidUTF8(std::string const& _value, size_t _expectedPos)
|
||||
{
|
||||
size_t pos;
|
||||
if (validateUTF8(asString(fromHex(_value)), pos))
|
||||
@@ -94,7 +93,7 @@ BOOST_AUTO_TEST_CASE(invalid)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(corpus)
|
||||
{
|
||||
string source = R"(
|
||||
std::string source = R"(
|
||||
κόσμε
|
||||
|
||||
hélló
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::util::test
|
||||
{
|
||||
@@ -34,14 +33,14 @@ BOOST_AUTO_TEST_SUITE(WhiskersTest, *boost::unit_test::label("nooptions"))
|
||||
|
||||
BOOST_AUTO_TEST_CASE(no_templates)
|
||||
{
|
||||
string templ = "this text does not contain templates";
|
||||
std::string templ = "this text does not contain templates";
|
||||
BOOST_CHECK_EQUAL(Whiskers(templ).render(), templ);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(basic_replacement)
|
||||
{
|
||||
string templ = "a <b> x <c> -> <d>.";
|
||||
string result = Whiskers(templ)
|
||||
std::string templ = "a <b> x <c> -> <d>.";
|
||||
std::string result = Whiskers(templ)
|
||||
("b", "BE")
|
||||
("c", "CE")
|
||||
("d", "DE")
|
||||
@@ -51,43 +50,43 @@ BOOST_AUTO_TEST_CASE(basic_replacement)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(tag_unavailable)
|
||||
{
|
||||
string templ = "<b>";
|
||||
std::string templ = "<b>";
|
||||
Whiskers m(templ);
|
||||
BOOST_CHECK_THROW(m.render(), WhiskersError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(list_unavailable)
|
||||
{
|
||||
string templ = "<#b></b>";
|
||||
std::string templ = "<#b></b>";
|
||||
Whiskers m(templ);
|
||||
BOOST_CHECK_THROW(m.render(), WhiskersError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_type_collision)
|
||||
{
|
||||
string templ = "<b><#b></b>";
|
||||
std::string templ = "<b><#b></b>";
|
||||
Whiskers m(templ);
|
||||
m("b", "x");
|
||||
BOOST_CHECK_THROW(m("b", vector<map<string, string>>{}), WhiskersError);
|
||||
BOOST_CHECK_THROW(m("b", std::vector<std::map<std::string, std::string>>{}), WhiskersError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(conditional)
|
||||
{
|
||||
string templ = "<?b>X</b>";
|
||||
std::string templ = "<?b>X</b>";
|
||||
BOOST_CHECK_EQUAL(Whiskers(templ)("b", true).render(), "X");
|
||||
BOOST_CHECK_EQUAL(Whiskers(templ)("b", false).render(), "");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(conditional_with_else)
|
||||
{
|
||||
string templ = "<?b>X<!b>Y</b>";
|
||||
std::string templ = "<?b>X<!b>Y</b>";
|
||||
BOOST_CHECK_EQUAL(Whiskers(templ)("b", true).render(), "X");
|
||||
BOOST_CHECK_EQUAL(Whiskers(templ)("b", false).render(), "Y");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(broken_conditional_with_else)
|
||||
{
|
||||
string templ = "<?b>X<!bY</b>";
|
||||
std::string templ = "<?b>X<!bY</b>";
|
||||
BOOST_CHECK_THROW(Whiskers{templ}, WhiskersError);
|
||||
|
||||
templ = "<?bX<!b>Y</b>";
|
||||
@@ -99,7 +98,7 @@ BOOST_AUTO_TEST_CASE(broken_conditional_with_else)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(broken_conditional_value_with_else)
|
||||
{
|
||||
string templ = "<?+b>X<!+bY</+b>";
|
||||
std::string templ = "<?+b>X<!+bY</+b>";
|
||||
BOOST_CHECK_THROW(Whiskers{templ}, WhiskersError);
|
||||
|
||||
templ = "<?+bX<!+b>Y</+b>";
|
||||
@@ -111,7 +110,7 @@ BOOST_AUTO_TEST_CASE(broken_conditional_value_with_else)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(broken_list_parameter)
|
||||
{
|
||||
string templ = "<#b><a></b";
|
||||
std::string templ = "<#b><a></b";
|
||||
BOOST_CHECK_THROW(Whiskers{templ}, WhiskersError);
|
||||
|
||||
templ = "<#b<a></b>";
|
||||
@@ -120,7 +119,7 @@ BOOST_AUTO_TEST_CASE(broken_list_parameter)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(conditional_plus_params)
|
||||
{
|
||||
string templ = " - <?b>_<r><!b>^<t></b> - ";
|
||||
std::string templ = " - <?b>_<r><!b>^<t></b> - ";
|
||||
Whiskers m1(templ);
|
||||
m1("b", true);
|
||||
m1("r", "R");
|
||||
@@ -136,10 +135,10 @@ BOOST_AUTO_TEST_CASE(conditional_plus_params)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(conditional_plus_list)
|
||||
{
|
||||
string templ = " - <?b>_<#l><x></l><!b><#l><y></l></b> - ";
|
||||
std::string templ = " - <?b>_<#l><x></l><!b><#l><y></l></b> - ";
|
||||
Whiskers m(templ);
|
||||
m("b", false);
|
||||
vector<map<string, string>> list(2);
|
||||
std::vector<std::map<std::string, std::string>> list(2);
|
||||
list[0]["x"] = "1";
|
||||
list[0]["y"] = "a";
|
||||
list[1]["x"] = "2";
|
||||
@@ -150,21 +149,21 @@ BOOST_AUTO_TEST_CASE(conditional_plus_list)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(string_as_conditional)
|
||||
{
|
||||
string templ = "<?+b>+<b><!+b>-</+b>";
|
||||
std::string templ = "<?+b>+<b><!+b>-</+b>";
|
||||
BOOST_CHECK_EQUAL(Whiskers(templ)("b", "abc").render(), "+abc");
|
||||
BOOST_CHECK_EQUAL(Whiskers(templ)("b", "").render(), "-");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(string_as_conditional_wrong)
|
||||
{
|
||||
string templ = "<?+b>+<b></b>";
|
||||
std::string templ = "<?+b>+<b></b>";
|
||||
BOOST_CHECK_EQUAL(Whiskers(templ)("b", "abc").render(), "<?+b>+abc</b>");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(complicated_replacement)
|
||||
{
|
||||
string templ = "a <b> x <complicated> \n <nested>>.";
|
||||
string result = Whiskers(templ)
|
||||
std::string templ = "a <b> x <complicated> \n <nested>>.";
|
||||
std::string result = Whiskers(templ)
|
||||
("b", "BE")
|
||||
("complicated", "CO<M>PL")
|
||||
("nested", "NEST")
|
||||
@@ -174,53 +173,53 @@ BOOST_AUTO_TEST_CASE(complicated_replacement)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(non_existing_list)
|
||||
{
|
||||
string templ = "a <#b></b>";
|
||||
std::string templ = "a <#b></b>";
|
||||
Whiskers m(templ);
|
||||
BOOST_CHECK_THROW(m.render(), WhiskersError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(empty_list)
|
||||
{
|
||||
string templ = "a <#b></b>x";
|
||||
string result = Whiskers(templ)("b", vector<Whiskers::StringMap>{}).render();
|
||||
std::string templ = "a <#b></b>x";
|
||||
std::string result = Whiskers(templ)("b", std::vector<Whiskers::StringMap>{}).render();
|
||||
BOOST_CHECK_EQUAL(result, "a x");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(list)
|
||||
{
|
||||
string templ = "a<#b>( <g> - <h> )</b>x";
|
||||
vector<map<string, string>> list(2);
|
||||
std::string templ = "a<#b>( <g> - <h> )</b>x";
|
||||
std::vector<std::map<std::string, std::string>> list(2);
|
||||
list[0]["g"] = "GE";
|
||||
list[0]["h"] = "H";
|
||||
list[1]["g"] = "2GE";
|
||||
list[1]["h"] = "2H";
|
||||
string result = Whiskers(templ)("b", list).render();
|
||||
std::string result = Whiskers(templ)("b", list).render();
|
||||
BOOST_CHECK_EQUAL(result, "a( GE - H )( 2GE - 2H )x");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(recursive_list)
|
||||
{
|
||||
// Check that templates resulting from lists are not expanded again
|
||||
string templ = "a<#b> 1<g>3 </b><x>";
|
||||
vector<map<string, string>> list(1);
|
||||
std::string templ = "a<#b> 1<g>3 </b><x>";
|
||||
std::vector<std::map<std::string, std::string>> list(1);
|
||||
list[0]["g"] = "<x>";
|
||||
string result = Whiskers(templ)("x", "X")("b", list).render();
|
||||
std::string result = Whiskers(templ)("x", "X")("b", list).render();
|
||||
BOOST_CHECK_EQUAL(result, "a 1<x>3 X");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(list_can_access_upper)
|
||||
{
|
||||
string templ = "<#b>(<a>)</b>";
|
||||
vector<map<string, string>> list(2);
|
||||
std::string templ = "<#b>(<a>)</b>";
|
||||
std::vector<std::map<std::string, std::string>> list(2);
|
||||
Whiskers m(templ);
|
||||
string result = m("a", "A")("b", list).render();
|
||||
std::string result = m("a", "A")("b", list).render();
|
||||
BOOST_CHECK_EQUAL(result, "(A)(A)");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(parameter_collision)
|
||||
{
|
||||
string templ = "a <#b></b>";
|
||||
vector<map<string, string>> list(1);
|
||||
std::string templ = "a <#b></b>";
|
||||
std::vector<std::map<std::string, std::string>> list(1);
|
||||
list[0]["a"] = "x";
|
||||
Whiskers m(templ);
|
||||
BOOST_CHECK_THROW(m("a", "X")("b", list), WhiskersError);
|
||||
@@ -229,14 +228,14 @@ BOOST_AUTO_TEST_CASE(parameter_collision)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_param)
|
||||
{
|
||||
string templ = "a <b >";
|
||||
std::string templ = "a <b >";
|
||||
Whiskers m(templ);
|
||||
BOOST_CHECK_THROW(m("b ", "X"), WhiskersError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_param_rendered)
|
||||
{
|
||||
string templ = "a <b >";
|
||||
std::string templ = "a <b >";
|
||||
Whiskers m(templ);
|
||||
BOOST_CHECK_EQUAL(m.render(), templ);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user