Commits

shuerhaaken committed 750a32f

add tests for labels in ogg and mp3

Comments (0)

Files changed (3)

libtaginfo/taginfo_internal.h

 
 inline StringList split(const String str, const String &separator) {
     return StringList::split(str, separator);
-//    StringList list;
-//    for(int index = 0;;) {
-//        int sep = str.find(separator, index);
-//        if(sep < 0) {
-//            list.append(str.substr(index, str.size() - index));
-//        break;
-//        }
-//        else {
-//            list.append(str.substr(index, sep - index));
-//            index = sep + separator.size();
-//        }
-//    }
-//    return list;
 }
 
 inline String join(const StringList strlist, const String &separator) {
-    return strlist.toString("|");
-//    String out("", String::UTF8);
-//    for(StringList::ConstIterator it = strlist.begin(); it != strlist.end(); ++it) {
-//      out.append(*it);
-//      out.append(separator);
-//    }
-//    if(out.size() > 0)
-//        return out.substr(0, out.size() - 1);
-//    else
-//        return out;
+    return strlist.toString(separator);
 }
 
 
 
 inline string dirname_of(const string& fname) {
      size_t pos = fname.find_last_of("\\/");
-     return (string::npos == pos)
-         ? ""
-         : fname.substr(0, pos);
+     return (string::npos == pos) ? "" : fname.substr(0, pos);
 }
 
 
 
 
 
-
-
-
 ////////// APE
 
 void check_ape_label_frame(TagLib::APE::Tag * apetag, const char * description, const String &value);
 
 
 
+////////// MP4
+
+bool get_mp4_cover_art(TagLib::MP4::Tag * mp4tag, char*& data, int &data_length, ImageType &image_type);
+bool set_mp4_cover_art(TagLib::MP4::Tag * mp4tag, const char* data, int data_length, ImageType image_type);
+
+String get_mp4_lyrics(TagLib::MP4::Tag * mp4tag);
+bool set_mp4_lyrics(TagLib::MP4::Tag * mp4tag, const String &lyrics);
+
+////////// end MP4
+
+
 
 ////////// XIPH
 
 
 
 
-////////// MP4
-
-bool get_mp4_cover_art(TagLib::MP4::Tag * mp4tag, char*& data, int &data_length, ImageType &image_type);
-bool set_mp4_cover_art(TagLib::MP4::Tag * mp4tag, const char* data, int data_length, ImageType image_type);
-
-String get_mp4_lyrics(TagLib::MP4::Tag * mp4tag);
-bool set_mp4_lyrics(TagLib::MP4::Tag * mp4tag, const String &lyrics);
-
-////////// end MP4
-
-
 

tests/write_mp3/main.cc

 
 using namespace TagInfo;
 
+bool check_list_equal(const StringList &list, const StringList &second) {
+    //std::cout <<  "first : " << list.toString()   << std::endl;
+    //std::cout <<  "second: " << second.toString() << std::endl;
+    return(list.toString("") == second.toString(""));
+}
+
 int main( void ) {
     Info * info;
     std::string val = TESTDIR "samples/sample_v2_only.mp3";
     dst << src.rdbuf();
     
     info = Info::create_tag_info(target);
+    
+    StringList labels = StringList();
+    labels.append("user label1 äöüé");
+    labels.append("user label1 äiiüé");
+    
     if( info ) {
         info->set_title(TESTNAME);
         info->set_album_artist("äöé");
         info->set_is_compilation(true);
+        info->set_album_labels_list(labels);
         info->write();
         //std::cout <<  "done writing mp3" << std::endl;
     }
         if( info->read() ) {
             if(info->get_title() == TESTNAME &&
                info->get_album_artist() == "äöé" &&
-               info->get_is_compilation() == true) {
+               info->get_is_compilation() == true &&
+               check_list_equal(info->get_album_labels_list(), labels) ) {
                 delete info;
                 if(remove(target.c_str()) != 0 )
                     return EXIT_FAILURE;

tests/write_ogg/main.cc

 using namespace TagInfo;
 
 
+bool check_list_equal(const StringList &list, const StringList &second) {
+    //std::cout <<  "first : " << list.toString()   << std::endl;
+    //std::cout <<  "second: " << second.toString() << std::endl;
+    return(list.toString("") == second.toString(""));
+}
+
 int main( void ) {
     Info * info;
     std::string val = TESTDIR "samples/sample.ogg";
     dst << src.rdbuf();
     
     info = Info::create_tag_info(target);
+    
+    StringList labels = StringList();
+    labels.append("user label1 äöüé");
+    labels.append("user label1 äiiüé");
+    
     if( info ) {
         info->set_title(TESTNAME);
         info->set_album_artist("äöé");
         info->set_is_compilation(true);
+        info->set_track_labels_list(labels);
         info->write();
     }
     delete info;
         if( info->read() ) {
             if(info->get_title() == TESTNAME &&
                info->get_album_artist() == "äöé" &&
-               info->get_is_compilation() == true) {
+               info->get_is_compilation() == true &&
+               check_list_equal(info->get_track_labels_list(), labels) ) {
                 delete info;
                 if(remove(target.c_str()) != 0 )
                     return EXIT_FAILURE;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.