From 0930d32fd19d7ebad9ba950cea8048f689dea82a Mon Sep 17 00:00:00 2001 From: janis Date: Thu, 30 Jun 2022 17:06:50 +0100 Subject: [PATCH] tests --- src/main.cc | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main.cc b/src/main.cc index 0a130e3..2a7780c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,7 @@ #include "format.hpp" #include "panic.hpp" #include "print.hpp" +#include "ranges/enumerate.hpp" #include "ranges/first.hpp" #include "ranges/generated.hpp" #include "tagged_union.hpp" @@ -11,20 +12,41 @@ #define UTIL_ASSERT_FORMAT #include "assert.hpp" #include "ranges/collect.hpp" +#include #include #include -#include #include +#include using namespace std::string_view_literals; +using namespace util::bitflag_operators; + +enum class E { + A = 0x1, + B = 0x10, + C = 0x100, + D = 0x1000, +}; int main(int argc, const char *argv[]) { printf("Hello, Alloy!\n"); + + const auto a = E::A; + const auto ab = E::A | E::B; + const auto all = E::A | E::B | E::C | E::D; + auto vec = std::vector({1, 2, 3, 4, 5}); auto range = vec | std::views::filter([](auto &i) { return i % 2; }); auto infinite_range = util::views::from([] {return 1;}) | std::views::take(5); + auto map = + vec | util::views::enumerate | util::views::collect>; + + for (auto &&[i, e] : map) { + util::println("[{}] {}", i, e); + } + auto random = util::views::from([] { return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY" [std::rand() % @@ -42,11 +64,11 @@ util::println("{}", random); util::print("{}\n", i); } -util::print("hello {}\n", "world"); - - util::assert_eq("asdf"sv, "nsdf"sv); - const auto set = util::collect>(range); + + util::print("hello {}\n", "world"); + + util::assert_ne("asdf"sv, "nsdf"sv); util::panic("asdf {}", 42); return 1; } \ No newline at end of file