LUMIERA.clone/tests/core/steam/asset/identity-of-assets-test.cpp
Ichthyostega afa7ca2e4d Upgrade: switch to C++23 (see #1245)
The Lumiera »Reference Platform« is now upgraded to Debian/Buster, which provides GCC-14 and Clang-20.
Thus the compiler support for C++20 language features seems solid enough, and C++23,
while still in ''experimental stage'' can be seen as a complement and addendum.

This changeset
 * upgrades the compile switches for the build system
 * provides all the necessary adjustments to keep the code base compilable

Notable changes:
 * λ-capture by value now requires explicit qualification how to handle `this`
 * comparison operators are now handled transparently by the core language,
   largely obsoleting boost::operators. This change incurs several changes
   to implicit handling rules and causes lots of ambiguities — which typically
   pinpoint some long standing design issues, especially related to MObjects
   and the ''time entities''. Most tweaks done here can be ''considered preliminary''
 * unfortunately the upgraded standard ''fails'' to handle **tuple-like** entities
   in a satisfactory way — rather an ''exposition-only'' concept is introduced,
   which applies solely to some containers from the STL, thereby breaking some
   very crucial code in the render entities, which was built upon the notion of
   ''tuple-like'' entities and the ''tuple protocol''. The solution is to
   abandon the STL in this respect and **provide an alternative implementation**
   of the `apply` function and related elements.
2025-06-19 01:52:55 +02:00

107 lines
3.3 KiB
C++
Raw 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.

/*
IdentityOfAssets(Test) - Asset object identity and versioning
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 identity-of-assets-test.cpp
** unit test \ref IdentityOfAssets_test
*/
#include "include/logging.h"
#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 creating several Assets and checking object identity,
* detection of duplicates and version handling.
* @see proc_interface::AssetManager#reg
*/
class IdentityOfAssets_test : public Test
{
virtual void run(Arg arg)
{
createDuplicate();
if (!isnil (arg))
dumpAssetManager();
TRACE (asset_mem, "leaving IdentityOfAssets_test::run()");
}
typedef shared_ptr<asset::Media> PM;
/** @test produce an ID clash.
* documents the current behaviour of the code as of 9/07
* @todo this test is expected to break when the detection
* of duplicate registrations is implemented.
*/
void createDuplicate()
{
MediaAccessMock useMockMedia;
PM mm1 = asset::Media::create ("test-1.mov", VIDEO);
Asset::Ident idi (mm1->ident); // duplicate Ident record
PM mm1X = asset::Media::create (idi); // note: we actually don't call any ctor
CHECK (mm1 == mm1X); // instead, we got mm1 back.
PM mm2 = asset::Media::create (idi,"test-2.mov");
CHECK (mm1->getID() == mm2->getID()); // different object, same hash
AssetManager& aMang = AssetManager::instance();
CHECK (aMang.getAsset (mm1->getID()) == mm2); // record of mm1 was replaced by mm2
CHECK (aMang.getAsset (mm2->getID()) == mm2); ////////////////////////TICKET #501 : clarify Placement and MObject identity
CHECK (aMang.known (mm1->getID()));
CHECK (aMang.known (mm2->getID()));
CHECK (mm1->ident.name == "test-1");
CHECK (mm2->ident.name == "test-1");
CHECK (mm1->getFilename() == "test-1.mov");
CHECK (mm2->getFilename() == "test-2.mov");
TRACE (asset_mem, "leaving test method scope");
}
};
/** Register this test class... */
LAUNCHER (IdentityOfAssets_test, "unit asset");
}}} // namespace steam::asset::test