Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed May 22, 2024
1 parent f0a6d38 commit 0ddfefa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/struct_pb/tests/unittest_proto3.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include <ylt/struct_pb.hpp>
#include "unittest_proto3.pb.h"
#if defined(STRUCT_PB_WITH_PROTO)
#include "data_def.pb.h"
#include "unittest_proto3.pb.h"
#endif

#define PUBLIC : iguana::pb_base

Expand Down Expand Up @@ -270,6 +272,7 @@ inline stpb::Monster create_sp_monster() {
return m;
}

#if defined(STRUCT_PB_WITH_PROTO)
void SetBaseTypeMsg(const stpb::BaseTypeMsg& st, pb::BaseTypeMsg& msg) {
msg.set_optional_int32(st.optional_int32);
msg.set_optional_int64(st.optional_int64);
Expand All @@ -292,7 +295,7 @@ void CheckBaseTypeMsg(const stpb::BaseTypeMsg& st, const pb::BaseTypeMsg& msg) {
CHECK(st.optional_bool == msg.optional_bool());
CHECK(st.optional_string == msg.optional_string());
CHECK(static_cast<int32_t>(st.optional_enum) ==
static_cast<int32_t>(msg.optional_enum()));
static_cast<int32_t>(msg.optional_enum()));
}

void SetIguanaTypeMsg(const stpb::IguanaTypeMsg& st, pb::IguanaTypeMsg& msg) {
Expand Down Expand Up @@ -367,7 +370,7 @@ void CheckRepeatBaseTypeMsg(const stpb::RepeatBaseTypeMsg& st,
}
for (size_t i = 0; i < st.repeated_enum.size(); ++i) {
CHECK(static_cast<int>(st.repeated_enum[i]) ==
static_cast<int>(msg.repeated_enum(i)));
static_cast<int>(msg.repeated_enum(i)));
}
}

Expand Down Expand Up @@ -451,8 +454,7 @@ void CheckNestedMsg(const stpb::NestedMsg& st, const pb::NestedMsg& msg) {
CheckIguanaTypeMsg(st.repeat_iguna_msg[i], msg.repeat_iguna_msg(i));
}

CHECK(st.repeat_repeat_base_msg.size() ==
msg.repeat_repeat_base_msg_size());
CHECK(st.repeat_repeat_base_msg.size() == msg.repeat_repeat_base_msg_size());
for (size_t i = 0; i < st.repeat_repeat_base_msg.size(); ++i) {
CheckRepeatBaseTypeMsg(st.repeat_repeat_base_msg[i],
msg.repeat_repeat_base_msg(i));
Expand Down Expand Up @@ -484,15 +486,15 @@ void CheckMapMsg(const stpb::MapMsg& st, const pb::MapMsg& msg) {
CHECK(it->second == pair.second);
}
CHECK(msg.str_iguana_type_msg_map_size() ==
st.str_iguana_type_msg_map.size());
st.str_iguana_type_msg_map.size());
for (const auto& pair : st.str_iguana_type_msg_map) {
auto it = msg.str_iguana_type_msg_map().find(pair.first);
CHECK(it != msg.str_iguana_type_msg_map().end());
CheckIguanaTypeMsg(pair.second, it->second);
}

CHECK(msg.int_repeat_base_msg_map_size() ==
st.int_repeat_base_msg_map.size());
st.int_repeat_base_msg_map.size());
for (const auto& pair : st.int_repeat_base_msg_map) {
auto it = msg.int_repeat_base_msg_map().find(pair.first);
CHECK(it != msg.int_repeat_base_msg_map().end());
Expand Down Expand Up @@ -571,6 +573,7 @@ void CheckNestOneofMsg(const stpb::NestOneofMsg& st,
},
st.nest_one_of_msg);
}
#endif

inline void print_hex_str(const std::string& str) {
std::ostringstream oss;
Expand Down

0 comments on commit 0ddfefa

Please sign in to comment.