Source

libtaginfo / tests / write_aif / main.cc

Full commit
#include "taginfo.h"
#include <stdio.h>
#include <iostream>
#include <fstream>

//#define TESTNAME "xyz 1 23"

using namespace TagInfo;

int main( void ) {
    Info * info;
    std::string val = TESTDIR "samples/sample.aif";
    
    //std::cout << std::endl << "val: " << val << std::endl;
    std::string target = "/tmp/out_01.aif";
    
    std::ifstream  src(val.c_str());
    std::ofstream  dst(target.c_str());
    dst << src.rdbuf();
    
    info = Info::create_tag_info(target);
    if(info) {
        info->set_title("titlöe");
        info->set_album_artist("äöé");
        info->set_is_compilation(true);
        info->set_comments("Cömmmééèntß");
        info->write();
    }
    delete info;
    info = NULL;
    
    info = Info::create_tag_info(target);
    if( info ) {
        if(info->read()) {
            //std::cout << "info->get_title() " << info->get_title() << std::endl;
            if(info->get_title() == "titlöe" &&
               info->get_album_artist() == "äöé" &&
               info->get_is_compilation() &&
               info->get_comments() == "Cömmmééèntß") {
                delete info;
                if(remove(target.c_str()) != 0 )
                    return EXIT_FAILURE;
                return EXIT_SUCCESS;
            }
        }
        delete info;
        if(remove(target.c_str()) != 0 )
            return EXIT_FAILURE;
        return EXIT_FAILURE;
    }
    else {
       delete info;
        if(remove(target.c_str()) != 0 )
            return EXIT_FAILURE;
        return EXIT_FAILURE;
    }
}