cbcd9c594d
I was only ever comparing the lowercase version of the name, so this should be done in a single place (the GenericTag) to make maintenance easier. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
/**
|
|
* @file
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/tags/generic.h>
|
|
#include <tests/test.h>
|
|
|
|
static void test_generic_tag()
|
|
{
|
|
GenericTag tag("Generic Tag");
|
|
File f("generic_tag", 0);
|
|
|
|
test_equal(tag.name(), (std::string)"Generic Tag");
|
|
test_equal(tag.lowercase(), (std::string)"generic tag");
|
|
test_equal(tag.primary_key(), (std::string)"Generic Tag");
|
|
|
|
f.open(OPEN_WRITE);
|
|
tag.write(f);
|
|
f.close();
|
|
|
|
tag = GenericTag();
|
|
test_equal(tag.name(), (std::string)"");
|
|
test_equal(tag.lowercase(), (std::string)"");
|
|
test_equal(tag.primary_key(), (std::string)"");
|
|
|
|
f.open(OPEN_READ);
|
|
tag.read(f);
|
|
f.close();
|
|
|
|
test_equal(tag.name(), (std::string)"Generic Tag");
|
|
test_equal(tag.lowercase(), (std::string)"generic tag");
|
|
test_equal(tag.primary_key(), (std::string)"Generic Tag");
|
|
}
|
|
|
|
static void test_generic_tag_comparison()
|
|
{
|
|
GenericTag A("A"), a("a"), B("B"), empty("");
|
|
|
|
test_equal(A.compare(&A), 0);
|
|
test_equal(a.compare(&a), 0);
|
|
test_equal(A.compare(&B), -1);
|
|
test_equal(B.compare(&A), 1);
|
|
|
|
test_equal(empty.compare(&A), 1);
|
|
test_equal(A.compare(&empty), -1);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
run_test("Generic Tag Test", test_generic_tag);
|
|
run_test("Generic Tag Compare Test", test_generic_tag_comparison);
|
|
return 0;
|
|
}
|