proxygen
BitIteratorTest.cpp File Reference
#include <folly/container/BitIterator.h>
#include <limits>
#include <type_traits>
#include <vector>
#include <folly/portability/GTest.h>

Go to the source code of this file.

Functions

 TEST (BitIterator, Simple)
 
 TEST (BitIterator, Const)
 

Function Documentation

TEST ( BitIterator  ,
Simple   
)

Definition at line 57 of file BitIteratorTest.cpp.

References EXPECT_EQ, folly::makeBitIterator(), and v.

57  {
58  std::vector<int> v;
59  v.push_back(0x10);
60  v.push_back(0x42);
61  auto bi(makeBitIterator(v.begin()));
62  checkIt(0x10, bi);
63  checkIt(0x42, bi);
64  checkRange(0x0000004200000010ULL, v.begin(), v.end());
65 
66  v[0] = 0;
67  bi = v.begin();
68  *bi++ = true; // 1
69  *bi++ = false;
70  *bi++ = true; // 4
71  *bi++ = false;
72  *bi++ = false;
73  *bi++ = true; // 32
74  *++bi = true; // 128 (note pre-increment)
75 
76  EXPECT_EQ(165, v[0]);
77 }
auto v
BitIterator< BaseIter > makeBitIterator(const BaseIter &iter)
Definition: BitIterator.h:161
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( BitIterator  ,
Const   
)

Definition at line 79 of file BitIteratorTest.cpp.

References folly::makeBitIterator(), and v.

79  {
80  std::vector<int> v;
81  v.push_back(0x10);
82  v.push_back(0x42);
83  auto bi(makeBitIterator(v.cbegin()));
84  checkIt(0x10, bi);
85  checkIt(0x42, bi);
86 }
auto v
BitIterator< BaseIter > makeBitIterator(const BaseIter &iter)
Definition: BitIterator.h:161