summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2019-03-27 15:32:05 -0700
committerGitHub <noreply@github.com>2019-03-27 15:32:05 -0700
commitcf35baa1ad70f0dca734f93bcc2b54d8d059bcdd (patch)
tree3c9881fcceaba1dbb5f04fe01ddc5f2dc5c647d1 /tests
parent928ef7f2c02f18d9945dd750884dffbdebef1b98 (diff)
Moved macros from upb.h to port_def.inc to avoid leaking them to users. (#160)
* Use port_def.inc to prevent macros from leaking to users. * Added helpful comments to port_def.inc/port_undef.inc.
Diffstat (limited to 'tests')
-rw-r--r--tests/conformance_upb.c4
-rw-r--r--tests/json/test_json.cc2
-rw-r--r--tests/pb/test_decoder.cc2
-rw-r--r--tests/pb/test_encoder.cc2
-rw-r--r--tests/pb/test_varint.c2
-rw-r--r--tests/test_cpp.cc2
-rw-r--r--tests/test_table.cc11
-rw-r--r--tests/test_util.h6
8 files changed, 24 insertions, 7 deletions
diff --git a/tests/conformance_upb.c b/tests/conformance_upb.c
index a0526d7..782346f 100644
--- a/tests/conformance_upb.c
+++ b/tests/conformance_upb.c
@@ -50,6 +50,8 @@ void DoTest(
const conformance_ConformanceRequest* request,
conformance_ConformanceResponse *response,
upb_arena *arena) {
+ protobuf_test_messages_proto3_TestAllTypesProto3 *test_message;
+
if (!strview_eql(conformance_ConformanceRequest_message_type(request),
proto3_msg)) {
static const char msg[] = "Only proto3 for now.";
@@ -58,8 +60,6 @@ void DoTest(
return;
}
- protobuf_test_messages_proto3_TestAllTypesProto3 *test_message;
-
switch (conformance_ConformanceRequest_payload_case(request)) {
case conformance_ConformanceRequest_payload_protobuf_payload: {
upb_strview payload = conformance_ConformanceRequest_protobuf_payload(request);
diff --git a/tests/json/test_json.cc b/tests/json/test_json.cc
index 3dc4a6c..3fddfb6 100644
--- a/tests/json/test_json.cc
+++ b/tests/json/test_json.cc
@@ -13,6 +13,8 @@
#include <string>
+#include "upb/port_def.inc"
+
// Macros for readability in test case list: allows us to give TEST("...") /
// EXPECT("...") pairs.
#define TEST(x) x
diff --git a/tests/pb/test_decoder.cc b/tests/pb/test_decoder.cc
index 7450445..fb69541 100644
--- a/tests/pb/test_decoder.cc
+++ b/tests/pb/test_decoder.cc
@@ -47,6 +47,8 @@
#include "upb/upb.h"
#endif // !AMALGAMATED
+#include "upb/port_def.inc"
+
#undef PRINT_FAILURE
#define PRINT_FAILURE(expr) \
fprintf(stderr, "Assertion failed: %s:%d\n", __FILE__, __LINE__); \
diff --git a/tests/pb/test_encoder.cc b/tests/pb/test_encoder.cc
index aa33370..3039767 100644
--- a/tests/pb/test_encoder.cc
+++ b/tests/pb/test_encoder.cc
@@ -6,6 +6,8 @@
#include "upb/pb/decoder.h"
#include "upb/pb/encoder.h"
+#include "upb/port_def.inc"
+
std::string read_string(const char *filename) {
size_t len;
char *str = upb_readfile(filename, &len);
diff --git a/tests/pb/test_varint.c b/tests/pb/test_varint.c
index 7b2fe41..ebee282 100644
--- a/tests/pb/test_varint.c
+++ b/tests/pb/test_varint.c
@@ -3,6 +3,8 @@
#include "upb/pb/varint.int.h"
#include "tests/upb_test.h"
+#include "upb/port_def.inc"
+
/* Test that we can round-trip from int->varint->int. */
static void test_varint_for_num(upb_decoderet (*decoder)(const char*),
uint64_t num) {
diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc
index ed8e9c4..8feb6e2 100644
--- a/tests/test_cpp.cc
+++ b/tests/test_cpp.cc
@@ -19,6 +19,8 @@
#include "upb/upb.h"
#include "upb_test.h"
+#include "upb/port_def.inc"
+
template <class T>
void AssertInsert(T* const container, const typename T::value_type& val) {
bool inserted = container->insert(val).second;
diff --git a/tests/test_table.cc b/tests/test_table.cc
index 96a5387..063eb68 100644
--- a/tests/test_table.cc
+++ b/tests/test_table.cc
@@ -6,15 +6,18 @@
#include <limits.h>
#include <string.h>
#include <sys/resource.h>
-#include <ext/hash_map>
#include <iostream>
#include <map>
#include <set>
#include <string>
+#include <unordered_map>
#include <vector>
+
#include "tests/upb_test.h"
#include "upb/table.int.h"
+#include "upb/port_def.inc"
+
// Convenience interface for C++. We don't put this in upb itself because
// the table is not exposed to users.
@@ -397,7 +400,7 @@ void test_inttable(int32_t *keys, uint16_t num_entries, const char *desc) {
Table table;
uint32_t largest_key = 0;
std::map<uint32_t, uint32_t> m;
- __gnu_cxx::hash_map<uint32_t, uint32_t> hm;
+ std::unordered_map<uint32_t, uint32_t> hm;
for(size_t i = 0; i < num_entries; i++) {
int32_t key = keys[i];
largest_key = UPB_MAX((int32_t)largest_key, key);
@@ -546,7 +549,7 @@ void test_inttable(int32_t *keys, uint16_t num_entries, const char *desc) {
total = get_usertime() - before;
printf("%ld/s (%0.1f%% of upb)\n", (long)(i/total), i / upb_rand_i);
- printf("__gnu_cxx::hash_map<uint32_t, uint32_t>(seq): ");
+ printf("std::unordered_map<uint32_t, uint32_t>(seq): ");
fflush(stdout);
before = get_usertime();
for(i = 0; true; i++) {
@@ -557,7 +560,7 @@ void test_inttable(int32_t *keys, uint16_t num_entries, const char *desc) {
total = get_usertime() - before;
printf("%ld/s (%0.1f%% of upb)\n", (long)(i/total), i / upb_seq_i);
- printf("__gnu_cxx::hash_map<uint32_t, uint32_t>(rand): ");
+ printf("std::unordered_map<uint32_t, uint32_t>(rand): ");
fflush(stdout);
before = get_usertime();
for(i = 0; true; i++) {
diff --git a/tests/test_util.h b/tests/test_util.h
index 680673d..4854100 100644
--- a/tests/test_util.h
+++ b/tests/test_util.h
@@ -10,6 +10,8 @@
#include "tests/upb_test.h"
#include "upb/sink.h"
+#include "upb/port_def.inc"
+
#ifdef __cplusplus
upb_bufhandle global_handle;
@@ -223,4 +225,6 @@ error:
return NULL;
}
-#endif
+#include "upb/port_undef.inc"
+
+#endif /* UPB_TEST_UTIL_H_ */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback