landed the bdecode branch in master. lazy_bdecode/lazy_entry is now being replaced by bdecode/bdecode_node
This commit is contained in:
@@ -177,9 +177,9 @@ int main(int argc, char* argv[])
|
||||
state.resize(size);
|
||||
fread(&state[0], 1, state.size(), f);
|
||||
|
||||
lazy_entry e;
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
lazy_bdecode(&state[0], &state[0] + state.size(), e, ec);
|
||||
bdecode(&state[0], &state[0] + state.size(), e, ec);
|
||||
if (ec)
|
||||
fprintf(stderr, "failed to parse .dht file: (%d) %s\n"
|
||||
, ec.value(), ec.message().c_str());
|
||||
|
@@ -34,11 +34,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/random/mersenne_twister.hpp>
|
||||
#include <boost/random/uniform_int_distribution.hpp>
|
||||
#include "libtorrent/lazy_entry.hpp"
|
||||
#include "libtorrent/bdecode.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
#include "libtorrent/error_code.hpp"
|
||||
|
||||
using libtorrent::lazy_entry;
|
||||
using libtorrent::bdecode_node;
|
||||
using boost::random::mt19937;
|
||||
using boost::random::uniform_int_distribution;
|
||||
|
||||
@@ -233,52 +233,52 @@ void render_arbitrary_item(std::string& out)
|
||||
}
|
||||
}
|
||||
|
||||
void render_variant(std::string& out, lazy_entry const& e)
|
||||
void render_variant(std::string& out, bdecode_node const& e)
|
||||
{
|
||||
switch (e.type())
|
||||
{
|
||||
case lazy_entry::dict_t:
|
||||
case bdecode_node::dict_t:
|
||||
print_dict(out);
|
||||
for (int i = 0; i < e.dict_size(); ++i)
|
||||
{
|
||||
std::pair<std::string, lazy_entry const*> item = e.dict_at(i);
|
||||
std::pair<std::string, bdecode_node> item = e.dict_at(i);
|
||||
const bool duplicate = g_seed == 1;
|
||||
const bool skipped = g_seed == 2;
|
||||
g_seed -= 2;
|
||||
if (duplicate)
|
||||
{
|
||||
print_string(out, item.first);
|
||||
render_variant(out, *item.second);
|
||||
render_variant(out, item.second);
|
||||
}
|
||||
if (!skipped)
|
||||
{
|
||||
print_string(out, item.first);
|
||||
render_variant(out, *item.second);
|
||||
render_variant(out, item.second);
|
||||
}
|
||||
|
||||
render_arbitrary_item(out);
|
||||
}
|
||||
print_terminate(out);
|
||||
break;
|
||||
case lazy_entry::list_t:
|
||||
case bdecode_node::list_t:
|
||||
print_list(out);
|
||||
for (int i = 0; i < e.list_size(); ++i)
|
||||
{
|
||||
const bool duplicate = g_seed == 1;
|
||||
const bool skipped = g_seed == 2;
|
||||
g_seed -= 2;
|
||||
if (duplicate) render_variant(out, *e.list_at(i));
|
||||
if (duplicate) render_variant(out, e.list_at(i));
|
||||
|
||||
render_arbitrary_item(out);
|
||||
|
||||
if (!skipped) render_variant(out, *e.list_at(i));
|
||||
if (!skipped) render_variant(out, e.list_at(i));
|
||||
}
|
||||
print_terminate(out);
|
||||
break;
|
||||
case lazy_entry::int_t:
|
||||
case bdecode_node::int_t:
|
||||
print_int(out, e.int_value());
|
||||
break;
|
||||
case lazy_entry::string_t:
|
||||
case bdecode_node::string_t:
|
||||
print_string(out, e.string_value());
|
||||
break;
|
||||
default:
|
||||
@@ -371,8 +371,8 @@ int main(int argc, char const* argv[])
|
||||
continue;
|
||||
}
|
||||
|
||||
lazy_entry e;
|
||||
if (buf.size() == 0 || lazy_bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
bdecode_node e;
|
||||
if (buf.size() == 0 || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR parsing file: %s\n%s\n"
|
||||
, *argv, ec.message().c_str());
|
||||
|
@@ -3,10 +3,15 @@
|
||||
OBJECT_PATH=bin/gcc-4.8/debug/asserts-off/boost-source/debug-iterators-on/export-extra-on/invariant-checks-off/link-static/logging-on/test-coverage-on/threading-multi/src
|
||||
|
||||
function run_test {
|
||||
set +e
|
||||
rm $OBJECT_PATH/*.gcda
|
||||
set -e
|
||||
|
||||
cd test
|
||||
set +e
|
||||
rm -rf bin
|
||||
set -e
|
||||
|
||||
bjam asserts=off invariant-checks=off link=static boost=source test-coverage=on picker-debugging=off -j4 $1
|
||||
cd ..
|
||||
|
||||
@@ -20,11 +25,16 @@ function run_test {
|
||||
|
||||
# force rebuilding and rerunning the unit tests
|
||||
cd test
|
||||
set +e
|
||||
rm -rf bin
|
||||
set -e
|
||||
cd ..
|
||||
|
||||
set +e
|
||||
mkdir test-coverage
|
||||
set -e
|
||||
|
||||
run_test test_bdecode "*/bdecode.*"
|
||||
run_test test_piece_picker "*/piece_picker.*"
|
||||
run_test test_torrent_info "*/torrent_info.*"
|
||||
run_test test_part_file "*/part_file.*"
|
||||
@@ -40,5 +50,3 @@ run_test test_sliding_average "*/sliding_average.*"
|
||||
run_test test_string "*/escape_string.*"
|
||||
run_test test_utf8 "*/ConvertUTF.*"
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user