2011-10-15 04:12:51 +02:00
|
|
|
|
/*
|
|
|
|
|
|
BufferMetadataKey(Test) - calculation of (internal) buffer metadata type keys
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
2011, Hermann Vosseler <Ichthyostega@web.de>
|
2011-10-15 04:12:51 +02: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.
|
2011-10-15 04:12:51 +02: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
|
|
|
|
* *****************************************************************/
|
2011-10-15 04:12:51 +02:00
|
|
|
|
|
2017-02-22 01:54:20 +01:00
|
|
|
|
/** @file buffer-metadata-key-test.cpp
|
2017-02-22 03:17:18 +01:00
|
|
|
|
** unit test \ref BufferMetadataKey_test
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2011-10-15 04:12:51 +02:00
|
|
|
|
|
|
|
|
|
|
#include "lib/error.hpp"
|
|
|
|
|
|
#include "lib/test/run.hpp"
|
|
|
|
|
|
#include "lib/test/test-helper.hpp"
|
2018-11-15 23:42:43 +01:00
|
|
|
|
#include "steam/engine/buffer-metadata.hpp"
|
2011-10-15 04:12:51 +02:00
|
|
|
|
|
|
|
|
|
|
#include <cstdlib>
|
2011-10-15 05:05:30 +02:00
|
|
|
|
#include <cstring>
|
|
|
|
|
|
#include <limits>
|
2011-10-15 04:12:51 +02:00
|
|
|
|
|
|
|
|
|
|
using util::isnil;
|
|
|
|
|
|
using util::isSameObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
namespace steam {
|
2011-10-15 04:12:51 +02:00
|
|
|
|
namespace engine{
|
|
|
|
|
|
namespace metadata{
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
|
|
namespace { // Test fixture
|
|
|
|
|
|
|
|
|
|
|
|
const size_t TEST_MAX_SIZE = 1024 * 1024;
|
|
|
|
|
|
|
2011-10-15 05:05:30 +02:00
|
|
|
|
|
2011-10-15 22:46:08 +02:00
|
|
|
|
/**
|
2011-10-15 05:05:30 +02:00
|
|
|
|
* Test Mock to verify the attachment of objects to the buffer.
|
|
|
|
|
|
* An instance of this class overwrites the occupied storage
|
|
|
|
|
|
* with an ascending sequence of numbers on construction,
|
|
|
|
|
|
* and clears the memory area on destruction.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This allows to verify that an instance of this class
|
|
|
|
|
|
* has actually been placed into the buffer, and will be
|
|
|
|
|
|
* cleaned up properly
|
|
|
|
|
|
*/
|
|
|
|
|
|
template<size_t siz>
|
|
|
|
|
|
struct PlacedNumbers
|
|
|
|
|
|
{
|
|
|
|
|
|
typedef char Pattern[siz];
|
|
|
|
|
|
|
|
|
|
|
|
Pattern pattern_;
|
|
|
|
|
|
|
|
|
|
|
|
PlacedNumbers()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (size_t i=0; i<siz; ++i)
|
|
|
|
|
|
pattern_[i] = i % CHAR_MAX;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~PlacedNumbers()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (size_t i=0; i<siz; ++i)
|
|
|
|
|
|
pattern_[i] = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* === diagnostics === */
|
|
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
|
verifyFilled (const void* buff)
|
|
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (buff);
|
|
|
|
|
|
const Pattern& patt = *reinterpret_cast<const Pattern*> (buff);
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i=0; i<siz; ++i)
|
|
|
|
|
|
if (patt[i] != char(i % CHAR_MAX))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
|
verifyCleared (const void* buff)
|
|
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (buff);
|
|
|
|
|
|
const Pattern& patt = *reinterpret_cast<const Pattern*> (buff);
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i=0; i<siz; ++i)
|
|
|
|
|
|
if (patt[i])
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2011-10-15 22:46:08 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Helper to investigate the settings stored in Metadata Key elements.
|
|
|
|
|
|
* Since these are protected, we use an derived class as adapter
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct KeyTypeSpecialisationDiagnostics
|
|
|
|
|
|
: Key
|
|
|
|
|
|
{
|
|
|
|
|
|
size_t const& investigateSize() const { return this->storageSize_; }
|
|
|
|
|
|
TypeHandler const& investigateHandler() const { return this->instanceFunc_; }
|
2024-07-27 17:17:02 +02:00
|
|
|
|
LocalTag const& investigateSpecifics() const { return this->specifics_; }
|
2011-10-15 05:05:30 +02:00
|
|
|
|
|
2011-10-15 22:46:08 +02:00
|
|
|
|
KeyTypeSpecialisationDiagnostics (Key const& toInvestigate)
|
|
|
|
|
|
: Key(toInvestigate)
|
|
|
|
|
|
{ }
|
2011-10-15 05:05:30 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2011-10-15 04:12:51 +02:00
|
|
|
|
|
2011-10-15 22:46:08 +02:00
|
|
|
|
inline size_t
|
|
|
|
|
|
verifySize (Key const& subject)
|
|
|
|
|
|
{
|
|
|
|
|
|
return KeyTypeSpecialisationDiagnostics(subject).investigateSize();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline const TypeHandler
|
|
|
|
|
|
verifyHandler (Key const& subject)
|
|
|
|
|
|
{
|
|
|
|
|
|
return KeyTypeSpecialisationDiagnostics(subject).investigateHandler();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-27 17:17:02 +02:00
|
|
|
|
inline const LocalTag
|
2011-10-15 22:46:08 +02:00
|
|
|
|
verifySpecifics (Key const& subject)
|
|
|
|
|
|
{
|
|
|
|
|
|
return KeyTypeSpecialisationDiagnostics(subject).investigateSpecifics();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}//(End) Test helpers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-15 04:12:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
2013-10-24 23:06:36 +02:00
|
|
|
|
/*******************************************************************//**
|
2011-10-15 04:12:51 +02:00
|
|
|
|
* @test verify calculation and relations of Buffer metadata type keys.
|
|
|
|
|
|
* These are used internally within the standard implementation
|
|
|
|
|
|
* of BufferProvider to keep track of various kinds of buffers,
|
|
|
|
|
|
* to provide a service for attaching metadata, e.g. a state flag.
|
|
|
|
|
|
* These metadata key entries are based on chained hash values,
|
|
|
|
|
|
* thus forming sort-of a "type" hierarchy.
|
|
|
|
|
|
* - the actual BufferProvider instance-ID is the top level
|
|
|
|
|
|
* - second level is the size of the buffer required
|
|
|
|
|
|
* - optionally, custom ctor/dtor functions can be registered
|
2011-10-15 22:46:08 +02:00
|
|
|
|
* - also optionally, implementation might attach an private-ID
|
2011-10-15 04:12:51 +02:00
|
|
|
|
*/
|
|
|
|
|
|
class BufferMetadataKey_test : public Test
|
|
|
|
|
|
{
|
2024-11-13 02:23:23 +01:00
|
|
|
|
size_t SIZE_A{0};
|
|
|
|
|
|
size_t SIZE_B{0};
|
|
|
|
|
|
|
2011-10-15 04:12:51 +02:00
|
|
|
|
|
|
|
|
|
|
virtual void
|
2025-06-07 23:59:57 +02:00
|
|
|
|
run (Arg)
|
2011-10-15 04:12:51 +02:00
|
|
|
|
{
|
2024-11-13 02:23:23 +01:00
|
|
|
|
seedRand();
|
|
|
|
|
|
SIZE_A = 1 + rani(TEST_MAX_SIZE);
|
|
|
|
|
|
SIZE_B = 1 + rani(TEST_MAX_SIZE);
|
|
|
|
|
|
|
2011-10-15 04:12:51 +02:00
|
|
|
|
CHECK (ensure_proper_fixture());
|
|
|
|
|
|
buildSimpleKeys();
|
|
|
|
|
|
verifyChainedHashes();
|
2011-10-15 05:05:30 +02:00
|
|
|
|
verifyTypeHandler<500>();
|
2011-10-15 04:12:51 +02:00
|
|
|
|
verifyTypeSpecialisation();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2025-06-07 23:59:57 +02:00
|
|
|
|
ensure_proper_fixture()
|
2011-10-15 04:12:51 +02:00
|
|
|
|
{
|
|
|
|
|
|
return (SIZE_A != SIZE_B);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
buildSimpleKeys()
|
|
|
|
|
|
{
|
|
|
|
|
|
HashVal family(123);
|
|
|
|
|
|
Key k1(family, SIZE_A);
|
2024-11-13 02:23:23 +01:00
|
|
|
|
Key k12(k1, SIZE_B);
|
2024-07-27 17:17:02 +02:00
|
|
|
|
Key k123(k12, LocalTag(56));
|
2011-10-15 04:12:51 +02:00
|
|
|
|
|
|
|
|
|
|
CHECK (HashVal (k1));
|
|
|
|
|
|
CHECK (HashVal (k12));
|
|
|
|
|
|
CHECK (HashVal (k123));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
verifyChainedHashes()
|
|
|
|
|
|
{
|
|
|
|
|
|
HashVal family(123);
|
|
|
|
|
|
HashVal otherFamily(456);
|
|
|
|
|
|
|
|
|
|
|
|
Key k1(family, SIZE_A);
|
|
|
|
|
|
Key k1o(otherFamily, SIZE_A);
|
|
|
|
|
|
CHECK (HashVal(k1) != HashVal(k1o));
|
|
|
|
|
|
|
|
|
|
|
|
// hash is reproducible
|
|
|
|
|
|
CHECK (HashVal(k1) == HashVal(Key(family, SIZE_A)));
|
|
|
|
|
|
|
|
|
|
|
|
// differentiate on buffer size
|
2024-11-13 02:23:23 +01:00
|
|
|
|
Key k12(k1, SIZE_B);
|
2011-10-15 04:12:51 +02:00
|
|
|
|
Key k121(k12, SIZE_A);
|
|
|
|
|
|
Key k2(family, SIZE_B);
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (HashVal(k1) != HashVal(k121));
|
|
|
|
|
|
CHECK (HashVal(k12) != HashVal(k2));
|
|
|
|
|
|
|
|
|
|
|
|
// so the specialisation path really matters, but this is reproducible...
|
|
|
|
|
|
CHECK (HashVal(k121) == HashVal(Key(Key(Key(family,SIZE_A),SIZE_B),SIZE_A)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-15 05:05:30 +02:00
|
|
|
|
template<size_t SIZ>
|
|
|
|
|
|
void
|
|
|
|
|
|
verifyTypeHandler()
|
|
|
|
|
|
{
|
|
|
|
|
|
char buff[SIZ];
|
|
|
|
|
|
memset (buff, '\0', SIZ);
|
|
|
|
|
|
|
|
|
|
|
|
typedef PlacedNumbers<SIZ> Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
TypeHandler attachPattern = TypeHandler::create<Pattern>();
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (attachPattern.isValid());
|
|
|
|
|
|
CHECK (0 != hash_value(attachPattern));
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (Pattern::verifyCleared (buff));
|
2011-10-15 17:47:50 +02:00
|
|
|
|
attachPattern.createAttached (buff); // invoke the ctor-functor to place an instance of PlacedNumbers
|
2011-10-15 05:05:30 +02:00
|
|
|
|
CHECK (Pattern::verifyFilled (buff));
|
|
|
|
|
|
attachPattern.destroyAttached (buff); // invoke the dtor-functor to clear the attached instance
|
|
|
|
|
|
CHECK (Pattern::verifyCleared (buff));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
verifyTypeSpecialisation()
|
|
|
|
|
|
{
|
|
|
|
|
|
HashVal family(123);
|
2011-10-15 22:46:08 +02:00
|
|
|
|
Key kb (family, SIZE_A); // "root" key
|
2011-10-15 05:05:30 +02:00
|
|
|
|
|
2011-10-15 17:47:50 +02:00
|
|
|
|
typedef PlacedNumbers<45> Marker;
|
|
|
|
|
|
TypeHandler placeMarker = TypeHandler::create<Marker>();
|
2011-10-15 05:05:30 +02:00
|
|
|
|
TypeHandler noHandler;
|
|
|
|
|
|
|
2024-11-13 02:23:23 +01:00
|
|
|
|
LocalTag opaque1 (rani(1000));
|
|
|
|
|
|
LocalTag opaque2 (1000 + rani(1000));
|
2011-10-15 17:47:50 +02:00
|
|
|
|
|
2011-10-15 22:46:08 +02:00
|
|
|
|
Key k_siz (kb, SIZE_B); // sub-key to "root": use a different buffer size
|
|
|
|
|
|
Key k_han0(kb, noHandler); // sub-key to "root": use a locally defined type functor
|
|
|
|
|
|
Key k_han1(kb, placeMarker); // sub-key to "root": use yet another type functor
|
|
|
|
|
|
Key k_loc1(kb, opaque1); // sub-key to "root": attach an private opaque ID
|
|
|
|
|
|
Key k_loc2(kb, opaque2); // sub-key to "root": attach another opaque ID
|
2011-10-15 17:47:50 +02:00
|
|
|
|
|
|
|
|
|
|
CHECK (kb != k_siz );
|
|
|
|
|
|
CHECK (kb != k_han0);
|
|
|
|
|
|
CHECK (kb != k_han1);
|
|
|
|
|
|
CHECK (kb != k_loc1);
|
|
|
|
|
|
CHECK (kb != k_loc2);
|
|
|
|
|
|
CHECK (k_siz != k_han0);
|
|
|
|
|
|
CHECK (k_siz != k_han1);
|
|
|
|
|
|
CHECK (k_siz != k_loc1);
|
|
|
|
|
|
CHECK (k_siz != k_loc2);
|
|
|
|
|
|
CHECK (k_han0 != k_han1);
|
|
|
|
|
|
CHECK (k_han0 != k_loc1);
|
|
|
|
|
|
CHECK (k_han0 != k_loc2);
|
|
|
|
|
|
CHECK (k_han1 != k_loc1);
|
|
|
|
|
|
CHECK (k_han1 != k_loc2);
|
|
|
|
|
|
CHECK (k_loc1 != k_loc2);
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_siz ));
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_han0));
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_han1));
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_loc1));
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_loc2));
|
|
|
|
|
|
CHECK (HashVal(k_siz ) != HashVal(k_han0));
|
|
|
|
|
|
CHECK (HashVal(k_siz ) != HashVal(k_han1));
|
|
|
|
|
|
CHECK (HashVal(k_siz ) != HashVal(k_loc1));
|
|
|
|
|
|
CHECK (HashVal(k_siz ) != HashVal(k_loc2));
|
|
|
|
|
|
CHECK (HashVal(k_han0) != HashVal(k_han1));
|
|
|
|
|
|
CHECK (HashVal(k_han0) != HashVal(k_loc1));
|
|
|
|
|
|
CHECK (HashVal(k_han0) != HashVal(k_loc2));
|
|
|
|
|
|
CHECK (HashVal(k_han1) != HashVal(k_loc1));
|
|
|
|
|
|
CHECK (HashVal(k_han1) != HashVal(k_loc2));
|
|
|
|
|
|
CHECK (HashVal(k_loc1) != HashVal(k_loc2));
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (SIZE_A == verifySize(kb ));
|
|
|
|
|
|
CHECK (SIZE_B == verifySize(k_siz ));
|
|
|
|
|
|
CHECK (SIZE_A == verifySize(k_han0));
|
|
|
|
|
|
CHECK (SIZE_A == verifySize(k_han1));
|
|
|
|
|
|
CHECK (SIZE_A == verifySize(k_loc1));
|
|
|
|
|
|
CHECK (SIZE_A == verifySize(k_loc2));
|
|
|
|
|
|
|
2024-07-27 17:17:02 +02:00
|
|
|
|
CHECK (TypeHandler::RAW == verifyHandler(kb ));
|
|
|
|
|
|
CHECK (TypeHandler::RAW == verifyHandler(k_siz ));
|
|
|
|
|
|
CHECK ( noHandler == verifyHandler(k_han0));
|
|
|
|
|
|
CHECK ( placeMarker == verifyHandler(k_han1));
|
|
|
|
|
|
CHECK (TypeHandler::RAW == verifyHandler(k_loc1));
|
|
|
|
|
|
CHECK (TypeHandler::RAW == verifyHandler(k_loc2));
|
2011-10-15 17:47:50 +02:00
|
|
|
|
|
2024-07-27 17:17:02 +02:00
|
|
|
|
CHECK (LocalTag::UNKNOWN == verifySpecifics(kb ));
|
|
|
|
|
|
CHECK (LocalTag::UNKNOWN == verifySpecifics(k_siz ));
|
|
|
|
|
|
CHECK (LocalTag::UNKNOWN == verifySpecifics(k_han0));
|
|
|
|
|
|
CHECK (LocalTag::UNKNOWN == verifySpecifics(k_han1));
|
|
|
|
|
|
CHECK ( opaque1 == verifySpecifics(k_loc1));
|
|
|
|
|
|
CHECK ( opaque2 == verifySpecifics(k_loc2));
|
2011-10-15 22:46:08 +02:00
|
|
|
|
|
2011-10-15 17:47:50 +02:00
|
|
|
|
|
|
|
|
|
|
// Verify 2nd level specialisation (some examples)
|
2025-06-07 23:59:57 +02:00
|
|
|
|
Key k_han1_siz (k_han1, SIZE_B); // sub-key deriving from k_han1, but differing buffer size
|
2011-10-15 22:46:08 +02:00
|
|
|
|
Key k_siz_han1 (k_siz, placeMarker); // sub-key deriving from k_siz, but using another type functor
|
2011-10-15 17:47:50 +02:00
|
|
|
|
|
|
|
|
|
|
// Verify some 3rd level specialisations
|
|
|
|
|
|
Key k_han1_siz_loc2 (k_han1_siz, opaque2);
|
|
|
|
|
|
Key k_loc2_han1_siz (Key(k_loc2,placeMarker), SIZE_B);
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (SIZE_B == verifySize(k_han1_siz ));
|
|
|
|
|
|
CHECK (SIZE_B == verifySize(k_siz_han1 ));
|
|
|
|
|
|
CHECK (SIZE_B == verifySize(k_han1_siz_loc2));
|
|
|
|
|
|
CHECK (SIZE_B == verifySize(k_loc2_han1_siz));
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (placeMarker == verifyHandler(k_han1_siz ));
|
|
|
|
|
|
CHECK (placeMarker == verifyHandler(k_siz_han1 ));
|
|
|
|
|
|
CHECK (placeMarker == verifyHandler(k_han1_siz_loc2));
|
|
|
|
|
|
CHECK (placeMarker == verifyHandler(k_loc2_han1_siz));
|
|
|
|
|
|
|
2024-07-27 17:17:02 +02:00
|
|
|
|
CHECK (LocalTag::UNKNOWN == verifySpecifics(k_han1_siz ));
|
|
|
|
|
|
CHECK (LocalTag::UNKNOWN == verifySpecifics(k_siz_han1 ));
|
2011-10-15 22:46:08 +02:00
|
|
|
|
CHECK (opaque2 == verifySpecifics(k_han1_siz_loc2));
|
|
|
|
|
|
CHECK (opaque2 == verifySpecifics(k_loc2_han1_siz));
|
2011-10-15 17:47:50 +02:00
|
|
|
|
|
|
|
|
|
|
// for equality, also the order of specialisation matters
|
|
|
|
|
|
CHECK (k_han1_siz != k_siz_han1 );
|
|
|
|
|
|
CHECK (k_han1_siz_loc2 != k_loc2_han1_siz);
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (HashVal(k_han1_siz ) != HashVal(k_siz_han1 ));
|
|
|
|
|
|
CHECK (HashVal(k_han1_siz_loc2) != HashVal(k_loc2_han1_siz));
|
|
|
|
|
|
|
2011-10-15 22:46:08 +02:00
|
|
|
|
// yet this *is* an semantic equality test
|
2011-10-15 17:47:50 +02:00
|
|
|
|
Key k_again (Key(k_han1,SIZE_B), opaque2);
|
|
|
|
|
|
CHECK (k_again == k_han1_siz_loc2);
|
|
|
|
|
|
CHECK (HashVal(k_again) == HashVal(k_han1_siz_loc2));
|
|
|
|
|
|
|
|
|
|
|
|
// pick just some combinations for cross verification...
|
|
|
|
|
|
CHECK (kb != k_han1_siz );
|
|
|
|
|
|
CHECK (kb != k_siz_han1 );
|
|
|
|
|
|
CHECK (kb != k_han1_siz_loc2);
|
|
|
|
|
|
CHECK (kb != k_loc2_han1_siz);
|
|
|
|
|
|
CHECK (k_han1 != k_han1_siz );
|
|
|
|
|
|
CHECK (k_han1 != k_siz_han1 );
|
|
|
|
|
|
CHECK (k_han1 != k_han1_siz_loc2);
|
|
|
|
|
|
CHECK (k_han1 != k_loc2_han1_siz);
|
|
|
|
|
|
CHECK (k_siz != k_han1_siz );
|
|
|
|
|
|
CHECK (k_siz != k_siz_han1 );
|
|
|
|
|
|
CHECK (k_siz != k_han1_siz_loc2);
|
|
|
|
|
|
CHECK (k_siz != k_loc2_han1_siz);
|
|
|
|
|
|
CHECK (k_loc2 != k_han1_siz );
|
|
|
|
|
|
CHECK (k_loc2 != k_siz_han1 );
|
|
|
|
|
|
CHECK (k_loc2 != k_han1_siz_loc2);
|
|
|
|
|
|
CHECK (k_loc2 != k_loc2_han1_siz);
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_han1_siz ));
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_siz_han1 ));
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_han1_siz_loc2));
|
|
|
|
|
|
CHECK (HashVal(kb ) != HashVal(k_loc2_han1_siz));
|
|
|
|
|
|
CHECK (HashVal(k_han1) != HashVal(k_han1_siz ));
|
|
|
|
|
|
CHECK (HashVal(k_han1) != HashVal(k_siz_han1 ));
|
|
|
|
|
|
CHECK (HashVal(k_han1) != HashVal(k_han1_siz_loc2));
|
|
|
|
|
|
CHECK (HashVal(k_han1) != HashVal(k_loc2_han1_siz));
|
|
|
|
|
|
CHECK (HashVal(k_siz ) != HashVal(k_han1_siz ));
|
|
|
|
|
|
CHECK (HashVal(k_siz ) != HashVal(k_siz_han1 ));
|
|
|
|
|
|
CHECK (HashVal(k_siz ) != HashVal(k_han1_siz_loc2));
|
|
|
|
|
|
CHECK (HashVal(k_siz ) != HashVal(k_loc2_han1_siz));
|
|
|
|
|
|
CHECK (HashVal(k_loc2) != HashVal(k_han1_siz ));
|
|
|
|
|
|
CHECK (HashVal(k_loc2) != HashVal(k_siz_han1 ));
|
|
|
|
|
|
CHECK (HashVal(k_loc2) != HashVal(k_han1_siz_loc2));
|
|
|
|
|
|
CHECK (HashVal(k_loc2) != HashVal(k_loc2_han1_siz));
|
2011-10-15 05:05:30 +02:00
|
|
|
|
}
|
2011-10-15 04:12:51 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
|
LAUNCHER (BufferMetadataKey_test, "unit player");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
}}}} // namespace steam::engine::metadata::test
|