コード例 #1
0
      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++);

      }

      AND_THEN("You can check if any address is within that range") {

        EXPECT(not range.in_range(1));
        EXPECT(not range.in_range((uintptr_t)seq));
        EXPECT(range.in_range((uintptr_t)seq_start));
        EXPECT(range.in_range((uintptr_t)seq_end));
        EXPECT(not range.in_range((uintptr_t)seq + 22));
      }

      AND_THEN("You can resize that range (but you should let the memory map do that)")
        {
          auto sz = range.size();
          range.resize(range.size() + 100);
          EXPECT(range.size() == sz + 100);
          range.resize(range.size() + 10000);
          EXPECT(range.size() == sz + 10100);
        }
    }
コード例 #2
0
ファイル: memmap.hpp プロジェクト: bowlofstew/IncludeOS
 bool overlaps(const Fixed_memory_range& other) const {
   // Other range overlaps with my range
   return in_range(other.addr_start()) or in_range(other.addr_end())
     // Or my range is inside other range
     or (other.in_range(addr_start()) and other.in_range(addr_end()));
 }
コード例 #3
0
ファイル: memmap.cpp プロジェクト: AnnikaH/IncludeOS
bool Fixed_memory_range::overlaps(const Fixed_memory_range& other) const noexcept {
  return (in_range(other.addr_start()) or in_range(other.addr_end()))   //< Other range overlaps with my range
      or (other.in_range(addr_start()) and other.in_range(addr_end())); //< My range is inside other range
}