#include <kernel/memmap.hpp> CASE ("Using the fixed memory range class") { GIVEN ("A fixed memory range over raw sequence of bytes") { // A dynamically allocated "raw pool" of bytes // @note : In the kernel memory map these would be physical ranges char* seq = const_cast<char*>("Spans provide a safer way to access memory"); Fixed_memory_range range(reinterpret_cast<uintptr_t>(seq + 16), reinterpret_cast<uintptr_t>(seq + 20), "Demo range", "A range inside a local pool"); auto seq_start = seq + 16; auto seq_end = seq + 20; EXPECT(range.size() == seq_end - seq_start + 1); EXPECT(std::string(range.name()) == std::string("Demo range")); THEN("You can iterate safely over that range, and not out of bounds"){ for (auto i : range) EXPECT(i); auto i = range.begin(); for (; i != range.end(); i++) EXPECT(*i); EXPECT_THROWS(++i); EXPECT_THROWS(i++); }