diff --git a/Atomic/Dropbox.test/0.cc b/Atomic/Dropbox.test/0.cc new file mode 100644 index 0000000..284010f --- /dev/null +++ b/Atomic/Dropbox.test/0.cc @@ -0,0 +1,45 @@ +static_assert( __cplusplus > 2023'00 ); + +#include "../Dropbox.h" + +#include +#include + +#include +#include + +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() }, + }; +}; diff --git a/Atomic/Dropbox.test/CMakeLists.txt b/Atomic/Dropbox.test/CMakeLists.txt new file mode 100644 index 0000000..b099603 --- /dev/null +++ b/Atomic/Dropbox.test/CMakeLists.txt @@ -0,0 +1 @@ +unit_test( 0 )