diff --git a/tests/core/tags/track.cpp b/tests/core/tags/track.cpp index 6372e48f..ee6d9df6 100644 --- a/tests/core/tags/track.cpp +++ b/tests/core/tags/track.cpp @@ -1,6 +1,9 @@ /** * Copyright 2014 (c) Anna Schumaker. */ +extern "C" { +#include +} #include #include #include "../test.h" @@ -164,54 +167,25 @@ static void test_track_tag_lookup() test_equal(library->size(), (unsigned)0); } -static std::string find_expected_date(const std::string &locale) -{ - std::stringstream ss; - time_t rawtime = time(NULL); - struct tm *now = localtime(&rawtime); - - if ((now->tm_mon + 1) < 10) - ss << "0"; - ss << (now->tm_mon + 1) << "/"; - if (now->tm_mday < 10) - ss << "0"; - ss << now->tm_mday << "/"; - - if (locale == "C") - ss << (now->tm_year % 100); - else if (locale == "en_US") - ss << (now->tm_year + 1900); - else - ss << "????"; - return ss.str(); -} - static void test_track_tag_locale() { - Track *a, *b; - - a = tags :: add_track(album, artist, genre, library, + time_t rawtime = time(NULL); + struct tm *now = localtime(&rawtime); + Track *track = tags :: add_track(album, artist, genre, library, MUSIC_DIR + "/Hyrule Symphony/6 - Kakariko Village.mp3", "Kakariko Village", 186, 6); - test_equal(a->count(), (unsigned)0); - a->played(); - test_equal(a->count(), (unsigned)1); - test_track_tag_load_db(1); - + gchar *date; std::setlocale(LC_TIME, "C"); - test_equal(a->date(), find_expected_date("C")); - std::setlocale(LC_TIME, "en_US"); - test_equal(a->date(), find_expected_date("en_US")); + date = string_tm2str(now); + test_equal(track->count(), (unsigned)0); + test_equal(track->date(), "Never"); - b = tags :: add_track(album, artist, genre, library, - MUSIC_DIR + "/Hyrule Symphony/0 - intro.mp3", - "Intro", 56, 0); - - test_equal(a->compare_date(a), 0); - test_equal(a->compare_date(b), 2015); - test_equal(b->compare_date(a), -2015); + track->played(); + test_equal(track->count(), (unsigned)1); + test_equal(track->date(), date); + g_free(date); } DECLARE_UNIT_TESTS( @@ -219,5 +193,5 @@ DECLARE_UNIT_TESTS( UNIT_TEST("Track Tag Constructor", test_track_tag_constructor), UNIT_TEST("Track Tag Destructor Test", test_track_tag_destructor), UNIT_TEST("Track Tag Lookup Test", test_track_tag_lookup), - UNIT_TEST("Track Tag Locale Test", test_track_tag_locale), + UNIT_TEST("Track Tag Date Test", test_track_tag_locale), );