Move rtc_json code from API dir, enable unit test, unmark testonly
This change does three things:
- Move rtc_json into rtc_base/strings/, a non-API directory more fitting to
its purpose.
- Make a target for the currently unused json_unittest.
- Make the code available for use in non-test code again.
Bug: webrtc:9802
Change-Id: Id964a8a4b47b732a962a364894a4dbd3e7f4650f
Reviewed-on: https://webrtc-review.googlesource.com/103126
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24932}
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 8dc98b6..e9efbd1 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -683,11 +683,10 @@
}
rtc_source_set("rtc_json") {
- testonly = true
defines = []
sources = [
- "json.cc",
- "json.h",
+ "strings/json.cc",
+ "strings/json.h",
]
deps = [
":stringutils",
@@ -1264,6 +1263,20 @@
]
}
+ rtc_source_set("rtc_json_unittests") {
+ testonly = true
+
+ sources = [
+ "strings/json_unittest.cc",
+ ]
+ deps = [
+ ":rtc_base_tests_main",
+ ":rtc_base_tests_utils",
+ ":rtc_json",
+ "../test:test_support",
+ ]
+ }
+
rtc_source_set("rtc_base_unittests") {
testonly = true
defines = []
diff --git a/rtc_base/json.cc b/rtc_base/strings/json.cc
similarity index 99%
rename from rtc_base/json.cc
rename to rtc_base/strings/json.cc
index f7716ab..efcb97a 100644
--- a/rtc_base/json.cc
+++ b/rtc_base/strings/json.cc
@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "rtc_base/json.h"
+#include "rtc_base/strings/json.h"
#include <errno.h>
#include <limits.h>
diff --git a/rtc_base/json.h b/rtc_base/strings/json.h
similarity index 96%
rename from rtc_base/json.h
rename to rtc_base/strings/json.h
index b8e6d95..0cb9542 100644
--- a/rtc_base/json.h
+++ b/rtc_base/strings/json.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef RTC_BASE_JSON_H_
-#define RTC_BASE_JSON_H_
+#ifndef RTC_BASE_STRINGS_JSON_H_
+#define RTC_BASE_STRINGS_JSON_H_
#include <string>
#include <vector>
@@ -85,4 +85,4 @@
} // namespace rtc
-#endif // RTC_BASE_JSON_H_
+#endif // RTC_BASE_STRINGS_JSON_H_
diff --git a/rtc_base/json_unittest.cc b/rtc_base/strings/json_unittest.cc
similarity index 98%
rename from rtc_base/json_unittest.cc
rename to rtc_base/strings/json_unittest.cc
index 17b126a..2215769 100644
--- a/rtc_base/json_unittest.cc
+++ b/rtc_base/strings/json_unittest.cc
@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "rtc_base/json.h"
+#include "rtc_base/strings/json.h"
#include <vector>
@@ -88,7 +88,7 @@
EXPECT_TRUE(GetUIntFromJson(big_u, &out));
EXPECT_EQ(0xFFFFFFFFU, out);
EXPECT_FALSE(GetUIntFromJson(in_s, &out));
- // TODO: Fail reading negative strings.
+ // TODO(bugs.webrtc.org/9804): Fail reading negative strings.
// EXPECT_FALSE(GetUIntFromJson(in_si, &out));
EXPECT_FALSE(GetUIntFromJson(in_i, &out));
EXPECT_FALSE(GetUIntFromJson(big_sn, &out));