Go to the documentation of this file.
32 #include <sys/resource.h>
38 #include <unordered_map>
41 #include "gtest/gtest.h"
46 #include "upb/port_def.inc"
58 #define FUNCS(name, type_t, enumval) \
60 upb_value MakeUpbValue<type_t>(type_t val) { \
61 return upb_value_##name(val); \
64 type_t GetUpbValue<type_t>(upb_value val) { \
65 return upb_value_get##name(val); \
94 std::pair<bool, upb_value>
ret;
100 std::pair<bool, upb_value>
ret;
106 std::pair<bool, upb_value>
ret;
114 std::pair<uintptr_t, upb_value> > {
129 std::pair<uintptr_t, upb_value>
ret;
161 std::pair<bool, upb_value>
ret;
168 std::pair<bool, upb_value>
ret;
179 std::pair<std::string, upb_value> > {
194 std::pair<std::string, upb_value>
ret;
226 std::pair<bool, T>
ret;
229 ret.second = GetUpbValue<T>(
found.second);
236 std::pair<bool, T>
ret;
239 ret.second = GetUpbValue<T>(
found.second);
247 std::pair<std::string, T> > {
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);
299 std::pair<bool, T>
ret;
302 ret.second = GetUpbValue<T>(
found.second);
309 std::pair<bool, T>
ret;
312 ret.second = GetUpbValue<T>(
found.second);
320 std::pair<uintptr_t, T> > {
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);
357 #define CPU_TIME_PER_TEST 0.5
363 getrusage(RUSAGE_SELF, &
usage);
364 return usage.ru_utime.tv_sec + (
usage.ru_utime.tv_usec / 1000000.0);
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");
389 std::map<std::string, int32_t>
m;
392 std::set<std::string>
all;
402 if (
m.find(
key) !=
m.end()) {
420 for (
int i = 0;
i < 10;
i++) {
427 int new_lg2 =
table.table_.table_.t.size_lg2 + 1;
429 new_lg2 =
UPB_MIN(new_lg2, 16);
430 table.Resize(new_lg2);
446 keys_.push_back(10101 +
i);
460 std::map<uint32_t, uint32_t>
m;
461 std::unordered_map<uint32_t, uint32_t> hm;
462 for (
const auto&
key : keys_) {
472 if (
m.find(
i) !=
m.end()) {
482 for (
size_t i = 0;
i < keys_.size();
i += 2) {
483 std::pair<bool, uint32_t>
found =
table.Remove(keys_[
i]);
497 if (
m.find(
i) !=
m.end()) {
509 bool replaced =
table.Replace(
i,
i * 3);
510 if (
m.find(
i) !=
m.end()) {
523 if (
m.find(
i) !=
m.end()) {
573 for (
int i = 0;
i < 2048;
i++) {
#define EXPECT_FALSE(condition)
UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val)
std::pair< bool, T > Lookup(const std::string &key) const
static iterator end(StrTable *table)
void Resize(size_t size_lg2)
UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype)
bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a)
std::pair< uintptr_t, T > operator*() const
static iterator end(TypedStrTable *table)
static iterator end(IntTable *table)
std::pair< std::string, T > operator*() const
bool Insert(const std::string &key, T val)
bool upb_inttable_iter_isequal(const upb_inttable_iter *i1, const upb_inttable_iter *i2)
std::pair< bool, T > Remove(const std::string &key)
std::pair< bool, upb_value > Lookup32(uint32_t key) const
static int Init(CMessage *self, PyObject *args, PyObject *kwargs)
iterator(TypedStrTable *table)
bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, upb_value *v)
bool Insert(const std::string &key, upb_value val)
iterator(TypedIntTable *table)
const typedef MCPhysReg * iterator
const char * upb_strtable_iter_key(const upb_strtable_iter *i)
#define T(upbtypeconst, upbtype, ctype, default_value)
grpc_core::ScopedArenaPtr arena
bool Replace(uintptr_t key, T val)
std::pair< bool, T > Lookup(uintptr_t key) const
iterator(IntTable *table)
UPB_INLINE void upb_inttable_compact(upb_inttable *t)
bool Insert(uintptr_t key, T val)
void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t)
T GetUpbValue(upb_value val)
bool Insert(uintptr_t key, upb_value val)
#define EXPECT_NE(val1, val2)
uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i)
std::pair< bool, upb_value > Lookup(uintptr_t key) const
bool upb_inttable_done(const upb_inttable_iter *i)
UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype)
unsigned __int64 uint64_t
void upb_inttable_next(upb_inttable_iter *iter)
void upb_strtable_next(upb_strtable_iter *i)
INSTANTIATE_TEST_SUITE_P(IntTableParams, IntTableTest, testing::Values(8, 64, 512, -32))
_W64 unsigned int uintptr_t
std::pair< bool, T > Remove(uintptr_t key)
upb_value MakeUpbValue(T val)
static iterator end(TypedIntTable *table)
bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val)
size_t upb_inttable_count(const upb_inttable *t)
void upb_inttable_begin(upb_inttable_iter *i, const upb_inttable *t)
std::vector< int32_t > keys_
bool operator==(const iterator &other) const
#define FUNCS(name, type_t, enumval)
bool operator!=(const iterator &other) const
iterator(StrTable *table)
internal::ValueArray< T... > Values(T... v)
std::pair< uintptr_t, upb_value > operator*() const
UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len, upb_value *val)
bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v)
bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val)
bool Replace(uintptr_t key, upb_value val)
UniquePtr< SSL_SESSION > ret
std::pair< bool, upb_value > Remove(uintptr_t key)
void upb_strtable_iter_setdone(upb_strtable_iter *i)
#define ASSERT_TRUE(condition)
static const ParamType & GetParam()
bool operator!=(const iterator &other) const
bool operator==(const iterator &other) const
bool upb_strtable_iter_isequal(const upb_strtable_iter *i1, const upb_strtable_iter *i2)
upb_value upb_strtable_iter_value(const upb_strtable_iter *i)
std::pair< bool, upb_value > Remove(const std::string &key)
upb_value upb_inttable_iter_value(const upb_inttable_iter *i)
#define EXPECT_TRUE(condition)
std::pair< std::string, upb_value > operator*() const
TEST_P(IntTableTest, TestIntTable)
bool operator!=(const iterator &other) const
bool operator==(const iterator &other) const
UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key, upb_value val)
void upb_inttable_iter_setdone(upb_inttable_iter *i)
bool operator==(const iterator &other) const
std::pair< bool, upb_value > Lookup(const std::string &key) const
UPB_INLINE size_t upb_strtable_count(const upb_strtable *t)
bool operator!=(const iterator &other) const
void Resize(size_t size_lg2)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:33