48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
#include <Void/Binary/Reader.hpp>
|
|
#include <Void/Functional/Result.hpp>
|
|
#include <Void/FunctionalCoreFormatting/Repr.hpp>
|
|
#include <Void/Math/Numeric.hpp>
|
|
#include <Void/Text/Str.hpp>
|
|
#include <Void/Time/Stopwatch.hpp>
|
|
|
|
#include <array>
|
|
#include <bit>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
namespace
|
|
{
|
|
struct Point {
|
|
int x;
|
|
int y;
|
|
};
|
|
} // namespace
|
|
|
|
int main()
|
|
{
|
|
const auto sum = Void::Numeric::checked_add(19, 23);
|
|
if (!sum || *sum != 42) {
|
|
return 1;
|
|
}
|
|
|
|
const auto trimmed = Void::Str::trim(" void ");
|
|
if (trimmed != "void") {
|
|
return 1;
|
|
}
|
|
|
|
Void::Time::Stopwatch sw;
|
|
sw.start();
|
|
(void)sw.stop();
|
|
|
|
const std::array bytes{std::byte{0x00}, std::byte{0x2A}};
|
|
Void::Binary::Reader reader{bytes};
|
|
const auto num = reader.read<std::uint16_t>(std::endian::big);
|
|
if (!num || *num != 42) {
|
|
return 1;
|
|
}
|
|
|
|
const auto r = Void::Result::ok(Point{1, 2});
|
|
const auto text = Void::Result::Detail::repr(*r);
|
|
return !text.empty() ? 0 : 1;
|
|
}
|