コード例 #1
0
void MetalinkEditorTest::testLoadTorrent3()
{
    // Setup
    wxString filename = get_testfile(wxT("test2.metalink"));
    MetalinkEditor editor;
    // Exercise
    editor.open(filename);
    // Verify
    CPPUNIT_ASSERT_EQUAL(1, editor.num_files());
    MetalinkFile file = editor.get_file();
    CPPUNIT_ASSERT(file.get_filename() == wxT("test55"));
    CPPUNIT_ASSERT(file.get_sources().size() == 1);
    MetalinkSource src = file.get_sources().at(0);
    CPPUNIT_ASSERT(src.get_uri() == wxT("http://torrent.com/test.torrent"));
    CPPUNIT_ASSERT(src.get_priority() == 23);
    CPPUNIT_ASSERT(src.get_location().empty());
    CPPUNIT_ASSERT(src.is_torrent());
}
コード例 #2
0
void Metalink4Writer::write_file(const MetalinkFile& file)
{
    start(wxT("file"));
    add_attr(wxT("name"), file.get_filename());
    close_start();
    add_element(wxT("identity"), file.get_identity());
    add_element(wxT("description"), file.get_description());
    add_element(wxT("version"), file.get_version());
    add_element(wxT("size"), file.get_size());
    write_hashes(file);
    write_piece_hash(file);
    const std::vector<MetalinkSource>& sources = file.get_sources();
    for(std::vector<MetalinkSource>::const_iterator i = sources.begin(),
            eoi = sources.end(); i != eoi; ++i) {
        write_source(*i);
    }
    end(wxT("file"));
}