extension_test.cc
Go to the documentation of this file.
1 //
2 // Copyright 2017 The Abseil Authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // https://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
18 
19 #include <random>
20 #include <string>
21 
23 
24 #include "gtest/gtest.h"
25 
26 namespace {
27 
28 std::string MakeRandomString(size_t len) {
29  std::random_device rd;
30  std::mt19937 gen(rd());
31  std::uniform_int_distribution<> dis('a', 'z');
32  std::string s(len, '0');
33  for (char& c : s) {
34  c = dis(gen);
35  }
36  return s;
37 }
38 
39 TEST(FormatExtensionTest, SinkAppendSubstring) {
40  for (size_t chunk_size : {1, 10, 100, 1000, 10000}) {
41  std::string expected, actual;
43  for (size_t chunks = 0; chunks < 10; ++chunks) {
44  std::string rand = MakeRandomString(chunk_size);
45  expected += rand;
46  sink.Append(rand);
47  }
48  sink.Flush();
49  EXPECT_EQ(actual, expected);
50  }
51 }
52 
53 TEST(FormatExtensionTest, SinkAppendChars) {
54  for (size_t chunk_size : {1, 10, 100, 1000, 10000}) {
55  std::string expected, actual;
57  for (size_t chunks = 0; chunks < 10; ++chunks) {
58  std::string rand = MakeRandomString(1);
59  expected.append(chunk_size, rand[0]);
60  sink.Append(chunk_size, rand[0]);
61  }
62  sink.Flush();
63  EXPECT_EQ(actual, expected);
64  }
65 }
66 } // namespace
TEST(Symbolize, Unimplemented)


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:19:56