feat(Core): detach Uuid from Math, add CheckedBits and portable Hash (M-CORE-02, M-CORE-03)
This commit is contained in:
1 parent
8d28c7e3c4
commit
cbc900412b
9 files changed
+555
-117
No files matched your search
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidCoreOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS Core)
|
||||
|
||||
add_executable(void_core_only_consumer main.cpp)
|
||||
target_link_libraries(void_core_only_consumer PRIVATE Void::Core)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME VoidCoreOnlyConsumer COMMAND void_core_only_consumer)
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <Void/Core/Bits.hpp>
|
||||
#include <Void/Core/CheckedBits.hpp>
|
||||
#include <Void/Core/Hash.hpp>
|
||||
#include <Void/Core/Meta.hpp>
|
||||
#include <Void/Core/Uuid.hpp>
|
||||
|
||||
#include <random>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::mt19937_64 rng{7};
|
||||
const auto u = Void::Uuid::v4(rng);
|
||||
const auto chars = Void::Uuid::format_chars(u);
|
||||
const auto reparsed =
|
||||
Void::Uuid::parse(std::string_view{chars.data(), chars.size()});
|
||||
if (!reparsed || *reparsed != u) {
|
||||
return 1;
|
||||
}
|
||||
const auto aligned = Void::Bits::checked_align_up(13u, 8u);
|
||||
if (!aligned || *aligned != 16u) {
|
||||
return 1;
|
||||
}
|
||||
const auto h = Void::Hash::fnv1a64("core-only");
|
||||
return h != 0 ? 0 : 1;
|
||||
}
|
||||
@@ -81,6 +81,11 @@ set(_no_external_deps
|
||||
|
||||
# A header-only component must remain independently consumable even when every
|
||||
# optional external package is explicitly unavailable.
|
||||
has_modules(_has_core Core)
|
||||
if(_has_core)
|
||||
run_consumer(CoreOnly "${install_prefix}" "CoreOnly" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
has_modules(_has_binary Binary)
|
||||
if(_has_binary)
|
||||
run_consumer(Binary "${install_prefix}" "Binary" ${_no_external_deps})
|
||||
|
||||
Reference in new issue
Block a user