Public API

Namespaces

drogon

Defines

Defines (CacheMap.h)

WHEELS_NUM 4

BUCKET_NUM_PER_WHEEL 200

TICK_INTERVAL 1.0

Defines (drogon_test.h)

TEST_CTX drogon_test_ctx_

DROGON_TESTCASE_PREIX_ drtest__

DROGON_TESTCASE_PREIX_STR_ "drtest__"

TEST_FLAG_ drgood__

DROGON_TEST_STRINGIFY__(x)
#x

DROGON_TEST_STRINGIFY(x)
DROGON_TEST_STRINGIFY__(x)

DROGON_TEST_CONCAT__(a,b)
a##b

DROGON_TEST_CONCAT(a,b)
DROGON_TEST_CONCAT__(a, b)

ERROR_MSG(func_name,expr)
drogon::test::printErr()
<< "\x1B[1;37mIn test case " << TEST_CTX->fullname() << "\n"
<< "\x1B[0;37m↳ " << __FILE__ << ":" << __LINE__
<< " \x1B[0;31m FAILED:\x1B[0m\n"
<< " \033[0;34m"
<< drogon::test::internal::stringifyFuncCall(func_name, expr)
<< "\x1B[0m\n"

PASSED_MSG(func_name,expr)
drogon::test::print()
<< "\x1B[1;37mIn test case " << TEST_CTX->fullname() << "\n"
<< "\x1B[0;37m↳ " << __FILE__ << ":" << __LINE__
<< " \x1B[0;32m PASSED:\x1B[0m\n"
<< " \033[0;34m"
<< drogon::test::internal::stringifyFuncCall(func_name, expr)
<< "\x1B[0m\n"

SET_TEST_SUCCESS__ do
{
TEST_FLAG_ = true;
} while (0);

TEST_INTERNAL__(func_name,expr,eval,on_exception,on_non_standard_exception,on_leaving)
do
{
bool TEST_FLAG_ = false;
using drogon::test::internal::stringifyFuncCall;
using drogon::test::printErr;
drogon::test::internal::numAssertions++;
try
{
eval;
}
catch (const std::exception& e)
{
on_exception;
}
catch (...)
{
on_non_standard_exception;
}
if (TEST_FLAG_)
drogon::test::internal::numCorrectAssertions++;
else
TEST_CTX->setFailed();
on_leaving;
} while (0);

