tests
This commit is contained in:
parent
a4f4a0a069
commit
0930d32fd1
32
src/main.cc
32
src/main.cc
|
@ -1,6 +1,7 @@
|
||||||
#include "format.hpp"
|
#include "format.hpp"
|
||||||
#include "panic.hpp"
|
#include "panic.hpp"
|
||||||
#include "print.hpp"
|
#include "print.hpp"
|
||||||
|
#include "ranges/enumerate.hpp"
|
||||||
#include "ranges/first.hpp"
|
#include "ranges/first.hpp"
|
||||||
#include "ranges/generated.hpp"
|
#include "ranges/generated.hpp"
|
||||||
#include "tagged_union.hpp"
|
#include "tagged_union.hpp"
|
||||||
|
@ -11,20 +12,41 @@
|
||||||
#define UTIL_ASSERT_FORMAT
|
#define UTIL_ASSERT_FORMAT
|
||||||
#include "assert.hpp"
|
#include "assert.hpp"
|
||||||
#include "ranges/collect.hpp"
|
#include "ranges/collect.hpp"
|
||||||
|
#include <map>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace std::string_view_literals;
|
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[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
printf("Hello, Alloy!\n");
|
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<int>({1, 2, 3, 4, 5});
|
auto vec = std::vector<int>({1, 2, 3, 4, 5});
|
||||||
|
|
||||||
auto range = vec | std::views::filter([](auto &i) { return i % 2; });
|
auto range = vec | std::views::filter([](auto &i) { return i % 2; });
|
||||||
auto infinite_range = util::views::from([] {return 1;}) | std::views::take(5);
|
auto infinite_range = util::views::from([] {return 1;}) | std::views::take(5);
|
||||||
|
|
||||||
|
auto map =
|
||||||
|
vec | util::views::enumerate | util::views::collect<std::map<int, int>>;
|
||||||
|
|
||||||
|
for (auto &&[i, e] : map) {
|
||||||
|
util::println("[{}] {}", i, e);
|
||||||
|
}
|
||||||
|
|
||||||
auto random = util::views::from([] {
|
auto random = util::views::from([] {
|
||||||
return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY"
|
return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY"
|
||||||
[std::rand() %
|
[std::rand() %
|
||||||
|
@ -42,11 +64,11 @@ util::println("{}", random);
|
||||||
util::print("{}\n", i);
|
util::print("{}\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
util::print("hello {}\n", "world");
|
|
||||||
|
|
||||||
util::assert_eq("asdf"sv, "nsdf"sv);
|
|
||||||
|
|
||||||
const auto set = util::collect<std::set<int>>(range);
|
const auto set = util::collect<std::set<int>>(range);
|
||||||
|
|
||||||
|
util::print("hello {}\n", "world");
|
||||||
|
|
||||||
|
util::assert_ne("asdf"sv, "nsdf"sv);
|
||||||
util::panic("asdf {}", 42);
|
util::panic("asdf {}", 42);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
Loading…
Reference in a new issue