LUMIERA.clone/tests/core/steam/asset/ordering-of-assets-test.cpp

131 lines
3.9 KiB
C++
Raw Normal View History

/*
OrderingOfAssets(Test) - equality and comparisons
2010-12-17 23:28:49 +01:00
Copyright: clarify and simplify the file headers * Lumiera source code always was copyrighted by individual contributors * there is no entity "Lumiera.org" which holds any copyrights * Lumiera source code is provided under the GPL Version 2+ == Explanations == Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above. For this to become legally effective, the ''File COPYING in the root directory is sufficient.'' The licensing header in each file is not strictly necessary, yet considered good practice; attaching a licence notice increases the likeliness that this information is retained in case someone extracts individual code files. However, it is not by the presence of some text, that legally binding licensing terms become effective; rather the fact matters that a given piece of code was provably copyrighted and published under a license. Even reformatting the code, renaming some variables or deleting parts of the code will not alter this legal situation, but rather creates a derivative work, which is likewise covered by the GPL! The most relevant information in the file header is the notice regarding the time of the first individual copyright claim. By virtue of this initial copyright, the first author is entitled to choose the terms of licensing. All further modifications are permitted and covered by the License. The specific wording or format of the copyright header is not legally relevant, as long as the intention to publish under the GPL remains clear. The extended wording was based on a recommendation by the FSF. It can be shortened, because the full terms of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
Copyright (C)
2008, Hermann Vosseler <Ichthyostega@web.de>
2010-12-17 23:28:49 +01:00
Copyright: clarify and simplify the file headers * Lumiera source code always was copyrighted by individual contributors * there is no entity "Lumiera.org" which holds any copyrights * Lumiera source code is provided under the GPL Version 2+ == Explanations == Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above. For this to become legally effective, the ''File COPYING in the root directory is sufficient.'' The licensing header in each file is not strictly necessary, yet considered good practice; attaching a licence notice increases the likeliness that this information is retained in case someone extracts individual code files. However, it is not by the presence of some text, that legally binding licensing terms become effective; rather the fact matters that a given piece of code was provably copyrighted and published under a license. Even reformatting the code, renaming some variables or deleting parts of the code will not alter this legal situation, but rather creates a derivative work, which is likewise covered by the GPL! The most relevant information in the file header is the notice regarding the time of the first individual copyright claim. By virtue of this initial copyright, the first author is entitled to choose the terms of licensing. All further modifications are permitted and covered by the License. The specific wording or format of the copyright header is not legally relevant, as long as the intention to publish under the GPL remains clear. The extended wording was based on a recommendation by the FSF. It can be shortened, because the full terms of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
  **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.
2010-12-17 23:28:49 +01:00
Copyright: clarify and simplify the file headers * Lumiera source code always was copyrighted by individual contributors * there is no entity "Lumiera.org" which holds any copyrights * Lumiera source code is provided under the GPL Version 2+ == Explanations == Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above. For this to become legally effective, the ''File COPYING in the root directory is sufficient.'' The licensing header in each file is not strictly necessary, yet considered good practice; attaching a licence notice increases the likeliness that this information is retained in case someone extracts individual code files. However, it is not by the presence of some text, that legally binding licensing terms become effective; rather the fact matters that a given piece of code was provably copyrighted and published under a license. Even reformatting the code, renaming some variables or deleting parts of the code will not alter this legal situation, but rather creates a derivative work, which is likewise covered by the GPL! The most relevant information in the file header is the notice regarding the time of the first individual copyright claim. By virtue of this initial copyright, the first author is entitled to choose the terms of licensing. All further modifications are permitted and covered by the License. The specific wording or format of the copyright header is not legally relevant, as long as the intention to publish under the GPL remains clear. The extended wording was based on a recommendation by the FSF. It can be shortened, because the full terms of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
* *****************************************************************/
/** @file ordering-of-assets-test.cpp
** unit test \ref OrderingOfAssets_test
*/
#include "lib/test/run.hpp"
#include "lib/util.hpp"
#include "steam/assetmanager.hpp"
#include "steam/asset/media.hpp"
#include "steam/asset/proc.hpp"
#include "steam/asset/asset-diagnostics.hpp"
#include "vault/media-access-mock.hpp"
#include "lib/depend-inject.hpp"
using util::isnil;
using std::string;
namespace steam {
namespace asset{
namespace test {
using MediaAccessMock = lib::DependInject<vault::MediaAccessFacade>
::Local<vault::test::MediaAccessMock>;
/**************************************************//**
* @test validate the equality and order relations of
* Asset::Ident and Asset objects.
* @note a known problem is that only Asset smart ptrs
* are supported for comparison, not smartpointers
* of Asset subclasses. To solve this, we would
* either have to repeat the operator definitions,
* or resort to template metaprogramming tricks.
* Just providing templated comparison operators
* would generally override the behaviour of
* std::shared_ptr, which is not desirable.
* @see Asset::Ident#compare
*/
class OrderingOfAssets_test : public Test
{
virtual void run(Arg)
{
MediaAccessMock useMockMedia;
Asset::Ident key1("test-1", Category(AUDIO), "ichthyo", 5);
PAsset mm1 = asset::Media::create(key1, "Name-1");
Asset::Ident key2("test-1", Category(AUDIO), "ichthyo", 7);
PAsset mm2 = asset::Media::create(key2, "Name-2");
Asset::Ident key3("test-2", Category(AUDIO), "ichthyo", 5);
PAsset mm3 = asset::Media::create(key3, "Name-3");
Asset::Ident key4("test-2", Category(AUDIO), "stega", 5);
PAsset mm4 = asset::Media::create(key4, "Name-4");
Asset::Ident key5("test-1", Category(VIDEO), "ichthyo", 5);
PAsset mm5 = asset::Media::create(key5, "Name-5");
// ordering of keys
CHECK (key1 == key2);
CHECK (key2 != key3);
CHECK (key3 != key4);
CHECK (key4 != key5);
CHECK (key1 != key5);
CHECK ( 0 > key2 <=> key3 );
CHECK ( 0 < key3 <=> key2 );
CHECK ( 0 > key3 <=> key4 );
CHECK ( 0 > key4 <=> key5 );
CHECK ( 0 > key1 <=> key5 );
CHECK ( 0 > key2 <=> key5 );
CHECK ( 0 > key3 <=> key5 );
CHECK ( 0 > key1 <=> key3 );
CHECK ( 0 > key1 <=> key4 );
CHECK ( 0 > key2 <=> key4 );
// ordering of Asset smart ptrs
CHECK (mm1 == mm2);
CHECK (mm2 != mm3);
CHECK (mm3 != mm4);
CHECK (mm4 != mm5);
CHECK (mm1 != mm5);
CHECK (mm2 < mm3);
CHECK (mm2 <= mm3);
CHECK (mm3 > mm2);
CHECK (mm3 >= mm2);
CHECK (mm3 < mm4);
CHECK (mm4 < mm5);
CHECK (mm1 < mm5);
CHECK (mm2 < mm5);
CHECK (mm3 < mm5);
CHECK (mm1 < mm3);
CHECK (mm1 < mm4);
CHECK (mm2 < mm4);
}
};
/** Register this test class... */
LAUNCHER (OrderingOfAssets_test, "unit asset");
}}} // namespace steam::asset::test