mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Restyle sources
This commit is contained in:
@@ -17,7 +17,7 @@ class empty_base_optimization_test
|
||||
: public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
template <class T>
|
||||
template<class T>
|
||||
class test1
|
||||
: private empty_base_optimization<T>
|
||||
{
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
T const& member() const {return Base::member();}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
template<class T>
|
||||
class test2
|
||||
{
|
||||
void* m_p;
|
||||
@@ -53,34 +53,34 @@ public:
|
||||
|
||||
static
|
||||
bool
|
||||
test_one ()
|
||||
test_one()
|
||||
{
|
||||
test1<int> t1(1);
|
||||
test2<int> t2(2);
|
||||
static_assert(sizeof(t1) == sizeof(t2), "don't optimize for int");
|
||||
if (t1.member() != 1)
|
||||
if(t1.member() != 1)
|
||||
return false;
|
||||
if (t2.member() != 2)
|
||||
if(t2.member() != 2)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
test_two ()
|
||||
test_two()
|
||||
{
|
||||
test1<Empty> t1((Empty()));
|
||||
test2<Empty> t2((Empty()));
|
||||
static_assert(sizeof(t1) < sizeof(t2), "do optimize for Empty");
|
||||
if (t1.member() != true)
|
||||
if(t1.member() != true)
|
||||
return false;
|
||||
if (t2.member() != true)
|
||||
if(t2.member() != true)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
run ()
|
||||
run()
|
||||
{
|
||||
BEAST_EXPECT(test_one());
|
||||
BEAST_EXPECT(test_two());
|
||||
|
||||
@@ -30,7 +30,7 @@ escaped_string(boost::string_ref const& s)
|
||||
out.append("\\r");
|
||||
else if(*p == '\n')
|
||||
out.append("\\n");
|
||||
else if (*p == '\t')
|
||||
else if(*p == '\t')
|
||||
out.append("\\t");
|
||||
else
|
||||
out.append(p, 1);
|
||||
|
||||
@@ -223,7 +223,7 @@ private:
|
||||
template<class T, class R =
|
||||
decltype(std::declval<T>().on_start(), std::true_type{})>
|
||||
static R check(int);
|
||||
template <class>
|
||||
template<class>
|
||||
static std::false_type check(...);
|
||||
using type = decltype(check<C>(0));
|
||||
public:
|
||||
@@ -253,7 +253,7 @@ private:
|
||||
std::declval<std::string const&>()),
|
||||
std::true_type{})>
|
||||
static R check(int);
|
||||
template <class>
|
||||
template<class>
|
||||
static std::false_type check(...);
|
||||
using type = decltype(check<C>(0));
|
||||
public:
|
||||
@@ -283,7 +283,7 @@ private:
|
||||
decltype(std::declval<T>().on_headers_complete(
|
||||
std::declval<error_code&>()), std::true_type{})>
|
||||
static R check(int);
|
||||
template <class>
|
||||
template<class>
|
||||
static std::false_type check(...);
|
||||
using type = decltype(check<C>(0));
|
||||
public:
|
||||
@@ -314,7 +314,7 @@ private:
|
||||
std::declval<bool>(), std::declval<bool>()),
|
||||
std::true_type{})>
|
||||
static R check(int);
|
||||
template <class>
|
||||
template<class>
|
||||
static std::false_type check(...);
|
||||
using type = decltype(check<C>(0));
|
||||
public:
|
||||
@@ -349,7 +349,7 @@ private:
|
||||
std::declval<bool>(), std::declval<bool>()),
|
||||
std::true_type{})>
|
||||
static R check(int);
|
||||
template <class>
|
||||
template<class>
|
||||
static std::false_type check(...);
|
||||
#if 0
|
||||
using type = decltype(check<C>(0));
|
||||
@@ -389,7 +389,7 @@ private:
|
||||
std::declval<void const*>(), std::declval<std::size_t>(),
|
||||
std::declval<error_code&>()), std::true_type{})>
|
||||
static R check(int);
|
||||
template <class>
|
||||
template<class>
|
||||
static std::false_type check(...);
|
||||
using type = decltype(check<C>(0));
|
||||
public:
|
||||
@@ -418,7 +418,7 @@ private:
|
||||
template<class T, class R =
|
||||
decltype(std::declval<T>().on_complete(), std::true_type{})>
|
||||
static R check(int);
|
||||
template <class>
|
||||
template<class>
|
||||
static std::false_type check(...);
|
||||
using type = decltype(check<C>(0));
|
||||
public:
|
||||
@@ -488,7 +488,7 @@ nodejs_basic_parser<Derived>::write(
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
std::size_t bytes_used = 0;
|
||||
for (auto const& buffer : buffers)
|
||||
for(auto const& buffer : buffers)
|
||||
{
|
||||
auto const n = write(
|
||||
buffer_cast<void const*>(buffer),
|
||||
@@ -609,7 +609,7 @@ template<class Derived>
|
||||
void
|
||||
nodejs_basic_parser<Derived>::check_header()
|
||||
{
|
||||
if (! value_.empty())
|
||||
if(! value_.empty())
|
||||
{
|
||||
//detail::trim(value_);
|
||||
call_on_field(field_, value_,
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
{
|
||||
std::array<std::uint8_t, 256> values;
|
||||
std::uint8_t i = 0;
|
||||
for (auto& c : values)
|
||||
for(auto& c : values)
|
||||
c = i++;
|
||||
return values;
|
||||
})();
|
||||
@@ -39,12 +39,12 @@ public:
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
|
||||
// Invalid range 128-193
|
||||
for (auto it = std::next(buf.begin(), 128);
|
||||
for(auto it = std::next(buf.begin(), 128);
|
||||
it != std::next(buf.begin(), 194); ++it)
|
||||
BEAST_EXPECT(! utf8.write(&(*it), 1));
|
||||
|
||||
// Invalid range 245-255
|
||||
for (auto it = std::next(buf.begin(), 245);
|
||||
for(auto it = std::next(buf.begin(), 245);
|
||||
it != buf.end(); ++it)
|
||||
BEAST_EXPECT(! utf8.write(&(*it), 1));
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
// First byte valid range 194-223
|
||||
buf[0] = static_cast<std::uint8_t>(i);
|
||||
|
||||
for (auto j = 128; j <= 191; ++j)
|
||||
for(auto j = 128; j <= 191; ++j)
|
||||
{
|
||||
// Second byte valid range 128-191
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
@@ -67,14 +67,14 @@ public:
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
}
|
||||
|
||||
for (auto j = 0; j <= 127; ++j)
|
||||
for(auto j = 0; j <= 127; ++j)
|
||||
{
|
||||
// Second byte invalid range 0-127
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
BEAST_EXPECT(! utf8.write(buf, 2));
|
||||
}
|
||||
|
||||
for (auto j = 192; j <= 255; ++j)
|
||||
for(auto j = 192; j <= 255; ++j)
|
||||
{
|
||||
// Second byte invalid range 192-255
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
@@ -88,19 +88,19 @@ public:
|
||||
{
|
||||
utf8_checker utf8;
|
||||
std::uint8_t buf[3];
|
||||
for (auto i = 224; i <= 239; ++i)
|
||||
for(auto i = 224; i <= 239; ++i)
|
||||
{
|
||||
// First byte valid range 224-239
|
||||
buf[0] = static_cast<std::uint8_t>(i);
|
||||
|
||||
std::int32_t const b = (i == 224 ? 160 : 128);
|
||||
std::int32_t const e = (i == 237 ? 159 : 191);
|
||||
for (auto j = b; j <= e; ++j)
|
||||
for(auto j = b; j <= e; ++j)
|
||||
{
|
||||
// Second byte valid range 128-191 or 160-191 or 128-159
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
|
||||
for (auto k = 128; k <= 191; ++k)
|
||||
for(auto k = 128; k <= 191; ++k)
|
||||
{
|
||||
// Third byte valid range 128-191
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
@@ -108,14 +108,14 @@ public:
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
}
|
||||
|
||||
for (auto k = 0; k <= 127; ++k)
|
||||
for(auto k = 0; k <= 127; ++k)
|
||||
{
|
||||
// Third byte invalid range 0-127
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
|
||||
for (auto k = 192; k <= 255; ++k)
|
||||
for(auto k = 192; k <= 255; ++k)
|
||||
{
|
||||
// Third byte invalid range 192-255
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
@@ -123,14 +123,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (auto j = 0; j < b; ++j)
|
||||
for(auto j = 0; j < b; ++j)
|
||||
{
|
||||
// Second byte invalid range 0-127 or 0-159
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
|
||||
for (auto j = e + 1; j <= 255; ++j)
|
||||
for(auto j = e + 1; j <= 255; ++j)
|
||||
{
|
||||
// Second byte invalid range 160-255 or 192-255
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
@@ -145,24 +145,24 @@ public:
|
||||
using boost::asio::const_buffers_1;
|
||||
utf8_checker utf8;
|
||||
std::uint8_t buf[4];
|
||||
for (auto i = 240; i <= 244; ++i)
|
||||
for(auto i = 240; i <= 244; ++i)
|
||||
{
|
||||
// First byte valid range 240-244
|
||||
buf[0] = static_cast<std::uint8_t>(i);
|
||||
|
||||
std::int32_t const b = (i == 240 ? 144 : 128);
|
||||
std::int32_t const e = (i == 244 ? 143 : 191);
|
||||
for (auto j = b; j <= e; ++j)
|
||||
for(auto j = b; j <= e; ++j)
|
||||
{
|
||||
// Second byte valid range 128-191 or 144-191 or 128-143
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
|
||||
for (auto k = 128; k <= 191; ++k)
|
||||
for(auto k = 128; k <= 191; ++k)
|
||||
{
|
||||
// Third byte valid range 128-191
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
|
||||
for (auto n = 128; n <= 191; ++n)
|
||||
for(auto n = 128; n <= 191; ++n)
|
||||
{
|
||||
// Fourth byte valid range 128-191
|
||||
buf[3] = static_cast<std::uint8_t>(n);
|
||||
@@ -170,14 +170,14 @@ public:
|
||||
BEAST_EXPECT(utf8.finish());
|
||||
}
|
||||
|
||||
for (auto n = 0; n <= 127; ++n)
|
||||
for(auto n = 0; n <= 127; ++n)
|
||||
{
|
||||
// Fourth byte invalid range 0-127
|
||||
buf[3] = static_cast<std::uint8_t>(n);
|
||||
BEAST_EXPECT(! utf8.write(const_buffers_1{buf, 4}));
|
||||
}
|
||||
|
||||
for (auto n = 192; n <= 255; ++n)
|
||||
for(auto n = 192; n <= 255; ++n)
|
||||
{
|
||||
// Fourth byte invalid range 192-255
|
||||
buf[3] = static_cast<std::uint8_t>(n);
|
||||
@@ -185,14 +185,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (auto k = 0; k <= 127; ++k)
|
||||
for(auto k = 0; k <= 127; ++k)
|
||||
{
|
||||
// Third byte invalid range 0-127
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
BEAST_EXPECT(! utf8.write(buf, 4));
|
||||
}
|
||||
|
||||
for (auto k = 192; k <= 255; ++k)
|
||||
for(auto k = 192; k <= 255; ++k)
|
||||
{
|
||||
// Third byte invalid range 192-255
|
||||
buf[2] = static_cast<std::uint8_t>(k);
|
||||
@@ -200,14 +200,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (auto j = 0; j < b; ++j)
|
||||
for(auto j = 0; j < b; ++j)
|
||||
{
|
||||
// Second byte invalid range 0-127 or 0-143
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
BEAST_EXPECT(! utf8.write(buf, 3));
|
||||
}
|
||||
|
||||
for (auto j = e + 1; j <= 255; ++j)
|
||||
for(auto j = e + 1; j <= 255; ++j)
|
||||
{
|
||||
// Second byte invalid range 144-255 or 192-255
|
||||
buf[1] = static_cast<std::uint8_t>(j);
|
||||
|
||||
Reference in New Issue
Block a user