units
Use physical dimensions at compile-time or run-time.
Functions
bit-range-test.cpp File Reference

Test-cases for vnix::bit_range. More...

#include "../vnix/bit-range.hpp"
#include "catch.hpp"
Include dependency graph for bit-range-test.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Bit can be set.","[bit]")
 
 TEST_CASE ("Bit-range can be set.","[bit-range]")
 

Detailed Description

Test-cases for vnix::bit_range.

License: BSD three-clause; see LICENSE.

Definition in file bit-range-test.cpp.

Function Documentation

TEST_CASE ( "Bit can be set."  ,
""  [bit] 
)

Definition at line 12 of file bit-range-test.cpp.

12  {
13  REQUIRE(bit<uint8_t>(0) == 0x01);
14  REQUIRE(bit<uint8_t>(1) == 0x02);
15  REQUIRE(bit<uint8_t>(2) == 0x04);
16  REQUIRE(bit<uint8_t>(3) == 0x08);
17  REQUIRE(bit<uint8_t>(4) == 0x10);
18  REQUIRE(bit<uint8_t>(5) == 0x20);
19  REQUIRE(bit<uint8_t>(6) == 0x40);
20  REQUIRE(bit<uint8_t>(7) == 0x80);
21 }

Here is the call graph for this function:

TEST_CASE ( "Bit-range can be set."  ,
""  [bit-range] 
)

Definition at line 24 of file bit-range-test.cpp.

24  {
25  for (unsigned off1 = 0; off1 < 8; ++off1) {
26  for (unsigned off2 = 0; off2 < 8; ++off2) {
27  uint8_t truth = 0;
28  if (off1 < off2) {
29  for (unsigned i = off1; i <= off2; ++i) { truth |= (1 << i); }
30  } else {
31  for (unsigned i = off2; i <= off1; ++i) { truth |= (1 << i); }
32  }
33  REQUIRE(bit_range<uint8_t>(off1, off2) == truth);
34  }
35  }
36 }

Here is the call graph for this function: