コード例 #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_source(const MetalinkSource& source)
{
    if(source.is_torrent()) {
        start(wxT("metaurl"));
        add_attr(wxT("mediatype"), wxT("torrent"));
        if(!source.get_prioritystr().empty()) {
            add_attr(wxT("priority"), source.get_prioritystr());
        }
        end(wxT("metaurl"), source.get_uri());
    } else {
        start(wxT("url"));
        if(!source.get_prioritystr().empty()) {
            add_attr(wxT("priority"), source.get_prioritystr());
        }
        if(!source.get_location().empty()) {
            add_attr(wxT("location"), source.get_location());
        }
        end(wxT("url"), source.get_uri());
    }
}