EVAL_AND_CHECK_TRUE__(func_name,expr)
do
{
bool drresult__;
std::string drexpansion__;
std::tie(drresult__, drexpansion__) =
(drogon::test::internal::Decomposer() <= expr).result();
if (!drresult__)
{
ERROR_MSG(func_name, #expr)
<< "With expansion\n"
<< " \033[0;33m" << drexpansion__ << "\x1B[0m\n\n";
}
else
SET_TEST_SUCCESS__;
} while (0);

RETURN_ON_FAILURE__ do
{
if (!TEST_FLAG_)
return;
} while (0);

CO_RETURN_ON_FAILURE__ do
{
if (!TEST_FLAG_)
co_return;
} while (0);

DIE_ON_FAILURE__ do
{
using namespace drogon::test;
if (!TEST_FLAG_)
{
printTestStats();
printErr() << "Force exiting due to a mandation failed.\n";
exit(1);
}
} while (0);

EVAL__(expr)
do
{
expr;
} while (0);

NOTHING__ {
}

CHECK_INTERNAL__(expr,func_name,on_leave)
do
{
TEST_INTERNAL__(func_name,
expr,
EVAL_AND_CHECK_TRUE__(func_name, expr),
PRINT_UNEXPECTED_EXCEPTION__(func_name, #expr),
PRINT_NONSTANDARD_EXCEPTION__(func_name, #expr),
on_leave PRINT_PASSED__(func_name, #expr));
} while (0)

CHECK_THROWS_INTERNAL__(expr,func_name,on_leave)
do
{
TEST_INTERNAL__(func_name,
expr,
EVAL__(expr),
SET_TEST_SUCCESS__,
SET_TEST_SUCCESS__,
PRINT_ERR_NOEXCEPTION__(#expr, func_name)
on_leave PRINT_PASSED__(func_name, #expr));
} while (0)

CHECK_THROWS_AS_INTERNAL__(expr,func_name,except_type,on_leave)
do
{
bool exceptionThrown = false;
TEST_INTERNAL__(
func_name,
expr,
EVAL__(expr),
{
exceptionThrown = true;
if (dynamic_cast<const except_type*>(&e) != nullptr)
SET_TEST_SUCCESS__;
},
{ exceptionThrown = true; },
PRINT_ERR_BAD_EXCEPTION__(#expr ", " #except_type,
func_name,
except_type,
exceptionThrown,
TEST_FLAG_)
on_leave PRINT_PASSED__(func_name, #expr ", " #except_type));
} while (0)

CHECK_NOTHROW_INTERNAL__(expr,func_name,on_leave)
do
{
TEST_INTERNAL__(func_name,
expr,
EVAL__(expr) SET_TEST_SUCCESS__,
NOTHING__,
NOTHING__,
PRINT_ERR_WITHEXCEPTION__(#expr, func_name)
on_leave PRINT_PASSED__(func_name, #expr));
} while (0)

CHECK(expr)
CHECK_INTERNAL__(expr, "CHECK", NOTHING__)

CHECK_THROWS(expr)
CHECK_THROWS_INTERNAL__(expr, "CHECK_THROWS", NOTHING__)

CHECK_NOTHROW(expr)
CHECK_NOTHROW_INTERNAL__(expr, "CHECK_NOTHROW", NOTHING__)

CHECK_THROWS_AS(expr,except_type)
CHECK_THROWS_AS_INTERNAL__(expr, "CHECK_THROWS_AS", except_type, NOTHING__)

REQUIRE(expr)
CHECK_INTERNAL__(expr, "REQUIRE", RETURN_ON_FAILURE__)

REQUIRE_THROWS(expr)
CHECK_THROWS_INTERNAL__(expr, "REQUIRE_THROWS", RETURN_ON_FAILURE__)

REQUIRE_NOTHROW(expr)
CHECK_NOTHROW_INTERNAL__(expr, "REQUIRE_NOTHROW", RETURN_ON_FAILURE__)

REQUIRE_THROWS_AS(expr,except_type)
CHECK_THROWS_AS_INTERNAL__(expr,
"REQUIRE_THROWS_AS",
except_type,
RETURN_ON_FAILURE__)

CO_REQUIRE(expr)
CHECK_INTERNAL__(expr, "CO_REQUIRE", CO_RETURN_ON_FAILURE__)

CO_REQUIRE_THROWS(expr)
CHECK_THROWS_INTERNAL__(expr, "CO_REQUIRE_THROWS", CO_RETURN_ON_FAILURE__)

CO_REQUIRE_NOTHROW(expr)
CHECK_NOTHROW_INTERNAL__(expr, "CO_REQUIRE_NOTHROW", CO_RETURN_ON_FAILURE__)

CO_REQUIRE_THROWS_AS(expr,except_type)
CHECK_THROWS_AS_INTERNAL__(expr,
"CO_REQUIRE_THROWS_AS",
except_type,
CO_RETURN_ON_FAILURE__)

MANDATE(expr)
CHECK_INTERNAL__(expr, "MANDATE", DIE_ON_FAILURE__)

MANDATE_THROWS(expr)
CHECK_THROWS_INTERNAL__(expr, "MANDATE_THROWS", DIE_ON_FAILURE__)

MANDATE_NOTHROW(expr)
CHECK_NOTHROW_INTERNAL__(expr, "MANDATE_NOTHROW", DIE_ON_FAILURE__)

MANDATE_THROWS_AS(expr,except_type)
CHECK_THROWS_AS_INTERNAL__(expr,
"MANDATE_THROWS_AS",
except_type,
DIE_ON_FAILURE__)

STATIC_REQUIRE(expr)
do
{
TEST_CTX;
drogon::test::internal::numAssertions++;
static_assert((expr), #expr " failed.");
drogon::test::internal::numCorrectAssertions++;
} while (0);

FAIL(message)
do
{
using namespace drogon::test;
TEST_CTX->setFailed();
printErr() << "\x1B[1;37mIn test case " << TEST_CTX->fullname()
<< "\n"
<< "\x1B[0;37m" << __FILE__ << ":" << __LINE__
<< " \x1B[0;31m FAILED:\x1B[0m\n"
<< " Reason: " << message << "\n\n";
drogon::test::internal::numAssertions++;
} while (0)

FAULT(message)
do
{
using namespace drogon::test;
FAIL(message);
printTestStats();
printErr() << "Force exiting due to a FAULT statement.\n";
exit(1);
} while (0)

SUCCESS()
do
{
if (drogon::test::internal::printSuccessfulTests)
drogon::test::print()
<< "\x1B[1;37mIn test case " << TEST_CTX->fullname() << "\n"
<< "\x1B[0;37m↳ " << __FILE__ << ":" << __LINE__
<< " \x1B[0;32m PASSED:\x1B[0m\n"
<< " \033[0;34mSUCCESS()\x1B[0m\n\n";
TEST_CTX;
drogon::test::internal::numAssertions++;
drogon::test::internal::numCorrectAssertions++;
} while (0)

DROGON_TEST_CLASS_NAME_(test_name)
DROGON_TEST_CONCAT(DROGON_TESTCASE_PREIX_, test_name)

DROGON_TEST(test_name)
struct DROGON_TEST_CLASS_NAME_(test_name)
: public drogon::DrObject<DROGON_TEST_CLASS_NAME_(test_name)>,
public drogon::test::TestCase
{
DROGON_TEST_CLASS_NAME_(test_name)
() : drogon::test::TestCase(#test_name)
{
}
inline void doTest_(std::shared_ptr<drogon::test::Case>) override;
};
void DROGON_TEST_CLASS_NAME_(test_name)::doTest_(
std::shared_ptr<drogon::test::Case> TEST_CTX)

SUBTEST(name)
(std::make_shared<drogon::test::Case>(TEST_CTX, name))

SUBSECTION(name)
for (std::shared_ptr<drogon::test::Case> ctx_hold__ = TEST_CTX,
ctx_tmp__ = SUBTEST(#name);
ctx_tmp__ != nullptr;
TEST_CTX = ctx_hold__, ctx_tmp__ = nullptr)
if (TEST_CTX = ctx_tmp__, TEST_CTX != nullptr)

Defines (HttpController.h)

METHOD_LIST_BEGIN static void initPathRouting()
{

HttpController.h An Tao

Copyright 2018, An Tao. All rights reserved. https://github.com/an-tao/drogon Use of this source code is governed by a MIT license that can be found in the License file.

Drogon For more details on the class, see the wiki site (the 'HttpController' section)

Mentioned in:

Getting Started / A very simple example

Controller Introduction / Controller HttpController / Generation

Controller Introduction / Controller HttpController / Usage

Controller Introduction / Controller HttpController / Parameters mapping

METHOD_ADD(method,pattern,...)
registerMethod(&method, pattern, {__VA_ARGS__}, true, #method)

Mentioned in:

ADD_METHOD_TO(method,path_pattern,...)
registerMethod(&method, path_pattern, {__VA_ARGS__}, false, #method)

Mentioned in:

ADD_METHOD_VIA_REGEX(method,regex,...)
registerMethodViaRegex(&method, regex, {__VA_ARGS__}, #method)

Mentioned in:

METHOD_LIST_END return;
}

Mentioned in:

Defines (HttpSimpleController.h)

PATH_LIST_BEGIN static void initPathRouting()
{

HttpSimpleController.h An Tao

Copyright 2018, An Tao. All rights reserved. https://github.com/an-tao/drogon Use of this source code is governed by a MIT license that can be found in the License file.

Drogon

Mentioned in:

Getting Started / A very simple example

Quick Start / Dynamic Site

Controller Introduction / Controller

Controller Introduction / Controller HttpSimpleController

PATH_ADD(path,...)
registerSelf__(path, {__VA_ARGS__});

Mentioned in:

PATH_LIST_END }

Mentioned in:

Defines (WebSocketController.h)

WS_PATH_LIST_BEGIN static void initPathRouting()
{

WebSocketController.h An Tao

Copyright 2018, An Tao. All rights reserved. https://github.com/an-tao/drogon Use of this source code is governed by a MIT license that can be found in the License file.

Drogon

Mentioned in:

Controller Introduction / Controller WebSocketController / WebSocketController

WS_PATH_ADD(path,...)
registerSelf__(path, {__VA_ARGS__});

Mentioned in:

WS_PATH_LIST_END }

Mentioned in:






Add Discussion as Guest

Log in