diff options
author | Josh Haberman <jhaberman@gmail.com> | 2013-10-24 12:43:19 -0700 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2013-10-24 12:43:19 -0700 |
commit | 26d98ca94f2f049e8767b4a9a33d185a3d7ea0fd (patch) | |
tree | 340bcf495f06ed05c9f3fb423f210caf4edce2b1 /tests/test_table.cc | |
parent | 61109fca1f967771c21dc7184aee35f3b439c577 (diff) |
Merge from Google-internal development:
- rewritten decoder; interpreted decoder is bytecode-based,
JIT decoder no longer falls back to the interpreter.
- C++ improvements: C++11-compatible iterators, upb::reffed_ptr
for RAII refcounting, better upcast/downcast support.
- removed the gross upb_value abstraction from public upb.h.
Diffstat (limited to 'tests/test_table.cc')
-rw-r--r-- | tests/test_table.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/test_table.cc b/tests/test_table.cc index 80b0139..747a97b 100644 --- a/tests/test_table.cc +++ b/tests/test_table.cc @@ -6,6 +6,7 @@ * Tests for upb_table. */ +#include <limits.h> #include <string.h> #include <sys/resource.h> #include <ext/hash_map> @@ -16,7 +17,7 @@ #include <vector> #include "tests/test_util.h" #include "tests/upb_test.h" -#include "upb/table.h" +#include "upb/table.int.h" bool benchmark = false; #define CPU_TIME_PER_TEST 0.5 @@ -126,6 +127,19 @@ void test_inttable(int32_t *keys, uint16_t num_entries, const char *desc) { } } + // Test replace. + for(uint32_t i = 0; i <= largest_key; i++) { + upb_value v = upb_value_uint32(i*3); + bool replaced = upb_inttable_replace(&table, i, v); + if(m.find(i) != m.end()) { /* Assume map implementation is correct. */ + ASSERT(replaced); + m[i] = i * 3; + hm[i] = i * 3; + } else { + ASSERT(!replaced); + } + } + // Compact and test correctness again. upb_inttable_compact(&table); for(uint32_t i = 0; i <= largest_key; i++) { @@ -133,9 +147,9 @@ void test_inttable(int32_t *keys, uint16_t num_entries, const char *desc) { bool found = upb_inttable_lookup(&table, i, &v); if(m.find(i) != m.end()) { /* Assume map implementation is correct. */ ASSERT(found); - ASSERT(upb_value_getuint32(v) == i*2); - ASSERT(m[i] == i*2); - ASSERT(hm[i] == i*2); + ASSERT(upb_value_getuint32(v) == i*3); + ASSERT(m[i] == i*3); + ASSERT(hm[i] == i*3); } else { ASSERT(!found); } |