forked from Alepha/Alepha
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
static_assert( __cplusplus > 2023'00 );
|
|
|
|
#include "../Dropbox.h"
|
|
|
|
#include <Alepha/Testing/TableTest.h>
|
|
#include <Alepha/Testing/test.h>
|
|
|
|
#include <Alepha/Utility/enroll.h>
|
|
#include <Alepha/Utility/evaluate.h>
|
|
|
|
static auto init= Alepha::Utility::enroll <=[]
|
|
{
|
|
using namespace Alepha::Testing::exports;
|
|
using namespace Alepha::Testing::literals;
|
|
using namespace Alepha::Utility::exports::evaluate_m;
|
|
|
|
const std::string tooLong= "Supercalifragalisticexpialidocious and "
|
|
"Antidisestablishmentarianism";
|
|
|
|
"Does weight computation make sense for strings?"_test <=TableTest
|
|
<
|
|
[]( const std::string &init, const std::size_t sz )
|
|
{
|
|
std::string s= init;
|
|
if( sz ) s.reserve( sz );
|
|
return Alepha::Atomic::Dropbox_m::computeWeight( s );
|
|
}
|
|
>
|
|
::Cases
|
|
{
|
|
{ "Empty string, SSO", { "", 0 }, sizeof( std::string ) },
|
|
{ "Empty string, no SSO", { "", 1000 }, sizeof( std::string ) + 1000 },
|
|
|
|
{ "'Hello', SSO", { "Hello", 0 }, sizeof( std::string ) },
|
|
{ "'Hello', no SSO", { "Hello", 1000 }, sizeof( std::string ) + 1000 },
|
|
|
|
|
|
// This pair of cases are extremely sensitive to SSO implementation.
|
|
// If the SSO supports at least 16 bytes (including Null), then these pass.
|
|
{ "Hex digits, except for F, SSO", { "0123456789ABCDE", 0 }, sizeof( std::string ) },
|
|
{ "Hex digits, except for F, SSO", { "0123456789ABCDE", 1000 }, sizeof( std::string ) + 1000 },
|
|
|
|
{ "Too long", { tooLong, 0 }, sizeof( std::string ) + tooLong.capacity() },
|
|
};
|
|
};
|