test_table.cc
Go to the documentation of this file.
1 // Copyright (c) 2009-2021, Google LLC
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name of Google LLC nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 // ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
19 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 /*
27  * Tests for upb_table.
28  */
29 
30 #include <limits.h>
31 #include <string.h>
32 #include <sys/resource.h>
33 
34 #include <iostream>
35 #include <map>
36 #include <set>
37 #include <string>
38 #include <unordered_map>
39 #include <vector>
40 
41 #include "gtest/gtest.h"
42 #include "upb/table_internal.h"
43 #include "upb/upb.hpp"
44 
45 // Must be last.
46 #include "upb/port_def.inc"
47 
48 // Convenience interface for C++. We don't put this in upb itself because
49 // the table is not exposed to users.
50 
51 namespace upb {
52 
53 template <class T>
55 template <class T>
57 
58 #define FUNCS(name, type_t, enumval) \
59  template <> \
60  upb_value MakeUpbValue<type_t>(type_t val) { \
61  return upb_value_##name(val); \
62  } \
63  template <> \
64  type_t GetUpbValue<type_t>(upb_value val) { \
65  return upb_value_get##name(val); \
66  }
67 
72 FUNCS(bool, bool, UPB_CTYPE_BOOL)
73 FUNCS(cstr, char*, UPB_CTYPE_CSTR)
74 FUNCS(ptr, void*, UPB_CTYPE_PTR)
75 FUNCS(constptr, const void*, UPB_CTYPE_CONSTPTR)
76 
77 #undef FUNCS
78 
79 class IntTable {
80  public:
82 
83  size_t count() { return upb_inttable_count(&table_); }
84 
86  return upb_inttable_insert(&table_, key, val, arena_.ptr());
87  }
88 
90  return upb_inttable_replace(&table_, key, val);
91  }
92 
93  std::pair<bool, upb_value> Remove(uintptr_t key) {
94  std::pair<bool, upb_value> ret;
95  ret.first = upb_inttable_remove(&table_, key, &ret.second);
96  return ret;
97  }
98 
99  std::pair<bool, upb_value> Lookup(uintptr_t key) const {
100  std::pair<bool, upb_value> ret;
101  ret.first = upb_inttable_lookup(&table_, key, &ret.second);
102  return ret;
103  }
104 
105  std::pair<bool, upb_value> Lookup32(uint32_t key) const {
106  std::pair<bool, upb_value> ret;
107  ret.first = upb_inttable_lookup(&table_, key, &ret.second);
108  return ret;
109  }
110 
112 
113  class iterator : public std::iterator<std::forward_iterator_tag,
114  std::pair<uintptr_t, upb_value> > {
115  public:
116  explicit iterator(IntTable* table) {
117  upb_inttable_begin(&iter_, &table->table_);
118  }
119 
123  return iter;
124  }
125 
126  void operator++() { return upb_inttable_next(&iter_); }
127 
128  std::pair<uintptr_t, upb_value> operator*() const {
129  std::pair<uintptr_t, upb_value> ret;
130  ret.first = upb_inttable_iter_key(&iter_);
131  ret.second = upb_inttable_iter_value(&iter_);
132  return ret;
133  }
134 
135  bool operator==(const iterator& other) const {
136  return upb_inttable_iter_isequal(&iter_, &other.iter_);
137  }
138 
139  bool operator!=(const iterator& other) const { return !(*this == other); }
140 
141  private:
143  };
144 
147 };
148 
149 class StrTable {
150  public:
152 
153  size_t count() { return upb_strtable_count(&table_); }
154 
155  bool Insert(const std::string& key, upb_value val) {
156  return upb_strtable_insert(&table_, key.c_str(), key.size(), val,
157  arena_.ptr());
158  }
159 
160  std::pair<bool, upb_value> Remove(const std::string& key) {
161  std::pair<bool, upb_value> ret;
162  ret.first =
163  upb_strtable_remove2(&table_, key.c_str(), key.size(), &ret.second);
164  return ret;
165  }
166 
167  std::pair<bool, upb_value> Lookup(const std::string& key) const {
168  std::pair<bool, upb_value> ret;
169  ret.first =
170  upb_strtable_lookup2(&table_, key.c_str(), key.size(), &ret.second);
171  return ret;
172  }
173 
174  void Resize(size_t size_lg2) {
175  upb_strtable_resize(&table_, size_lg2, arena_.ptr());
176  }
177 
178  class iterator : public std::iterator<std::forward_iterator_tag,
179  std::pair<std::string, upb_value> > {
180  public:
181  explicit iterator(StrTable* table) {
182  upb_strtable_begin(&iter_, &table->table_);
183  }
184 
188  return iter;
189  }
190 
191  void operator++() { return upb_strtable_next(&iter_); }
192 
193  std::pair<std::string, upb_value> operator*() const {
194  std::pair<std::string, upb_value> ret;
196  ret.first.assign(view.data, view.size);
197  ret.second = upb_strtable_iter_value(&iter_);
198  return ret;
199  }
200 
201  bool operator==(const iterator& other) const {
202  return upb_strtable_iter_isequal(&iter_, &other.iter_);
203  }
204 
205  bool operator!=(const iterator& other) const { return !(*this == other); }
206 
207  private:
209  };
210 
213 };
214 
215 template <class T>
217  public:
218  size_t count() { return table_.count(); }
219 
220  bool Insert(const std::string& key, T val) {
221  return table_.Insert(key, MakeUpbValue<T>(val));
222  }
223 
224  std::pair<bool, T> Remove(const std::string& key) {
225  std::pair<bool, upb_value> found = table_.Remove(key);
226  std::pair<bool, T> ret;
227  ret.first = found.first;
228  if (ret.first) {
229  ret.second = GetUpbValue<T>(found.second);
230  }
231  return ret;
232  }
233 
234  std::pair<bool, T> Lookup(const std::string& key) const {
235  std::pair<bool, upb_value> found = table_.Lookup(key);
236  std::pair<bool, T> ret;
237  ret.first = found.first;
238  if (ret.first) {
239  ret.second = GetUpbValue<T>(found.second);
240  }
241  return ret;
242  }
243 
244  void Resize(size_t size_lg2) { table_.Resize(size_lg2); }
245 
246  class iterator : public std::iterator<std::forward_iterator_tag,
247  std::pair<std::string, T> > {
248  public:
252  iter.iter_ = StrTable::iterator::end(&table->table_);
253  return iter;
254  }
255 
256  void operator++() { ++iter_; }
257 
258  std::pair<std::string, T> operator*() const {
259  std::pair<std::string, upb_value> val = *iter_;
260  std::pair<std::string, T> ret;
261  ret.first = val.first;
262  ret.second = GetUpbValue<T>(val.second);
263  return ret;
264  }
265 
266  bool operator==(const iterator& other) const {
267  return iter_ == other.iter_;
268  }
269 
270  bool operator!=(const iterator& other) const {
271  return iter_ != other.iter_;
272  }
273 
274  private:
276  };
277 
278  iterator begin() { return iterator(this); }
279  iterator end() { return iterator::end(this); }
280 
282 };
283 
284 template <class T>
286  public:
287  size_t count() { return table_.count(); }
288 
289  bool Insert(uintptr_t key, T val) {
290  return table_.Insert(key, MakeUpbValue<T>(val));
291  }
292 
293  bool Replace(uintptr_t key, T val) {
294  return table_.Replace(key, MakeUpbValue<T>(val));
295  }
296 
297  std::pair<bool, T> Remove(uintptr_t key) {
298  std::pair<bool, upb_value> found = table_.Remove(key);
299  std::pair<bool, T> ret;
300  ret.first = found.first;
301  if (ret.first) {
302  ret.second = GetUpbValue<T>(found.second);
303  }
304  return ret;
305  }
306 
307  std::pair<bool, T> Lookup(uintptr_t key) const {
308  std::pair<bool, upb_value> found = table_.Lookup(key);
309  std::pair<bool, T> ret;
310  ret.first = found.first;
311  if (ret.first) {
312  ret.second = GetUpbValue<T>(found.second);
313  }
314  return ret;
315  }
316 
317  void Compact() { table_.Compact(); }
318 
319  class iterator : public std::iterator<std::forward_iterator_tag,
320  std::pair<uintptr_t, T> > {
321  public:
324  return IntTable::iterator::end(&table->table_);
325  }
326 
327  void operator++() { ++iter_; }
328 
329  std::pair<uintptr_t, T> operator*() const {
330  std::pair<uintptr_t, upb_value> val = *iter_;
331  std::pair<uintptr_t, T> ret;
332  ret.first = val.first;
333  ret.second = GetUpbValue<T>(val.second);
334  return ret;
335  }
336 
337  bool operator==(const iterator& other) const {
338  return iter_ == other.iter_;
339  }
340 
341  bool operator!=(const iterator& other) const {
342  return iter_ != other.iter_;
343  }
344 
345  private:
347  };
348 
349  iterator begin() { return iterator(this); }
350  iterator end() { return iterator::end(this); }
351 
353 };
354 
355 } // namespace upb
356 
357 #define CPU_TIME_PER_TEST 0.5
358 
359 using std::vector;
360 
361 double get_usertime() {
362  struct rusage usage;
363  getrusage(RUSAGE_SELF, &usage);
364  return usage.ru_utime.tv_sec + (usage.ru_utime.tv_usec / 1000000.0);
365 }
366 
367 TEST(Table, StringTable) {
368  vector<std::string> keys;
369  keys.push_back("google.protobuf.FileDescriptorSet");
370  keys.push_back("google.protobuf.FileDescriptorProto");
371  keys.push_back("google.protobuf.DescriptorProto");
372  keys.push_back("google.protobuf.DescriptorProto.ExtensionRange");
373  keys.push_back("google.protobuf.FieldDescriptorProto");
374  keys.push_back("google.protobuf.EnumDescriptorProto");
375  keys.push_back("google.protobuf.EnumValueDescriptorProto");
376  keys.push_back("google.protobuf.ServiceDescriptorProto");
377  keys.push_back("google.protobuf.MethodDescriptorProto");
378  keys.push_back("google.protobuf.FileOptions");
379  keys.push_back("google.protobuf.MessageOptions");
380  keys.push_back("google.protobuf.FieldOptions");
381  keys.push_back("google.protobuf.EnumOptions");
382  keys.push_back("google.protobuf.EnumValueOptions");
383  keys.push_back("google.protobuf.ServiceOptions");
384  keys.push_back("google.protobuf.MethodOptions");
385  keys.push_back("google.protobuf.UninterpretedOption");
386  keys.push_back("google.protobuf.UninterpretedOption.NamePart");
387 
388  /* Initialize structures. */
389  std::map<std::string, int32_t> m;
390  typedef upb::TypedStrTable<int32_t> Table;
391  Table table;
392  std::set<std::string> all;
393  for (const auto& key : keys) {
394  all.insert(key);
395  table.Insert(key, key[0]);
396  m[key] = key[0];
397  }
398 
399  /* Test correctness. */
400  for (const auto& key : keys) {
401  std::pair<bool, int32_t> found = table.Lookup(key);
402  if (m.find(key) != m.end()) { /* Assume map implementation is correct. */
403  EXPECT_TRUE(found.first);
404  EXPECT_EQ(found.second, key[0]);
405  EXPECT_EQ(m[key], key[0]);
406  } else {
407  EXPECT_FALSE(found.first);
408  }
409  }
410 
411  for (Table::iterator it = table.begin(); it != table.end(); ++it) {
412  std::set<std::string>::iterator i = all.find((*it).first);
413  EXPECT_NE(i, all.end());
414  all.erase(i);
415  }
416  EXPECT_TRUE(all.empty());
417 
418  // Test iteration with resizes.
419 
420  for (int i = 0; i < 10; i++) {
421  for (Table::iterator it = table.begin(); it != table.end(); ++it) {
422  // Even if we invalidate the iterator it should only return real elements.
423  EXPECT_EQ((*it).second, m[(*it).first]);
424 
425  // Force a resize even though the size isn't changing.
426  // Also forces the table size to grow so some new buckets end up empty.
427  int new_lg2 = table.table_.table_.t.size_lg2 + 1;
428  // Don't use more than 64k tables, to avoid exhausting memory.
429  new_lg2 = UPB_MIN(new_lg2, 16);
430  table.Resize(new_lg2);
431  }
432  }
433 }
434 
436  void SetUp() override {
437  if (GetParam() > 0) {
438  for (int i = 0; i < GetParam(); i++) {
439  keys_.push_back(i + 1);
440  }
441  } else {
442  for (int32_t i = 0; i < 64; i++) {
443  if (i < 32)
444  keys_.push_back(i + 1);
445  else
446  keys_.push_back(10101 + i);
447  }
448  }
449  }
450 
451  protected:
452  std::vector<int32_t> keys_;
453 };
454 
455 TEST_P(IntTableTest, TestIntTable) {
456  /* Initialize structures. */
457  typedef upb::TypedIntTable<uint32_t> Table;
458  Table table;
459  uint32_t largest_key = 0;
460  std::map<uint32_t, uint32_t> m;
461  std::unordered_map<uint32_t, uint32_t> hm;
462  for (const auto& key : keys_) {
463  largest_key = UPB_MAX((int32_t)largest_key, key);
464  table.Insert(key, key * 2);
465  m[key] = key * 2;
466  hm[key] = key * 2;
467  }
468 
469  /* Test correctness. */
470  for (uint32_t i = 0; i <= largest_key; i++) {
471  std::pair<bool, uint32_t> found = table.Lookup(i);
472  if (m.find(i) != m.end()) { /* Assume map implementation is correct. */
473  EXPECT_TRUE(found.first);
474  EXPECT_EQ(found.second, i * 2);
475  EXPECT_EQ(m[i], i * 2);
476  EXPECT_EQ(hm[i], i * 2);
477  } else {
478  EXPECT_FALSE(found.first);
479  }
480  }
481 
482  for (size_t i = 0; i < keys_.size(); i += 2) {
483  std::pair<bool, uint32_t> found = table.Remove(keys_[i]);
484  EXPECT_EQ(found.first, m.erase(keys_[i]) == 1);
485  if (found.first) {
486  EXPECT_EQ(found.second, (uint32_t)keys_[i] * 2);
487  }
488  hm.erase(keys_[i]);
489  m.erase(keys_[i]);
490  }
491 
492  EXPECT_EQ(table.count(), hm.size());
493 
494  /* Test correctness. */
495  for (uint32_t i = 0; i <= largest_key; i++) {
496  std::pair<bool, uint32_t> found = table.Lookup(i);
497  if (m.find(i) != m.end()) { /* Assume map implementation is correct. */
498  EXPECT_TRUE(found.first);
499  EXPECT_EQ(found.second, i * 2);
500  EXPECT_EQ(m[i], i * 2);
501  EXPECT_EQ(hm[i], i * 2);
502  } else {
503  EXPECT_FALSE(found.first);
504  }
505  }
506 
507  // Test replace.
508  for (uint32_t i = 0; i <= largest_key; i++) {
509  bool replaced = table.Replace(i, i * 3);
510  if (m.find(i) != m.end()) { /* Assume map implementation is correct. */
511  EXPECT_TRUE(replaced);
512  m[i] = i * 3;
513  hm[i] = i * 3;
514  } else {
515  EXPECT_FALSE(replaced);
516  }
517  }
518 
519  // Compact and test correctness again.
520  table.Compact();
521  for (uint32_t i = 0; i <= largest_key; i++) {
522  std::pair<bool, uint32_t> found = table.Lookup(i);
523  if (m.find(i) != m.end()) { /* Assume map implementation is correct. */
524  EXPECT_TRUE(found.first);
525  EXPECT_EQ(found.second, i * 3);
526  EXPECT_EQ(m[i], i * 3);
527  EXPECT_EQ(hm[i], i * 3);
528  } else {
529  EXPECT_FALSE(found.first);
530  }
531  }
532 }
533 
534 INSTANTIATE_TEST_SUITE_P(IntTableParams, IntTableTest,
535  testing::Values(8, 64, 512, -32));
536 
537 /*
538  * This test can't pass right now because the table can't store a value of
539  * (uint64_t)-1.
540  */
541 TEST(Table, MaxValue) {
542  /*
543  typedef upb::TypedIntTable<uint64_t> Table;
544  Table table;
545  uintptr_t uint64_max = (uint64_t)-1;
546  table.Insert(1, uint64_max);
547  std::pair<bool, uint64_t> found = table.Lookup(1);
548  ASSERT(found.first);
549  ASSERT(found.second == uint64_max);
550  */
551 }
552 
553 TEST(Table, Delete) {
555  upb_inttable t;
556  upb_inttable_init(&t, arena.ptr());
557  upb_inttable_insert(&t, 0, upb_value_bool(true), arena.ptr());
558  upb_inttable_insert(&t, 2, upb_value_bool(true), arena.ptr());
559  upb_inttable_insert(&t, 4, upb_value_bool(true), arena.ptr());
560  upb_inttable_compact(&t, arena.ptr());
561  upb_inttable_remove(&t, 0, NULL);
562  upb_inttable_remove(&t, 2, NULL);
563  upb_inttable_remove(&t, 4, NULL);
564 
568  ASSERT_TRUE(false);
569  }
570 }
571 
572 TEST(Table, Init) {
573  for (int i = 0; i < 2048; i++) {
574  /* Tests that the size calculations in init() (lg2 size for target load)
575  * work for all expected sizes. */
577  upb_strtable t;
578  upb_strtable_init(&t, i, arena.ptr());
579  }
580 }
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
test_group_name.all
all
Definition: test_group_name.py:241
UPB_CTYPE_BOOL
@ UPB_CTYPE_BOOL
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:672
upb::IntTable::IntTable
IntTable()
Definition: test_table.cc:81
upb_inttable_insert
UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:942
regen-readme.it
it
Definition: regen-readme.py:15
upb::TypedStrTable::Lookup
std::pair< bool, T > Lookup(const std::string &key) const
Definition: test_table.cc:234
UPB_CTYPE_INT64
@ UPB_CTYPE_INT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:669
upb::StrTable::iterator::end
static iterator end(StrTable *table)
Definition: test_table.cc:185
IntTableTest
Definition: test_table.cc:435
upb::StrTable::Resize
void Resize(size_t size_lg2)
Definition: test_table.cc:174
upb::StrTable::arena_
upb::Arena arena_
Definition: test_table.cc:211
google::protobuf::int64
int64_t int64
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:151
upb_strtable_init
UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:905
keys
const void * keys
Definition: abseil-cpp/absl/random/internal/randen.cc:49
upb_strtable_resize
bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1566
upb::TypedIntTable::iterator::operator*
std::pair< uintptr_t, T > operator*() const
Definition: test_table.cc:329
upb::TypedStrTable::iterator::end
static iterator end(TypedStrTable *table)
Definition: test_table.cc:250
upb::IntTable::iterator::end
static iterator end(IntTable *table)
Definition: test_table.cc:120
upb_StringView::data
const char * data
Definition: upb/upb/upb.h:73
upb::StrTable::iterator::iter_
upb_strtable_iter iter_
Definition: test_table.cc:208
upb_value
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:681
string.h
upb::TypedStrTable::iterator::operator*
std::pair< std::string, T > operator*() const
Definition: test_table.cc:258
upb::TypedStrTable::Insert
bool Insert(const std::string &key, T val)
Definition: test_table.cc:220
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
upb_inttable_iter_isequal
bool upb_inttable_iter_isequal(const upb_inttable_iter *i1, const upb_inttable_iter *i2)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1987
google::protobuf::uint32
uint32_t uint32
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:155
upb::StrTable::count
size_t count()
Definition: test_table.cc:153
upb::TypedStrTable::Remove
std::pair< bool, T > Remove(const std::string &key)
Definition: test_table.cc:224
upb::IntTable::Lookup32
std::pair< bool, upb_value > Lookup32(uint32_t key) const
Definition: test_table.cc:105
google::protobuf::python::cmessage::Init
static int Init(CMessage *self, PyObject *args, PyObject *kwargs)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/message.cc:1287
upb::StrTable::StrTable
StrTable()
Definition: test_table.cc:151
upb::TypedStrTable::iterator::iterator
iterator(TypedStrTable *table)
Definition: test_table.cc:249
upb_strtable_lookup2
bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, upb_value *v)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1612
upb::StrTable
Definition: test_table.cc:149
upb::TypedIntTable::iterator::operator++
void operator++()
Definition: test_table.cc:327
IntTableTest::SetUp
void SetUp() override
Definition: test_table.cc:436
upb::TypedIntTable::iterator
Definition: test_table.cc:319
upb::StrTable::Insert
bool Insert(const std::string &key, upb_value val)
Definition: test_table.cc:155
upb::TypedIntTable::iterator::iterator
iterator(TypedIntTable *table)
Definition: test_table.cc:322
iterator
const typedef MCPhysReg * iterator
Definition: MCRegisterInfo.h:27
upb_strtable_iter_key
const char * upb_strtable_iter_key(const upb_strtable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1651
T
#define T(upbtypeconst, upbtype, ctype, default_value)
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
upb::TypedIntTable::Replace
bool Replace(uintptr_t key, T val)
Definition: test_table.cc:293
upb::TypedIntTable::Lookup
std::pair< bool, T > Lookup(uintptr_t key) const
Definition: test_table.cc:307
upb::IntTable::iterator::operator++
void operator++()
Definition: test_table.cc:126
testing::TestWithParam
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1883
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
get_usertime
double get_usertime()
Definition: test_table.cc:361
upb::TypedIntTable
Definition: test_table.cc:285
UPB_MIN
#define UPB_MIN(x, y)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:126
upb::IntTable::iterator::iterator
iterator(IntTable *table)
Definition: test_table.cc:116
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
upb::IntTable::table_
upb_inttable table_
Definition: test_table.cc:146
upb::TypedStrTable::iterator::iter_
StrTable::iterator iter_
Definition: test_table.cc:275
upb_inttable_compact
UPB_INLINE void upb_inttable_compact(upb_inttable *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:1018
upb::TypedStrTable::begin
iterator begin()
Definition: test_table.cc:278
upb::TypedIntTable::Insert
bool Insert(uintptr_t key, T val)
Definition: test_table.cc:289
upb_strtable_begin
void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1636
google::protobuf::int32
int32_t int32
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:150
upb::GetUpbValue
T GetUpbValue(upb_value val)
gen_stats_data.found
bool found
Definition: gen_stats_data.py:61
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
UPB_CTYPE_INT32
@ UPB_CTYPE_INT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:668
upb::IntTable::Insert
bool Insert(uintptr_t key, upb_value val)
Definition: test_table.cc:85
upb_StringView::size
size_t size
Definition: upb/upb/upb.h:74
upb::StrTable::iterator
Definition: test_table.cc:178
EXPECT_NE
#define EXPECT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2028
upb::TypedIntTable::count
size_t count()
Definition: test_table.cc:287
upb_inttable_iter_key
uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1969
upb::IntTable::Lookup
std::pair< bool, upb_value > Lookup(uintptr_t key) const
Definition: test_table.cc:99
upb_inttable_iter
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:1113
upb::IntTable::Compact
void Compact()
Definition: test_table.cc:111
upb::TypedStrTable::iterator::operator++
void operator++()
Definition: test_table.cc:256
upb_inttable_done
bool upb_inttable_done(const upb_inttable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1958
upb_inttable_init
UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:901
table_internal.h
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
upb_inttable
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:848
upb::IntTable::iterator::iter_
upb_inttable_iter iter_
Definition: test_table.cc:142
upb_inttable_next
void upb_inttable_next(upb_inttable_iter *iter)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1943
upb::TypedIntTable::end
iterator end()
Definition: test_table.cc:350
upb
Definition: def.hpp:38
google::protobuf::uint64
uint64_t uint64
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:156
upb::StrTable::table_
upb_strtable table_
Definition: test_table.cc:212
upb_strtable_next
void upb_strtable_next(upb_strtable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1641
upb::TypedIntTable::Compact
void Compact()
Definition: test_table.cc:317
UPB_CTYPE_UINT32
@ UPB_CTYPE_UINT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:670
INSTANTIATE_TEST_SUITE_P
INSTANTIATE_TEST_SUITE_P(IntTableParams, IntTableTest, testing::Values(8, 64, 512, -32))
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
upb::StrTable::iterator::operator++
void operator++()
Definition: test_table.cc:191
upb::TypedIntTable::begin
iterator begin()
Definition: test_table.cc:349
upb::TypedIntTable::Remove
std::pair< bool, T > Remove(uintptr_t key)
Definition: test_table.cc:297
Delete
void Delete(T *t)
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:208
upb::MakeUpbValue
upb_value MakeUpbValue(T val)
upb::TypedIntTable::iterator::end
static iterator end(TypedIntTable *table)
Definition: test_table.cc:323
upb_inttable_replace
bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1810
upb_inttable_count
size_t upb_inttable_count(const upb_inttable *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1711
upb_inttable_begin
void upb_inttable_begin(upb_inttable_iter *i, const upb_inttable *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1936
IntTableTest::keys_
std::vector< int32_t > keys_
Definition: test_table.cc:452
upb::StrTable::iterator::operator==
bool operator==(const iterator &other) const
Definition: test_table.cc:201
upb::TypedStrTable::count
size_t count()
Definition: test_table.cc:218
upb::IntTable::count
size_t count()
Definition: test_table.cc:83
upb::Arena::ptr
upb_Arena * ptr()
Definition: upb.hpp:76
UPB_MAX
#define UPB_MAX(x, y)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:125
UPB_CTYPE_CSTR
@ UPB_CTYPE_CSTR
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:673
upb::Arena
Definition: upb.hpp:68
FUNCS
#define FUNCS(name, type_t, enumval)
Definition: test_table.cc:58
upb::TypedStrTable::iterator::operator!=
bool operator!=(const iterator &other) const
Definition: test_table.cc:270
upb::StrTable::iterator::iterator
iterator(StrTable *table)
Definition: test_table.cc:181
key
const char * key
Definition: hpack_parser_table.cc:164
testing::Values
internal::ValueArray< T... > Values(T... v)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-param-test.h:335
upb::IntTable::iterator::operator*
std::pair< uintptr_t, upb_value > operator*() const
Definition: test_table.cc:128
upb_strtable_remove2
UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len, upb_value *val)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:976
bloaty::usage
const char usage[]
Definition: bloaty.cc:1843
upb_StringView
Definition: upb/upb/upb.h:72
upb::TypedIntTable::iterator::iter_
IntTable::iterator iter_
Definition: test_table.cc:346
upb::TypedStrTable
Definition: test_table.cc:216
upb_inttable_lookup
bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1803
upb.hpp
upb_inttable_remove
bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1817
upb::TypedStrTable::table_
StrTable table_
Definition: test_table.cc:281
UPB_CTYPE_PTR
@ UPB_CTYPE_PTR
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:674
upb::IntTable::Replace
bool Replace(uintptr_t key, upb_value val)
Definition: test_table.cc:89
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
upb::IntTable::Remove
std::pair< bool, upb_value > Remove(uintptr_t key)
Definition: test_table.cc:93
upb_strtable_iter_setdone
void upb_strtable_iter_setdone(upb_strtable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1668
TEST
TEST(Table, StringTable)
Definition: test_table.cc:367
ASSERT_TRUE
#define ASSERT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1973
testing::WithParamInterface< int >::GetParam
static const ParamType & GetParam()
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1855
upb::StrTable::iterator::operator!=
bool operator!=(const iterator &other) const
Definition: test_table.cc:205
upb::TypedStrTable::iterator::operator==
bool operator==(const iterator &other) const
Definition: test_table.cc:266
upb_strtable_iter_isequal
bool upb_strtable_iter_isequal(const upb_strtable_iter *i1, const upb_strtable_iter *i2)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1673
upb_strtable
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:844
upb_strtable_iter_value
upb_value upb_strtable_iter_value(const upb_strtable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1663
upb::IntTable
Definition: test_table.cc:79
upb::StrTable::Remove
std::pair< bool, upb_value > Remove(const std::string &key)
Definition: test_table.cc:160
upb_inttable_iter_value
upb_value upb_inttable_iter_value(const upb_inttable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1974
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
upb::TypedStrTable::end
iterator end()
Definition: test_table.cc:279
upb::StrTable::iterator::operator*
std::pair< std::string, upb_value > operator*() const
Definition: test_table.cc:193
upb::TypedIntTable::table_
IntTable table_
Definition: test_table.cc:352
TEST_P
TEST_P(IntTableTest, TestIntTable)
Definition: test_table.cc:455
upb::IntTable::iterator::operator!=
bool operator!=(const iterator &other) const
Definition: test_table.cc:139
upb::TypedIntTable::iterator::operator==
bool operator==(const iterator &other) const
Definition: test_table.cc:337
table
uint8_t table[256]
Definition: hpack_parser.cc:456
iter
Definition: test_winkernel.cpp:47
UPB_CTYPE_CONSTPTR
@ UPB_CTYPE_CONSTPTR
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:675
upb_strtable_iter
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:1086
regress.m
m
Definition: regress/regress.py:25
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
upb::IntTable::arena_
upb::Arena arena_
Definition: test_table.cc:145
UPB_CTYPE_UINT64
@ UPB_CTYPE_UINT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:671
upb_strtable_insert
UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key, upb_value val)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:953
upb_inttable_iter_setdone
void upb_inttable_iter_setdone(upb_inttable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1981
upb::IntTable::iterator::operator==
bool operator==(const iterator &other) const
Definition: test_table.cc:135
upb::TypedStrTable::iterator
Definition: test_table.cc:246
upb::StrTable::Lookup
std::pair< bool, upb_value > Lookup(const std::string &key) const
Definition: test_table.cc:167
upb_strtable_count
UPB_INLINE size_t upb_strtable_count(const upb_strtable *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:919
upb::TypedIntTable::iterator::operator!=
bool operator!=(const iterator &other) const
Definition: test_table.cc:341
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
upb::TypedStrTable::Resize
void Resize(size_t size_lg2)
Definition: test_table.cc:244
upb::IntTable::iterator
Definition: test_table.cc:113


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:33