Commits

shuerhaaken committed 32865e5

add forgotten test files

  • Participants
  • Parent commits 6e1e0e2

Comments (0)

Files changed (2)

File libtaginfo/opusinfo.cc

+/*
+ * Copyright (C) 2013 Jörn Magens
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file LICENSE.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth 
+ * Floor, Boston, MA  02110-1301  USA
+ * https://www.gnu.org/licenses/lgpl-2.1.txt
+ *
+ * Author:
+ * 	Jörn Magens <shuerhaaken@googlemail.com>
+ */
+
+#ifdef TAGLIB_ONE_NINE
+
+#include "taginfo.h"
+#include "taginfo_internal.h"
+#include "taginfo_xiphtags.h"
+
+
+#include <opusfile.h>
+
+
+using namespace TagInfo;
+
+
+
+// OpusInfo
+
+OpusInfo::OpusInfo(const String &filename) : XiphInfo(filename) {
+    if(file_name.isEmpty()) {
+        valid = false;
+        printf("File name empty!\n");
+    }
+    else {
+        taglib_file = new TagLib::Ogg::Opus::File(file_name.toCString(false), true, TagLib::AudioProperties::Fast);
+    }
+    if(taglib_file) {
+        xiphcomment = ((TagLib::Ogg::Opus::File *) taglib_file)->tag();
+        if(!xiphcomment || xiphcomment->isEmpty()) {
+            taglib_tag = ((TagLib::Ogg::Opus::File *) taglib_file)->tag();
+            if(!taglib_tag) {
+                printf("Cant get tag object from '%s'\n", file_name.toCString(false));
+                valid = false;
+            }
+        }
+    }
+    else {
+        printf("Cant get xiphcomment from '%s'\n", file_name.toCString(false));
+        xiphcomment = NULL;
+        valid = false;
+    }
+}
+
+
+OpusInfo::~OpusInfo() {
+}
+
+#endif

File tests/write_opus/main.cc

+#include "taginfo.h"
+#include <stdio.h>
+#include <iostream>
+#include <fstream>
+
+#define TESTNAME "xyz 1 23"
+
+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.opus";
+    //std::cout << std::endl << "val: " << val << std::endl;
+    
+    std::string target("/tmp/out_01.opus");
+    
+    std::ifstream  src(val.c_str());
+    std::ofstream  dst(target.c_str());
+    dst << src.rdbuf();
+    
+    StringList labels = StringList();
+    labels.append("user label1 äöüé");
+    labels.append("user label1 äiiüé");
+    
+    info = Info::create(target);
+    if( info ) {
+        info->set_artist("artißt");
+        info->set_genre("gen re");
+        info->set_composer("cömpozér");
+        info->set_year(1982);
+        info->set_rating(0);
+        info->set_title("titlöe");
+        info->set_original_artist ("ürgar t");
+        info->set_homepage("ööö");
+        info->set_encoder("encödr");
+        info->set_track_number(2);
+        info->set_track_count(5);
+        info->set_volume_number(1);
+        info->set_volume_count(3);
+        info->set_copyright("Cöpppyright");
+        info->set_album_artist("äöé");
+        info->set_is_compilation(true);
+        info->set_comments("Cömmméé\nèntß");
+        info->set_album_labels_list(labels);
+        info->set_artist_labels_list(labels);
+        info->set_track_labels_list(labels);
+        info->save();
+    }
+    delete info;
+    info = NULL;
+    
+    info = Info::create(target);
+    if( info ) {
+        if( info->load() ) {
+            //std::cout << "info->get_copyright() : " << info->get_copyright() << std::endl;
+            //std::cout << "info->get_encoder() : " << info->get_encoder() << std::endl;
+            //std::cout << "info->get_homepage() : " << info->get_homepage() << std::endl;
+            if(info->get_artist() == "artißt" &&
+               info->get_genre() == "gen re" &&
+               info->get_composer() == "cömpozér" &&
+               info->get_year() == 1982 &&
+               info->get_title() == "titlöe" &&
+               info->get_original_artist () == "ürgar t" &&
+               info->get_homepage() == "ööö" &&
+               info->get_encoder() == "encödr" &&
+               info->get_track_number() == 2 &&
+               info->get_track_count() == 5 &&
+               info->get_volume_number() == 1 &&
+               info->get_volume_count() == 3 &&
+               info->get_copyright() == "Cöpppyright" &&
+               info->get_album_artist() == "äöé" &&
+               info->get_is_compilation() &&
+               info->get_comments() == "Cömmméé\nèntß" &&
+               check_list_equal(info->get_artist_labels_list(), labels) &&
+               check_list_equal(info->get_album_labels_list(), labels) &&
+               check_list_equal(info->get_track_labels_list(), labels) ) {
+                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;
+    }
+}