core/tags/track: Clean up date handling unit test

Most of this isn't needed anymore now that date handling is being tested
elsewhere.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-10-28 04:11:12 -04:00
parent ea35d81c22
commit 422f6a389f
1 changed files with 15 additions and 41 deletions

View File

@ -1,6 +1,9 @@
/**
* Copyright 2014 (c) Anna Schumaker.
*/
extern "C" {
#include <core/string.h>
}
#include <core/filter.h>
#include <core/tags/track.h>
#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),
);