proxygen
DigestBuilderTest.cpp File Reference
#include <folly/stats/detail/DigestBuilder-defs.h>
#include <chrono>
#include <random>
#include <thread>
#include <folly/Range.h>
#include <folly/portability/GTest.h>

Go to the source code of this file.

Classes

class  SimpleDigest< MergeSize >
 

Functions

 TEST (DigestBuilder, SingleThreadUnfilledBuffer)
 
 TEST (DigestBuilder, SingleThreadFilledBuffer)
 
 TEST (DigestBuilder, MultipleThreads)
 

Function Documentation

TEST ( DigestBuilder  ,
SingleThreadUnfilledBuffer   
)

Definition at line 55 of file DigestBuilderTest.cpp.

References folly::detail::DigestBuilder< DigestT >::append(), folly::detail::DigestBuilder< DigestT >::build(), shell_builder::builder, EXPECT_EQ, and i.

55  {
57  for (int i = 0; i < 999; ++i) {
58  builder.append(i);
59  }
60  EXPECT_EQ(100, builder.build().getSize());
61 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( DigestBuilder  ,
SingleThreadFilledBuffer   
)

Definition at line 63 of file DigestBuilderTest.cpp.

References folly::detail::DigestBuilder< DigestT >::append(), folly::detail::DigestBuilder< DigestT >::build(), shell_builder::builder, EXPECT_EQ, and i.

63  {
65  for (int i = 0; i < 1000; ++i) {
66  builder.append(i);
67  }
68  EXPECT_EQ(100, builder.build().getSize());
69 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST ( DigestBuilder  ,
MultipleThreads   
)

Definition at line 71 of file DigestBuilderTest.cpp.

References folly::detail::DigestBuilder< DigestT >::append(), folly::detail::DigestBuilder< DigestT >::build(), shell_builder::builder, EXPECT_EQ, i, and threads.

71  {
73  std::vector<std::thread> threads;
74  for (int i = 0; i < 10; ++i) {
75  threads.push_back(std::thread([i, &builder]() {
76  for (int j = 0; j < 100; ++j) {
77  builder.append(i * 100 + j);
78  }
79  }));
80  }
81  for (auto& thread : threads) {
82  thread.join();
83  }
84 
85  EXPECT_EQ(100, builder.build().getSize());
86 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
std::vector< std::thread::id > threads