aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/blockchain_db.cpp4
-rw-r--r--tests/unit_tests/epee_utils.cpp20
-rw-r--r--tests/unit_tests/ringct.cpp4
-rw-r--r--tests/unit_tests/rolling_median.cpp2
4 files changed, 24 insertions, 6 deletions
diff --git a/tests/unit_tests/blockchain_db.cpp b/tests/unit_tests/blockchain_db.cpp
index f302d7946..d7c60cecb 100644
--- a/tests/unit_tests/blockchain_db.cpp
+++ b/tests/unit_tests/blockchain_db.cpp
@@ -162,7 +162,7 @@ protected:
{
block bl;
blobdata bd = h2b(i);
- parse_and_validate_block_from_blob(bd, bl);
+ CHECK_AND_ASSERT_THROW_MES(parse_and_validate_block_from_blob(bd, bl), "Invalid block");
m_blocks.push_back(std::make_pair(bl, bd));
}
for (auto& i : t_transactions)
@@ -172,7 +172,7 @@ protected:
{
transaction tx;
blobdata bd = h2b(j);
- parse_and_validate_tx_from_blob(bd, tx);
+ CHECK_AND_ASSERT_THROW_MES(parse_and_validate_tx_from_blob(bd, tx), "Invalid transaction");
txs.push_back(std::make_pair(tx, bd));
}
m_txs.push_back(txs);
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp
index 946731826..32328edd9 100644
--- a/tests/unit_tests/epee_utils.cpp
+++ b/tests/unit_tests/epee_utils.cpp
@@ -27,6 +27,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <array>
+#include <boost/predef/other/endian.h>
#include <boost/endian/conversion.hpp>
#include <boost/range/algorithm/equal.hpp>
#include <boost/range/algorithm_ext/iota.hpp>
@@ -135,7 +136,7 @@ namespace
EXPECT_FALSE( lhs >= rhs ); \
EXPECT_TRUE( rhs >= lhs )
- #ifdef BOOST_LITTLE_ENDIAN
+ #if BOOST_ENDIAN_LITTLE_BYTE
#define CHECK_LESS_ENDIAN(lhs, rhs) CHECK_LESS( rhs , lhs )
#else
#define CHECK_LESS_ENDIAN(lhs, rhs) CHECK_LESS( lhs , rhs )
@@ -946,3 +947,20 @@ TEST(parsing, number)
epee::misc_utils::parse::match_number(i, s.end(), val);
ASSERT_EQ(val, "+9.34e+03");
}
+
+TEST(parsing, unicode)
+{
+ std::string bs;
+ std::string s;
+ std::string::const_iterator si;
+
+ s = "\"\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "");
+ s = "\"\\u0000\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, std::string(1, '\0'));
+ s = "\"\\u0020\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, " ");
+ s = "\"\\u1\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs));
+ s = "\"\\u12\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs));
+ s = "\"\\u123\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs));
+ s = "\"\\u1234\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "ሴ");
+ s = "\"foo\\u1234bar\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "fooሴbar");
+ s = "\"\\u3042\\u307e\\u3084\\u304b\\u3059\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "あまやかす");
+}
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp
index 4d51ec434..d2b2c3109 100644
--- a/tests/unit_tests/ringct.cpp
+++ b/tests/unit_tests/ringct.cpp
@@ -779,8 +779,8 @@ TEST(ringct, range_proofs_accept_very_long_simple)
inputs[n] = n;
outputs[n] = n;
}
- std::random_shuffle(inputs, inputs + N);
- std::random_shuffle(outputs, outputs + N);
+ std::shuffle(inputs, inputs + N, crypto::random_device{});
+ std::shuffle(outputs, outputs + N, crypto::random_device{});
EXPECT_TRUE(range_proof_test(true, NELTS(inputs), inputs, NELTS(outputs), outputs, false, true));
}
diff --git a/tests/unit_tests/rolling_median.cpp b/tests/unit_tests/rolling_median.cpp
index 547fe092f..9e4cf87b8 100644
--- a/tests/unit_tests/rolling_median.cpp
+++ b/tests/unit_tests/rolling_median.cpp
@@ -143,7 +143,7 @@ TEST(rolling_median, order)
m.insert(random[i]);
ASSERT_EQ(med, m.median());
- std::shuffle(random.begin(), random.end(), std::default_random_engine(crypto::rand<unsigned>()));
+ std::shuffle(random.begin(), random.end(), crypto::random_device{});
m.clear();
for (int i = 0; i < 1000; ++i)
m.insert(random[i]);