proxygen
SparseByteSetTest.cpp File Reference
#include <folly/container/SparseByteSet.h>
#include <cstdint>
#include <limits>
#include <random>
#include <set>
#include <folly/portability/GTest.h>

Go to the source code of this file.

Functions

 TEST_F (SparseByteSetTest, empty)
 
 TEST_F (SparseByteSetTest, each)
 
 TEST_F (SparseByteSetTest, each_random)
 

Function Documentation

TEST_F ( SparseByteSetTest  ,
empty   
)

Definition at line 39 of file SparseByteSetTest.cpp.

References c, EXPECT_FALSE, max, min, and s.

39  {
40  for (auto c = lims::min(); c < lims::max(); ++c) {
41  EXPECT_FALSE(s.contains(c));
42  }
43 }
LogLevel max
Definition: LogLevel.cpp:31
LogLevel min
Definition: LogLevel.cpp:30
static set< string > s
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
char c
TEST_F ( SparseByteSetTest  ,
each   
)

Definition at line 45 of file SparseByteSetTest.cpp.

References c, EXPECT_FALSE, EXPECT_TRUE, max, min, and s.

45  {
46  for (auto c = lims::min(); c < lims::max(); ++c) {
47  EXPECT_TRUE(s.add(c));
48  EXPECT_TRUE(s.contains(c));
49  }
50  for (auto c = lims::min(); c < lims::max(); ++c) {
51  EXPECT_FALSE(s.add(c));
52  EXPECT_TRUE(s.contains(c));
53  }
54 }
LogLevel max
Definition: LogLevel.cpp:31
LogLevel min
Definition: LogLevel.cpp:30
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static set< string > s
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
char c
TEST_F ( SparseByteSetTest  ,
each_random   
)

Definition at line 56 of file SparseByteSetTest.cpp.

References c, dist, EXPECT_EQ, EXPECT_TRUE, max, min, rng, s, and uint8_t.

56  {
57  mt19937 rng;
58  uniform_int_distribution<uint16_t> dist{lims::min(), lims::max()};
59  set<uint8_t> added;
60  while (added.size() <= lims::max()) {
61  auto c = uint8_t(dist(rng));
62  EXPECT_EQ(added.count(c), s.contains(c));
63  EXPECT_EQ(!added.count(c), s.add(c));
64  added.insert(c);
65  EXPECT_TRUE(added.count(c)); // sanity
66  EXPECT_TRUE(s.contains(c));
67  }
68 }
LogLevel max
Definition: LogLevel.cpp:31
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
auto rng
Definition: CollectTest.cpp:31
LogLevel min
Definition: LogLevel.cpp:30
std::uniform_int_distribution< milliseconds::rep > dist
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static set< string > s
char c