LUMIERA.clone/tests/steam/asset/asset-category-test.cpp
Ichthyostega 3caa5cfb03 Tests: reorganise test folders
This resolves a long-standing issue:
we could not use proper include paths for test-helper code that was defined alongside the tests.

Since some test-helper code must now be relocated into the »Vault«-Layer,
I took the opportunity to finally resolve this annoyance. The solution is two-fold
 * introduce a dedicated test-support library
 * remove the quirks that were necessary to support some plain-C tests
Together, this allows to raise the include-directory by one level,
and then to adjust all folder names so that they match the namespace
2026-03-07 00:56:19 +01:00

136 lines
3.4 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
AssetCategory(Test) - verifying Asset category tuple functions
Copyright (C)
2008, Hermann Vosseler <Ichthyostega@web.de>
  **Lumiera** is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the
  Free Software Foundation; either version 2 of the License, or (at your
  option) any later version. See the file COPYING for further details.
* *****************************************************************/
/** @file asset-category-test.cpp
** unit test \ref AssetCategory_test
*/
#include "test/run.hpp"
#include "lib/format-cout.hpp"
#include "lib/format-string.hpp"
#include "lib/util.hpp"
#include "steam/asset/category.hpp"
using util::_Fmt;
using util::isnil;
using std::string;
namespace steam {
namespace asset{
namespace test {
/*******************************************************************//**
* @test checking the properties of Asset Category structs.
* They are included in the Asset::Ident identification tuple
* of Assets and can be used to organize Assets into a tree
* like structure
*/
class AssetCategory_test : public Test
{
virtual void
run(Arg)
{
createCategory();
containmentQuery();
ordering();
}
void createCategory()
{
Category c1 (AUDIO);
Category c2 (VIDEO,"bin1");
Category c3 (VIDEO,"bin1/subbin");
Category c4 (EFFECT,"some_kind");
_Fmt fmt ("Category: %s");
cout << fmt % c1 << "\n";
cout << fmt % c2 << "\n";
cout << fmt % c3 << "\n";
cout << fmt % c4 << "\n";
}
void containmentQuery()
{
Category c1 (VIDEO);
Category c2 (VIDEO,"bin1");
Category c3 (VIDEO,"bin1/subbin");
Category c4 (EFFECT,"some_kind");
CHECK ( c1.hasKind(VIDEO) );
CHECK (!c1.hasKind(AUDIO) );
CHECK ( c2.isWithin(c1) );
CHECK ( c3.isWithin(c2) );
CHECK ( c3.isWithin(c1) );
CHECK (!c1.isWithin(c2) );
CHECK (!c2.isWithin(c3) );
CHECK (!c1.isWithin(c3) );
CHECK (!c3.isWithin(c4) );
CHECK (!c4.isWithin(c3) );
}
void ordering()
{
Category c1 (AUDIO);
Category c2 (VIDEO);
Category c3 (EFFECT);
Category c4 (CODEC);
Category c5 (STRUCT);
Category c6 (META);
CHECK (0 > c1 <=> c2 );
CHECK (0 > c2 <=> c3 );
CHECK (0 > c3 <=> c4 );
CHECK (0 > c4 <=> c5 );
CHECK (0 > c5 <=> c6 );
CHECK (0 ==c1 <=> c1 );
CHECK (0 > c1 <=> c6 );
Category c21 (VIDEO,"bin1");
Category c22 (VIDEO,"bin2");
Category c23 (VIDEO,"bin2/sub");
CHECK (0 > c1 <=> c21 );
CHECK (0 > c2 <=> c21 );
CHECK (0 < c22 <=> c21 );
CHECK (0 < c23 <=> c22 );
CHECK (0 < c23 <=> c21 );
CHECK (0 ==c22 <=> c22 );
CHECK ( c2 == c2 );
CHECK ( c2 != c22 );
CHECK ( c2 != c3 );
}
};
/** Register this test class... */
LAUNCHER (AssetCategory_test, "unit asset");
}}} // namespace steam::asset::test