aboutsummaryrefslogtreecommitdiff
path: root/src/test/script_tests.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2014-08-20 15:15:16 -0400
committerJonas Schnelli <jonas.schnelli@include7.ch>2015-06-04 09:16:05 +0200
commit15982a8b69ec6ab3c3a6bf71fc6a9b681d3ff541 (patch)
tree854a48a039d4199dbc1acf33ef94d06d007f1348 /src/test/script_tests.cpp
parent5e3060c0d104c734e7e2a200e2d937ea01166c8a (diff)
Convert tree to using univalue. Eliminate all json_spirit uses.
Diffstat (limited to 'src/test/script_tests.cpp')
-rw-r--r--src/test/script_tests.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index c0614cca43..b4cab3245c 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -26,9 +26,7 @@
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
-#include "json/json_spirit_reader_template.h"
-#include "json/json_spirit_utils.h"
-#include "json/json_spirit_writer_template.h"
+#include "json_spirit_wrapper.h"
using namespace std;
using namespace json_spirit;
@@ -46,7 +44,7 @@ read_json(const std::string& jsondata)
{
Value v;
- if (!read_string(jsondata, v) || v.type() != array_type)
+ if (!v.read(jsondata) || !v.isArray())
{
BOOST_ERROR("Parse error.");
return Array();
@@ -636,10 +634,9 @@ BOOST_AUTO_TEST_CASE(script_valid)
// scripts.
Array tests = read_json(std::string(json_tests::script_valid, json_tests::script_valid + sizeof(json_tests::script_valid)));
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- string strTest = write_string(tv, false);
+ for (unsigned int idx = 0; idx < tests.size(); idx++) {
+ Array test = tests[idx];
+ string strTest = test.write();
if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments)
{
if (test.size() != 1) {
@@ -662,11 +659,10 @@ BOOST_AUTO_TEST_CASE(script_invalid)
// Scripts that should evaluate as invalid
Array tests = read_json(std::string(json_tests::script_invalid, json_tests::script_invalid + sizeof(json_tests::script_invalid)));
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- string strTest = write_string(tv, false);
- if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments)
+ for (unsigned int idx = 0; idx < tests.size(); idx++) {
+ Array test = tests[idx];
+ string strTest = test.write();
+ if (test.size() < 3) // Allow size > 2; extra stuff ignored (useful for comments)
{
if (test.size() != 1) {
BOOST_ERROR("Bad test: " << strTest);