summaryrefslogtreecommitdiff
path: root/libjsonpb/verify/include
diff options
context:
space:
mode:
authorThiƩbaud Weksteen <tweek@google.com>2020-10-26 15:44:13 +0100
committerThiƩbaud Weksteen <tweek@google.com>2020-10-26 15:54:14 +0100
commitf5397480a691df4997c9b12400957874df7dc460 (patch)
tree6f0c652eaed9c821dd1656ecce4ebca04c99cec2 /libjsonpb/verify/include
parent7ebc9e6cd61d5b167ccccbea85f42387370f51a7 (diff)
downloadextras-f5397480a691df4997c9b12400957874df7dc460.tar.gz
libjsonpb: format files
Format *.cpp according to the new .clang-format-2. The following command was used to generate this change: $ find . \( -name \*.cpp -o -name \*.h \) -exec clang-format \ --style=file -i {} \; Test: mm Bug: 171699326 Change-Id: I7f1199fd8a3431500484f7373ccb5f1583a00956
Diffstat (limited to 'libjsonpb/verify/include')
-rw-r--r--libjsonpb/verify/include/jsonpb/json_schema_test.h29
-rw-r--r--libjsonpb/verify/include/jsonpb/verify.h11
2 files changed, 13 insertions, 27 deletions
diff --git a/libjsonpb/verify/include/jsonpb/json_schema_test.h b/libjsonpb/verify/include/jsonpb/json_schema_test.h
index 3db19310..6fa834b2 100644
--- a/libjsonpb/verify/include/jsonpb/json_schema_test.h
+++ b/libjsonpb/verify/include/jsonpb/json_schema_test.h
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
#pragma once
#include <unistd.h>
@@ -46,12 +45,9 @@ class JsonSchemaTestConfig {
/**
* If it returns true, tests are skipped when the file is not found.
*/
- virtual bool optional() const {
- return false;
- }
+ virtual bool optional() const { return false; }
};
-using JsonSchemaTestConfigFactory =
- std::function<std::unique_ptr<JsonSchemaTestConfig>()>;
+using JsonSchemaTestConfigFactory = std::function<std::unique_ptr<JsonSchemaTestConfig>()>;
template <typename T>
class AbstractJsonSchemaTestConfig : public JsonSchemaTestConfig {
@@ -68,22 +64,18 @@ class AbstractJsonSchemaTestConfig : public JsonSchemaTestConfig {
template <typename T>
JsonSchemaTestConfigFactory MakeTestParam(const std::string& path) {
- return [path]() {
- return std::make_unique<AbstractJsonSchemaTestConfig<T>>(path);
- };
+ return [path]() { return std::make_unique<AbstractJsonSchemaTestConfig<T>>(path); };
}
-class JsonSchemaTest
- : public ::testing::TestWithParam<JsonSchemaTestConfigFactory> {
+class JsonSchemaTest : public ::testing::TestWithParam<JsonSchemaTestConfigFactory> {
public:
void SetUp() override {
- auto&& config =
- ::testing::TestWithParam<JsonSchemaTestConfigFactory>::GetParam()();
+ auto&& config = ::testing::TestWithParam<JsonSchemaTestConfigFactory>::GetParam()();
file_path_ = config->file_path();
if (access(file_path_.c_str(), F_OK) == -1) {
- ASSERT_EQ(ENOENT, errno) << "File '" << file_path_ << "' is not accessible: "
- << strerror(errno);
+ ASSERT_EQ(ENOENT, errno) << "File '" << file_path_
+ << "' is not accessible: " << strerror(errno);
ASSERT_TRUE(config->optional()) << "Missing mandatory file " << file_path_;
GTEST_SKIP();
}
@@ -92,12 +84,9 @@ class JsonSchemaTest
object_ = config->CreateMessage();
auto res = internal::JsonStringToMessage(json_, object_.get());
- ASSERT_TRUE(res.ok()) << "Invalid format of file " << file_path_
- << ": " << res.error();
- }
- google::protobuf::Message* message() const {
- return object_.get();
+ ASSERT_TRUE(res.ok()) << "Invalid format of file " << file_path_ << ": " << res.error();
}
+ google::protobuf::Message* message() const { return object_.get(); }
std::string file_path_;
std::string json_;
std::unique_ptr<google::protobuf::Message> object_;
diff --git a/libjsonpb/verify/include/jsonpb/verify.h b/libjsonpb/verify/include/jsonpb/verify.h
index c05b13d2..bb247e7e 100644
--- a/libjsonpb/verify/include/jsonpb/verify.h
+++ b/libjsonpb/verify/include/jsonpb/verify.h
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
#pragma once
#include <sstream>
@@ -64,8 +63,8 @@ namespace jsonpb {
// path: path to navigate inside JSON tree. For example, {"foo", "bar"} for
// the value "string" in
// {"foo": {"bar" : "string"}}
-bool AllFieldsAreKnown(const google::protobuf::Message& message,
- const std::string& json, std::string* error);
+bool AllFieldsAreKnown(const google::protobuf::Message& message, const std::string& json,
+ std::string* error);
// Format the given JSON string according to Prototype T. This will serialize
// the JSON string to a Prototype message, then re-print the message as JSON. By
@@ -78,14 +77,12 @@ bool AllFieldsAreKnown(const google::protobuf::Message& message,
// scratch_space: The scratch space to use to store the Protobuf message. It
// must be a pointer
// to the schema that the JSON string conforms to.
-bool EqReformattedJson(const std::string& json,
- google::protobuf::Message* scratch_space,
+bool EqReformattedJson(const std::string& json, google::protobuf::Message* scratch_space,
std::string* error);
namespace internal {
// See EqReformattedJson().
-ErrorOr<std::string> FormatJson(const std::string& json,
- google::protobuf::Message* scratch_space);
+ErrorOr<std::string> FormatJson(const std::string& json, google::protobuf::Message* scratch_space);
} // namespace internal