mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 14:15:17 +00:00
bulk code format fix (#8707)
This commit is contained in:
@@ -37,9 +37,9 @@ extern int testing_fails;
|
||||
|
||||
// Listener of TestFail, like 'gtest::OnTestPartResult' event handler.
|
||||
// Called in TestFail after a failed assertion.
|
||||
typedef bool (*TestFailEventListener)(const char *expval, const char *val,
|
||||
const char *exp, const char *file,
|
||||
int line, const char *func);
|
||||
typedef bool (*TestFailEventListener)(const char* expval, const char* val,
|
||||
const char* exp, const char* file,
|
||||
int line, const char* func);
|
||||
|
||||
// Prepare test engine (MSVC assertion setup, etc).
|
||||
// listener - this function will be notified on each TestFail call.
|
||||
@@ -52,11 +52,11 @@ void InitTestEngine(TestFailEventListener listener = nullptr);
|
||||
int CloseTestEngine(bool force_report = false);
|
||||
|
||||
// Write captured state to a log and terminate test run.
|
||||
void TestFail(const char *expval, const char *val, const char *exp,
|
||||
const char *file, int line, const char *func = nullptr);
|
||||
void TestFail(const char* expval, const char* val, const char* exp,
|
||||
const char* file, int line, const char* func = nullptr);
|
||||
|
||||
void TestEqStr(const char *expval, const char *val, const char *exp,
|
||||
const char *file, int line, const char *func = nullptr);
|
||||
void TestEqStr(const char* expval, const char* val, const char* exp,
|
||||
const char* file, int line, const char* func = nullptr);
|
||||
|
||||
// Workaround for `enum class` printing.
|
||||
// There is an issue with the printing of enums with a fixed underlying type.
|
||||
@@ -66,14 +66,15 @@ void TestEqStr(const char *expval, const char *val, const char *exp,
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1601
|
||||
// https://stackoverflow.com/questions/34336024/ambiguous-overload-when-writing-an-enum-with-an-enum-base-but-only-with-clang
|
||||
|
||||
template<typename T, bool is_enum_type = flatbuffers::is_enum<T>::value>
|
||||
template <typename T, bool is_enum_type = flatbuffers::is_enum<T>::value>
|
||||
struct underlying_of_scalar {
|
||||
static_assert(flatbuffers::is_scalar<T>::value, "invalid type T");
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<typename T> struct underlying_of_scalar<T, true> {
|
||||
// clang-format off
|
||||
template <typename T>
|
||||
struct underlying_of_scalar<T, true> {
|
||||
// clang-format off
|
||||
// There are old compilers without full C++11 support (see stl_emulation.h).
|
||||
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
||||
using type = typename std::underlying_type<T>::type;
|
||||
@@ -83,14 +84,14 @@ template<typename T> struct underlying_of_scalar<T, true> {
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
typename underlying_of_scalar<T>::type scalar_as_underlying(T v) {
|
||||
return static_cast<typename underlying_of_scalar<T>::type>(v);
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
void TestEq(T expval, U val, const char *exp, const char *file, int line,
|
||||
const char *func) {
|
||||
template <typename T, typename U>
|
||||
void TestEq(T expval, U val, const char* exp, const char* file, int line,
|
||||
const char* func) {
|
||||
if (static_cast<U>(expval) != val) {
|
||||
TestFail(flatbuffers::NumToString(scalar_as_underlying(expval)).c_str(),
|
||||
flatbuffers::NumToString(scalar_as_underlying(val)).c_str(), exp,
|
||||
@@ -98,19 +99,19 @@ void TestEq(T expval, U val, const char *exp, const char *file, int line,
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
template <>
|
||||
inline void TestEq<std::string, std::string>(std::string expval,
|
||||
std::string val, const char *exp,
|
||||
const char *file, int line,
|
||||
const char *func) {
|
||||
std::string val, const char* exp,
|
||||
const char* file, int line,
|
||||
const char* func) {
|
||||
if (expval != val) {
|
||||
TestFail(expval.c_str(), val.c_str(), exp, file, line, func);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
void TestNe(T expval, U val, const char *exp, const char *file, int line,
|
||||
const char *func) {
|
||||
template <typename T, typename U>
|
||||
void TestNe(T expval, U val, const char* exp, const char* file, int line,
|
||||
const char* func) {
|
||||
if (static_cast<U>(expval) == val) {
|
||||
TestFail(flatbuffers::NumToString(scalar_as_underlying(expval)).c_str(),
|
||||
flatbuffers::NumToString(scalar_as_underlying(val)).c_str(), exp,
|
||||
@@ -118,11 +119,11 @@ void TestNe(T expval, U val, const char *exp, const char *file, int line,
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
template <>
|
||||
inline void TestNe<std::string, std::string>(std::string expval,
|
||||
std::string val, const char *exp,
|
||||
const char *file, int line,
|
||||
const char *func) {
|
||||
std::string val, const char* exp,
|
||||
const char* file, int line,
|
||||
const char* func) {
|
||||
if (expval == val) {
|
||||
TestFail(expval.c_str(), val.c_str(), exp, file, line, func);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user