1
0
forked from Alepha/Alepha

Dangit! Forgot the test.

This commit is contained in:
2024-07-29 15:51:50 -04:00
parent c5d1079deb
commit 97050bf5f1
2 changed files with 46 additions and 0 deletions

45
Atomic/Dropbox.test/0.cc Normal file
View File

@ -0,0 +1,45 @@
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() },
};
};

View File

@ -0,0 +1 @@
unit_test( 0 )