56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
/**
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/tags/generic.h>
|
|
#include "../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");
|
|
|
|
tag = GenericTag(tag);
|
|
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);
|
|
}
|
|
|
|
DECLARE_UNIT_TESTS(
|
|
UNIT_TEST("Generic Tag", test_generic_tag),
|
|
UNIT_TEST("Generic Tag Comparison", test_generic_tag_comparison),
|
|
);
|