Merge pull request #940 from oatpp/better_logging

Better logging
This commit is contained in:
Leonid Stryzhevskyi 2024-05-14 18:29:07 -07:00 committed by GitHub
commit c7a8164c4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
103 changed files with 1552 additions and 926 deletions

2
.gitignore vendored
View File

@ -38,6 +38,8 @@
# idea
.idea/
cmake-build-debug/
cmake-build-debug-visual-studio/
cmake-build-debug-wsl/
# local build
build*/

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/src/oatpp/Environment.hpp" OATPP_VERSION_MACRO REGEX "#define OATPP_VERSION \"[0-9]+.[0-9]+.[0-9]+\"$")
string(REGEX REPLACE "#define OATPP_VERSION \"([0-9]+.[0-9]+.[0-9]+)\"$" "\\1" oatpp_VERSION "${OATPP_VERSION_MACRO}")

View File

@ -12,6 +12,7 @@ Contents:
- [oatpp::Tree](#oatpptree)
- [Remapper](#remapper)
- [oatpp::web::mime::ContentMappers](#oatppwebmimecontentmappers)
- [New OATPP_LOGx format](#new-oatpp_logx-format)
- [Restructuring](#restructuring)
@ -149,6 +150,29 @@ on `Content-Type`/`Accept` headers.
}
```
## New OATPP_LOGx format
Now oatpp logs are type-safe. Also log formatting changed.
#### Macro
| old logs | new logs |
|--------------|--------------|
| `OATPP_LOGV` | `OATPP_LOGv` |
| `OATPP_LOGD` | `OATPP_LOGd` |
| `OATPP_LOGI` | `OATPP_LOGi` |
| `OATPP_LOGW` | `OATPP_LOGw` |
| `OATPP_LOGE` | `OATPP_LOGe` |
#### Formatting
Instead of old formatting "%s", "%d", "%f" use "{}" for any variable type:
```cpp
OATPP_LOGd("MyController", "User: name={}, age={}", user->name, user->age)
```
## Restructuring
### Files

View File

@ -35,6 +35,8 @@ add_library(oatpp
oatpp/base/Config.hpp
oatpp/base/Countable.cpp
oatpp/base/Countable.hpp
oatpp/base/Log.cpp
oatpp/base/Log.hpp
oatpp/base/ObjectHandle.hpp
oatpp/codegen/api_controller/auth_define.hpp
oatpp/codegen/api_controller/auth_undef.hpp

View File

@ -23,6 +23,7 @@
***************************************************************************/
#include "Checker.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace test {
@ -33,7 +34,7 @@ PerformanceChecker::PerformanceChecker(const char* tag)
PerformanceChecker::~PerformanceChecker(){
v_int64 elapsedTicks = oatpp::Environment::getMicroTickCount() - m_ticks;
OATPP_LOGD(m_tag, "%ld(micro)", elapsedTicks)
OATPP_LOGd(m_tag, "{}(micro)", elapsedTicks)
}
v_int64 PerformanceChecker::getElapsedTicks(){
@ -54,9 +55,9 @@ ThreadLocalObjectsChecker::~ThreadLocalObjectsChecker(){
v_counter objectsCreatedPerTest = oatpp::Environment::getThreadLocalObjectsCreated() - m_objectsCreated;
if(leakingObjects == 0){
OATPP_LOGE(m_tag, "OK:\n created(obj): %ld", objectsCreatedPerTest)
OATPP_LOGe(m_tag, "OK:\n created(obj): {}", objectsCreatedPerTest)
}else{
OATPP_LOGE(m_tag, "FAILED, leakingObjects = %ld", leakingObjects)
OATPP_LOGe(m_tag, "FAILED, leakingObjects = {}", leakingObjects)
OATPP_ASSERT(false)
}

View File

@ -30,7 +30,7 @@ namespace oatpp { namespace test {
void UnitTest::run(v_int32 times) {
OATPP_LOGI(TAG, "\033[1mSTART\033[0m...")
OATPP_LOGi(TAG, "\033[1mSTART\033[0m...")
v_counter objectsCount = oatpp::Environment::getObjectsCount();
v_counter objectsCreated = oatpp::Environment::getObjectsCreated();
@ -51,11 +51,11 @@ void UnitTest::run(v_int32 times) {
v_counter objectsCreatedPerTest = oatpp::Environment::getObjectsCreated() - objectsCreated;
if(leakingObjects == 0){
OATPP_LOGI(TAG, "\033[1mFINISHED\033[0m - \033[1;32msuccess!\033[0m")
OATPP_LOGI(TAG, "\033[33m%ld(micro), %ld(objs)\033[0m\n", millis, objectsCreatedPerTest)
OATPP_LOGi(TAG, "\033[1mFINISHED\033[0m - \033[1;32msuccess!\033[0m")
OATPP_LOGi(TAG, "\033[33m{}(micro), {}(objs)\033[0m\n", millis, objectsCreatedPerTest)
}else{
OATPP_LOGE(TAG, "\033[1mFINISHED\033[0m - \033[1;31mfailed\033[0m, leakingObjects = %ld", leakingObjects)
OATPP_LOGe(TAG, "\033[1mFINISHED\033[0m - \033[1;31mfailed\033[0m, leakingObjects = {}", leakingObjects)
exit(EXIT_FAILURE);

View File

@ -26,7 +26,7 @@
#define oatpp_test_UnitTest_hpp
#include "oatpp/Environment.hpp"
#include "oatpp/macro/basic.hpp"
#include "oatpp/base/Log.hpp"
#include <functional>

View File

@ -100,11 +100,11 @@ public:
bool runConditionForLambda = true;
m_server = std::make_shared<oatpp::network::Server>(m_connectionProvider, m_connectionHandler);
OATPP_LOGD("\033[1;34mClientServerTestRunner\033[0m", "\033[1;34mRunning server on port %s. Timeout %ld(micro)\033[0m",
OATPP_LOGd("\033[1;34mClientServerTestRunner\033[0m", "\033[1;34mRunning server on port {}. Timeout {}(micro)\033[0m",
m_connectionProvider->getProperty("port").toString()->c_str(),
timeout.count())
std::function<bool()> condition = [&runConditionForLambda](){
std::function<bool()> condition = [&runConditionForLambda]() noexcept {
return runConditionForLambda;
};
@ -137,7 +137,7 @@ public:
clientThread.join();
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - startTime);
OATPP_LOGD("\033[1;34mClientServerTestRunner\033[0m", "\033[1;34mFinished with time %ld(micro). Stopping server...\033[0m", elapsed.count())
OATPP_LOGd("\033[1;34mClientServerTestRunner\033[0m", "\033[1;34mFinished with time {}(micro). Stopping server...\033[0m", elapsed.count())
running = false;
timeoutCondition.notify_one();

View File

@ -25,6 +25,8 @@
#include "Environment.hpp"
#include "oatpp/base/Log.hpp"
#include <iomanip>
#include <chrono>
#include <iostream>
@ -309,18 +311,18 @@ std::shared_ptr<Logger> Environment::getLogger() {
void Environment::printCompilationConfig() {
OATPP_LOGD("oatpp-version", OATPP_VERSION)
OATPP_LOGd("oatpp-version", OATPP_VERSION)
#ifdef OATPP_DISABLE_ENV_OBJECT_COUNTERS
OATPP_LOGD("oatpp/Config", "OATPP_DISABLE_ENV_OBJECT_COUNTERS")
OATPP_LOGd("oatpp/Config", "OATPP_DISABLE_ENV_OBJECT_COUNTERS")
#endif
#ifdef OATPP_COMPAT_BUILD_NO_THREAD_LOCAL
OATPP_LOGD("oatpp/Config", "OATPP_COMPAT_BUILD_NO_THREAD_LOCAL")
OATPP_LOGd("oatpp/Config", "OATPP_COMPAT_BUILD_NO_THREAD_LOCAL")
#endif
#ifdef OATPP_THREAD_HARDWARE_CONCURRENCY
OATPP_LOGD("oatpp/Config", "OATPP_THREAD_HARDWARE_CONCURRENCY=%d", OATPP_THREAD_HARDWARE_CONCURRENCY)
OATPP_LOGd("oatpp/Config", "OATPP_THREAD_HARDWARE_CONCURRENCY={}", OATPP_THREAD_HARDWARE_CONCURRENCY)
#endif
}
@ -331,49 +333,6 @@ void Environment::log(v_uint32 priority, const std::string& tag, const std::stri
}
}
void Environment::logFormatted(v_uint32 priority, const LogCategory& category, const char* message, ...) {
if (category.categoryEnabled && (category.enabledPriorities & (1U << priority))) {
va_list args;
va_start(args, message);
vlogFormatted(priority, category.tag, message, args);
va_end(args);
}
}
void Environment::logFormatted(v_uint32 priority, const std::string& tag, const char* message, ...) {
va_list args;
va_start(args, message);
vlogFormatted(priority, tag, message, args);
va_end(args);
}
void Environment::vlogFormatted(v_uint32 priority, const std::string& tag, const char* message, va_list args) {
// do we have a logger and the priority is enabled?
if (m_logger == nullptr || !m_logger->isLogPriorityEnabled(priority)) {
return;
}
// if we dont need to format anything, just print the message
if(message == nullptr) {
log(priority, tag, std::string());
return;
}
// check how big our buffer has to be
va_list argscpy;
va_copy(argscpy, args);
v_buff_size allocsize = vsnprintf(nullptr, 0, message, argscpy) + 1;
// alloc the buffer (or the max size)
if (allocsize > m_logger->getMaxFormattingBufferSize()) {
allocsize = m_logger->getMaxFormattingBufferSize();
}
auto buffer = std::unique_ptr<char[]>(new char[allocsize]);
memset(buffer.get(), 0, static_cast<size_t>(allocsize));
// actually format
vsnprintf(buffer.get(), static_cast<size_t>(allocsize), message, args);
// call (user) providen log function
log(priority, tag, buffer.get());
}
void Environment::registerComponent(const std::string& typeName, const std::string& componentName, void* component) {
std::lock_guard<std::mutex> lock(getComponentsMutex());
auto& bucket = getComponents()[typeName];

View File

@ -87,8 +87,8 @@ namespace oatpp {
/**
* Interface for system-wide Logger.<br>
* All calls to `OATPP_DISABLE_LOGV`, `OATPP_DISABLE_LOGD`, `OATPP_DISABLE_LOGI`,
* `OATPP_DISABLE_LOGW`, `OATPP_DISABLE_LOGE` will come here.
* All calls to `OATPP_LOGv`, `OATPP_LOGd`, `OATPP_LOGi`,
* `OATPP_LOGw`, `OATPP_LOGe` will come here.
*/
class Logger {
public:
@ -358,7 +358,6 @@ public:
private:
static void registerComponent(const std::string& typeName, const std::string& componentName, void* component);
static void unregisterComponent(const std::string& typeName, const std::string& componentName);
static void vlogFormatted(v_uint32 priority, const std::string& tag, const char* message, va_list args) GPP_ATTRIBUTE(format (printf, 3, 0));
public:
/**
@ -442,26 +441,6 @@ public:
*/
static void log(v_uint32 priority, const std::string& tag, const std::string& message);
/**
* Format message and call `Logger::log()`<br>
* Message is formatted using `vsnprintf` method.
* @param priority - log-priority channel of the message.
* @param tag - tag of the log message.
* @param message - message.
* @param ... - format arguments.
*/
static void logFormatted(v_uint32 priority, const std::string& tag, const char* message, ...) GPP_ATTRIBUTE(format (printf, 3, 4));
/**
* Format message and call `Logger::log()`<br>
* Message is formatted using `vsnprintf` method.
* @param priority - log-priority channel of the message.
* @param category - category of the log message.
* @param message - message.
* @param ... - format arguments.
*/
static void logFormatted(v_uint32 priority, const LogCategory& category, const char* message, ...) GPP_ATTRIBUTE(format (printf, 3, 4));
/**
* Get component object by typeName.
* @param typeName - type name of the component.
@ -484,124 +463,6 @@ public:
static v_int64 getMicroTickCount();
};
/**
* Default oatpp assert method.
* @param FMT - the format string used for the expression
* @param EXP - expression that must be `true`.
*/
#define OATPP_ASSERT_FMT(FMT, EXP) \
if(!(EXP)) { \
OATPP_LOGE("\033[1mASSERT\033[0m[\033[1;31mFAILED\033[0m]", FMT, #EXP) \
exit(EXIT_FAILURE); \
}
/**
* Default oatpp assert method.
* @param EXP - expression that must be `true`.
*/
#define OATPP_ASSERT(EXP) \
if(!(EXP)) { \
OATPP_LOGE("\033[1mASSERT\033[0m[\033[1;31mFAILED\033[0m]", #EXP) \
exit(EXIT_FAILURE); \
}
/**
* Convenience macro to declare a logging category directly in a class header.
* @param NAME - variable-name of the category which is later used to reference the category.
*/
#define OATPP_DECLARE_LOG_CATEGORY(NAME) \
static oatpp::LogCategory NAME;
/**
* Convenience macro to implement a logging category directly in a class header.
* @param NAME - variable-name of the category which is later used to reference the category.
* @param TAG - tag printed with each message printed usig this category.
* @param ENABLED - enable or disable a category (bool).
*/
#define OATPP_LOG_CATEGORY(NAME, TAG, ENABLED) \
oatpp::LogCategory NAME = oatpp::LogCategory(TAG, ENABLED);
#ifndef OATPP_DISABLE_LOGV
/**
* Log message with &l:Logger::PRIORITY_V; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGV`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGV(TAG, ...) \
oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_V, TAG, __VA_ARGS__);
#else
#define OATPP_LOGV(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGD
/**
* Log message with &l:Logger::PRIORITY_D; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGD`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGD(TAG, ...) \
oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_D, TAG, __VA_ARGS__);
#else
#define OATPP_LOGD(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGI
/**
* Log message with &l:Logger::PRIORITY_I; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGI`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGI(TAG, ...) \
oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_I, TAG, __VA_ARGS__);
#else
#define OATPP_LOGI(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGW
/**
* Log message with &l:Logger::PRIORITY_W; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGW`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGW(TAG, ...) \
oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_W, TAG, __VA_ARGS__);
#else
#define OATPP_LOGW(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGE
/**
* Log message with &l:Logger::PRIORITY_E; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGE`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGE(TAG, ...) \
oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_E, TAG, __VA_ARGS__);
#else
#define OATPP_LOGE(TAG, ...)
#endif
}

View File

@ -30,6 +30,7 @@
// epoll based implementation
#include "oatpp/async/Processor.hpp"
#include "oatpp/base/Log.hpp"
#include <unistd.h>
#include <sys/epoll.h>
@ -46,22 +47,22 @@ void IOEventWorker::initEventQueue() {
#endif
if(m_eventQueueHandle == -1) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_create1() failed. errno=%d", errno)
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_create1() failed. errno={}", errno)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::epoll_create1() failed.");
}
m_outEvents = std::unique_ptr<v_char8[]>(new (std::nothrow) v_char8[MAX_EVENTS * sizeof(epoll_event)]);
if(!m_outEvents) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]",
"Error. Unable to allocate %lu bytes for events.", MAX_EVENTS * sizeof(epoll_event))
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]",
"Error. Unable to allocate {} bytes for events.", MAX_EVENTS * sizeof(epoll_event))
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Unable to allocate memory for events.");
}
m_wakeupTrigger = ::eventfd(0, EFD_NONBLOCK);
if(m_wakeupTrigger == -1) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::eventfd() failed. errno=%d", errno)
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::eventfd() failed. errno={}", errno)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::eventfd() failed.");
}
@ -78,7 +79,7 @@ void IOEventWorker::initEventQueue() {
auto res = ::epoll_ctl(m_eventQueueHandle, EPOLL_CTL_ADD, m_wakeupTrigger, &event);
if(res == -1) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_ctl failed. errno=%d", errno)
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_ctl failed. errno={}", errno)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::epoll_ctl() failed.");
}
@ -104,7 +105,7 @@ void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation,
case Action::TYPE_IO_REPEAT: break;
default:
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]", "Error. Unknown Action. action.getType()==%d", action.getType())
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]", "Error. Unknown Action. action.getType()=={}", action.getType())
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]: Error. Unknown Action.");
}
@ -131,7 +132,7 @@ void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation,
auto res = epoll_ctl(m_eventQueueHandle, operation, action.getIOHandle(), &event);
if(res == -1) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::setEpollEvent()]", "Error. Call to epoll_ctl failed. operation=%d, errno=%d", operation, errno)
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::setEpollEvent()]", "Error. Call to epoll_ctl failed. operation={}, errno={}", operation, errno)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::setEpollEvent()]: Error. Call to epoll_ctl failed.");
}
@ -159,13 +160,15 @@ void IOEventWorker::waitEvents() {
auto eventsCount = epoll_wait(m_eventQueueHandle, outEvents, MAX_EVENTS, -1);
if((eventsCount < 0) && (errno != EINTR)) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n"
"errno=%d\n"
"in-events=%d\n"
"foreman=%lx\n"
"this=%lx\n"
"specialization=%d",
errno, m_inEventsCount, reinterpret_cast<v_buff_usize>(m_foreman), reinterpret_cast<v_buff_usize>(this), m_specialization)
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n"
"errno={}\n"
"in-events={}\n"
"foreman={}\n"
"this={}\n"
"specialization={}",
errno, m_inEventsCount,
reinterpret_cast<v_buff_usize>(m_foreman), reinterpret_cast<v_buff_usize>(this),
static_cast<v_int32>(m_specialization))
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed.");
}
@ -216,10 +219,10 @@ void IOEventWorker::waitEvents() {
res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, action.getIOHandle(), nullptr);
if(res == -1) {
OATPP_LOGE(
OATPP_LOGe(
"[oatpp::async::worker::IOEventWorker::waitEvents()]",
"Error. Call to epoll_ctl failed. operation=%d, errno=%d. action_code=%d, worker_specialization=%d",
EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization
"Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}",
EPOLL_CTL_DEL, errno, action.getIOEventCode(), static_cast<v_int32>(m_specialization)
)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed.");
}
@ -233,10 +236,10 @@ void IOEventWorker::waitEvents() {
res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, action.getIOHandle(), nullptr);
if(res == -1) {
OATPP_LOGE(
OATPP_LOGe(
"[oatpp::async::worker::IOEventWorker::waitEvents()]",
"Error. Call to epoll_ctl failed. operation=%d, errno=%d. action_code=%d, worker_specialization=%d",
EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization
"Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}",
EPOLL_CTL_DEL, errno, action.getIOEventCode(), static_cast<v_int32>(m_specialization)
)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed.");
}
@ -253,7 +256,7 @@ void IOEventWorker::waitEvents() {
res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, prevAction.getIOHandle(), nullptr);
if(res == -1) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation=%d, errno=%d", EPOLL_CTL_DEL, errno)
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation={}, errno={}", EPOLL_CTL_DEL, errno)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed.");
}

View File

@ -30,6 +30,7 @@
// kqueue based implementation
#include "oatpp/async/Processor.hpp"
#include "oatpp/base/Log.hpp"
#include <sys/event.h>
@ -44,8 +45,8 @@ void IOEventWorker::initEventQueue() {
m_outEvents = std::unique_ptr<v_char8[]>(new (std::nothrow) v_char8[MAX_EVENTS * sizeof(struct kevent)]);
if(!m_outEvents) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]",
"Error. Unable to allocate %d bytes for events.", MAX_EVENTS * sizeof(struct kevent))
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]",
"Error. Unable to allocate {} bytes for events.", v_int32(MAX_EVENTS * sizeof(struct kevent)))
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Unable to allocate memory for events.");
}
@ -69,7 +70,7 @@ void IOEventWorker::triggerWakeup() {
void IOEventWorker::setTriggerEvent(p_char8 eventPtr) {
struct kevent* event = (struct kevent*) eventPtr;
auto* event = reinterpret_cast<struct kevent*>(eventPtr);
std::memset(event, 0, sizeof(struct kevent));
@ -86,7 +87,7 @@ void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation,
switch(action.getType()) {
case Action::TYPE_IO_WAIT: break;
case Action::TYPE_IO_WAIT:
case Action::TYPE_IO_REPEAT: break;
default:
@ -94,10 +95,10 @@ void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation,
}
struct kevent* event = (struct kevent*) eventPtr;
auto* event = reinterpret_cast<struct kevent*>(eventPtr);
std::memset(event, 0, sizeof(struct kevent));
event->ident = action.getIOHandle();
event->ident = static_cast<uintptr_t>(action.getIOHandle());
event->flags = EV_ADD | EV_ONESHOT;
event->udata = coroutine;
@ -128,10 +129,10 @@ void IOEventWorker::consumeBacklog() {
m_inEventsCapacity = m_inEventsCount;
m_inEvents = std::unique_ptr<v_char8[]>(new (std::nothrow) v_char8[m_inEventsCapacity * sizeof(struct kevent)]);
m_inEvents = std::unique_ptr<v_char8[]>(new (std::nothrow) v_char8[static_cast<unsigned long>(m_inEventsCapacity) * sizeof(struct kevent)]);
if(!m_inEvents) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::consumeBacklog()]",
"Error. Unable to allocate %d bytes for events.", m_inEventsCapacity * sizeof(struct kevent))
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::consumeBacklog()]",
"Error. Unable to allocate {} bytes for events.", v_uint64(static_cast<unsigned long>(m_inEventsCapacity) * sizeof(struct kevent)))
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::consumeBacklog()]: Error. Unable to allocate memory for events.");
}
@ -140,7 +141,7 @@ void IOEventWorker::consumeBacklog() {
setTriggerEvent(&m_inEvents[0]);
auto curr = m_backlog.first;
v_int32 i = 1;
unsigned long i = 1;
while(curr != nullptr) {
setCoroutineEvent(curr, 0, &m_inEvents[i * sizeof(struct kevent)]);
curr = nextCoroutine(curr);
@ -155,15 +156,20 @@ void IOEventWorker::consumeBacklog() {
void IOEventWorker::waitEvents() {
auto eventsCount = kevent(m_eventQueueHandle, (struct kevent*)m_inEvents.get(), m_inEventsCount, (struct kevent*)m_outEvents.get(), MAX_EVENTS,nullptr);
auto eventsCount = kevent(m_eventQueueHandle,
reinterpret_cast<struct kevent *>(m_inEvents.get()),
m_inEventsCount,
reinterpret_cast<struct kevent *>(m_outEvents.get()),
MAX_EVENTS,
nullptr);
if((eventsCount < 0) && (errno != EINTR)) {
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n"
"errno=%d\n"
"in-events=%d\n"
"foreman=%d\n"
"this=%d\n"
"specialization=%d",
OATPP_LOGe("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n"
"errno={}\n"
"in-events={}\n"
"foreman={}\n"
"this={}\n"
"specialization={}",
errno, m_inEventsCount, m_foreman, this, m_specialization)
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed.");
}
@ -173,11 +179,11 @@ void IOEventWorker::waitEvents() {
for(v_int32 i = 0; i < eventsCount; i ++) {
struct kevent* event = (struct kevent *)&m_outEvents[i * sizeof(struct kevent)];
auto coroutine = (CoroutineHandle*) event->udata;
auto* event = reinterpret_cast<struct kevent *>(&m_outEvents[static_cast<unsigned long>(i) * sizeof(struct kevent)]);
auto coroutine = reinterpret_cast<CoroutineHandle*>(event->udata);
if((event->flags & EV_ERROR) > 0) {
OATPP_LOGD("Error", "data='%s'", strerror((int)event->data))
OATPP_LOGd("Error", "data='{}'", strerror(static_cast<int>(event->data)))
continue;
}

View File

@ -22,8 +22,8 @@
*
***************************************************************************/
#ifndef oatpp_base_Countable
#define oatpp_base_Countable
#ifndef oatpp_base_Countable_hpp
#define oatpp_base_Countable_hpp
#include "oatpp/Environment.hpp"
@ -59,4 +59,4 @@ public:
}}
#endif /* oatpp_base_Countable */
#endif /* oatpp_base_Countable_hpp */

329
src/oatpp/base/Log.cpp Normal file
View File

@ -0,0 +1,329 @@
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************/
#include "Log.hpp"
#include "oatpp/utils/parser/Caret.hpp"
#include "oatpp/macro/basic.hpp"
namespace oatpp { namespace base {
LogMessage::LogMessage(const oatpp::String& msg)
: m_msg(msg != nullptr ? msg : "<null>")
, m_stream(256)
, m_currParam(0)
{
utils::parser::Caret caret(m_msg);
while (caret.canContinue()) {
if(caret.findText("{}", 2)) {
m_params.push_back({caret.getPosition(), caret.getPosition() + 2});
caret.inc(2);
}
}
}
std::string LogMessage::toStdString() const {
if(m_currParam == 0) {
m_stream.writeSimple(m_msg->data(), static_cast<v_buff_size>(m_msg->size()));
} else if(m_currParam > 0) {
auto& prev = m_params.at(m_currParam - 1);
m_stream.writeSimple(m_msg->data() + prev.endPos, static_cast<v_buff_size>(m_msg->size()) - prev.endPos);
}
return m_stream.toStdString();
}
bool LogMessage::writeNextChunk() {
if(m_currParam >= m_params.size()) return false;
if(m_currParam == 0) {
auto& curr = m_params.at(m_currParam);
m_stream.writeSimple(m_msg->data(), curr.startPos);
} else if(m_currParam > 0) {
auto& prev = m_params.at(m_currParam - 1);
auto& curr = m_params.at(m_currParam);
m_stream.writeSimple(m_msg->data() + prev.endPos, curr.startPos - prev.endPos);
}
m_currParam ++;
return true;
}
LogMessage& LogMessage::operator << (const char* str) {
if(writeNextChunk()) {
if(str != nullptr) {
m_stream.writeSimple(str);
} else {
m_stream.writeSimple("{<char*(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (bool value) {
if(writeNextChunk()) {
m_stream.writeAsString(value);
}
return *this;
}
LogMessage& LogMessage::operator << (char value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_int32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (unsigned char value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_uint32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (short value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_int32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (unsigned short value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_uint32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (int value) {
if(writeNextChunk()) {
m_stream.writeAsString(value);
}
return *this;
}
LogMessage& LogMessage::operator << (unsigned value) {
if(writeNextChunk()) {
m_stream.writeAsString(value);
}
return *this;
}
LogMessage& LogMessage::operator << (long value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_int32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (unsigned long value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_uint32>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (long long value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_int64>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (unsigned long long value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_uint64>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (float value) {
if(writeNextChunk()) {
m_stream.writeAsString(value);
}
return *this;
}
LogMessage& LogMessage::operator << (double value) {
if(writeNextChunk()) {
m_stream.writeAsString(value);
}
return *this;
}
LogMessage& LogMessage::operator << (long double value) {
if(writeNextChunk()) {
m_stream.writeAsString(static_cast<v_float64>(value));
}
return *this;
}
LogMessage& LogMessage::operator << (const oatpp::String& str) {
if(writeNextChunk()) {
if(str != nullptr) {
m_stream.writeSimple(str);
} else {
m_stream.writeSimple("{<String(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const Boolean& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<Boolean(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const Int8& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<Int8(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const UInt8& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<UInt8(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const Int16& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<Int16(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const UInt16& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<UInt16(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const Int32& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<Int32(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const UInt32& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<UInt32(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const Int64& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<Int64(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const UInt64& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<UInt64(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const Float32& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<Float32(null)>}");
}
}
return *this;
}
LogMessage& LogMessage::operator << (const Float64& value) {
if(writeNextChunk()) {
if(value.get() != nullptr) {
m_stream.writeAsString(*value);
} else {
m_stream.writeSimple("{<Float64(null)>}");
}
}
return *this;
}
void Log::log(v_uint32 priority, const std::string& tag, const LogMessage& message) {
oatpp::Environment::log(priority, tag, message.toStdString());
}
void Log::log(v_uint32 priority, const LogCategory& category, const LogMessage& message) {
if (category.categoryEnabled && (category.enabledPriorities & (1U << priority))) {
log(priority, category.tag, message);
}
}
}}

244
src/oatpp/base/Log.hpp Normal file
View File

@ -0,0 +1,244 @@
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************/
#ifndef oatpp_base_Log_hpp
#define oatpp_base_Log_hpp
#include "oatpp/data/stream/BufferStream.hpp"
#include "oatpp/macro/basic.hpp"
namespace oatpp { namespace base {
class LogMessage {
private:
struct Parameter {
v_buff_size startPos;
v_buff_size endPos;
};
private:
bool writeNextChunk();
private:
oatpp::String m_msg;
mutable data::stream::BufferOutputStream m_stream;
v_uint64 m_currParam;
std::vector<Parameter> m_params;
public:
explicit LogMessage(const oatpp::String& msg);
std::string toStdString() const;
LogMessage& operator << (const char* str);
LogMessage& operator << (bool value);
LogMessage& operator << (char value);
LogMessage& operator << (unsigned char value);
LogMessage& operator << (short value);
LogMessage& operator << (unsigned short value);
LogMessage& operator << (int value);
LogMessage& operator << (unsigned value);
LogMessage& operator << (long value);
LogMessage& operator << (unsigned long value);
LogMessage& operator << (long long value);
LogMessage& operator << (unsigned long long value);
LogMessage& operator << (float value);
LogMessage& operator << (double value);
LogMessage& operator << (long double value);
LogMessage& operator << (const oatpp::String& str);
LogMessage& operator << (const Boolean& value);
LogMessage& operator << (const Int8& value);
LogMessage& operator << (const UInt8& value);
LogMessage& operator << (const Int16& value);
LogMessage& operator << (const UInt16& value);
LogMessage& operator << (const Int32& value);
LogMessage& operator << (const UInt32& value);
LogMessage& operator << (const Int64& value);
LogMessage& operator << (const UInt64& value);
LogMessage& operator << (const Float32& value);
LogMessage& operator << (const Float64& value);
};
struct Log {
static void ignore(std::initializer_list<void*> list) {
(void) list;
}
template<typename ... Types>
static void stream(v_uint32 priority, const std::string& tag, const oatpp::String& message, Types... args) {
oatpp::base::LogMessage msg(message);
ignore({std::addressof(msg << args)...});
log(priority, tag, msg);
}
template<typename ... Types>
static void stream(v_uint32 priority, const LogCategory& category, const oatpp::String& message, Types... args) {
oatpp::base::LogMessage msg(message);
ignore({std::addressof(msg << args)...});
log(priority, category, msg);
}
static void log(v_uint32 priority, const std::string& tag, const LogMessage& message);
static void log(v_uint32 priority, const LogCategory& category, const LogMessage& message);
};
}}
////////////////////////////
////////////////////////////
////////////////////////////
#ifndef OATPP_DISABLE_LOGV
/**
* Log message with &l:Logger::PRIORITY_V; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGV`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGv(TAG, ...) \
oatpp::base::Log::stream(oatpp::Logger::PRIORITY_V, TAG, __VA_ARGS__);
#else
#define OATPP_LOGv(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGD
/**
* Log message with &l:Logger::PRIORITY_D; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGD`*
* @param TAG - message tag.
* @param ...(1) - message
* @param ... - optional format parameter.
*/
#define OATPP_LOGd(TAG, ...) \
oatpp::base::Log::stream(oatpp::Logger::PRIORITY_D, TAG, __VA_ARGS__);
#else
#define OATPP_LOGd(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGI
/**
* Log message with &l:Logger::PRIORITY_I; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGI`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGi(TAG, ...) \
oatpp::base::Log::stream(oatpp::Logger::PRIORITY_I, TAG, __VA_ARGS__);
#else
#define OATPP_LOGi(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGW
/**
* Log message with &l:Logger::PRIORITY_W; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGW`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGw(TAG, ...) \
oatpp::base::Log::stream(oatpp::Logger::PRIORITY_W, TAG, __VA_ARGS__);
#else
#define OATPP_LOGw(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGE
/**
* Log message with &l:Logger::PRIORITY_E; <br>
* *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGE`*
* @param TAG - message tag.
* @param ...(1) - message.
* @param ... - optional format parameter.
*/
#define OATPP_LOGe(TAG, ...) \
oatpp::base::Log::stream(oatpp::Logger::PRIORITY_E, TAG, __VA_ARGS__);
#else
#define OATPP_LOGe(TAG, ...)
#endif
//////////////////////
//////////////////////
//////////////////////
/**
* Convenience macro to declare a logging category directly in a class header.
* @param NAME - variable-name of the category which is later used to reference the category.
*/
#define OATPP_DECLARE_LOG_CATEGORY(NAME) \
static oatpp::LogCategory NAME;
/**
* Convenience macro to implement a logging category directly in a class header.
* @param NAME - variable-name of the category which is later used to reference the category.
* @param TAG - tag printed with each message printed usig this category.
* @param ENABLED - enable or disable a category (bool).
*/
#define OATPP_LOG_CATEGORY(NAME, TAG, ENABLED) \
oatpp::LogCategory NAME = oatpp::LogCategory(TAG, ENABLED);
//////////////////////
//////////////////////
//////////////////////
/**
* Default oatpp assert method.
* @param FMT - the format string used for the expression
* @param EXP - expression that must be `true`.
*/
#define OATPP_ASSERT_FMT(FMT, EXP) \
if(!(EXP)) { \
OATPP_LOGe("\033[1mASSERT\033[0m[\033[1;31mFAILED\033[0m]", FMT, #EXP) \
exit(EXIT_FAILURE); \
}
/**
* Default oatpp assert method.
* @param EXP - expression that must be `true`.
*/
#define OATPP_ASSERT(EXP) \
if(!(EXP)) { \
OATPP_LOGe("\033[1mASSERT\033[0m[\033[1;31mFAILED\033[0m]", #EXP) \
exit(EXIT_FAILURE); \
}
#endif /* oatpp_base_Log_hpp */

View File

@ -23,6 +23,7 @@
***************************************************************************/
#include "Utils.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace concurrency {
@ -53,7 +54,7 @@ v_int32 Utils::setThreadAffinityToCpuRange(std::thread::native_handle_type nativ
v_int32 result = pthread_setaffinity_np(nativeHandle, sizeof(cpu_set_t), &cpuset);
if (result != 0) {
OATPP_LOGD("[oatpp::concurrency::Thread::assignThreadToCpu(...)]", "error code - %d", result)
OATPP_LOGd("[oatpp::concurrency::Thread::assignThreadToCpu(...)]", "error code - {}", result)
}
return result;
@ -74,7 +75,7 @@ v_int32 Utils::calcHardwareConcurrency() {
#if !defined(OATPP_THREAD_HARDWARE_CONCURRENCY)
v_int32 concurrency = static_cast<v_int32>(std::thread::hardware_concurrency());
if(concurrency == 0) {
OATPP_LOGD("[oatpp::concurrency:Thread::calcHardwareConcurrency()]", "Warning - failed to get hardware_concurrency. Setting hardware_concurrency=1")
OATPP_LOGd("[oatpp::concurrency:Thread::calcHardwareConcurrency()]", "Warning - failed to get hardware_concurrency. Setting hardware_concurrency=1")
concurrency = 1;
}
return concurrency;

View File

@ -41,7 +41,7 @@ TemporaryFile::FileHandle::~FileHandle() {
oatpp::String TemporaryFile::constructRandomFilename(const oatpp::String &dir, v_int32 randomWordSizeBytes, const oatpp::String &extension) {
std::unique_ptr<v_char8[]> buff(new v_char8[randomWordSizeBytes]);
std::unique_ptr<v_char8[]> buff(new v_char8[static_cast<unsigned long>(randomWordSizeBytes)]);
utils::random::Random::randomBytes(buff.get(), randomWordSizeBytes);
data::stream::BufferOutputStream s(randomWordSizeBytes * 2 + 4);
encoding::Hex::encode(&s, buff.get(), randomWordSizeBytes, encoding::Hex::ALPHABET_LOWER);

View File

@ -34,7 +34,7 @@ namespace oatpp { namespace data{ namespace stream {
data::stream::DefaultInitializedContext BufferOutputStream::DEFAULT_CONTEXT(data::stream::StreamType::STREAM_INFINITE);
BufferOutputStream::BufferOutputStream(v_buff_size initialCapacity, const std::shared_ptr<void>& captureData)
: m_data(new v_char8[initialCapacity])
: m_data(new v_char8[static_cast<unsigned long>(initialCapacity)])
, m_capacity(initialCapacity)
, m_position(0)
, m_maxCapacity(-1)
@ -88,7 +88,7 @@ void BufferOutputStream::reserveBytesUpfront(v_buff_size count) {
throw std::runtime_error("[oatpp::data::stream::BufferOutputStream::reserveBytesUpfront()]: Error. Unable to allocate requested memory.");
}
p_char8 newData = new v_char8[newCapacity];
auto newData = new v_char8[static_cast<unsigned long>(newCapacity)];
std::memcpy(newData, m_data, static_cast<size_t>(m_position));
delete [] m_data;
@ -120,7 +120,7 @@ void BufferOutputStream::setCurrentPosition(v_buff_size position) {
void BufferOutputStream::reset(v_buff_size initialCapacity) {
delete [] m_data;
m_data = new v_char8[initialCapacity];
m_data = new v_char8[static_cast<unsigned long>(initialCapacity)];
m_capacity = initialCapacity;
m_position = 0;
}
@ -129,6 +129,10 @@ oatpp::String BufferOutputStream::toString() {
return oatpp::String(reinterpret_cast<const char*>(m_data), m_position);
}
std::string BufferOutputStream::toStdString() const {
return std::string(reinterpret_cast<const char*>(m_data), static_cast<unsigned long>(m_position));
}
oatpp::String BufferOutputStream::getSubstring(v_buff_size pos, v_buff_size count) {
if(pos + count <= m_position) {
return oatpp::String(reinterpret_cast<const char*>(m_data + pos), count);
@ -189,7 +193,7 @@ BufferInputStream::BufferInputStream(const std::shared_ptr<std::string>& memoryH
{}
BufferInputStream::BufferInputStream(const oatpp::String& data, const std::shared_ptr<void>& captureData)
: BufferInputStream(data.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(data->data())), static_cast<v_buff_size>(data->size()), captureData)
: BufferInputStream(data.getPtr(), reinterpret_cast<p_char8>(data->data()), static_cast<v_buff_size>(data->size()), captureData)
{}
void BufferInputStream::reset(const std::shared_ptr<std::string>& memoryHandle,

View File

@ -127,6 +127,12 @@ public:
*/
oatpp::String toString();
/**
* Copy data to `std::string`.
* @return
*/
std::string toStdString() const;
/**
* Create &id:oatpp::String; from part of buffer.
* @param pos - starting position in buffer.

View File

@ -32,7 +32,7 @@ data::stream::DefaultInitializedContext FIFOInputStream::DEFAULT_CONTEXT(data::s
FIFOInputStream::FIFOInputStream(v_buff_size initialSize)
: m_memoryHandle(std::make_shared<std::string>(initialSize, static_cast<char>(0)))
, m_fifo(std::make_shared<data::buffer::FIFOBuffer>(reinterpret_cast<void*>(const_cast<char*>(m_memoryHandle->data())), m_memoryHandle->size(), 0, 0, false))
, m_fifo(std::make_shared<data::buffer::FIFOBuffer>(reinterpret_cast<void*>(m_memoryHandle->data()), m_memoryHandle->size(), 0, 0, false))
, m_maxCapacity(-1) {
}
@ -87,8 +87,8 @@ void FIFOInputStream::reserveBytesUpfront(v_buff_size count) {
// ToDo: In-Memory-Resize
auto newHandle = std::make_shared<std::string>(newCapacity, static_cast<char>(0));
v_io_size oldSize = m_fifo->availableToRead();
m_fifo->read(reinterpret_cast<void*>(const_cast<char*>(newHandle->data())), oldSize);
auto newFifo = std::make_shared<data::buffer::FIFOBuffer>(reinterpret_cast<void*>(const_cast<char*>(newHandle->data())), newHandle->size(), 0, oldSize, oldSize > 0);
m_fifo->read(reinterpret_cast<void*>(newHandle->data()), oldSize);
auto newFifo = std::make_shared<data::buffer::FIFOBuffer>(reinterpret_cast<void*>(newHandle->data()), newHandle->size(), 0, oldSize, oldSize > 0);
m_memoryHandle = newHandle;
m_fifo = newFifo;
}

View File

@ -23,6 +23,7 @@
***************************************************************************/
#include "FileStream.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace data{ namespace stream {
@ -52,7 +53,7 @@ FileInputStream::FileInputStream(const char* filename, const std::shared_ptr<voi
: FileInputStream(std::fopen(filename, "rb"), true, captureData)
{
if(!m_file) {
OATPP_LOGE("[oatpp::data::stream::FileInputStream::FileInputStream(filename)]", "Error. Can't open file '%s'.", filename)
OATPP_LOGe("[oatpp::data::stream::FileInputStream::FileInputStream(filename)]", "Error. Can't open file '{}'.", filename)
throw std::runtime_error("[oatpp::data::stream::FileInputStream::FileInputStream(filename)]: Error. Can't open file.");
}
}
@ -132,7 +133,7 @@ FileOutputStream::FileOutputStream(const char* filename, const char* mode, const
: FileOutputStream(std::fopen(filename, mode), true, captureData)
{
if(!m_file) {
OATPP_LOGE("[oatpp::data::stream::FileOutputStream::FileOutputStream(filename, mode)]", "Error. Can't open file '%s'.", filename)
OATPP_LOGe("[oatpp::data::stream::FileOutputStream::FileOutputStream(filename, mode)]", "Error. Can't open file '{}'.", filename)
throw std::runtime_error("[oatpp::data::stream::FileOutputStream::FileOutputStream(filename, mode)]: Error. Can't open file.");
}
}

View File

@ -24,6 +24,7 @@
#include "./Stream.hpp"
#include "oatpp/utils/Conversion.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace data{ namespace stream {
@ -42,7 +43,7 @@ v_io_size WriteCallback::writeSimple(const void *data, v_buff_size count) {
async::Action action;
auto res = write(data, count, action);
if(!action.isNone()) {
OATPP_LOGE("[oatpp::data::stream::WriteCallback::writeSimple()]", "Error. writeSimple is called on a stream in Async mode.")
OATPP_LOGe("[oatpp::data::stream::WriteCallback::writeSimple()]", "Error. writeSimple is called on a stream in Async mode.")
throw std::runtime_error("[oatpp::data::stream::WriteCallback::writeSimple()]: Error. writeSimple is called on a stream in Async mode.");
}
return res;
@ -54,7 +55,7 @@ v_io_size WriteCallback::writeExactSizeDataSimple(data::buffer::InlineWriteData&
async::Action action;
auto res = write(inlineData, action);
if(!action.isNone()) {
OATPP_LOGE("[oatpp::data::stream::WriteCallback::writeExactSizeDataSimple()]", "Error. writeExactSizeDataSimple() is called on a stream in Async mode.")
OATPP_LOGe("[oatpp::data::stream::WriteCallback::writeExactSizeDataSimple()]", "Error. writeExactSizeDataSimple() is called on a stream in Async mode.")
throw std::runtime_error("[oatpp::data::stream::WriteCallback::writeExactSizeDataSimple()]: Error. writeExactSizeDataSimple() is called on a stream in Async mode.");
}
if(res == IOError::BROKEN_PIPE || res == IOError::ZERO_VALUE) {
@ -93,7 +94,7 @@ async::Action WriteCallback::writeExactSizeDataAsyncInline(data::buffer::InlineW
case IOError::RETRY_WRITE:
return async::Action::createActionByType(async::Action::TYPE_REPEAT);
default:
OATPP_LOGE("[oatpp::data::stream::writeExactSizeDataAsyncInline()]", "Error. Unknown IO result.")
OATPP_LOGe("[oatpp::data::stream::writeExactSizeDataAsyncInline()]", "Error. Unknown IO result.")
return new async::Error(
"[oatpp::data::stream::writeExactSizeDataAsyncInline()]: Error. Unknown IO result.");
}
@ -146,7 +147,7 @@ v_io_size ReadCallback::readExactSizeDataSimple(data::buffer::InlineReadData& in
async::Action action;
auto res = read(inlineData, action);
if(!action.isNone()) {
OATPP_LOGE("[oatpp::data::stream::ReadCallback::readExactSizeDataSimple()]", "Error. readExactSizeDataSimple() is called on a stream in Async mode.")
OATPP_LOGe("[oatpp::data::stream::ReadCallback::readExactSizeDataSimple()]", "Error. readExactSizeDataSimple() is called on a stream in Async mode.")
throw std::runtime_error("[oatpp::data::stream::ReadCallback::readExactSizeDataSimple()]: Error. readExactSizeDataSimple() is called on a stream in Async mode.");
}
if(res <= 0 && res != IOError::RETRY_READ && res != IOError::RETRY_WRITE) {
@ -185,7 +186,7 @@ async::Action ReadCallback::readExactSizeDataAsyncInline(data::buffer::InlineRea
case IOError::RETRY_WRITE:
return async::Action::createActionByType(async::Action::TYPE_REPEAT);
default:
OATPP_LOGE("[oatpp::data::stream::readExactSizeDataAsyncInline()]", "Error. Unknown IO result.")
OATPP_LOGe("[oatpp::data::stream::readExactSizeDataAsyncInline()]", "Error. Unknown IO result.")
return new async::Error(
"[oatpp::data::stream::readExactSizeDataAsyncInline()]: Error. Unknown IO result.");
}
@ -219,7 +220,7 @@ async::Action ReadCallback::readSomeDataAsyncInline(data::buffer::InlineReadData
case IOError::RETRY_WRITE:
return async::Action::createActionByType(async::Action::TYPE_REPEAT);
default:
OATPP_LOGE("[oatpp::data::stream::readSomeDataAsyncInline()]", "Error. Unknown IO result.")
OATPP_LOGe("[oatpp::data::stream::readSomeDataAsyncInline()]", "Error. Unknown IO result.")
return new async::Error(
"[oatpp::data::stream::readSomeDataAsyncInline()]: Error. Unknown IO result.");
}
@ -235,7 +236,7 @@ v_io_size ReadCallback::readSimple(void *data, v_buff_size count) {
async::Action action;
auto res = read(data, count, action);
if(!action.isNone()) {
OATPP_LOGE("[oatpp::data::stream::ReadCallback::readSimple()]", "Error. readSimple is called on a stream in Async mode.")
OATPP_LOGe("[oatpp::data::stream::ReadCallback::readSimple()]", "Error. readSimple is called on a stream in Async mode.")
throw std::runtime_error("[oatpp::data::stream::ReadCallback::readSimple()]: Error. readSimple is called on a stream in Async mode.");
}
return res;

View File

@ -45,7 +45,7 @@ String String::loadFromFile(const char* filename) {
if (file.is_open()) {
auto result = data::type::String(file.tellg());
file.seekg(0, std::ios::beg);
file.read(const_cast<char*>(result->data()), static_cast<std::streamsize>(result->size()));
file.read(result->data(), static_cast<std::streamsize>(result->size()));
file.close();
return result;
}

View File

@ -109,8 +109,8 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp
auto result = oatpp::String(resultSize);
p_char8 bdata = reinterpret_cast<p_char8>(const_cast<void*>(data));
p_char8 resultData = reinterpret_cast<p_char8>(const_cast<char*>(result->data()));
auto bdata = reinterpret_cast<const v_char8*>(data);
auto resultData = reinterpret_cast<p_char8>(result->data());
v_buff_size pos = 0;
while (pos + 2 < size) {
@ -159,7 +159,7 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux
}
auto result = oatpp::String(resultSize);
p_char8 resultData = reinterpret_cast<p_char8>(const_cast<char*>(result->data()));
auto resultData = reinterpret_cast<p_char8>(result->data());
v_buff_size pos = 0;
while (pos + 3 < base64StrLength) {
v_char8 b0 = getAlphabetCharIndex(static_cast<v_char8>(data[pos]), auxiliaryChars);

View File

@ -225,8 +225,8 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f
if(escapedSize == size) {
return String(data, size);
}
auto result = String(escapedSize);
p_char8 resultData = reinterpret_cast<p_char8>(const_cast<char*>(result->data()));
String result(escapedSize);
auto resultData = reinterpret_cast<p_char8>(result->data());
v_buff_size pos = 0;
{
@ -375,11 +375,11 @@ oatpp::String Utils::unescapeString(const char* data, v_buff_size size, v_int64&
if(errorCode != 0){
return nullptr;
}
auto result = String(unescapedSize);
String result(unescapedSize);
if(unescapedSize == size) {
std::memcpy(reinterpret_cast<void*>(const_cast<char*>(result->data())), data, static_cast<size_t>(size));
std::memcpy(reinterpret_cast<void*>(result->data()), data, static_cast<size_t>(size));
} else {
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(const_cast<char*>(result->data())));
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(result->data()));
}
return result;
@ -394,9 +394,9 @@ std::string Utils::unescapeStringToStdString(const char* data, v_buff_size size,
std::string result;
result.resize(static_cast<size_t>(unescapedSize));
if(unescapedSize == size) {
std::memcpy(reinterpret_cast<void*>(const_cast<char*>(result.data())), data, static_cast<size_t>(size));
std::memcpy(reinterpret_cast<void*>(result.data()), data, static_cast<size_t>(size));
} else {
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(const_cast<char*>(result.data())));
unescapeStringToBuffer(data, size, reinterpret_cast<p_char8>(result.data()));
}
return result;

View File

@ -23,6 +23,7 @@
***************************************************************************/
#include "ConnectionProviderSwitch.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace network {
@ -48,7 +49,7 @@ std::shared_ptr<ConnectionProvider> ConnectionProviderSwitch::getCurrentProvider
if(!provider) {
const char* const TAG = "[oatpp::network::ConnectionProviderSwitch::getCurrentProvider()]";
const char* const msg = "Error. Can't provide connection. There is no provider set.";
OATPP_LOGE(TAG, msg)
OATPP_LOGe(TAG, msg)
throw std::runtime_error(std::string(TAG) + ": " + msg);
}

View File

@ -24,6 +24,8 @@
#include "Server.hpp"
#include "oatpp/base/Log.hpp"
#include <thread>
#include <chrono>
@ -62,7 +64,7 @@ void Server::conditionalMainLoop() {
setStatus(STATUS_STOPPING);
}
} else {
OATPP_LOGD("[oatpp::network::server::mainLoop()]", "Error. Server already stopped - closing connection...")
OATPP_LOGd("[oatpp::network::server::mainLoop()]", "Error. Server already stopped - closing connection...")
}
}
@ -86,7 +88,7 @@ void Server::mainLoop(Server *instance) {
if (instance->getStatus() == STATUS_RUNNING) {
instance->m_connectionHandler->handleConnection(connectionHandle, params /* null params */);
} else {
OATPP_LOGD("[oatpp::network::server::mainLoop()]", "Error. Server already stopped - closing connection...")
OATPP_LOGd("[oatpp::network::server::mainLoop()]", "Error. Server already stopped - closing connection...")
}
}
}
@ -121,7 +123,7 @@ void Server::run(std::function<bool()> conditional) {
void Server::run(bool startAsNewThread) {
std::unique_lock<std::mutex> ul(m_mutex);
OATPP_LOGW("[oatpp::network::server::run(bool)]", "Using oatpp::network::server::run(bool) is deprecated and will be removed in the next release. Please implement your own threading (See https://github.com/oatpp/oatpp-threaded-starter).")
OATPP_LOGw("[oatpp::network::server::run(bool)]", "Using oatpp::network::server::run(bool) is deprecated and will be removed in the next release. Please implement your own threading (See https://github.com/oatpp/oatpp-threaded-starter).")
switch (getStatus()) {
case STATUS_STARTING:
throw std::runtime_error("[oatpp::network::server::run()] Error. Server already starting");

View File

@ -33,7 +33,7 @@ oatpp::String Url::Parser::parseScheme(oatpp::utils::parser::Caret& caret) {
caret.findChar(':');
v_buff_size size = caret.getPosition() - pos0;
if(size > 0) {
std::unique_ptr<v_char8[]> buff(new v_char8[size]);
std::unique_ptr<v_char8[]> buff(new v_char8[static_cast<unsigned long>(size)]);
std::memcpy(buff.get(), &caret.getData()[pos0], static_cast<size_t>(size));
utils::String::lowerCase_ASCII(buff.get(), size);
return oatpp::String(reinterpret_cast<const char*>(buff.get()), size);

View File

@ -24,6 +24,8 @@
#include "ConnectionMonitor.hpp"
#include "oatpp/base/Log.hpp"
#include <chrono>
#include <thread>
@ -59,8 +61,8 @@ ConnectionMonitor::ConnectionProxy::~ConnectionProxy() {
if(m_stats.metricsData.size() > 0) {
for(auto& pair : m_stats.metricsData) {
OATPP_LOGE("[oatpp::network::ConnectionMonitor::ConnectionProxy::~ConnectionProxy()]",
"Error. Memory leak. Metric data was not deleted: Metric name - '%s'", pair.first->c_str())
OATPP_LOGe("[oatpp::network::ConnectionMonitor::ConnectionProxy::~ConnectionProxy()]",
"Error. Memory leak. Metric data was not deleted: Metric name - '{}'", pair.first->c_str())
}
}
@ -186,8 +188,8 @@ void ConnectionMonitor::Monitor::freeConnectionStats(ConnectionStats& stats) {
if(it != m_statCollectors.end()) {
it->second->deleteMetricData(metric.second);
} else {
OATPP_LOGE("[oatpp::network::ConnectionMonitor::Monitor::freeConnectionStats]",
"Error. Can't free Metric data. Unknown Metric: name - '%s'", metric.first->c_str())
OATPP_LOGe("[oatpp::network::ConnectionMonitor::Monitor::freeConnectionStats]",
"Error. Can't free Metric data. Unknown Metric: name - '{}'", metric.first->c_str())
}
}

View File

@ -101,7 +101,7 @@ v_io_size Connection::write(const void *buff, v_buff_size count, async::Action&
} else if(e == WSAECONNRESET) {
return IOError::BROKEN_PIPE;
} else {
//OATPP_LOGD("Connection", "write errno=%d", e)
//OATPP_LOGd("Connection", "write errno={}", e)
return IOError::BROKEN_PIPE; // Consider all other errors as a broken pipe.
}
}
@ -138,7 +138,7 @@ v_io_size Connection::write(const void *buff, v_buff_size count, async::Action&
return IOError::BROKEN_PIPE;
}
//OATPP_LOGD("Connection", "write errno=%d", e)
//OATPP_LOGd("Connection", "write errno={}", e)
return IOError::BROKEN_PIPE; // Consider all other errors as a broken pipe.
}
return result;
@ -176,7 +176,7 @@ v_io_size Connection::read(void *buff, v_buff_size count, async::Action& action)
} else if(e == WSAECONNRESET) {
return IOError::BROKEN_PIPE;
} else {
//OATPP_LOGD("Connection", "write errno=%d", e)
//OATPP_LOGd("Connection", "write errno={}", e)
return IOError::BROKEN_PIPE; // Consider all other errors as a broken pipe.
}
}
@ -208,7 +208,7 @@ v_io_size Connection::read(void *buff, v_buff_size count, async::Action& action)
return IOError::BROKEN_PIPE;
}
//OATPP_LOGD("Connection", "write errno=%d", e)
//OATPP_LOGd("Connection", "write errno={}", e)
return IOError::BROKEN_PIPE; // Consider all other errors as a broken pipe.
}
return result;

View File

@ -26,6 +26,7 @@
#include "oatpp/network/tcp/Connection.hpp"
#include "oatpp/utils/Conversion.hpp"
#include "oatpp/base/Log.hpp"
#include <fcntl.h>
#include <errno.h>
@ -123,7 +124,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::get() {
if(clientHandle >= 0) {
if(connect(clientHandle, currResult->ai_addr, static_cast<v_sock_size>(currResult->ai_addrlen)) == 0) {
if(connect(clientHandle, currResult->ai_addr, currResult->ai_addrlen) == 0) {
break;
} else {
err = errno;
@ -151,7 +152,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::get() {
int yes = 1;
v_int32 ret = setsockopt(clientHandle, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(int));
if(ret < 0) {
OATPP_LOGD("[oatpp::network::tcp::client::ConnectionProvider::getConnection()]", "Warning. Failed to set %s for socket", "SO_NOSIGPIPE")
OATPP_LOGd("[oatpp::network::tcp::client::ConnectionProvider::getConnection()]", "Warning. Failed to set {} for socket", "SO_NOSIGPIPE")
}
#endif
@ -266,7 +267,7 @@ oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::str
int yes = 1;
v_int32 ret = setsockopt(m_clientHandle, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(int));
if(ret < 0) {
OATPP_LOGD("[oatpp::network::tcp::client::ConnectionProvider::getConnectionAsync()]", "Warning. Failed to set %s for socket", "SO_NOSIGPIPE")
OATPP_LOGd("[oatpp::network::tcp::client::ConnectionProvider::getConnectionAsync()]", "Warning. Failed to set {} for socket", "SO_NOSIGPIPE")
}
#endif
@ -282,7 +283,7 @@ oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::str
Action doConnect() {
errno = 0;
auto res = connect(m_clientHandle, m_currentResult->ai_addr, static_cast<v_sock_size>(m_currentResult->ai_addrlen));
auto res = connect(m_clientHandle, m_currentResult->ai_addr, m_currentResult->ai_addrlen);
#if defined(WIN32) || defined(_WIN32)

View File

@ -25,6 +25,7 @@
#include "./ConnectionProvider.hpp"
#include "oatpp/utils/Conversion.hpp"
#include "oatpp/base/Log.hpp"
#include <fcntl.h>
@ -178,7 +179,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
const int iResult = getaddrinfo(m_address.host->c_str(), portStr->c_str(), &hints, &result);
if (iResult != 0) {
OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", "Error. Call to getaddrinfo() failed with result=%d", iResult)
OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", "Error. Call to getaddrinfo() failed with result={}", iResult)
throw std::runtime_error("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: Error. Call to getaddrinfo() failed.");
}
@ -195,8 +196,8 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
if (setsockopt(serverHandle, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&no, sizeof( int ) ) != 0 ) {
const size_t buflen = 500;
char buf[buflen];
OATPP_LOGW("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Warning. Failed to set %s for accepting socket: %s", "IPV6_V6ONLY",
OATPP_LOGw("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Warning. Failed to set {} for accepting socket: {}", "IPV6_V6ONLY",
strerror_s(buf, buflen, errno))
}
}
@ -218,8 +219,8 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
freeaddrinfo(result);
if (currResult == nullptr) {
OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Error. Couldn't bind. WSAGetLastError=%ld", WSAGetLastError())
OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Error. Couldn't bind. WSAGetLastError={}", WSAGetLastError())
throw std::runtime_error("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: "
"Error. Couldn't bind ");
}
@ -268,7 +269,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
ret = getaddrinfo(m_address.host->c_str(), portStr->c_str(), &hints, &result);
if (ret != 0) {
OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", "Error. Call to getaddrinfo() failed with result=%d: %s", ret, strerror(errno))
OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", "Error. Call to getaddrinfo() failed with result={}: {}", ret, strerror(errno))
throw std::runtime_error("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: Error. Call to getaddrinfo() failed.");
}
@ -280,11 +281,11 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
if (serverHandle >= 0) {
if (setsockopt(serverHandle, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0) {
OATPP_LOGW("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Warning. Failed to set %s for accepting socket: %s", "SO_REUSEADDR", strerror(errno))
OATPP_LOGw("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Warning. Failed to set {} for accepting socket: {}", "SO_REUSEADDR", strerror(errno))
}
if (bind(serverHandle, currResult->ai_addr, static_cast<v_sock_size>(currResult->ai_addrlen)) == 0 &&
if (bind(serverHandle, currResult->ai_addr, currResult->ai_addrlen) == 0 &&
listen(serverHandle, 10000) == 0)
{
break;
@ -302,8 +303,8 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){
if (currResult == nullptr) {
std::string err = strerror(errno);
OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Error. Couldn't bind. %s", err.c_str())
OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]",
"Error. Couldn't bind. {}", err.c_str())
throw std::runtime_error("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: "
"Error. Couldn't bind " + err);
}
@ -329,7 +330,7 @@ void ConnectionProvider::prepareConnectionHandle(oatpp::v_io_handle handle) {
int yes = 1;
v_int32 ret = setsockopt(handle, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(int));
if(ret < 0) {
OATPP_LOGD("[oatpp::network::tcp::server::ConnectionProvider::prepareConnectionHandle()]", "Warning. Failed to set %s for socket", "SO_NOSIGPIPE")
OATPP_LOGd("[oatpp::network::tcp::server::ConnectionProvider::prepareConnectionHandle()]", "Warning. Failed to set {} for socket", "SO_NOSIGPIPE")
}
#endif
@ -397,7 +398,7 @@ provider::ResourceHandle<data::stream::IOStream> ConnectionProvider::getExtended
::close(handle);
#endif
OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::getExtendedConnection()]", "Error. Unknown address family.")
OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::getExtendedConnection()]", "Error. Unknown address family.")
return nullptr;
}

View File

@ -23,6 +23,7 @@
***************************************************************************/
#include "Interface.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace network { namespace virtual_ {
@ -85,7 +86,7 @@ Interface::~Interface() {
{
std::lock_guard<std::mutex> lock(m_listenerMutex);
if (m_listenerLock != nullptr) {
OATPP_LOGE("[oatpp::network::virtual_::Interface::~Interface()]",
OATPP_LOGe("[oatpp::network::virtual_::Interface::~Interface()]",
"Error! Interface destructor called, but listener is still bonded!!!")
m_listenerLock.load()->m_interface = nullptr;
}
@ -175,7 +176,7 @@ void Interface::unbindListener(ListenerLock* listenerLock) {
m_listenerLock = nullptr;
dropAllConnection();
} else {
OATPP_LOGE("[oatpp::network::virtual_::Interface::unbindListener()]", "Error! Unbinding wrong listener!!!")
OATPP_LOGe("[oatpp::network::virtual_::Interface::unbindListener()]", "Error! Unbinding wrong listener!!!")
}
}

View File

@ -37,6 +37,7 @@
#include "oatpp/Types.hpp"
#include "oatpp/utils/Conversion.hpp"
#include "oatpp/base/Log.hpp"
#include <string>
#include <list>
@ -230,8 +231,8 @@ public:
(void) parameter;
OATPP_LOGE("[oatpp::web::client::ApiClient::TypeInterpretation::toString()]",
"Error. No conversion from '%s' to '%s' is defined.", typeName->c_str(), "oatpp::String")
OATPP_LOGe("[oatpp::web::client::ApiClient::TypeInterpretation::toString()]",
"Error. No conversion from '{}' to '{}' is defined.", typeName, "oatpp::String")
throw std::runtime_error(
"[oatpp::web::client::ApiClient::TypeInterpretation::toString()]: Error. "

View File

@ -53,7 +53,7 @@ std::pair<oatpp::String, oatpp::String> ContentMappers::typeAndSubtype(const dat
}
void ContentMappers::putMapper(const std::shared_ptr<data::mapping::ObjectMapper>& mapper) {
std::unique_lock lock(m_mutex);
std::unique_lock<std::shared_mutex> lock(m_mutex);
if(m_defaultMapper == nullptr) {
m_defaultMapper = mapper;
}
@ -62,12 +62,12 @@ void ContentMappers::putMapper(const std::shared_ptr<data::mapping::ObjectMapper
}
void ContentMappers::setDefaultMapper(const oatpp::String& contentType) {
std::unique_lock lock(m_mutex);
std::unique_lock<std::shared_mutex> lock(m_mutex);
m_defaultMapper = m_mappers.at(contentType);
}
void ContentMappers::setDefaultMapper(const std::shared_ptr<data::mapping::ObjectMapper>& mapper) {
std::unique_lock lock(m_mutex);
std::unique_lock<std::shared_mutex> lock(m_mutex);
m_defaultMapper = mapper;
if(m_defaultMapper) {
m_index[m_defaultMapper->getInfo().mimeType][m_defaultMapper->getInfo().mimeSubtype] = m_defaultMapper;
@ -76,7 +76,7 @@ void ContentMappers::setDefaultMapper(const std::shared_ptr<data::mapping::Objec
}
std::shared_ptr<data::mapping::ObjectMapper> ContentMappers::getMapper(const oatpp::String& contentType) const {
std::shared_lock lock(m_mutex);
std::shared_lock<std::shared_mutex> lock(m_mutex);
auto it = m_mappers.find(contentType);
if(it == m_mappers.end()) {
return nullptr;
@ -85,7 +85,7 @@ std::shared_ptr<data::mapping::ObjectMapper> ContentMappers::getMapper(const oat
}
std::shared_ptr<data::mapping::ObjectMapper> ContentMappers::getDefaultMapper() const {
std::shared_lock lock(m_mutex);
std::shared_lock<std::shared_mutex> lock(m_mutex);
return m_defaultMapper;
}
@ -162,7 +162,7 @@ std::shared_ptr<data::mapping::ObjectMapper> ContentMappers::selectMapper(const
std::shared_ptr<data::mapping::ObjectMapper> ContentMappers::selectMapper(const oatpp::String& acceptHeader) const {
std::shared_lock lock(m_mutex);
std::shared_lock<std::shared_mutex> lock(m_mutex);
if(!acceptHeader || acceptHeader->empty()) {
return m_defaultMapper;
@ -177,7 +177,7 @@ std::shared_ptr<data::mapping::ObjectMapper> ContentMappers::selectMapper(const
std::shared_ptr<data::mapping::ObjectMapper> ContentMappers::selectMapper(const std::vector<oatpp::String>& acceptableContentTypes) const {
std::shared_lock lock(m_mutex);
std::shared_lock<std::shared_mutex> lock(m_mutex);
if(acceptableContentTypes.empty()) {
return m_defaultMapper;
@ -194,7 +194,7 @@ std::shared_ptr<data::mapping::ObjectMapper> ContentMappers::selectMapper(const
}
void ContentMappers::clear() {
std::unique_lock lock(m_mutex);
std::unique_lock<std::shared_mutex> lock(m_mutex);
m_defaultMapper = nullptr;
m_mappers.clear();
}

View File

@ -58,7 +58,7 @@ void Multipart::writeNextPartSimple(const std::shared_ptr<Part>& part) {
}
oatpp::String Multipart::generateRandomBoundary(v_int32 boundarySize) {
std::unique_ptr<v_char8[]> buffer(new v_char8[boundarySize]);
std::unique_ptr<v_char8[]> buffer(new v_char8[static_cast<unsigned long>(boundarySize)]);
utils::random::Random::randomBytes(buffer.get(), boundarySize);
return encoding::Base64::encode(buffer.get(), boundarySize, encoding::Base64::ALPHABET_BASE64_URL_SAFE);
}

View File

@ -23,6 +23,7 @@
***************************************************************************/
#include "PartReader.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace web { namespace mime { namespace multipart {
@ -73,12 +74,12 @@ void StreamPartReader::onPartData(const std::shared_ptr<Part>& part, const char*
if(size > 0) {
if(m_maxDataSize > 0 && tagObject->size + size > m_maxDataSize) {
OATPP_LOGE("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]", "Error. Part size exceeds specified maxDataSize=%ld", m_maxDataSize)
OATPP_LOGe("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]", "Error. Part size exceeds specified maxDataSize={}", m_maxDataSize)
throw std::runtime_error("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]: Error. Part size exceeds specified maxDataSize");
}
auto res = tagObject->outputStream->writeExactSizeDataSimple(data, size);
if(res != size) {
OATPP_LOGE("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]", "Error. Failed to stream all data. Streamed %ld/%ld", res, size)
OATPP_LOGe("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]", "Error. Failed to stream all data. Streamed {}/{}", res, size)
throw std::runtime_error("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]: Error. Failed to stream all data.");
}
tagObject->size += res;
@ -163,7 +164,7 @@ async::CoroutineStarter AsyncStreamPartReader::onPartDataAsync(const std::shared
if(size > 0) {
if(m_maxDataSize > 0 && tagObject->size + size > m_maxDataSize) {
OATPP_LOGE("[oatpp::web::mime::multipart::AsyncStreamPartReader::onPartDataAsync()]", "Error. Part size exceeds specified maxDataSize=%ld", m_maxDataSize)
OATPP_LOGe("[oatpp::web::mime::multipart::AsyncStreamPartReader::onPartDataAsync()]", "Error. Part size exceeds specified maxDataSize={}", m_maxDataSize)
throw std::runtime_error("[oatpp::web::mime::multipart::AsyncStreamPartReader::onPartDataAsync()]: Error. Part size exceeds specified maxDataSize");
}
return tagObject->outputStream->writeExactSizeDataAsync(data, size);

View File

@ -69,7 +69,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff
stream.write("\r\n", 2, action);
m_chunkHeader = stream.toString();
dataOut.set(reinterpret_cast<p_char8>(const_cast<char*>(m_chunkHeader->data())), static_cast<v_buff_size>(m_chunkHeader->size()));
dataOut.set(reinterpret_cast<p_char8>(m_chunkHeader->data()), static_cast<v_buff_size>(m_chunkHeader->size()));
m_firstChunk = false;
m_writeChunkHeader = false;
@ -96,7 +96,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff
stream.write("0\r\n\r\n", 5, action);
m_chunkHeader = stream.toString();
dataOut.set(reinterpret_cast<p_char8>(const_cast<char*>(m_chunkHeader->data())), static_cast<v_buff_size>(m_chunkHeader->size()));
dataOut.set(reinterpret_cast<p_char8>(m_chunkHeader->data()), static_cast<v_buff_size>(m_chunkHeader->size()));
m_firstChunk = false;
m_writeChunkHeader = false;

View File

@ -23,6 +23,7 @@
***************************************************************************/
#include "RequestHeadersReader.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace web { namespace protocol { namespace http { namespace incoming {
@ -78,7 +79,7 @@ RequestHeadersReader::Result RequestHeadersReader::readHeaders(data::stream::Inp
error.ioStatus = readHeadersSectionIterative(iteration, stream, action);
if(!action.isNone()) {
OATPP_LOGE("[oatpp::web::protocol::http::incoming::RequestHeadersReader::readHeaders]", "Error. Async action is unexpected.")
OATPP_LOGe("[oatpp::web::protocol::http::incoming::RequestHeadersReader::readHeaders]", "Error. Async action is unexpected.")
throw std::runtime_error("[oatpp::web::protocol::http::incoming::RequestHeadersReader::readHeaders]: Error. Async action is unexpected.");
}

View File

@ -29,7 +29,7 @@ namespace oatpp { namespace web { namespace protocol { namespace http { namespac
BufferBody::BufferBody(const oatpp::String &buffer, const data::share::StringKeyLabel &contentType)
: m_buffer(buffer ? buffer : "")
, m_contentType(contentType)
, m_inlineData(reinterpret_cast<void*>(const_cast<char*>(m_buffer->data())), static_cast<v_buff_size>(m_buffer->size()))
, m_inlineData(reinterpret_cast<void*>(m_buffer->data()), static_cast<v_buff_size>(m_buffer->size()))
{}
std::shared_ptr<BufferBody> BufferBody::createShared(const oatpp::String &buffer,
@ -67,7 +67,7 @@ void BufferBody::declareHeaders(Headers &headers) {
}
p_char8 BufferBody::getKnownData() {
return reinterpret_cast<p_char8>(const_cast<char*>(m_buffer->data()));
return reinterpret_cast<p_char8>(m_buffer->data());
}
v_int64 BufferBody::getKnownSize() {

View File

@ -24,13 +24,14 @@
#include "MultipartBody.hpp"
#include "oatpp/data/stream/BufferStream.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace web { namespace protocol { namespace http { namespace outgoing {
v_io_size MultipartBody::readBody(void *buffer, v_buff_size count, async::Action& action) {
const auto& stream = m_iterator.getPartInputStream();
if(!stream) {
OATPP_LOGW("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::readBody()]", "Warning. Part has no input stream.")
OATPP_LOGw("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::readBody()]", "Warning. Part has no input stream.")
return 0;
}
return stream->read(buffer, count, action);
@ -81,7 +82,7 @@ v_io_size MultipartBody::read(void *buffer, v_buff_size count, async::Action& ac
break;
default:
OATPP_LOGE("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::read()]", "Error. Invalid state %d", m_state)
OATPP_LOGe("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::read()]", "Error. Invalid state {}", m_state)
return 0;
}
@ -107,7 +108,7 @@ v_io_size MultipartBody::read(void *buffer, v_buff_size count, async::Action& ac
}
} else if(action.isNone()) {
OATPP_LOGE("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::read()]", "Error. Invalid read result %ld. State=%d", res, m_state)
OATPP_LOGe("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::read()]", "Error. Invalid read result {}. State={}", res, m_state)
return 0;
}
@ -134,7 +135,7 @@ v_io_size MultipartBody::readBoundary(const std::shared_ptr<Multipart>& multipar
boundary = "\r\n--" + multipart->getBoundary() + "\r\n";
}
readStream.reset(boundary.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(boundary->data())), static_cast<v_buff_size>(boundary->size()));
readStream.reset(boundary.getPtr(), reinterpret_cast<p_char8>(boundary->data()), static_cast<v_buff_size>(boundary->size()));
}
@ -161,7 +162,7 @@ v_io_size MultipartBody::readHeaders(const std::shared_ptr<Multipart>& multipart
http::Utils::writeHeaders(part->getHeaders(), &stream);
stream.writeSimple("\r\n", 2);
auto str = stream.toString();
readStream.reset(str.getPtr(), reinterpret_cast<p_char8>(const_cast<char*>(str->data())), static_cast<v_buff_size>(str->size()));
readStream.reset(str.getPtr(), reinterpret_cast<p_char8>(str->data()), static_cast<v_buff_size>(str->size()));
}

View File

@ -204,7 +204,7 @@ HttpProcessor::ConnectionState HttpProcessor::processNextRequest(ProcessingResou
handler->handleConnection(resources.connection, response->getConnectionUpgradeParameters());
connectionState = ConnectionState::DELEGATED;
} else {
OATPP_LOGW("[oatpp::web::server::HttpProcessor::processNextRequest()]", "Warning. ConnectionUpgradeHandler not set!")
OATPP_LOGw("[oatpp::web::server::HttpProcessor::processNextRequest()]", "Warning. ConnectionUpgradeHandler not set!")
connectionState = ConnectionState::CLOSING;
}
}
@ -396,7 +396,7 @@ HttpProcessor::Coroutine::Action HttpProcessor::Coroutine::onRequestDone() {
handler->handleConnection(m_connection, m_currentResponse->getConnectionUpgradeParameters());
m_connectionState = ConnectionState::DELEGATED;
} else {
OATPP_LOGW("[oatpp::web::server::HttpProcessor::Coroutine::onResponseFormed()]", "Warning. ConnectionUpgradeHandler not set!")
OATPP_LOGw("[oatpp::web::server::HttpProcessor::Coroutine::onResponseFormed()]", "Warning. ConnectionUpgradeHandler not set!")
m_connectionState = ConnectionState::CLOSING;
}
break;
@ -425,7 +425,7 @@ HttpProcessor::Coroutine::Action HttpProcessor::Coroutine::handleError(Error* er
}
if(m_currentResponse) {
//OATPP_LOGE("[oatpp::web::server::HttpProcessor::Coroutine::handleError()]", "Unhandled error. '%s'. Dropping connection", error->what())
//OATPP_LOGe("[oatpp::web::server::HttpProcessor::Coroutine::handleError()]", "Unhandled error. '{}'. Dropping connection", error->what())
return error;
}

View File

@ -36,6 +36,7 @@
#include "oatpp/web/protocol/http/outgoing/ResponseFactory.hpp"
#include "oatpp/utils/Conversion.hpp"
#include "oatpp/base/Log.hpp"
#include <list>
#include <unordered_map>
@ -453,8 +454,8 @@ public:
static T fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) {
(void) text;
success = false;
OATPP_LOGE("[oatpp::web::server::api::ApiController::TypeInterpretation::fromString()]",
"Error. No conversion from '%s' to '%s' is defined.", "oatpp::String", typeName->c_str())
OATPP_LOGe("[oatpp::web::server::api::ApiController::TypeInterpretation::fromString()]",
"Error. No conversion from '{}' to '{}' is defined.", "oatpp::String", typeName)
throw std::runtime_error("[oatpp::web::server::api::ApiController::TypeInterpretation::fromString()]: Error. "
"No conversion from 'oatpp::String' to '" + *typeName + "' is defined. "
"Please define type conversion.");

View File

@ -103,7 +103,7 @@ std::shared_ptr<Pattern> Pattern::parse(const char* data){
}
std::shared_ptr<Pattern> Pattern::parse(const oatpp::String& data){
return parse(reinterpret_cast<p_char8>(const_cast<char*>(data->data())), static_cast<v_buff_size>(data->size()));
return parse(reinterpret_cast<p_char8>(data->data()), static_cast<v_buff_size>(data->size()));
}
v_char8 Pattern::findSysChar(oatpp::utils::parser::Caret& caret) {

View File

@ -148,7 +148,7 @@ public:
for(auto& pair : m_endpointsByPattern) {
auto mapping = pair.first->toString();
OATPP_LOGD("Router", "url '%s %s' -> mapped", reinterpret_cast<const char*>(branch.getData()), mapping->c_str())
OATPP_LOGd("Router", "url '{} {}' -> mapped", reinterpret_cast<const char*>(branch.getData()), mapping)
}
}

View File

@ -6,6 +6,8 @@ add_executable(oatppAllTests
oatpp/async/LockTest.hpp
oatpp/base/CommandLineArgumentsTest.cpp
oatpp/base/CommandLineArgumentsTest.hpp
oatpp/base/LogTest.cpp
oatpp/base/LogTest.hpp
oatpp/data/buffer/ProcessorTest.cpp
oatpp/data/buffer/ProcessorTest.hpp
oatpp/data/mapping/ObjectRemapperTest.cpp

View File

@ -66,6 +66,8 @@
#include "oatpp/data/buffer/ProcessorTest.hpp"
#include "oatpp/base/CommandLineArgumentsTest.hpp"
#include "oatpp/base/LogTest.hpp"
#include "oatpp/LoggerTest.hpp"
#include "oatpp/async/Coroutine.hpp"
@ -84,28 +86,31 @@ void runTests() {
oatpp::Environment::printCompilationConfig();
OATPP_LOGD("Tests", "oatpp::String size=%lu", sizeof(oatpp::String))
OATPP_LOGD("Tests", "std::string size=%lu", sizeof(std::string))
OATPP_LOGD("Tests", "Vector size=%lu", sizeof(std::vector<int>))
OATPP_LOGD("Tests", "Map size=%lu", sizeof(std::unordered_map<oatpp::String, oatpp::String>))
OATPP_LOGD("Tests", "Tree size=%lu", sizeof(oatpp::data::mapping::Tree))
OATPP_LOGd("Tests", "oatpp::String size={}", sizeof(oatpp::String))
OATPP_LOGd("Tests", "oatpp::String size={}", sizeof(oatpp::String))
OATPP_LOGd("Tests", "std::string size={}", sizeof(std::string))
OATPP_LOGd("Tests", "Vector size={}", sizeof(std::vector<int>))
OATPP_LOGd("Tests", "Map size={}", sizeof(std::unordered_map<oatpp::String, oatpp::String>))
OATPP_LOGd("Tests", "Tree size={}", sizeof(oatpp::data::mapping::Tree))
//return;
OATPP_LOGD("Tests", "coroutine handle size=%lu", sizeof(oatpp::async::CoroutineHandle))
OATPP_LOGD("Tests", "coroutine size=%lu", sizeof(oatpp::async::AbstractCoroutine))
OATPP_LOGD("Tests", "action size=%lu", sizeof(oatpp::async::Action))
OATPP_LOGD("Tests", "class count=%d", oatpp::data::type::ClassId::getClassCount())
OATPP_LOGd("Tests", "coroutine handle size={}", sizeof(oatpp::async::CoroutineHandle))
OATPP_LOGd("Tests", "coroutine size={}", sizeof(oatpp::async::AbstractCoroutine))
OATPP_LOGd("Tests", "action size={}", sizeof(oatpp::async::Action))
OATPP_LOGd("Tests", "class count={}", oatpp::data::type::ClassId::getClassCount())
auto names = oatpp::data::type::ClassId::getRegisteredClassNames();
v_int32 i = 0;
for(auto& name : names) {
OATPP_LOGD("CLASS", "%d --> '%s'", i, name)
OATPP_LOGd("CLASS", "{} --> '{}'", i, name)
i ++;
}
OATPP_RUN_TEST(oatpp::test::LoggerTest);
OATPP_RUN_TEST(oatpp::base::CommandLineArgumentsTest);
OATPP_RUN_TEST(oatpp::base::LogTest);
OATPP_RUN_TEST(oatpp::data::share::MemoryLabelTest);
OATPP_RUN_TEST(oatpp::data::share::LazyStringMapTest);

View File

@ -33,47 +33,47 @@ void LoggerTest::onRun() {
auto logger = std::static_pointer_cast<oatpp::DefaultLogger>(oatpp::Environment::getLogger());
OATPP_LOGV("LoggerTest", "Verbose Log")
OATPP_LOGD("LoggerTest", "Debug Log")
OATPP_LOGI("LoggerTest", "Info Log")
OATPP_LOGW("LoggerTest", "Warning Log")
OATPP_LOGE("LoggerTest", "Error Log")
OATPP_LOGv("LoggerTest", "Verbose Log")
OATPP_LOGd("LoggerTest", "Debug Log")
OATPP_LOGi("LoggerTest", "Info Log")
OATPP_LOGw("LoggerTest", "Warning Log")
OATPP_LOGe("LoggerTest", "Error Log")
OATPP_LOGI("LoggerTest", " --- Disabling Debug Log")
OATPP_LOGi("LoggerTest", " --- Disabling Debug Log")
logger->disablePriority(oatpp::DefaultLogger::PRIORITY_D);
OATPP_ASSERT(!logger->isLogPriorityEnabled(oatpp::DefaultLogger::PRIORITY_D))
OATPP_LOGV("LoggerTest", "Verbose Log")
OATPP_LOGD("LoggerTest", "Debug Log")
OATPP_LOGI("LoggerTest", "Info Log")
OATPP_LOGW("LoggerTest", "Warning Log")
OATPP_LOGE("LoggerTest", "Error Log")
OATPP_LOGv("LoggerTest", "Verbose Log")
OATPP_LOGd("LoggerTest", "Debug Log")
OATPP_LOGi("LoggerTest", "Info Log")
OATPP_LOGw("LoggerTest", "Warning Log")
OATPP_LOGe("LoggerTest", "Error Log")
OATPP_LOGI("LoggerTest", " --- Enabling Debug Log again")
OATPP_LOGi("LoggerTest", " --- Enabling Debug Log again")
logger->enablePriority(oatpp::DefaultLogger::PRIORITY_D);
OATPP_ASSERT(logger->isLogPriorityEnabled(oatpp::DefaultLogger::PRIORITY_D))
OATPP_LOGV("LoggerTest", "Verbose Log")
OATPP_LOGD("LoggerTest", "Debug Log")
OATPP_LOGI("LoggerTest", "Info Log")
OATPP_LOGW("LoggerTest", "Warning Log")
OATPP_LOGE("LoggerTest", "Error Log")
OATPP_LOGv("LoggerTest", "Verbose Log")
OATPP_LOGd("LoggerTest", "Debug Log")
OATPP_LOGi("LoggerTest", "Info Log")
OATPP_LOGw("LoggerTest", "Warning Log")
OATPP_LOGe("LoggerTest", "Error Log")
OATPP_LOGI(TESTCATEGORY, " --- Log-Test with category")
OATPP_LOGV(TESTCATEGORY, "Verbose Log")
OATPP_LOGD(TESTCATEGORY, "Debug Log")
OATPP_LOGI(TESTCATEGORY, "Info Log")
OATPP_LOGW(TESTCATEGORY, "Warning Log")
OATPP_LOGE(TESTCATEGORY, "Error Log")
OATPP_LOGi(TESTCATEGORY, " --- Log-Test with category")
OATPP_LOGv(TESTCATEGORY, "Verbose Log")
OATPP_LOGd(TESTCATEGORY, "Debug Log")
OATPP_LOGi(TESTCATEGORY, "Info Log")
OATPP_LOGw(TESTCATEGORY, "Warning Log")
OATPP_LOGe(TESTCATEGORY, "Error Log")
OATPP_LOGI(TESTCATEGORY, " --- Disabling Debug Log for category")
OATPP_LOGi(TESTCATEGORY, " --- Disabling Debug Log for category")
TESTCATEGORY.disablePriority(oatpp::DefaultLogger::PRIORITY_D);
OATPP_ASSERT(!TESTCATEGORY.isLogPriorityEnabled(oatpp::DefaultLogger::PRIORITY_D))
OATPP_LOGV(TESTCATEGORY, "Verbose Log")
OATPP_LOGD(TESTCATEGORY, "Debug Log")
OATPP_LOGI(TESTCATEGORY, "Info Log")
OATPP_LOGW(TESTCATEGORY, "Warning Log")
OATPP_LOGE(TESTCATEGORY, "Error Log")
OATPP_LOGv(TESTCATEGORY, "Verbose Log")
OATPP_LOGd(TESTCATEGORY, "Debug Log")
OATPP_LOGi(TESTCATEGORY, "Info Log")
OATPP_LOGw(TESTCATEGORY, "Warning Log")
OATPP_LOGe(TESTCATEGORY, "Error Log")
}

View File

@ -51,7 +51,7 @@ public:
{}
Action act() override {
return m_cv->wait(m_lockGuard, [this]{return m_resource->counter == 100;})
return m_cv->wait(m_lockGuard, [this]() noexcept {return m_resource->counter == 100;})
.next(yieldTo(&TestCoroutineWait::onReady));
}
@ -78,7 +78,7 @@ public:
{}
Action act() override {
return m_cv->waitFor(m_lockGuard, [this]{return m_resource->counter == 100;}, std::chrono::seconds(5))
return m_cv->waitFor(m_lockGuard, [this]() noexcept{return m_resource->counter == 100;}, std::chrono::seconds(5))
.next(yieldTo(&TestCoroutineWaitWithTimeout::onReady));
}
@ -105,7 +105,7 @@ public:
{}
Action act() override {
return m_cv->waitFor(m_lockGuard, []{return false;}, std::chrono::seconds(1))
return m_cv->waitFor(m_lockGuard, []() noexcept{return false;}, std::chrono::seconds(1))
.next(yieldTo(&TestCoroutineTimeout::onReady));
}
@ -137,7 +137,7 @@ void ConditionVariableTest::onRun() {
for (v_int32 iter = 0; iter < 100; iter++) {
OATPP_LOGD("ITERATION 'WAIT'", "%d", iter)
OATPP_LOGd("ITERATION 'WAIT'", "{}", iter)
oatpp::async::Executor executor;
@ -174,7 +174,7 @@ void ConditionVariableTest::onRun() {
for (v_int32 iter = 0; iter < 100; iter++) {
OATPP_LOGD("ITERATION 'WAIT-WITH-TIMEOUT'", "%d", iter)
OATPP_LOGd("ITERATION 'WAIT-WITH-TIMEOUT'", "{}", iter)
oatpp::async::Executor executor;
@ -211,7 +211,7 @@ void ConditionVariableTest::onRun() {
for (v_int32 iter = 0; iter < 5; iter++) {
OATPP_LOGD("ITERATION 'TIMEOUT'", "%d", iter)
OATPP_LOGd("ITERATION 'TIMEOUT'", "{}", iter)
oatpp::async::Executor executor;

View File

@ -141,7 +141,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) {
for (v_buff_size j = 0; j < NUM_SYMBOLS; j++) {
if (data[i + j] != symbol) {
OATPP_LOGD("aaa", "j pos=%ld", j)
OATPP_LOGd("aaa", "j pos={}", j)
return false;
}
@ -153,7 +153,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) {
}
OATPP_LOGD("aaa", "No symbol found")
OATPP_LOGd("aaa", "No symbol found")
return false;
}
@ -202,7 +202,7 @@ void LockTest::onRun() {
if(!check) {
v_int32 code = c;
auto str = oatpp::String(reinterpret_cast<const char*>(&c), 1);
OATPP_LOGE(TAG, "Failed for symbol %d, '%s'", code, str->data())
OATPP_LOGe(TAG, "Failed for symbol {}, '{}'", code, str->data())
}
OATPP_ASSERT(check)
}

103
test/oatpp/base/LogTest.cpp Normal file
View File

@ -0,0 +1,103 @@
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************/
#include "LogTest.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp::base {
void LogTest::onRun() {
{
LogMessage msg("{}");
msg << "hello";
OATPP_ASSERT(msg.toStdString() == "hello")
}
{
LogMessage msg("{}");
msg << oatpp::String("hello");
OATPP_ASSERT(msg.toStdString() == "hello")
}
{
LogMessage msg("{}");
msg << std::string("hello");
OATPP_ASSERT(msg.toStdString() == "hello")
}
{
LogMessage msg("{} {}");
msg << true << false;
OATPP_ASSERT(msg.toStdString() == "true false")
}
{
LogMessage msg("{} {}");
msg << oatpp::Boolean(true) << oatpp::Boolean(false);
OATPP_ASSERT(msg.toStdString() == "true false")
}
{
v_int8 i8 = -8;
v_uint8 u8 = 8;
v_int16 i16 = -16;
v_uint16 u16 = 16;
v_int32 i32 = -32;
v_uint32 u32 = 32;
v_int64 i64 = -64;
v_uint64 u64 = 64;
LogMessage msg("{} {} {} {} {} {} {} {}");
msg << i8 << u8;
msg << i16 << u16;
msg << i32 << u32;
msg << i64 << u64;
OATPP_ASSERT(msg.toStdString() == "-8 8 -16 16 -32 32 -64 64")
}
OATPP_LOGv(TAG, "1={}, 2={}, 3={}", 1, 2, 3)
OATPP_LOGv(TAG, "empty params")
OATPP_LOGd(TAG, "1={}, 2={}, 3={}", 1, 2, 3)
OATPP_LOGd(TAG, "empty params")
OATPP_LOGi(TAG, "1={}, 2={}, 3={}", 1, 2, 3)
OATPP_LOGi(TAG, "empty params")
OATPP_LOGw(TAG, "1={}, 2={}, 3={}", 1, 2, 3)
OATPP_LOGw(TAG, "empty params")
OATPP_LOGe(TAG, "1={}, 2={}, 3={}", 1, 2, 3)
OATPP_LOGe(TAG, "empty params")
}
}

View File

@ -0,0 +1,45 @@
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************/
#ifndef oatpp_base_LogTest_hpp
#define oatpp_base_LogTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp::base {
/**
* Test command line arguments parsing.
*/
class LogTest : public oatpp::test::UnitTest{
public:
LogTest():UnitTest("TEST[base::LogTest]"){}
void onRun() override;
};
}
#endif /* oatpp_base_LogTest_hpp */

View File

@ -28,6 +28,7 @@
#include "oatpp/data/buffer/Processor.hpp"
#include "oatpp/async/Executor.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace data { namespace buffer {
@ -191,7 +192,7 @@ oatpp::String runTestCase(const oatpp::String& data, v_int32 p1N, v_int32 p2N, v
oatpp::base::ObjectHandle<Processor>(std::make_shared<ProcessorToLower>(p3N)),
});
std::unique_ptr<v_char8[]> buffer(new v_char8[bufferSize]);
std::unique_ptr<v_char8[]> buffer(new v_char8[static_cast<unsigned long>(bufferSize)]);
oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer.get(), bufferSize, &processor);
return outStream.toString();
@ -213,7 +214,7 @@ void ProcessorTest::onRun() {
auto result = runTestCase(data, p1N, p2N, p3N, buffSize);
if (result != etalon) {
OATPP_LOGD(TAG, "error[%d, %d, %d, b=%d] result='%s'", p1N, p2N, p3N, buffSize, result->data())
OATPP_LOGd(TAG, "error[{}, {}, {}, b={}] result='{}'", p1N, p2N, p3N, buffSize, result->data())
}
OATPP_ASSERT(result == etalon)

View File

@ -82,7 +82,7 @@ void ObjectRemapperTest::onRun() {
{
OATPP_LOGD(TAG, "Remap. useUnqualifiedFieldNames = false; useUnqualifiedEnumNames = true")
OATPP_LOGd(TAG, "Remap. useUnqualifiedFieldNames = false; useUnqualifiedEnumNames = true")
remapper.objectToTreeConfig().useUnqualifiedFieldNames = false;
remapper.treeToObjectConfig().useUnqualifiedFieldNames = false;
@ -112,7 +112,7 @@ void ObjectRemapperTest::onRun() {
{
OATPP_LOGD(TAG, "Remap. useUnqualifiedFieldNames = true; useUnqualifiedEnumNames = true")
OATPP_LOGd(TAG, "Remap. useUnqualifiedFieldNames = true; useUnqualifiedEnumNames = true")
remapper.objectToTreeConfig().useUnqualifiedFieldNames = true;
remapper.treeToObjectConfig().useUnqualifiedFieldNames = true;
@ -141,7 +141,7 @@ void ObjectRemapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Remap. Object to Vector")
OATPP_LOGd(TAG, "Remap. Object to Vector")
remapper.objectToTreeConfig().useUnqualifiedFieldNames = false;
remapper.treeToObjectConfig().useUnqualifiedFieldNames = false;
@ -170,7 +170,7 @@ void ObjectRemapperTest::onRun() {
{
OATPP_LOGD(TAG, "Remap tree fragments")
OATPP_LOGd(TAG, "Remap tree fragments")
Tree tree;
tree.setVector(3);

View File

@ -75,7 +75,7 @@ void ObjectToTreeMapperTest::onRun() {
ObjectToTreeMapper::Config config;
{
OATPP_LOGD(TAG, "Map String")
OATPP_LOGd(TAG, "Map String")
Tree tree;
ObjectToTreeMapper::State state;
state.tree = &tree;
@ -92,7 +92,7 @@ void ObjectToTreeMapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Map String in Any")
OATPP_LOGd(TAG, "Map String in Any")
Tree tree;
ObjectToTreeMapper::State state;
state.tree = &tree;
@ -110,7 +110,7 @@ void ObjectToTreeMapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Map Object qualified")
OATPP_LOGd(TAG, "Map Object qualified")
config.useUnqualifiedFieldNames = false;
Tree tree;
@ -180,7 +180,7 @@ void ObjectToTreeMapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Map Object unqualified")
OATPP_LOGd(TAG, "Map Object unqualified")
config.useUnqualifiedFieldNames = true;
Tree tree;
@ -250,7 +250,7 @@ void ObjectToTreeMapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Map Enum qualified")
OATPP_LOGd(TAG, "Map Enum qualified")
config.useUnqualifiedEnumNames = false;
Tree tree;
@ -268,7 +268,7 @@ void ObjectToTreeMapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Map Enum Unqualified")
OATPP_LOGd(TAG, "Map Enum Unqualified")
config.useUnqualifiedEnumNames = true;
Tree tree;

View File

@ -36,22 +36,24 @@ namespace {
template<typename T>
void testTreeValue(T value) {
OATPP_LOGD("TEST", "Test value retrieval for '%s'", Tree::NodePrimitiveType<T>::name)
OATPP_LOGd("TEST", "Test value retrieval for '{}'", Tree::NodePrimitiveType<T>::name)
Tree node;
//node.setValue<T>(value);
node = value;
auto v = node.getValue<T>();
OATPP_ASSERT(v == value && "value check")
OATPP_ASSERT(std::memcmp(&v, &value, sizeof(T)) == 0 && "value check")
node.setValue<T>(std::numeric_limits<T>::min());
auto min = node.getValue<T>();
OATPP_ASSERT(min == std::numeric_limits<T>::min() && "min check")
auto minLim = std::numeric_limits<T>::min();
OATPP_ASSERT(std::memcmp(&min, &minLim, sizeof(T)) == 0 && "min check")
node.setValue<T>(std::numeric_limits<T>::max());
auto max = node.getValue<T>();
OATPP_ASSERT(max == std::numeric_limits<T>::max() && "max check")
auto maxLim = std::numeric_limits<T>::max();
OATPP_ASSERT(std::memcmp(&max, &maxLim, sizeof(T)) == 0 && "max check")
}
@ -72,7 +74,7 @@ void TreeTest::onRun() {
testTreeValue<v_float64>(16);
{
OATPP_LOGD(TAG, "Case 1")
OATPP_LOGd(TAG, "Case 1")
Tree node;
oatpp::String original = "Hello World!";
node.setString(original);
@ -82,7 +84,7 @@ void TreeTest::onRun() {
}
{
OATPP_LOGD(TAG, "Case 2")
OATPP_LOGd(TAG, "Case 2")
Tree node1;
Tree node2;
@ -97,7 +99,7 @@ void TreeTest::onRun() {
}
{
OATPP_LOGD(TAG, "Case 3")
OATPP_LOGd(TAG, "Case 3")
Tree node1;
Tree node2;
@ -110,7 +112,7 @@ void TreeTest::onRun() {
}
{
OATPP_LOGD(TAG, "Case 4")
OATPP_LOGd(TAG, "Case 4")
std::vector<Tree> originalVector(10);
for(v_uint32 i = 0; i < 10; i ++) {
originalVector.at(i).setValue(i);
@ -138,7 +140,7 @@ void TreeTest::onRun() {
}
{
OATPP_LOGD(TAG, "Case 5")
OATPP_LOGd(TAG, "Case 5")
TreeMap originalMap;
for(v_uint32 i = 0; i < 10; i ++) {
originalMap["node_" + utils::Conversion::int32ToStr(static_cast<v_int32>(i))].setValue(i);
@ -163,7 +165,7 @@ void TreeTest::onRun() {
}
{
OATPP_LOGD(TAG, "Case 6")
OATPP_LOGd(TAG, "Case 6")
Tree article;
oatpp::Tree ot;
@ -175,19 +177,17 @@ void TreeTest::onRun() {
article["references"][0]["author"] = "Alexander";
article["references"][1]["author"] = "Leonid";
article["references"].getVector().size();
v_int32 value = article["pages"];
oatpp::String author = article["references"][0]["author"];
OATPP_LOGD(TAG, "pages=%d', refs='%s', node_type=%d", value, author->c_str(), static_cast<v_int32>(article.getType()))
OATPP_LOGd(TAG, "pages={}', refs='{}', node_type={}", value, author, static_cast<v_int32>(article.getType()))
}
{
OATPP_LOGD(TAG, "Attributes Case 1")
OATPP_LOGD(TAG, "size of Tree::Attributes='%lu'", sizeof(Tree::Attributes))
OATPP_LOGd(TAG, "Attributes Case 1")
OATPP_LOGd(TAG, "size of Tree::Attributes='{}'", sizeof(Tree::Attributes))
Tree::Attributes attr;
@ -211,7 +211,7 @@ void TreeTest::onRun() {
{
OATPP_LOGD(TAG, "Attributes Case 2")
OATPP_LOGd(TAG, "Attributes Case 2")
Tree::Attributes attr1;
Tree::Attributes attr2;
@ -254,7 +254,7 @@ void TreeTest::onRun() {
{
OATPP_LOGD(TAG, "Attributes Case 3")
OATPP_LOGd(TAG, "Attributes Case 3")
Tree tree1;
Tree tree2;

View File

@ -84,7 +84,7 @@ void TreeToObjectMapperTest::onRun() {
ObjectToTreeMapper::Config reverseConfig;
{
OATPP_LOGD(TAG, "Map Object qualified")
OATPP_LOGd(TAG, "Map Object qualified")
config.useUnqualifiedFieldNames = false;
Tree tree;
@ -161,7 +161,7 @@ void TreeToObjectMapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Map Object unqualified")
OATPP_LOGd(TAG, "Map Object unqualified")
config.useUnqualifiedFieldNames = true;
Tree tree;
@ -238,7 +238,7 @@ void TreeToObjectMapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Map Enum qualified")
OATPP_LOGd(TAG, "Map Enum qualified")
config.useUnqualifiedEnumNames = false;
Tree tree;
@ -261,7 +261,7 @@ void TreeToObjectMapperTest::onRun() {
}
{
OATPP_LOGD(TAG, "Map Enum unqualified")
OATPP_LOGd(TAG, "Map Enum unqualified")
config.useUnqualifiedEnumNames = true;
Tree tree;

View File

@ -36,7 +36,7 @@ namespace oatpp { namespace data { namespace share {
void MemoryLabelTest::onRun() {
{
OATPP_LOGI(TAG, "StringKeyLabel default constructor...")
OATPP_LOGi(TAG, "StringKeyLabel default constructor...")
StringKeyLabel s;
StringKeyLabel s0;
OATPP_ASSERT(!s)
@ -44,21 +44,21 @@ void MemoryLabelTest::onRun() {
OATPP_ASSERT(s == s0)
OATPP_ASSERT(s != "text")
OATPP_ASSERT(s != oatpp::String("text"))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "StringKeyLabel nullptr constructor...")
OATPP_LOGi(TAG, "StringKeyLabel nullptr constructor...")
StringKeyLabel s(nullptr);
OATPP_ASSERT(!s)
OATPP_ASSERT(s == nullptr)
OATPP_ASSERT(s != "text")
OATPP_ASSERT(s != oatpp::String("text"))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "StringKeyLabel const char* constructor...")
OATPP_LOGi(TAG, "StringKeyLabel const char* constructor...")
StringKeyLabel s("hello");
StringKeyLabel s0;
OATPP_ASSERT(s)
@ -69,11 +69,11 @@ void MemoryLabelTest::onRun() {
OATPP_ASSERT(s == oatpp::String("hello"))
OATPP_ASSERT(s != "text")
OATPP_ASSERT(s != oatpp::String("text"))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "StringKeyLabel oatpp::String constructor...")
OATPP_LOGi(TAG, "StringKeyLabel oatpp::String constructor...")
StringKeyLabel s(oatpp::String("hello"));
OATPP_ASSERT(s)
OATPP_ASSERT(s != nullptr)
@ -81,11 +81,11 @@ void MemoryLabelTest::onRun() {
OATPP_ASSERT(s == oatpp::String("hello"))
OATPP_ASSERT(s != "text")
OATPP_ASSERT(s != oatpp::String("text"))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "StringKeyLabelCI default constructor...")
OATPP_LOGi(TAG, "StringKeyLabelCI default constructor...")
StringKeyLabelCI s;
StringKeyLabelCI s0;
OATPP_ASSERT(!s)
@ -93,21 +93,21 @@ void MemoryLabelTest::onRun() {
OATPP_ASSERT(s == s0)
OATPP_ASSERT(s != "teXt")
OATPP_ASSERT(s != oatpp::String("teXt"))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "StringKeyLabelCI nullptr constructor...")
OATPP_LOGi(TAG, "StringKeyLabelCI nullptr constructor...")
StringKeyLabelCI s(nullptr);
OATPP_ASSERT(!s)
OATPP_ASSERT(s == nullptr)
OATPP_ASSERT(s != "teXt")
OATPP_ASSERT(s != oatpp::String("teXt"))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "StringKeyLabelCI const char* constructor...")
OATPP_LOGi(TAG, "StringKeyLabelCI const char* constructor...")
StringKeyLabelCI s("hello");
StringKeyLabelCI s0;
OATPP_ASSERT(s)
@ -118,11 +118,11 @@ void MemoryLabelTest::onRun() {
OATPP_ASSERT(s == oatpp::String("helLO"))
OATPP_ASSERT(s != "text")
OATPP_ASSERT(s != oatpp::String("teXt"))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "StringKeyLabelCI oatpp::String constructor...")
OATPP_LOGi(TAG, "StringKeyLabelCI oatpp::String constructor...")
StringKeyLabelCI s(oatpp::String("hello"));
OATPP_ASSERT(s)
OATPP_ASSERT(s != nullptr)
@ -130,11 +130,11 @@ void MemoryLabelTest::onRun() {
OATPP_ASSERT(s == oatpp::String("helLO"))
OATPP_ASSERT(s != "text")
OATPP_ASSERT(s != oatpp::String("teXt"))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "general test...")
OATPP_LOGi(TAG, "general test...")
oatpp::String sharedData = "big text goes here";
oatpp::String key1 = "key1";
@ -240,7 +240,7 @@ void MemoryLabelTest::onRun() {
}
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
@ -270,7 +270,7 @@ void MemoryLabelTest::onRun() {
for(auto& h : headers.getAll()) {
auto key = h.first.toString();
auto val = h.second.toString();
OATPP_LOGD(TAG, "'%s': '%s'", key->c_str(), val->c_str())
OATPP_LOGd(TAG, "'{}': '{}'", key->c_str(), val->c_str())
}
}

View File

@ -30,82 +30,80 @@ namespace oatpp { namespace data { namespace share {
void StringTemplateTest::onRun() {
typedef oatpp::data::share::StringTemplate StringTemplate;
{
OATPP_LOGI(TAG, "Case1 ...")
OATPP_LOGi(TAG, "Case1 ...")
StringTemplate t("{} World!", {{0, 1, "p1", nullptr}});
auto result = t.format(std::vector<oatpp::String>({"Hello"}));
OATPP_ASSERT(result == "Hello World!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case2 ...")
OATPP_LOGi(TAG, "Case2 ...")
StringTemplate t("{} World!", {{0, 1, "p1", nullptr}});
auto result = t.format(std::unordered_map<oatpp::String, oatpp::String>({{"p1", "Hello"}}));
OATPP_ASSERT(result == "Hello World!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case3 ...")
OATPP_LOGi(TAG, "Case3 ...")
StringTemplate t("Hello {}", {{6, 7, "p1", nullptr}});
auto result = t.format(std::vector<oatpp::String>({"World!"}));
OATPP_ASSERT(result == "Hello World!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case4 ...")
OATPP_LOGi(TAG, "Case4 ...")
StringTemplate t("Hello {}", {{6, 7, "p1", nullptr}});
auto result = t.format(std::unordered_map<oatpp::String, oatpp::String>({{"p1", "World!"}}));
OATPP_ASSERT(result == "Hello World!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case5 ...")
OATPP_LOGi(TAG, "Case5 ...")
StringTemplate t("Hello {} World!", {{6, 7, "p1", nullptr}});
auto result = t.format(std::vector<oatpp::String>({"My"}));
OATPP_ASSERT(result == "Hello My World!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case6 ...")
OATPP_LOGi(TAG, "Case6 ...")
StringTemplate t("Hello {} World!", {{6, 7, "p1", nullptr}});
auto result = t.format(std::unordered_map<oatpp::String, oatpp::String>({{"p1", "My"}}));
OATPP_ASSERT(result == "Hello My World!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case7 ...")
OATPP_LOGi(TAG, "Case7 ...")
StringTemplate t("? ? ?", {{0, 0, "p1", nullptr}, {2, 2, "p2", nullptr}, {4, 4, "p3", nullptr}});
auto result = t.format(std::vector<oatpp::String>({"Hello", "World", "Oat++!"}));
OATPP_ASSERT(result == "Hello World Oat++!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case8 ...")
OATPP_LOGi(TAG, "Case8 ...")
StringTemplate t("? ? ?", {{0, 0, "p1", nullptr}, {2, 2, "p2", nullptr}, {4, 4, "p3", nullptr}});
auto result = t.format(std::unordered_map<oatpp::String, oatpp::String>({{"p3", "Hello"}, {"p2", "World"}, {"p1", "Oat++!"}}));
OATPP_ASSERT(result == "Oat++! World Hello")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case9 ...")
OATPP_LOGi(TAG, "Case9 ...")
StringTemplate t("? ? ?", {{0, 0, "p1", nullptr}, {2, 2, "p2", nullptr}, {4, 4, "p3", nullptr}});
auto result = t.format("A");
OATPP_ASSERT(result == "A A A")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Case10 ...")
OATPP_LOGi(TAG, "Case10 ...")
StringTemplate t("? ? ?",
{
{0, 0, "p1", std::make_shared<oatpp::base::Countable>()},
@ -115,7 +113,7 @@ void StringTemplateTest::onRun() {
);
auto result = t.format("(A)");
OATPP_ASSERT(result == "(A) (A) (A)")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -38,7 +38,7 @@ void BufferStreamTest::onRun() {
stream << "int=" << 1 << ", float=" << 1.1 << ", "
<< "bool=" << true << " or " << false;
OATPP_LOGV(TAG, "str='%s'", stream.toString()->c_str())
OATPP_LOGv(TAG, "str='{}'", stream.toString()->c_str())
stream.setCurrentPosition(0);
stream << 101;

View File

@ -58,36 +58,36 @@ class Test : public oatpp::DTO {
void AnyTest::onRun() {
{
OATPP_LOGI(TAG, "Test default constructor...")
OATPP_LOGi(TAG, "Test default constructor...")
oatpp::Any any;
OATPP_ASSERT(!any)
OATPP_ASSERT(any.getValueType() == oatpp::data::type::__class::Any::getType())
OATPP_ASSERT(any.getStoredType() == nullptr)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test nullptr constructor...")
OATPP_LOGi(TAG, "Test nullptr constructor...")
oatpp::Any any(nullptr);
OATPP_ASSERT(!any)
OATPP_ASSERT(any.getValueType() == oatpp::data::type::__class::Any::getType())
OATPP_ASSERT(any.getStoredType() == nullptr)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test retrieve()...")
OATPP_LOGi(TAG, "Test retrieve()...")
oatpp::Any any(oatpp::String("Hello Any!"));
OATPP_ASSERT(any)
OATPP_ASSERT(any.getValueType() == oatpp::data::type::__class::Any::getType())
OATPP_ASSERT(any.getStoredType() == oatpp::data::type::__class::String::getType())
auto str = any.retrieve<oatpp::String>();
OATPP_ASSERT(str == "Hello Any!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test store()...")
OATPP_LOGi(TAG, "Test store()...")
oatpp::Any any(oatpp::Int32(32));
OATPP_ASSERT(any)
@ -102,11 +102,11 @@ void AnyTest::onRun() {
auto str = any.retrieve<oatpp::String>();
OATPP_ASSERT(str == "Hello Any!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test retrieve() class check...")
OATPP_LOGi(TAG, "Test retrieve() class check...")
oatpp::Any any(Dto1::createShared());
OATPP_ASSERT(any)
OATPP_ASSERT(any.getValueType() == oatpp::data::type::__class::Any::getType())
@ -121,11 +121,11 @@ void AnyTest::onRun() {
}
OATPP_ASSERT(wasError)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test copy-assign operator...")
OATPP_LOGi(TAG, "Test copy-assign operator...")
oatpp::Any any1(oatpp::String("Hello!"));
oatpp::Any any2;
@ -148,11 +148,11 @@ void AnyTest::onRun() {
OATPP_ASSERT(str1 == str2)
OATPP_ASSERT(str1.get() == str2.get() && str1 == "Hello!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test move-assign operator...")
OATPP_LOGi(TAG, "Test move-assign operator...")
oatpp::Any any1(oatpp::String("Hello!"));
oatpp::Any any2;
@ -175,7 +175,7 @@ void AnyTest::onRun() {
OATPP_ASSERT(str1 != str2)
OATPP_ASSERT(str2 == "Hello!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -58,7 +58,7 @@ ENUM(Enum3, v_int32,
void EnumTest::onRun() {
{
OATPP_LOGI(TAG, "Check Hash...")
OATPP_LOGi(TAG, "Check Hash...")
{
auto v = std::hash<oatpp::Enum<Enum1>>{}(oatpp::Enum<Enum1>());
@ -91,11 +91,11 @@ void EnumTest::onRun() {
OATPP_ASSERT(map[Enum1::V2] == "v2")
OATPP_ASSERT(map[Enum1::V3] == "v3")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check Meta...")
OATPP_LOGi(TAG, "Check Meta...")
{
const auto &entries = oatpp::Enum<Enum0>::getEntries();
OATPP_ASSERT(entries.size() == 0)
@ -125,11 +125,11 @@ void EnumTest::onRun() {
OATPP_ASSERT(v[2].index == 2 && v[2].name == "v-3" && v[2].value == Enum3::V_3 && v[2].description == "description_3")
}
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Declaration...")
OATPP_LOGi(TAG, "Declaration...")
OATPP_ASSERT(oatpp::Enum<Enum2>::Interpreter::notNull == false)
OATPP_ASSERT(oatpp::Enum<Enum2>::NotNull::Interpreter::notNull == true)
@ -159,11 +159,11 @@ void EnumTest::onRun() {
OATPP_ASSERT(interEnum[0].getStoredType() == oatpp::String::Class::getType())
}
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Interpreter AsString (Qualified)...")
OATPP_LOGi(TAG, "Test Interpreter AsString (Qualified)...")
oatpp::data::type::EnumInterpreterError e = oatpp::data::type::EnumInterpreterError::OK;
auto inter = oatpp::Enum<Enum2>::AsString::Interpreter::toInterpretation(oatpp::Enum<Enum2>::AsString(Enum2::NAME_1), false, e);
OATPP_ASSERT(inter.getValueType() == oatpp::String::Class::getType())
@ -178,11 +178,11 @@ void EnumTest::onRun() {
auto value = voidValue.cast<oatpp::Enum<Enum2>::AsString>();
OATPP_ASSERT(value == Enum2::NAME_1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Interpreter AsString (Unqualified)...")
OATPP_LOGi(TAG, "Test Interpreter AsString (Unqualified)...")
oatpp::data::type::EnumInterpreterError e = oatpp::data::type::EnumInterpreterError::OK;
auto inter = oatpp::Enum<Enum2>::AsString::Interpreter::toInterpretation(oatpp::Enum<Enum2>::AsString(Enum2::NAME_1), true, e);
OATPP_ASSERT(inter.getValueType() == oatpp::String::Class::getType())
@ -197,11 +197,11 @@ void EnumTest::onRun() {
auto value = voidValue.cast<oatpp::Enum<Enum2>::AsString>();
OATPP_ASSERT(value == Enum2::NAME_1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Interpreter AsNumber (Qualified)...")
OATPP_LOGi(TAG, "Test Interpreter AsNumber (Qualified)...")
oatpp::data::type::EnumInterpreterError e = oatpp::data::type::EnumInterpreterError::OK;
auto inter = oatpp::Enum<Enum2>::AsNumber::Interpreter::toInterpretation(oatpp::Enum<Enum2>::AsNumber(Enum2::NAME_1), false, e);
OATPP_ASSERT(inter.getValueType() == oatpp::Int32::Class::getType())
@ -216,11 +216,11 @@ void EnumTest::onRun() {
auto value = voidValue.cast<oatpp::Enum<Enum2>::AsNumber>();
OATPP_ASSERT(value == Enum2::NAME_1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Interpreter AsNumber (Unualified)...")
OATPP_LOGi(TAG, "Test Interpreter AsNumber (Unualified)...")
oatpp::data::type::EnumInterpreterError e = oatpp::data::type::EnumInterpreterError::OK;
auto inter = oatpp::Enum<Enum2>::AsNumber::Interpreter::toInterpretation(oatpp::Enum<Enum2>::AsNumber(Enum2::NAME_1), true, e);
OATPP_ASSERT(inter.getValueType() == oatpp::Int32::Class::getType())
@ -235,11 +235,11 @@ void EnumTest::onRun() {
auto value = voidValue.cast<oatpp::Enum<Enum2>::AsNumber>();
OATPP_ASSERT(value == Enum2::NAME_1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test default constructors and == operators...")
OATPP_LOGi(TAG, "Test default constructors and == operators...")
oatpp::Enum<Enum2>::AsString e1;
oatpp::Enum<Enum2>::AsString e2;
@ -261,11 +261,11 @@ void EnumTest::onRun() {
OATPP_ASSERT(e1.getValueType() != e4.getValueType()) // Types are not equal because interpreters are different
OATPP_ASSERT(e1.getValueType()->classId.id == e4.getValueType()->classId.id) // But classId is the same
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test value constructor and == operators...")
OATPP_LOGi(TAG, "Test value constructor and == operators...")
oatpp::Enum<Enum2> e1(Enum2::NAME_1);
oatpp::Enum<Enum2> e2(Enum2::NAME_1);
oatpp::Enum<Enum2> e3;
@ -280,11 +280,11 @@ void EnumTest::onRun() {
OATPP_ASSERT(e1 != Enum2::NAME_2)
OATPP_ASSERT(e3 != Enum2::NAME_1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test copy-assignment operator...")
OATPP_LOGi(TAG, "Test copy-assignment operator...")
oatpp::Enum<Enum2>::AsString e1;
oatpp::Enum<Enum2>::AsNumber e2(Enum2::NAME_1);
Enum2 ve;
@ -320,11 +320,11 @@ void EnumTest::onRun() {
OATPP_ASSERT(ve == Enum2::NAME_1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test move-assignment operator...")
OATPP_LOGi(TAG, "Test move-assignment operator...")
oatpp::Enum<Enum2>::AsString e1;
oatpp::Enum<Enum2>::AsNumber e2(Enum2::NAME_1);
@ -335,7 +335,7 @@ void EnumTest::onRun() {
OATPP_ASSERT(e1 == Enum2::NAME_1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}

View File

@ -73,7 +73,7 @@ namespace __class {
public:
oatpp::Object<PointDto> interpret(const Point& value) const override {
OATPP_LOGD("Point::Interpretation", "interpret")
OATPP_LOGd("Point::Interpretation", "interpret")
auto dto = PointDto::createShared();
dto->x = value->x;
dto->y = value->y;
@ -82,7 +82,7 @@ namespace __class {
}
Point reproduce(const oatpp::Object<PointDto>& value) const override {
OATPP_LOGD("Point::Interpretation", "reproduce")
OATPP_LOGd("Point::Interpretation", "reproduce")
return Point({value->x, value->y, value->z});
}
@ -127,7 +127,7 @@ namespace __class {
public:
oatpp::Object<LineDto> interpret(const Line& value) const override {
OATPP_LOGD("Line::Interpretation", "interpret")
OATPP_LOGd("Line::Interpretation", "interpret")
auto dto = LineDto::createShared();
dto->p1 = {value->p1.x, value->p1.y, value->p1.z};
dto->p2 = {value->p2.x, value->p2.y, value->p2.z};
@ -135,7 +135,7 @@ namespace __class {
}
Line reproduce(const oatpp::Object<LineDto>& value) const override {
OATPP_LOGD("Line::Interpretation", "reproduce")
OATPP_LOGd("Line::Interpretation", "reproduce")
return Line({{value->p1->x, value->p1->y, value->p1->z},
{value->p2->x, value->p2->y, value->p2->z}});
}
@ -193,13 +193,13 @@ void InterpretationTest::onRun() {
auto json1 = mapper.writeToString(l);
OATPP_LOGD(TAG, "json1='%s'", json1->c_str())
OATPP_LOGd(TAG, "json1='{}'", json1)
auto rl = mapper.readFromString<Line>(json1);
auto json2 = mapper.writeToString(rl);
OATPP_LOGD(TAG, "json2='%s'", json2->c_str())
OATPP_LOGd(TAG, "json2='{}'", json2)
OATPP_ASSERT(json1 == json2)

View File

@ -31,7 +31,7 @@ namespace oatpp { namespace data { namespace type {
void ListTest::onRun() {
{
OATPP_LOGI(TAG, "test default constructor...")
OATPP_LOGi(TAG, "test default constructor...")
oatpp::List<oatpp::String> list;
OATPP_ASSERT(!list)
@ -41,11 +41,11 @@ void ListTest::onRun() {
OATPP_ASSERT(list.getValueType()->classId.id == oatpp::data::type::__class::AbstractList::CLASS_ID.id)
OATPP_ASSERT(list.getValueType()->params.size() == 1)
OATPP_ASSERT(list.getValueType()->params.front() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test empty ilist constructor...")
OATPP_LOGi(TAG, "test empty ilist constructor...")
oatpp::List<oatpp::String> list({});
OATPP_ASSERT(list)
@ -56,11 +56,11 @@ void ListTest::onRun() {
OATPP_ASSERT(list.getValueType()->classId.id == oatpp::data::type::__class::AbstractList::CLASS_ID.id)
OATPP_ASSERT(list.getValueType()->params.size() == 1)
OATPP_ASSERT(list.getValueType()->params.front() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test createShared()...")
OATPP_LOGi(TAG, "test createShared()...")
oatpp::List<oatpp::String> list = oatpp::List<oatpp::String>::createShared();
OATPP_ASSERT(list)
@ -69,11 +69,11 @@ void ListTest::onRun() {
OATPP_ASSERT(list.get() != nullptr)
OATPP_ASSERT(list.getValueType()->classId.id == oatpp::data::type::__class::AbstractList::CLASS_ID.id)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test copy-assignment operator...")
OATPP_LOGi(TAG, "test copy-assignment operator...")
oatpp::List<oatpp::String> list1({});
oatpp::List<oatpp::String> list2;
@ -99,11 +99,11 @@ void ListTest::onRun() {
OATPP_ASSERT(list2[0] == "b")
OATPP_ASSERT(list2[1] == "c")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test move-assignment operator...")
OATPP_LOGi(TAG, "test move-assignment operator...")
oatpp::List<oatpp::String> list1({});
oatpp::List<oatpp::String> list2;
@ -111,11 +111,11 @@ void ListTest::onRun() {
OATPP_ASSERT(!list1)
OATPP_ASSERT(list2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test get element by index...")
OATPP_LOGi(TAG, "test get element by index...")
oatpp::List<oatpp::String> list = {"a", "b", "c"};
OATPP_ASSERT(list)
@ -133,11 +133,11 @@ void ListTest::onRun() {
OATPP_ASSERT(list[0] == "a")
OATPP_ASSERT(list[1] == "Hello!")
OATPP_ASSERT(list[2] == "c")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test polymorphicDispatcher...")
OATPP_LOGi(TAG, "test polymorphicDispatcher...")
oatpp::List<oatpp::String> list = {"a", "b", "c"};
auto polymorphicDispatcher = static_cast<const oatpp::data::type::__class::Collection::PolymorphicDispatcher*>(
@ -152,7 +152,7 @@ void ListTest::onRun() {
OATPP_ASSERT(list[1] == "b")
OATPP_ASSERT(list[2] == "c")
OATPP_ASSERT(list[3] == "d")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -197,7 +197,7 @@ void ObjectTest::onRun() {
}
{
OATPP_LOGI(TAG, "Test Meta 1...")
OATPP_LOGi(TAG, "Test Meta 1...")
auto type = Object<DtoA>::Class::getType();
auto dispatcher = static_cast<const oatpp::data::type::__class::AbstractObject::PolymorphicDispatcher*>(type->polymorphicDispatcher);
@ -210,11 +210,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(it->second->info.description == "identifier")
OATPP_ASSERT(it->second->info.pattern == "^[a-z0-9]+$")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Meta 2...")
OATPP_LOGi(TAG, "Test Meta 2...")
auto type = Object<DtoB>::Class::getType();
auto dispatcher = static_cast<const oatpp::data::type::__class::AbstractObject::PolymorphicDispatcher*>(type->polymorphicDispatcher);
@ -234,28 +234,28 @@ void ObjectTest::onRun() {
OATPP_ASSERT(it->second->info.description == "some field with a qualified name")
}
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 1...")
OATPP_LOGi(TAG, "Test 1...")
Object<DtoA> a;
OATPP_ASSERT(!a)
OATPP_ASSERT(a == nullptr)
OATPP_ASSERT(a.getValueType()->classId.id == oatpp::data::type::__class::AbstractObject::CLASS_ID.id)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 2...")
OATPP_LOGi(TAG, "Test 2...")
Object<DtoA> a;
Object<DtoA> b;
OATPP_ASSERT(a == b)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 3...")
OATPP_LOGi(TAG, "Test 3...")
auto a = DtoA::createShared();
Object<DtoA> b;
OATPP_ASSERT(a != b)
@ -263,20 +263,20 @@ void ObjectTest::onRun() {
auto ohc = a->hashCode();
auto whc = std::hash<oatpp::Object<DtoA>>{}(a);
OATPP_ASSERT(ohc == whc)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 4...")
OATPP_LOGi(TAG, "Test 4...")
auto a = Dto0::createShared();
auto b = Dto0::createShared();
OATPP_ASSERT(a != b)
OATPP_ASSERT(a->hashCode() != b->hashCode())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 5...")
OATPP_LOGi(TAG, "Test 5...")
auto a = DtoA::createShared();
auto b = DtoA::createShared();
@ -292,11 +292,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(a == b)
OATPP_ASSERT(a->hashCode() == b->hashCode())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 6...")
OATPP_LOGi(TAG, "Test 6...")
auto a = DtoB::createShared();
auto b = DtoB::createShared();
@ -318,11 +318,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(a == b)
OATPP_ASSERT(a->hashCode() == b->hashCode())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 7...")
OATPP_LOGi(TAG, "Test 7...")
auto a = DtoC::createShared();
auto b = DtoC::createShared();
@ -346,11 +346,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(a == b)
OATPP_ASSERT(a->hashCode() == b->hashCode())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 8...")
OATPP_LOGi(TAG, "Test 8...")
auto a = DtoB::createShared();
auto b = DtoB::createShared();
auto c = DtoB::createShared();
@ -374,20 +374,20 @@ void ObjectTest::onRun() {
OATPP_ASSERT(set[c] == true)
OATPP_ASSERT(set[d] == true)
OATPP_ASSERT(set[e] == true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 9...")
OATPP_LOGi(TAG, "Test 9...")
auto dto = DtoD::createShared();
OATPP_ASSERT(dto->a.getValueType() == oatpp::Int32::Class::getType())
OATPP_ASSERT(dto->a)
OATPP_ASSERT(dto->a == 64)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 10...")
OATPP_LOGi(TAG, "Test 10...")
OATPP_ASSERT(oatpp::Object<DtoA>::Class::getType()->extends(oatpp::Object<oatpp::DTO>::Class::getType()))
OATPP_ASSERT(oatpp::Object<DtoA>::Class::getType()->extends(oatpp::Object<DtoA>::Class::getType()))
OATPP_ASSERT(oatpp::Object<DtoB>::Class::getType()->extends(oatpp::Object<DtoA>::Class::getType()))
@ -395,11 +395,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(oatpp::Object<DtoC>::Class::getType()->extends(oatpp::Object<DtoA>::Class::getType()))
OATPP_ASSERT(oatpp::Object<DtoD>::Class::getType()->extends(oatpp::Object<DtoA>::Class::getType()))
OATPP_ASSERT(!oatpp::Object<DtoC>::Class::getType()->extends(oatpp::Object<DtoB>::Class::getType()))
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 11...")
OATPP_LOGi(TAG, "Test 11...")
auto map = oatpp::Object<PolymorphicDto1>::getPropertiesMap();
auto p = map["polymorph"];
@ -407,11 +407,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(p->info.description == "")
OATPP_ASSERT(p->info.typeSelector != nullptr)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 12...")
OATPP_LOGi(TAG, "Test 12...")
auto map = oatpp::Object<PolymorphicDto2>::getPropertiesMap();
auto p = map["polymorph"];
@ -419,11 +419,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(p->info.description == "description")
OATPP_ASSERT(p->info.typeSelector != nullptr)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 13...")
OATPP_LOGi(TAG, "Test 13...")
auto dto = oatpp::Object<PolymorphicDto2>::createShared();
OATPP_ASSERT(dto->type == nullptr)
@ -435,11 +435,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(dto->type == "hello")
OATPP_ASSERT(dto->type.getValueType() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 14...")
OATPP_LOGi(TAG, "Test 14...")
auto dto = oatpp::Object<PolymorphicDto2>::createShared();
bool thrown = false;
@ -447,17 +447,17 @@ void ObjectTest::onRun() {
try{
dto["type"] = oatpp::Int32(32);
} catch(std::runtime_error const& e) {
OATPP_LOGD(TAG, "error='%s'", e.what())
OATPP_LOGd(TAG, "error='{}'", e.what())
thrown = true;
}
OATPP_ASSERT(thrown)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 15...")
OATPP_LOGi(TAG, "Test 15...")
auto dto = oatpp::Object<PolymorphicDto2>::createShared();
bool thrown = false;
@ -465,17 +465,17 @@ void ObjectTest::onRun() {
try{
dto["non-existing"];
} catch(std::out_of_range const& e) {
OATPP_LOGD(TAG, "error='%s'", e.what())
OATPP_LOGd(TAG, "error='{}'", e.what())
thrown = true;
}
OATPP_ASSERT(thrown)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 16...")
OATPP_LOGi(TAG, "Test 16...")
oatpp::json::ObjectMapper mapper;
@ -487,12 +487,12 @@ void ObjectTest::onRun() {
OATPP_ASSERT(dto->polymorph.getValueType() == oatpp::Any::Class::getType())
auto json = mapper.writeToString(dto);
OATPP_LOGD(TAG, "json0='%s'", json->c_str())
OATPP_LOGd(TAG, "json0='{}'", json)
auto dtoClone = mapper.readFromString<oatpp::Object<PolymorphicDto1>>(json);
auto jsonClone = mapper.writeToString(dtoClone);
OATPP_LOGD(TAG, "json1='%s'", jsonClone->c_str())
OATPP_LOGd(TAG, "json1='{}'", jsonClone)
OATPP_ASSERT(json == jsonClone)
@ -503,11 +503,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(polymorphClone->fieldA == "type-A")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 17...")
OATPP_LOGi(TAG, "Test 17...")
oatpp::json::ObjectMapper mapper;
@ -519,12 +519,12 @@ void ObjectTest::onRun() {
OATPP_ASSERT(dto->polymorph.getValueType() == oatpp::Any::Class::getType())
auto json = mapper.writeToString(dto);
OATPP_LOGD(TAG, "json0='%s'", json->c_str())
OATPP_LOGd(TAG, "json0='{}'", json)
auto dtoClone = mapper.readFromString<oatpp::Object<PolymorphicDto3>>(json);
auto jsonClone = mapper.writeToString(dtoClone);
OATPP_LOGD(TAG, "json1='%s'", jsonClone->c_str())
OATPP_LOGd(TAG, "json1='{}'", jsonClone)
OATPP_ASSERT(json == jsonClone)
@ -535,11 +535,11 @@ void ObjectTest::onRun() {
OATPP_ASSERT(polymorphClone == "Hello World!")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test 18...")
OATPP_LOGi(TAG, "Test 18...")
oatpp::json::ObjectMapper mapper;
@ -551,12 +551,12 @@ void ObjectTest::onRun() {
OATPP_ASSERT(dto->polymorph.getValueType() == oatpp::Any::Class::getType())
auto json = mapper.writeToString(dto);
OATPP_LOGD(TAG, "json0='%s'", json->c_str())
OATPP_LOGd(TAG, "json0='{}'", json)
auto dtoClone = mapper.readFromString<oatpp::Object<PolymorphicDto3>>(json);
auto jsonClone = mapper.writeToString(dtoClone);
OATPP_LOGD(TAG, "json1='%s'", jsonClone->c_str())
OATPP_LOGd(TAG, "json1='{}'", jsonClone)
OATPP_ASSERT(json == jsonClone)
@ -569,7 +569,7 @@ void ObjectTest::onRun() {
OATPP_ASSERT(polymorphClone == nullptr)
OATPP_ASSERT(polymorphClone.getValueType() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -37,50 +37,50 @@ namespace {
void ObjectWrapperTest::onRun() {
{
OATPP_LOGI(TAG, "Check default valueType is assigned (default tparam Clazz)...")
OATPP_LOGi(TAG, "Check default valueType is assigned (default tparam Clazz)...")
TestWrapper<std::string> pw;
OATPP_ASSERT(!pw)
OATPP_ASSERT(pw == nullptr)
OATPP_ASSERT(pw.getValueType() == oatpp::data::type::__class::Void::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check default valueType is assigned (specified tparam Clazz)...")
OATPP_LOGi(TAG, "Check default valueType is assigned (specified tparam Clazz)...")
TestWrapper<std::string, oatpp::data::type::__class::String> pw;
OATPP_ASSERT(!pw)
OATPP_ASSERT(pw == nullptr)
OATPP_ASSERT(pw.getValueType() == oatpp::data::type::__class::String::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check valueType is assigned from constructor...")
OATPP_LOGi(TAG, "Check valueType is assigned from constructor...")
TestWrapper<std::string> pw(oatpp::data::type::__class::String::getType());
OATPP_ASSERT(!pw)
OATPP_ASSERT(pw == nullptr)
OATPP_ASSERT(pw.getValueType() == oatpp::data::type::__class::String::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check valueType is assigned from copy constructor...")
OATPP_LOGi(TAG, "Check valueType is assigned from copy constructor...")
TestWrapper<std::string> pw1(oatpp::data::type::__class::String::getType());
TestWrapper<std::string> pw2(pw1);
OATPP_ASSERT(pw2.getValueType() == oatpp::data::type::__class::String::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check valueType is assigned from move constructor...")
OATPP_LOGi(TAG, "Check valueType is assigned from move constructor...")
TestWrapper<std::string> pw1(oatpp::data::type::__class::String::getType());
TestWrapper<std::string> pw2(std::move(pw1));
OATPP_ASSERT(pw2.getValueType() == oatpp::data::type::__class::String::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check valueType is NOT assigned from copy-assign operator...")
OATPP_LOGi(TAG, "Check valueType is NOT assigned from copy-assign operator...")
TestWrapper<std::string> pw1(oatpp::data::type::__class::String::getType());
TestWrapper<std::string> pw2;
bool throws = false;
@ -91,11 +91,11 @@ void ObjectWrapperTest::onRun() {
}
OATPP_ASSERT(pw2.getValueType() == oatpp::data::type::__class::Void::getType())
OATPP_ASSERT(throws)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check valueType is NOT assigned from move-assign operator...")
OATPP_LOGi(TAG, "Check valueType is NOT assigned from move-assign operator...")
TestWrapper<std::string> pw1(oatpp::data::type::__class::String::getType());
TestWrapper<std::string> pw2;
bool throws = false;
@ -106,11 +106,11 @@ void ObjectWrapperTest::onRun() {
}
OATPP_ASSERT(pw2.getValueType() == oatpp::data::type::__class::Void::getType())
OATPP_ASSERT(throws)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check copy-assign operator. Check == operator...")
OATPP_LOGi(TAG, "Check copy-assign operator. Check == operator...")
TestWrapper<std::string> pw1;
OATPP_ASSERT(!pw1)
OATPP_ASSERT(pw1 == nullptr)
@ -131,11 +131,11 @@ void ObjectWrapperTest::onRun() {
OATPP_ASSERT(pw1 == pw2)
OATPP_ASSERT(pw1.get() == pw2.get())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check != operator...")
OATPP_LOGi(TAG, "Check != operator...")
TestWrapper<std::string, oatpp::data::type::__class::String> pw1(std::make_shared<std::string>("Hello!"));
OATPP_ASSERT(pw1)
OATPP_ASSERT(pw1 != nullptr)
@ -148,11 +148,11 @@ void ObjectWrapperTest::onRun() {
OATPP_ASSERT(pw1 != pw2)
OATPP_ASSERT(pw1.get() != pw2.get())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check move-assign operator. Check != operator...")
OATPP_LOGi(TAG, "Check move-assign operator. Check != operator...")
TestWrapper<std::string> pw1;
OATPP_ASSERT(!pw1)
OATPP_ASSERT(pw1 == nullptr)
@ -173,11 +173,11 @@ void ObjectWrapperTest::onRun() {
OATPP_ASSERT(pw1 != pw2)
OATPP_ASSERT(pw1.get() != pw2.get())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Check oatpp::Void type reassigned")
OATPP_LOGi(TAG, "Check oatpp::Void type reassigned")
oatpp::Void v;
v = oatpp::String("test");

View File

@ -31,7 +31,7 @@ namespace oatpp { namespace data { namespace type {
void PairListTest::onRun() {
{
OATPP_LOGI(TAG, "test default constructor...")
OATPP_LOGi(TAG, "test default constructor...")
oatpp::Fields<String> map;
OATPP_ASSERT(!map)
@ -43,11 +43,11 @@ void PairListTest::onRun() {
auto it = map.getValueType()->params.begin();
OATPP_ASSERT(*it++ == oatpp::String::Class::getType())
OATPP_ASSERT(*it++ == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test empty ilist constructor...")
OATPP_LOGi(TAG, "test empty ilist constructor...")
oatpp::Fields<String> map({});
OATPP_ASSERT(map)
@ -60,11 +60,11 @@ void PairListTest::onRun() {
auto it = map.getValueType()->params.begin();
OATPP_ASSERT(*it++ == oatpp::String::Class::getType())
OATPP_ASSERT(*it++ == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test createShared()...")
OATPP_LOGi(TAG, "test createShared()...")
oatpp::Fields<String> map = oatpp::Fields<String>::createShared();
OATPP_ASSERT(map)
@ -73,11 +73,11 @@ void PairListTest::onRun() {
OATPP_ASSERT(map.get() != nullptr)
OATPP_ASSERT(map.getValueType()->classId.id == oatpp::data::type::__class::AbstractPairList::CLASS_ID.id)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test copy-assignment operator...")
OATPP_LOGi(TAG, "test copy-assignment operator...")
oatpp::Fields<String> map1({});
oatpp::Fields<String> map2;
@ -107,11 +107,11 @@ void PairListTest::onRun() {
OATPP_ASSERT(map2.getValueByKey("key2") == "c")
OATPP_ASSERT(map2.getValueByKey("key3") == nullptr)
OATPP_ASSERT(map2.getValueByKey("key3", "default-val") == "default-val")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test move-assignment operator...")
OATPP_LOGi(TAG, "test move-assignment operator...")
oatpp::Fields<String> map1({});
oatpp::Fields<String> map2;
@ -119,11 +119,11 @@ void PairListTest::onRun() {
OATPP_ASSERT(!map1)
OATPP_ASSERT(map2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test get element by index...")
OATPP_LOGi(TAG, "test get element by index...")
oatpp::Fields<String> map = {{"key1", "a"}, {"key2", "b"}, {"key3", "c"}};
OATPP_ASSERT(map)
@ -141,11 +141,11 @@ void PairListTest::onRun() {
OATPP_ASSERT(map["key1"] == "a")
OATPP_ASSERT(map["key2"] == "Hello!")
OATPP_ASSERT(map["key3"] == "c")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test polymorphicDispatcher...")
OATPP_LOGi(TAG, "test polymorphicDispatcher...")
oatpp::Fields<String> map = {{"key1", "a"}, {"key2", "b"}, {"key3", "c"}};
auto polymorphicDispatcher = static_cast<const typename oatpp::data::type::__class::Map::PolymorphicDispatcher*>(
@ -160,7 +160,7 @@ void PairListTest::onRun() {
OATPP_ASSERT(map[1].first == "key2" && map[1].second == "b")
OATPP_ASSERT(map[2].first == "key3" && map[2].second == "c")
OATPP_ASSERT(map[3].first == "key1" && map[3].second == "d")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -33,7 +33,7 @@ namespace {
template<class T>
void checkHash(const T& val) {
auto h = std::hash<T>{}(val);
OATPP_LOGI("HASH", "type='%s', hash=%lu", val.getValueType()->classId.name, h)
OATPP_LOGi("HASH", "type='{}', hash={}", val.getValueType()->classId.name, h)
}
}
@ -55,36 +55,36 @@ void PrimitiveTest::onRun() {
}
{
OATPP_LOGI(TAG, "test default constructor")
OATPP_LOGi(TAG, "test default constructor")
oatpp::Int32 i;
OATPP_ASSERT(!i)
OATPP_ASSERT(i == nullptr)
OATPP_ASSERT(i.getValueType() == oatpp::Int32::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test value constructor")
OATPP_LOGi(TAG, "test value constructor")
oatpp::Int32 i(0);
OATPP_ASSERT(i)
OATPP_ASSERT(i != nullptr)
OATPP_ASSERT(i == 0)
OATPP_ASSERT(i.getValueType() == oatpp::Int32::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test implicit value constructor")
OATPP_LOGi(TAG, "test implicit value constructor")
oatpp::Int32 i = 0;
OATPP_ASSERT(i)
OATPP_ASSERT(i != nullptr)
OATPP_ASSERT(i == 0)
OATPP_ASSERT(i.getValueType() == oatpp::Int32::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test '==' and '!=' operators")
OATPP_LOGi(TAG, "test '==' and '!=' operators")
oatpp::Int32 i1 = 0;
oatpp::Int32 i2;
@ -109,11 +109,11 @@ void PrimitiveTest::onRun() {
OATPP_ASSERT(i1 == i2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test copy-assign operator")
OATPP_LOGi(TAG, "test copy-assign operator")
oatpp::Int32 i1 = 0;
oatpp::Int32 i2;
@ -134,7 +134,7 @@ void PrimitiveTest::onRun() {
}
{
OATPP_LOGI(TAG, "test move-assign operator")
OATPP_LOGi(TAG, "test move-assign operator")
oatpp::Int32 i1 = 0;
oatpp::Int32 i2;
@ -149,58 +149,58 @@ void PrimitiveTest::onRun() {
}
{
OATPP_LOGI(TAG, "test move-assign operator")
OATPP_LOGi(TAG, "test move-assign operator")
oatpp::Int32 i = 0;
v_int32 v = i;
OATPP_ASSERT(v == i)
}
{
OATPP_LOGI(TAG, "Test Boolean [nullptr]")
OATPP_LOGi(TAG, "Test Boolean [nullptr]")
oatpp::Boolean b;
OATPP_ASSERT(!b)
OATPP_ASSERT(b == nullptr)
OATPP_ASSERT(b != false)
OATPP_ASSERT(b != true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Boolean nullptr constructor")
OATPP_LOGi(TAG, "Test Boolean nullptr constructor")
oatpp::Boolean b = nullptr;
OATPP_ASSERT(!b)
OATPP_ASSERT(b == nullptr)
OATPP_ASSERT(b != false)
OATPP_ASSERT(b != true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Boolean [false]")
OATPP_LOGi(TAG, "Test Boolean [false]")
oatpp::Boolean b = false;
OATPP_ASSERT(!b) // <--- still !b
OATPP_ASSERT(b != nullptr)
OATPP_ASSERT(b == false)
OATPP_ASSERT(b != true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Boolean [true]")
OATPP_LOGi(TAG, "Test Boolean [true]")
oatpp::Boolean b = true;
OATPP_ASSERT(b)
OATPP_ASSERT(b != nullptr)
OATPP_ASSERT(b != false)
OATPP_ASSERT(b == true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Boolean copy-assign operator")
OATPP_LOGi(TAG, "Test Boolean copy-assign operator")
oatpp::Boolean b1 = true;
oatpp::Boolean b2;
@ -228,11 +228,11 @@ void PrimitiveTest::onRun() {
OATPP_ASSERT(b1 == b2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Test Boolean move-assign operator")
OATPP_LOGi(TAG, "Test Boolean move-assign operator")
oatpp::Boolean b1 = true;
oatpp::Boolean b2;
@ -241,11 +241,11 @@ void PrimitiveTest::onRun() {
OATPP_ASSERT(b2 != nullptr)
OATPP_ASSERT(b1 == nullptr)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "check default value")
OATPP_LOGi(TAG, "check default value")
oatpp::UInt8 s0;
oatpp::UInt8 s1 = 255;
OATPP_ASSERT(s0.getValue(128) == 128)

View File

@ -38,37 +38,37 @@ void StringTest::onRun() {
}
{
OATPP_LOGI(TAG, "test default constructor")
OATPP_LOGi(TAG, "test default constructor")
oatpp::String s;
OATPP_ASSERT(!s)
OATPP_ASSERT(s == nullptr)
OATPP_ASSERT(s == static_cast<const char*>(nullptr))
OATPP_ASSERT(s.getValueType() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test nullptr constructor")
OATPP_LOGi(TAG, "test nullptr constructor")
oatpp::String s(nullptr);
OATPP_ASSERT(!s)
OATPP_ASSERT(s == nullptr)
OATPP_ASSERT(s.getValueType() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test const char* constructor")
OATPP_LOGi(TAG, "test const char* constructor")
oatpp::String s("abc\0xyz");
OATPP_ASSERT(s)
OATPP_ASSERT(s != nullptr)
OATPP_ASSERT(s->size() == 3)
OATPP_ASSERT(s == "abc")
OATPP_ASSERT(s == "abc\0xyz")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test std::string constructor")
OATPP_LOGi(TAG, "test std::string constructor")
std::string a("abc\0xyz", 7);
oatpp::String s(a);
OATPP_ASSERT(s)
@ -78,11 +78,11 @@ void StringTest::onRun() {
OATPP_ASSERT(s != "abc\0xyz")
OATPP_ASSERT(s == std::string("abc\0xyz", 7))
OATPP_ASSERT(s == a)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test std::string move constructor")
OATPP_LOGi(TAG, "test std::string move constructor")
std::string a("abc\0xyz", 7);
oatpp::String s(std::move(a));
OATPP_ASSERT(s)
@ -92,11 +92,11 @@ void StringTest::onRun() {
OATPP_ASSERT(s != "abc\0xyz")
OATPP_ASSERT(s == std::string("abc\0xyz", 7))
OATPP_ASSERT(a == "")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test const char* assign operator")
OATPP_LOGi(TAG, "test const char* assign operator")
oatpp::String s;
s = "abc\0xyz";
OATPP_ASSERT(s)
@ -104,11 +104,11 @@ void StringTest::onRun() {
OATPP_ASSERT(s->size() == 3)
OATPP_ASSERT(s == "abc")
OATPP_ASSERT(s == "abc\0xyz")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test std::string assign operator")
OATPP_LOGi(TAG, "test std::string assign operator")
oatpp::String s;
std::string a = std::string("abc\0xyz", 7);
s = a;
@ -119,11 +119,11 @@ void StringTest::onRun() {
OATPP_ASSERT(s != "abc\0xyz")
OATPP_ASSERT(s == std::string("abc\0xyz", 7))
OATPP_ASSERT(s == a)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test std::string move assign operator")
OATPP_LOGi(TAG, "test std::string move assign operator")
oatpp::String s;
std::string a = std::string("abc\0xyz", 7);
s = std::move(a);
@ -134,20 +134,20 @@ void StringTest::onRun() {
OATPP_ASSERT(s != "abc\0xyz")
OATPP_ASSERT(s == std::string("abc\0xyz", 7))
OATPP_ASSERT(a == "")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test const char* implicit constructor")
OATPP_LOGi(TAG, "test const char* implicit constructor")
oatpp::String s = "";
OATPP_ASSERT(s)
OATPP_ASSERT(s != nullptr)
OATPP_ASSERT(s->size() == 0)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test '==', '!=' operators")
OATPP_LOGi(TAG, "test '==', '!=' operators")
oatpp::String s1 = "a";
oatpp::String s2;
@ -162,11 +162,11 @@ void StringTest::onRun() {
OATPP_ASSERT(s1 != s2)
OATPP_ASSERT(s2 != s1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test copy-asssign operator")
OATPP_LOGi(TAG, "test copy-asssign operator")
oatpp::String s1 = "s1";
oatpp::String s2;
@ -179,11 +179,11 @@ void StringTest::onRun() {
OATPP_ASSERT(s1 != s2)
OATPP_ASSERT(s2 != s1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test const char* assign operator")
OATPP_LOGi(TAG, "test const char* assign operator")
oatpp::String s1 = "s1";
oatpp::String s2(s1);
@ -194,11 +194,11 @@ void StringTest::onRun() {
OATPP_ASSERT(s1 != s2)
OATPP_ASSERT(s2 != s1)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test move assign operator")
OATPP_LOGi(TAG, "test move assign operator")
oatpp::String s1 = "s1";
oatpp::String s2;
@ -210,11 +210,11 @@ void StringTest::onRun() {
OATPP_ASSERT(s1 != s2)
OATPP_ASSERT(s1.get() != s2.get())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test compareCI_ASCII methods 1")
OATPP_LOGi(TAG, "test compareCI_ASCII methods 1")
oatpp::String s1 = "hello";
@ -231,7 +231,7 @@ void StringTest::onRun() {
}
{
OATPP_LOGI(TAG, "test compareCI_ASCII methods 2")
OATPP_LOGi(TAG, "test compareCI_ASCII methods 2")
oatpp::String s1;
@ -281,7 +281,7 @@ void StringTest::onRun() {
}
{
OATPP_LOGI(TAG, "test compareCI_ASCII methods 3")
OATPP_LOGi(TAG, "test compareCI_ASCII methods 3")
oatpp::String s1 = "hello";
@ -307,7 +307,7 @@ void StringTest::onRun() {
}
{
OATPP_LOGI(TAG, "check default value")
OATPP_LOGi(TAG, "check default value")
oatpp::String s0;
oatpp::String s1 = "hello";
OATPP_ASSERT(s0.getValue("def") == "def")

View File

@ -67,52 +67,52 @@ void TypeTest::onRun() {
auto obj = TestDto::createShared();
OATPP_LOGV(TAG, "type: '%s'", obj->field_string.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_string.getValueType()->classId.name)
OATPP_ASSERT(obj->field_string.getValueType()->classId == oatpp::data::type::__class::String::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_int8.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_int8.getValueType()->classId.name)
OATPP_ASSERT(obj->field_int8.getValueType()->classId == oatpp::data::type::__class::Int8::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_int16.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_int16.getValueType()->classId.name)
OATPP_ASSERT(obj->field_int16.getValueType()->classId == oatpp::data::type::__class::Int16::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_int32.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_int32.getValueType()->classId.name)
OATPP_ASSERT(obj->field_int32.getValueType()->classId == oatpp::data::type::__class::Int32::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_int64.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_int64.getValueType()->classId.name)
OATPP_ASSERT(obj->field_int64.getValueType()->classId == oatpp::data::type::__class::Int64::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_float32.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_float32.getValueType()->classId.name)
OATPP_ASSERT(obj->field_float32.getValueType()->classId == oatpp::data::type::__class::Float32::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_float64.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_float64.getValueType()->classId.name)
OATPP_ASSERT(obj->field_float64.getValueType()->classId == oatpp::data::type::__class::Float64::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_boolean.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_boolean.getValueType()->classId.name)
OATPP_ASSERT(obj->field_boolean.getValueType()->classId == oatpp::data::type::__class::Boolean::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_list_string.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_list_string.getValueType()->classId.name)
OATPP_ASSERT(obj->field_list_string.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_list_int32.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_list_int32.getValueType()->classId.name)
OATPP_ASSERT(obj->field_list_int32.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_list_int64.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_list_int64.getValueType()->classId.name)
OATPP_ASSERT(obj->field_list_int64.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_list_float32.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_list_float32.getValueType()->classId.name)
OATPP_ASSERT(obj->field_list_float32.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_list_float64.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_list_float64.getValueType()->classId.name)
OATPP_ASSERT(obj->field_list_float64.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_list_boolean.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_list_boolean.getValueType()->classId.name)
OATPP_ASSERT(obj->field_list_boolean.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->field_map_string_string.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->field_map_string_string.getValueType()->classId.name)
OATPP_ASSERT(obj->field_map_string_string.getValueType()->classId == oatpp::data::type::__class::AbstractPairList::CLASS_ID)
OATPP_LOGV(TAG, "type: '%s'", obj->obj1.getValueType()->classId.name)
OATPP_LOGv(TAG, "type: '{}'", obj->obj1.getValueType()->classId.name)
OATPP_ASSERT(obj->obj1.getValueType()->classId == oatpp::data::type::__class::AbstractObject::CLASS_ID)
OATPP_ASSERT(oatpp::String::Class::getType()->extends(oatpp::String::Class::getType()))

View File

@ -31,7 +31,7 @@ namespace oatpp { namespace data { namespace type {
void UnorderedMapTest::onRun() {
{
OATPP_LOGI(TAG, "test default constructor...")
OATPP_LOGi(TAG, "test default constructor...")
oatpp::UnorderedFields<String> map;
OATPP_ASSERT(!map)
@ -43,11 +43,11 @@ void UnorderedMapTest::onRun() {
auto it = map.getValueType()->params.begin();
OATPP_ASSERT(*it++ == oatpp::String::Class::getType())
OATPP_ASSERT(*it++ == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test empty ilist constructor...")
OATPP_LOGi(TAG, "test empty ilist constructor...")
oatpp::UnorderedFields<String> map({});
OATPP_ASSERT(map)
@ -60,11 +60,11 @@ void UnorderedMapTest::onRun() {
auto it = map.getValueType()->params.begin();
OATPP_ASSERT(*it++ == oatpp::String::Class::getType())
OATPP_ASSERT(*it++ == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test createShared()...")
OATPP_LOGi(TAG, "test createShared()...")
oatpp::UnorderedFields<String> map = oatpp::UnorderedFields<String>::createShared();
OATPP_ASSERT(map)
@ -73,11 +73,11 @@ void UnorderedMapTest::onRun() {
OATPP_ASSERT(map.get() != nullptr)
OATPP_ASSERT(map.getValueType()->classId.id == oatpp::data::type::__class::AbstractUnorderedMap::CLASS_ID.id)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test copy-assignment operator...")
OATPP_LOGi(TAG, "test copy-assignment operator...")
oatpp::UnorderedFields<String> map1({});
oatpp::UnorderedFields<String> map2;
@ -103,11 +103,11 @@ void UnorderedMapTest::onRun() {
OATPP_ASSERT(map2["key1"] == "b")
OATPP_ASSERT(map2["key2"] == "c")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test move-assignment operator...")
OATPP_LOGi(TAG, "test move-assignment operator...")
oatpp::UnorderedFields<String> map1({});
oatpp::UnorderedFields<String> map2;
@ -115,11 +115,11 @@ void UnorderedMapTest::onRun() {
OATPP_ASSERT(!map1)
OATPP_ASSERT(map2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test get element by index...")
OATPP_LOGi(TAG, "test get element by index...")
oatpp::UnorderedFields<String> map = {{"key1", "a"}, {"key2", "b"}, {"key3", "c"}};
OATPP_ASSERT(map)
@ -137,11 +137,11 @@ void UnorderedMapTest::onRun() {
OATPP_ASSERT(map["key1"] == "a")
OATPP_ASSERT(map["key2"] == "Hello!")
OATPP_ASSERT(map["key3"] == "c")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test polymorphicDispatcher...")
OATPP_LOGi(TAG, "test polymorphicDispatcher...")
oatpp::UnorderedFields<String> map = {{"key1", "a"}, {"key2", "b"}, {"key3", "c"}};
auto polymorphicDispatcher = static_cast<const typename oatpp::data::type::__class::Map::PolymorphicDispatcher*>(
@ -155,7 +155,7 @@ void UnorderedMapTest::onRun() {
OATPP_ASSERT(map["key1"] == "d")
OATPP_ASSERT(map["key2"] == "b")
OATPP_ASSERT(map["key3"] == "c")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -25,6 +25,7 @@
#include "UnorderedSetTest.hpp"
#include "oatpp/Types.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace data { namespace type {
@ -32,7 +33,7 @@ void UnorderedSetTest::onRun() {
{
OATPP_LOGI(TAG, "test default constructor...")
OATPP_LOGi(TAG, "test default constructor...")
oatpp::UnorderedSet<oatpp::String> set;
OATPP_ASSERT(!set)
@ -42,11 +43,11 @@ void UnorderedSetTest::onRun() {
OATPP_ASSERT(set.getValueType()->classId.id == oatpp::data::type::__class::AbstractUnorderedSet::CLASS_ID.id)
OATPP_ASSERT(set.getValueType()->params.size() == 1)
OATPP_ASSERT(set.getValueType()->params.front() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test empty ilist constructor...")
OATPP_LOGi(TAG, "test empty ilist constructor...")
oatpp::UnorderedSet<oatpp::String> set({});
OATPP_ASSERT(set)
@ -57,11 +58,11 @@ void UnorderedSetTest::onRun() {
OATPP_ASSERT(set.getValueType()->classId.id == oatpp::data::type::__class::AbstractUnorderedSet::CLASS_ID.id)
OATPP_ASSERT(set.getValueType()->params.size() == 1)
OATPP_ASSERT(set.getValueType()->params.front() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test createShared()...")
OATPP_LOGi(TAG, "test createShared()...")
oatpp::UnorderedSet<oatpp::String> set = oatpp::UnorderedSet<oatpp::String>::createShared();
OATPP_ASSERT(set)
@ -70,11 +71,11 @@ void UnorderedSetTest::onRun() {
OATPP_ASSERT(set.get() != nullptr)
OATPP_ASSERT(set.getValueType()->classId.id == oatpp::data::type::__class::AbstractUnorderedSet::CLASS_ID.id)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test copy-assignment operator...")
OATPP_LOGi(TAG, "test copy-assignment operator...")
oatpp::UnorderedSet<oatpp::String> set1({});
oatpp::UnorderedSet<oatpp::String> set2;
@ -101,11 +102,11 @@ void UnorderedSetTest::onRun() {
OATPP_ASSERT(set2["b"] == true)
OATPP_ASSERT(set2["c"] == true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test move-assignment operator...")
OATPP_LOGi(TAG, "test move-assignment operator...")
oatpp::UnorderedSet<oatpp::String> set1({});
oatpp::UnorderedSet<oatpp::String> set2;
@ -113,11 +114,11 @@ void UnorderedSetTest::onRun() {
OATPP_ASSERT(!set1)
OATPP_ASSERT(set2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test polymorphicDispatcher...")
OATPP_LOGi(TAG, "test polymorphicDispatcher...")
oatpp::UnorderedSet<oatpp::String> set = {"a", "b", "c"};
auto polymorphicDispatcher = static_cast<const typename oatpp::data::type::__class::Collection::PolymorphicDispatcher*>(
@ -136,7 +137,7 @@ void UnorderedSetTest::onRun() {
OATPP_ASSERT(set["b"])
OATPP_ASSERT(set["c"])
OATPP_ASSERT(set["d"])
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -25,13 +25,14 @@
#include "VectorTest.hpp"
#include "oatpp/Types.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace data { namespace type {
void VectorTest::onRun() {
{
OATPP_LOGI(TAG, "test default constructor...")
OATPP_LOGi(TAG, "test default constructor...")
oatpp::Vector<oatpp::String> vector;
OATPP_ASSERT(!vector)
@ -41,11 +42,11 @@ void VectorTest::onRun() {
OATPP_ASSERT(vector.getValueType()->classId.id == oatpp::data::type::__class::AbstractVector::CLASS_ID.id)
OATPP_ASSERT(vector.getValueType()->params.size() == 1)
OATPP_ASSERT(vector.getValueType()->params.front() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test empty ilist constructor...")
OATPP_LOGi(TAG, "test empty ilist constructor...")
oatpp::Vector<oatpp::String> vector({});
OATPP_ASSERT(vector)
@ -56,11 +57,11 @@ void VectorTest::onRun() {
OATPP_ASSERT(vector.getValueType()->classId.id == oatpp::data::type::__class::AbstractVector::CLASS_ID.id)
OATPP_ASSERT(vector.getValueType()->params.size() == 1)
OATPP_ASSERT(vector.getValueType()->params.front() == oatpp::String::Class::getType())
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test createShared()...")
OATPP_LOGi(TAG, "test createShared()...")
oatpp::Vector<oatpp::String> vector = oatpp::Vector<oatpp::String>::createShared();
OATPP_ASSERT(vector)
@ -69,11 +70,11 @@ void VectorTest::onRun() {
OATPP_ASSERT(vector.get() != nullptr)
OATPP_ASSERT(vector.getValueType()->classId.id == oatpp::data::type::__class::AbstractVector::CLASS_ID.id)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test copy-assignment operator...")
OATPP_LOGi(TAG, "test copy-assignment operator...")
oatpp::Vector<oatpp::String> vector1({});
oatpp::Vector<oatpp::String> vector2;
@ -99,11 +100,11 @@ void VectorTest::onRun() {
OATPP_ASSERT(vector2[0] == "b")
OATPP_ASSERT(vector2[1] == "c")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test move-assignment operator...")
OATPP_LOGi(TAG, "test move-assignment operator...")
oatpp::Vector<oatpp::String> vector1({});
oatpp::Vector<oatpp::String> vector2;
@ -111,11 +112,11 @@ void VectorTest::onRun() {
OATPP_ASSERT(!vector1)
OATPP_ASSERT(vector2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test get element by index...")
OATPP_LOGi(TAG, "test get element by index...")
oatpp::Vector<oatpp::String> vector = {"a", "b", "c"};
OATPP_ASSERT(vector)
@ -133,11 +134,11 @@ void VectorTest::onRun() {
OATPP_ASSERT(vector[0] == "a")
OATPP_ASSERT(vector[1] == "Hello!")
OATPP_ASSERT(vector[2] == "c")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "test polymorphicDispatcher...")
OATPP_LOGi(TAG, "test polymorphicDispatcher...")
oatpp::Vector<oatpp::String> vector = {"a", "b", "c"};
auto polymorphicDispatcher = static_cast<const oatpp::data::type::__class::Collection::PolymorphicDispatcher*>(
@ -152,7 +153,7 @@ void VectorTest::onRun() {
OATPP_ASSERT(vector[1] == "b")
OATPP_ASSERT(vector[2] == "c")
OATPP_ASSERT(vector[3] == "d")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -25,6 +25,7 @@
#include "Base64Test.hpp"
#include "oatpp/encoding/Base64.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace test { namespace encoding {
@ -35,7 +36,7 @@ void Base64Test::onRun() {
{
oatpp::String encoded = oatpp::encoding::Base64::encode(message);
OATPP_LOGV(TAG, "encoded='%s'", encoded->c_str())
OATPP_LOGv(TAG, "encoded='{}'", encoded->c_str())
OATPP_ASSERT(encoded == messageEncoded)
oatpp::String decoded = oatpp::encoding::Base64::decode(encoded);
OATPP_ASSERT(message == decoded)
@ -43,7 +44,7 @@ void Base64Test::onRun() {
{
oatpp::String encoded = oatpp::encoding::Base64::encode(message, oatpp::encoding::Base64::ALPHABET_BASE64_URL_SAFE);
OATPP_LOGV(TAG, "encoded='%s'", encoded->c_str())
OATPP_LOGv(TAG, "encoded='{}'", encoded->c_str())
oatpp::String decoded = oatpp::encoding::Base64::decode(encoded, oatpp::encoding::Base64::ALPHABET_BASE64_URL_SAFE_AUXILIARY_CHARS);
OATPP_ASSERT(message == decoded)
}

View File

@ -26,6 +26,7 @@
#include "oatpp/encoding/Hex.hpp"
#include "oatpp/encoding/Unicode.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace test { namespace encoding {
@ -50,7 +51,7 @@ void writeBinaryInt(v_int32 value){
}
}
OATPP_LOGV("bin", "value='%s'", reinterpret_cast<const char*>(&buff))
OATPP_LOGv("bin", "value='{}'", reinterpret_cast<const char*>(&buff))
}

View File

@ -26,6 +26,7 @@
#include "oatpp/utils/Random.hpp"
#include "oatpp/encoding/Url.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace test { namespace encoding {
@ -37,7 +38,7 @@ void UrlTest::onRun(){
for(v_int32 i = 0; i < 100; i++) {
oatpp::String buff(100);
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(const_cast<char*>(buff->data())), static_cast<v_buff_size>(buff->size()));
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(buff->data()), static_cast<v_buff_size>(buff->size()));
auto encoded = oatpp::encoding::Url::encode(buff, config);
auto decoded = oatpp::encoding::Url::decode(encoded);
OATPP_ASSERT(decoded == buff)
@ -50,7 +51,7 @@ void UrlTest::onRun(){
for(v_int32 i = 0; i < 100; i++) {
oatpp::String buff(100);
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(const_cast<char*>(buff->data())), static_cast<v_buff_size>(buff->size()));
utils::random::Random::randomBytes(reinterpret_cast<p_char8>(buff->data()), static_cast<v_buff_size>(buff->size()));
auto encoded = oatpp::encoding::Url::encode(buff, config);
auto decoded = oatpp::encoding::Url::decode(encoded);
OATPP_ASSERT(decoded == buff)
@ -61,7 +62,7 @@ void UrlTest::onRun(){
oatpp::encoding::Url::Config config;
config.spaceToPlus = false;
auto encoded = oatpp::encoding::Url::encode(" ", config);
OATPP_ASSERT_FMT("%s", encoded == "%20")
OATPP_ASSERT_FMT("{}", encoded == "%20")
}
{
@ -75,14 +76,14 @@ void UrlTest::onRun(){
oatpp::encoding::Url::Config config;
config.spaceToPlus = false;
auto encoded = oatpp::encoding::Url::encode("Смачна Овсяночка!", config);
OATPP_ASSERT_FMT("%s", encoded == "%D0%A1%D0%BC%D0%B0%D1%87%D0%BD%D0%B0%20%D0%9E%D0%B2%D1%81%D1%8F%D0%BD%D0%BE%D1%87%D0%BA%D0%B0%21")
OATPP_ASSERT_FMT("{}", encoded == "%D0%A1%D0%BC%D0%B0%D1%87%D0%BD%D0%B0%20%D0%9E%D0%B2%D1%81%D1%8F%D0%BD%D0%BE%D1%87%D0%BA%D0%B0%21")
}
{
oatpp::encoding::Url::Config config;
config.spaceToPlus = true;
auto encoded = oatpp::encoding::Url::encode("Смачна Овсяночка!", config);
OATPP_ASSERT_FMT("%s", encoded == "%D0%A1%D0%BC%D0%B0%D1%87%D0%BD%D0%B0+%D0%9E%D0%B2%D1%81%D1%8F%D0%BD%D0%BE%D1%87%D0%BA%D0%B0%21")
OATPP_ASSERT_FMT("{}", encoded == "%D0%A1%D0%BC%D0%B0%D1%87%D0%BD%D0%B0+%D0%9E%D0%B2%D1%81%D1%8F%D0%BD%D0%BE%D1%87%D0%BA%D0%B0%21")
}
}

View File

@ -25,6 +25,7 @@
#include "BooleanTest.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace json {
@ -32,31 +33,31 @@ void BooleanTest::onRun() {
oatpp::json::ObjectMapper mapper;
{
OATPP_LOGI(TAG, "Serialize true to string...")
OATPP_LOGd(TAG, "Serialize true to string...")
auto value = mapper.writeToString(Boolean(true));
OATPP_ASSERT(value == "true")
OATPP_LOGI(TAG, "OK")
OATPP_LOGd(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Serialize false to string...")
OATPP_LOGd(TAG, "Serialize false to string...")
auto value = mapper.writeToString(Boolean(false));
OATPP_ASSERT(value == "false")
OATPP_LOGI(TAG, "OK")
OATPP_LOGd(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserialize true string...")
OATPP_LOGd(TAG, "Deserialize true string...")
Boolean value = mapper.readFromString<Boolean>("true");
OATPP_ASSERT(static_cast<bool>(value))
OATPP_LOGI(TAG, "OK")
OATPP_LOGd(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserialize false string...")
OATPP_LOGd(TAG, "Deserialize false string...")
Boolean value = mapper.readFromString<Boolean>("false");
OATPP_ASSERT(!static_cast<bool>(value))
OATPP_LOGI(TAG, "OK")
OATPP_LOGd(TAG, "OK")
}
}

View File

@ -32,6 +32,7 @@
#include "oatpp/macro/basic.hpp"
#include "oatpp/macro/codegen.hpp"
#include "oatpp/base/Log.hpp"
#include "oatpp-test/Checker.hpp"
@ -77,7 +78,7 @@ void DTOMapperPerfTest::onRun() {
auto test1 = Test1::createTestInstance();
auto test1_Text = mapper.writeToString(test1);
OATPP_LOGV(TAG, "json='%s'", test1_Text->c_str())
OATPP_LOGv(TAG, "json='{}'", test1_Text->c_str())
{
oatpp::test::PerformanceChecker checker("Serializer");

View File

@ -35,6 +35,7 @@
#include "oatpp/utils/Conversion.hpp"
#include "oatpp/macro/codegen.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace json {
@ -269,11 +270,11 @@ void DTOMapperTest::onRun(){
auto result = mapper.writeToString(test1);
OATPP_LOGV(TAG, "json='%s'", result->c_str())
OATPP_LOGv(TAG, "json='{}'", result->c_str())
OATPP_LOGV(TAG, "...")
OATPP_LOGV(TAG, "...")
OATPP_LOGV(TAG, "...")
OATPP_LOGv(TAG, "...")
OATPP_LOGv(TAG, "...")
OATPP_LOGv(TAG, "...")
oatpp::utils::parser::Caret caret(result);
auto obj1 = mapper.readFromCaret<oatpp::Object<Test>>(caret);
@ -322,7 +323,7 @@ void DTOMapperTest::onRun(){
result = mapper.writeToString(obj1);
OATPP_LOGV(TAG, "json='%s'", result->c_str())
OATPP_LOGv(TAG, "json='{}'", result->c_str())
}
{
@ -331,7 +332,7 @@ void DTOMapperTest::onRun(){
try {
result = mapper.writeToString(test2);
} catch(std::runtime_error&) {
OATPP_LOGV(TAG, "Test2::field_string is required!")
OATPP_LOGv(TAG, "Test2::field_string is required!")
}
OATPP_ASSERT(result == nullptr)
}
@ -353,7 +354,7 @@ void DTOMapperTest::onRun(){
try {
result = mapper.writeToString(test4);
} catch(std::runtime_error&) {
OATPP_LOGV(TAG, "TestChild1::name is required!")
OATPP_LOGv(TAG, "TestChild1::name is required!")
}
OATPP_ASSERT(result == nullptr)
}
@ -389,12 +390,12 @@ void DTOMapperTest::onRun(){
obj2->anyList->push_back(map);
auto json = mapper.writeToString(obj2);
OATPP_LOGV(TAG, "any json='%s'", json->c_str())
OATPP_LOGv(TAG, "any json='{}'", json->c_str())
auto deserializedAny = mapper.readFromString<oatpp::Fields<oatpp::Any>>(json);
auto json2 = mapper.writeToString(deserializedAny);
OATPP_LOGV(TAG, "any json='%s'", json2->c_str())
OATPP_LOGv(TAG, "any json='{}'", json2->c_str())
}

View File

@ -27,6 +27,7 @@
#include <cmath>
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/base/Log.hpp"
#include "oatpp/macro/codegen.hpp"
namespace oatpp { namespace json {
@ -240,81 +241,81 @@ void DeserializerTest::onRun(){
data::type::DTOWrapper<Test5> obj5;
try {
obj5 = mapper.readFromString<oatpp::Object<Test5>>(R"({"strF":null})");
} catch (std::runtime_error& e) {
OATPP_LOGD(TAG, "Test5::strF is required!")
} catch (std::runtime_error&) {
OATPP_LOGd(TAG, "Test5::strF is required!")
}
OATPP_ASSERT(obj5 == nullptr)
try {
auto obj6 = mapper.readFromString<oatpp::Object<Test6>>(R"({"strF":null})");
} catch (std::runtime_error& e) {
} catch (std::runtime_error&) {
OATPP_ASSERT(false)
}
data::type::DTOWrapper<Test7> obj7;
try {
obj7 = mapper.readFromString<oatpp::Object<Test7>>(R"({"strF":"value1", "child":{"name":null}})");
} catch (std::runtime_error& e) {
OATPP_LOGD(TAG, "TestChild1::name is required!")
} catch (std::runtime_error&) {
OATPP_LOGd(TAG, "TestChild1::name is required!")
}
OATPP_ASSERT(obj7 == nullptr)
try {
auto obj8 = mapper.readFromString<oatpp::Object<Test8>>(R"({"strF":"value1", "child":{"name":null}})");
} catch (std::runtime_error& e) {
} catch (std::runtime_error&) {
OATPP_ASSERT(false)
}
OATPP_LOGD(TAG, "Any: String")
OATPP_LOGd(TAG, "Any: String")
{
auto dto = mapper.readFromString<oatpp::Object<AnyDto>>(R"({"any":"my_string"})");
OATPP_ASSERT(dto)
OATPP_ASSERT(dto->any.getStoredType() == String::Class::getType())
OATPP_ASSERT(dto->any.retrieve<String>() == "my_string")
}
OATPP_LOGD(TAG, "Any: Boolean")
OATPP_LOGd(TAG, "Any: Boolean")
{
auto dto = mapper.readFromString<oatpp::Object<AnyDto>>(R"({"any":false})");
OATPP_ASSERT(dto)
OATPP_ASSERT(dto->any.getStoredType() == Boolean::Class::getType())
OATPP_ASSERT(dto->any.retrieve<Boolean>() == false)
}
OATPP_LOGD(TAG, "Any: Negative Float")
OATPP_LOGd(TAG, "Any: Negative Float")
{
auto dto = mapper.readFromString<oatpp::Object<AnyDto>>(R"({"any":-1.23456789,"another":1.1})");
OATPP_ASSERT(dto)
OATPP_ASSERT(dto->any.getStoredType() == Float64::Class::getType())
OATPP_ASSERT(fabs(dto->any.retrieve<Float64>() - -1.23456789) < std::numeric_limits<double>::epsilon())
}
OATPP_LOGD(TAG, "Any: Positive Float")
OATPP_LOGd(TAG, "Any: Positive Float")
{
auto dto = mapper.readFromString<oatpp::Object<AnyDto>>(R"({"any":1.23456789,"another":1.1})");
OATPP_ASSERT(dto)
OATPP_ASSERT(dto->any.getStoredType() == Float64::Class::getType())
OATPP_ASSERT(fabs(dto->any.retrieve<Float64>() - 1.23456789) < std::numeric_limits<double>::epsilon())
}
OATPP_LOGD(TAG, "Any: Negative exponential Float")
OATPP_LOGd(TAG, "Any: Negative exponential Float")
{
auto dto = mapper.readFromString<oatpp::Object<AnyDto>>(R"({"any":-1.2345e30,"another":1.1})");
OATPP_ASSERT(dto)
OATPP_ASSERT(dto->any.getStoredType() == Float64::Class::getType())
OATPP_ASSERT(fabs(dto->any.retrieve<Float64>() - -1.2345e30) < std::numeric_limits<double>::epsilon())
}
OATPP_LOGD(TAG, "Any: Positive exponential Float")
OATPP_LOGd(TAG, "Any: Positive exponential Float")
{
auto dto = mapper.readFromString<oatpp::Object<AnyDto>>(R"({"any":1.2345e30,"another":1.1})");
OATPP_ASSERT(dto)
OATPP_ASSERT(dto->any.getStoredType() == Float64::Class::getType())
OATPP_ASSERT(fabs(dto->any.retrieve<Float64>() - 1.2345e30) < std::numeric_limits<double>::epsilon())
}
OATPP_LOGD(TAG, "Any: Big Integer")
OATPP_LOGd(TAG, "Any: Big Integer")
{
auto dto = mapper.readFromString<oatpp::Object<AnyDto>>(R"({"any":9223372036854775807,"another":1.1})");
OATPP_ASSERT(dto)
OATPP_ASSERT(dto->any.getStoredType() == Int64::Class::getType())
OATPP_ASSERT(dto->any.retrieve<Int64>() == 9223372036854775807)
}
OATPP_LOGD(TAG, "Any: Signed Integer")
OATPP_LOGd(TAG, "Any: Signed Integer")
{
auto dto = mapper.readFromString<oatpp::Object<AnyDto>>(R"({"any":-1234567890,"another":1.1})");
OATPP_ASSERT(dto)

View File

@ -59,127 +59,127 @@ void EnumTest::onRun() {
oatpp::json::ObjectMapper mapper;
{
OATPP_LOGI(TAG, "Serializer as string...")
OATPP_LOGi(TAG, "Serializer as string...")
oatpp::Fields<oatpp::Enum<Enum1>::AsString> map = {{"enum", Enum1::V1}};
auto json = mapper.writeToString(map);
OATPP_LOGD(TAG, "json='%s'", json->c_str())
OATPP_LOGd(TAG, "json='{}'", json->c_str())
OATPP_ASSERT(json == "{\"enum\":\"enum1-v1\"}")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Serializer as string null...")
OATPP_LOGi(TAG, "Serializer as string null...")
oatpp::Fields<oatpp::Enum<Enum1>::AsString> map = {{"enum", nullptr}};
auto json = mapper.writeToString(map);
OATPP_LOGD(TAG, "json='%s'", json->c_str())
OATPP_LOGd(TAG, "json='{}'", json->c_str())
OATPP_ASSERT(json == "{\"enum\":null}")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Serializer as string error on null...")
OATPP_LOGi(TAG, "Serializer as string error on null...")
bool error = false;
oatpp::Fields<oatpp::Enum<Enum1>::AsString::NotNull> map = {{"enum", nullptr}};
try {
auto json = mapper.writeToString(map);
} catch (const data::mapping::MappingError& e) {
OATPP_LOGD(TAG, "error - '%s'\ntrace:\n%s", e.what(), e.errorStack().stacktrace()->c_str())
OATPP_LOGd(TAG, "error - '{}'\ntrace:\n{}", e.what(), e.errorStack().stacktrace()->c_str())
error = true;
}
OATPP_ASSERT(error == true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Serializer as int...")
OATPP_LOGi(TAG, "Serializer as int...")
oatpp::Fields<oatpp::Enum<Enum1>::AsNumber> map = {{"enum", Enum1::V1}};
auto json = mapper.writeToString(map);
OATPP_LOGD(TAG, "json='%s'", json->c_str())
OATPP_LOGd(TAG, "json='{}'", json)
OATPP_ASSERT(json == "{\"enum\":10}")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Serializer as int null...")
OATPP_LOGi(TAG, "Serializer as int null...")
oatpp::Fields<oatpp::Enum<Enum1>::AsNumber> map = {{"enum", nullptr}};
auto json = mapper.writeToString(map);
OATPP_LOGD(TAG, "json='%s'", json->c_str())
OATPP_LOGd(TAG, "json='{}'", json)
OATPP_ASSERT(json == "{\"enum\":null}")
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Serializer as int error on null...")
OATPP_LOGi(TAG, "Serializer as int error on null...")
bool error = false;
oatpp::Fields<oatpp::Enum<Enum1>::AsNumber::NotNull> map = {{"enum", nullptr}};
try {
auto json = mapper.writeToString(map);
} catch (const data::mapping::MappingError& e) {
OATPP_LOGD(TAG, "error - '%s'\ntrace:\n%s", e.what(), e.errorStack().stacktrace()->c_str())
OATPP_LOGd(TAG, "error - '{}'\ntrace:\n{}", e.what(), e.errorStack().stacktrace())
error = true;
}
OATPP_ASSERT(error == true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserializer as string...")
OATPP_LOGi(TAG, "Deserializer as string...")
oatpp::String json = "{\"enum\":\"enum1-v2\"}";
auto map = mapper.readFromString<oatpp::Fields<oatpp::Enum<Enum1>::AsString>>(json);
OATPP_ASSERT(map["enum"] == Enum1::V2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserializer as string null...")
OATPP_LOGi(TAG, "Deserializer as string null...")
oatpp::String json = "{\"enum\":null}";
auto map = mapper.readFromString<oatpp::Fields<oatpp::Enum<Enum1>::AsString>>(json);
OATPP_ASSERT(map["enum"] == nullptr)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserializer as string error on null...")
OATPP_LOGi(TAG, "Deserializer as string error on null...")
bool error = false;
oatpp::String json = "{\"enum\":null}";
try {
auto map = mapper.readFromString<oatpp::Fields<oatpp::Enum<Enum1>::AsString::NotNull>>(json);
} catch (const data::mapping::MappingError& e) {
OATPP_LOGD(TAG, "error - '%s'\ntrace:\n%s", e.what(), e.errorStack().stacktrace()->c_str())
OATPP_LOGd(TAG, "error - '{}'\ntrace:\n{}", e.what(), e.errorStack().stacktrace()->c_str())
error = true;
}
OATPP_ASSERT(error == true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserializer as int...")
OATPP_LOGi(TAG, "Deserializer as int...")
oatpp::String json = "{\"enum\":20}";
auto map = mapper.readFromString<oatpp::Fields<oatpp::Enum<Enum1>::AsNumber>>(json);
OATPP_ASSERT(map["enum"] == Enum1::V2)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserializer as int null...")
OATPP_LOGi(TAG, "Deserializer as int null...")
oatpp::String json = "{\"enum\":null}";
auto map = mapper.readFromString<oatpp::Fields<oatpp::Enum<Enum1>::AsNumber>>(json);
OATPP_ASSERT(map["enum"] == nullptr)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
{
OATPP_LOGI(TAG, "Deserializer as int error on null...")
OATPP_LOGi(TAG, "Deserializer as int error on null...")
bool error = false;
oatpp::String json = "{\"enum\":null}";
try {
auto map = mapper.readFromString<oatpp::Fields<oatpp::Enum<Enum1>::AsNumber::NotNull>>(json);
} catch (const data::mapping::MappingError& e) {
OATPP_LOGD(TAG, "error - '%s'\ntrace:\n%s", e.what(), e.errorStack().stacktrace()->c_str())
OATPP_LOGd(TAG, "error - '{}'\ntrace:\n{}", e.what(), e.errorStack().stacktrace()->c_str())
error = true;
}
OATPP_ASSERT(error == true)
OATPP_LOGI(TAG, "OK")
OATPP_LOGi(TAG, "OK")
}
}

View File

@ -25,6 +25,7 @@
#include "UnorderedSetTest.hpp"
#include "oatpp/json/ObjectMapper.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace json {
@ -35,7 +36,7 @@ void UnorderedSetTest::onRun() {
{
oatpp::UnorderedSet<oatpp::String> set = {"Hello", "World", "!"};
auto json = mapper.writeToString(set);
OATPP_LOGD(TAG, "json='%s'", json->c_str())
OATPP_LOGd(TAG, "json='{}'", json->c_str())
}
{
@ -44,7 +45,7 @@ void UnorderedSetTest::onRun() {
OATPP_ASSERT(set)
OATPP_ASSERT(set->size() == 3)
for(auto& item : *set) {
OATPP_LOGD(TAG, "item='%s'", item->c_str())
OATPP_LOGd(TAG, "item='{}'", item->c_str())
}
}

View File

@ -26,6 +26,7 @@
#include "oatpp/network/ConnectionPool.hpp"
#include "oatpp/async/Executor.hpp"
#include "oatpp/base/Log.hpp"
namespace oatpp { namespace test { namespace network {
@ -202,7 +203,7 @@ void ConnectionPoolTest::onRun() {
executor.waitTasksFinished();
OATPP_LOGD(TAG, "connections_counter=%ld", connectionProvider->counter.load())
OATPP_LOGd(TAG, "connections_counter={}", connectionProvider->counter.load())
OATPP_ASSERT(connectionProvider->counter <= 10)
pool->stop();

View File

@ -25,6 +25,7 @@
#include "UrlTest.hpp"
#include "oatpp/network/Url.hpp"
#include "oatpp/base/Log.hpp"
#include "oatpp-test/Checker.hpp"
@ -36,7 +37,7 @@ void UrlTest::onRun() {
{
const char* urlText = "http://root@127.0.0.1:8000/path/to/resource/?q1=1&q2=2";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "http")
@ -51,7 +52,7 @@ void UrlTest::onRun() {
{
const char* urlText = "ftp://root@oatpp.io:8000/path/to/resource?q1=1&q2=2";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "ftp")
@ -66,7 +67,7 @@ void UrlTest::onRun() {
{
const char* urlText = "https://oatpp.io/?q1=1&q2=2";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "https")
@ -81,7 +82,7 @@ void UrlTest::onRun() {
{
const char* urlText = "https://oatpp.io/";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "https")
@ -94,7 +95,7 @@ void UrlTest::onRun() {
{
const char* urlText = "https://oatpp.io";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "https")
@ -107,7 +108,7 @@ void UrlTest::onRun() {
{
const char* urlText = "oatpp.io";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme == nullptr)
@ -120,7 +121,7 @@ void UrlTest::onRun() {
{
const char* urlText = "oatpp.io:8000/path";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme == nullptr)
@ -133,7 +134,7 @@ void UrlTest::onRun() {
{
const char* urlText = "?key1=value1&key2=value2&key3=value3";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.getSize() == 3)
OATPP_ASSERT(params.get("key1") == "value1")
@ -143,7 +144,7 @@ void UrlTest::onRun() {
{
const char *urlText = "?key1=value1&key2&key3=value3";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.getSize() == 3)
OATPP_ASSERT(params.get("key1") == "value1")
@ -153,7 +154,7 @@ void UrlTest::onRun() {
{
const char *urlText = "?key1=value1&key2&key3";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.getSize() == 3)
OATPP_ASSERT(params.get("key1") == "value1")
@ -163,7 +164,7 @@ void UrlTest::onRun() {
{
const char *urlText = "label?key1=value1&key2=value2&key3=value3";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.getSize() == 3)
OATPP_ASSERT(params.get("key1") == "value1")
@ -173,7 +174,7 @@ void UrlTest::onRun() {
{
const char* urlText = "label?key1=value1&key2&key3=value3";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.getSize() == 3)
OATPP_ASSERT(params.get("key1") == "value1")
@ -183,7 +184,7 @@ void UrlTest::onRun() {
{
const char* urlText = "label?key1=value1&key2&key3";
OATPP_LOGV(TAG, "urlText='%s'", urlText)
OATPP_LOGv(TAG, "urlText='{}'", urlText)
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.getSize() == 3)
OATPP_ASSERT(params.get("key1") == "value1")

View File

@ -47,7 +47,7 @@ class ReadCallback : public oatpp::data::stream::ReadCallback {
public:
v_io_size read(void *buffer, v_buff_size count, async::Action &action) override {
OATPP_LOGI("TEST", "read(...)")
OATPP_LOGi("TEST", "read(...)")
std::this_thread::sleep_for(std::chrono::milliseconds(100));
char* data = reinterpret_cast<char*>(buffer);
data[0] = 'A';
@ -101,9 +101,9 @@ std::shared_ptr<oatpp::network::Server> runServer(const std::shared_ptr<oatpp::n
std::thread t([server, connectionHandler]{
server->run();
OATPP_LOGD("TEST", "server stopped")
OATPP_LOGd("TEST", "server stopped")
connectionHandler->stop();
OATPP_LOGD("TEST", "connectionHandler stopped")
OATPP_LOGd("TEST", "connectionHandler stopped")
});
t.detach();
@ -124,13 +124,13 @@ std::shared_ptr<oatpp::network::Server> runAsyncServer(const std::shared_ptr<oat
std::thread t([server, connectionHandler, executor]{
server->run();
OATPP_LOGD("TEST_ASYNC", "server stopped")
OATPP_LOGd("TEST_ASYNC", "server stopped")
connectionHandler->stop();
OATPP_LOGD("TEST_ASYNC", "connectionHandler stopped")
OATPP_LOGd("TEST_ASYNC", "connectionHandler stopped")
executor->waitTasksFinished();
executor->stop();
executor->join();
OATPP_LOGD("TEST_ASYNC", "executor stopped")
OATPP_LOGd("TEST_ASYNC", "executor stopped")
});
t.detach();
@ -150,7 +150,7 @@ void runClient() {
auto data = response->readBodyToString();
OATPP_ASSERT(data)
OATPP_LOGD("TEST", "data->size() == %lu", data->size())
OATPP_LOGd("TEST", "data->size() == {}", data->size())
OATPP_ASSERT(data->size() < 110) // it should be less than 100. But we put 110 for redundancy
}
@ -190,7 +190,7 @@ void runAsyncClient() {
Action onBody(const oatpp::String& data) {
OATPP_ASSERT(data)
OATPP_LOGD("TEST", "data->size() == %lu", data->size())
OATPP_LOGd("TEST", "data->size() == {}", data->size())
OATPP_ASSERT(data->size() < 60) // it should be less than 50. But we put 60 for redundancy
m_monitor->stop();
return finish();
@ -203,11 +203,11 @@ void runAsyncClient() {
executor->execute<ClientCoroutine>();
executor->waitTasksFinished();
OATPP_LOGD("TEST_ASYNC_CLIENT", "task finished")
OATPP_LOGd("TEST_ASYNC_CLIENT", "task finished")
executor->stop();
OATPP_LOGD("TEST_ASYNC_CLIENT", "executor stopped")
OATPP_LOGd("TEST_ASYNC_CLIENT", "executor stopped")
executor->join();
OATPP_LOGD("TEST_ASYNC_CLIENT", "done")
OATPP_LOGd("TEST_ASYNC_CLIENT", "done")
}
@ -226,7 +226,7 @@ void ConnectionMonitorTest::onRun() {
);
{
OATPP_LOGD(TAG, "run simple API test")
OATPP_LOGd(TAG, "run simple API test")
auto server = runServer(monitor);
runClient();
server->stop();
@ -234,7 +234,7 @@ void ConnectionMonitorTest::onRun() {
}
{
OATPP_LOGD(TAG, "run Async API test")
OATPP_LOGd(TAG, "run Async API test")
auto server = runAsyncServer(monitor);
runClient();
server->stop();
@ -242,7 +242,7 @@ void ConnectionMonitorTest::onRun() {
}
{
OATPP_LOGD(TAG, "run Async Client test")
OATPP_LOGd(TAG, "run Async Client test")
auto server = runServer(monitor);
runAsyncClient();
server->stop();

View File

@ -66,7 +66,7 @@ namespace {
OATPP_ASSERT(stream.getCurrentPosition() == res)
OATPP_ASSERT(stream.toString() == "OK")
//OATPP_LOGV("client", "finished - OK")
//OATPP_LOGv("client", "finished - OK")
}

View File

@ -66,7 +66,7 @@ namespace {
}
}
}
OATPP_LOGV("WriterTask", "sent %ld bytes", m_transferedBytes)
OATPP_LOGv("WriterTask", "sent {} bytes", m_transferedBytes)
}
};
@ -94,14 +94,14 @@ namespace {
m_buffer->writeSimple(readBuffer, res);
}
}
OATPP_LOGV("ReaderTask", "sent %ld bytes", m_buffer->getCurrentPosition())
OATPP_LOGv("ReaderTask", "sent {} bytes", m_buffer->getCurrentPosition())
}
};
void runTransfer(const std::shared_ptr<Pipe>& pipe, v_int64 chunksToTransfer, bool writeNonBlock, bool readerNonBlock) {
OATPP_LOGV("transfer", "writer-nb: %d, reader-nb: %d", writeNonBlock, readerNonBlock)
OATPP_LOGv("transfer", "writer-nb: {}, reader-nb: {}", writeNonBlock, readerNonBlock)
auto buffer = std::make_shared<oatpp::data::stream::BufferOutputStream>();

View File

@ -77,7 +77,7 @@ public:
}
void stop() override {
OATPP_LOGD("TestProvider", "stop()")
OATPP_LOGd("TestProvider", "stop()")
}
};
@ -144,7 +144,7 @@ void PoolTemplateTest::onRun() {
const v_int64 maxResources = 1;
{
OATPP_LOGD(TAG, "Synchronously with timeout")
OATPP_LOGd(TAG, "Synchronously with timeout")
auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds(500));
oatpp::provider::ResourceHandle<Resource> resource = TestPool::get(poolTemplate);
@ -156,7 +156,7 @@ void PoolTemplateTest::onRun() {
OATPP_ASSERT(TestPool::get(poolTemplate) == nullptr)
}
{
OATPP_LOGD(TAG, "Synchronously without timeout")
OATPP_LOGd(TAG, "Synchronously without timeout")
auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds::zero());
oatpp::provider::ResourceHandle<Resource> resource = TestPool::get(poolTemplate);
@ -171,7 +171,7 @@ void PoolTemplateTest::onRun() {
OATPP_ASSERT(TestPool::get(poolTemplate) == nullptr)
}
{
OATPP_LOGD(TAG, "Asynchronously with timeout")
OATPP_LOGd(TAG, "Asynchronously with timeout")
oatpp::async::Executor executor(1, 1, 1);
auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds(500));
@ -200,7 +200,7 @@ void PoolTemplateTest::onRun() {
executor.join();
}
{
OATPP_LOGD(TAG, "Asynchronously without timeout")
OATPP_LOGd(TAG, "Asynchronously without timeout")
oatpp::async::Executor executor(1, 1, 1);
auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds::zero());

View File

@ -105,7 +105,7 @@ public:
}
void stop() override {
OATPP_LOGD("TestProvider", "stop()")
OATPP_LOGd("TestProvider", "stop()")
}
v_int64 getIdCounter() {
@ -181,7 +181,7 @@ void PoolTest::onRun() {
std::list<std::thread> threads;
OATPP_LOGD(TAG, "Run 1")
OATPP_LOGd(TAG, "Run 1")
for(v_int32 i = 0; i < 100; i ++ ) {
threads.push_back(std::thread(clientMethod, pool, false));
executor.execute<ClientCoroutine>(pool, false);
@ -189,14 +189,14 @@ void PoolTest::onRun() {
std::this_thread::sleep_for(std::chrono::milliseconds (200));
OATPP_LOGD(TAG, "1) pool->getCounter() == %ld", pool->getCounter())
OATPP_LOGd(TAG, "1) pool->getCounter() == {}", pool->getCounter())
OATPP_ASSERT(pool->getCounter() == 10)
OATPP_LOGD(TAG, "Waiting...")
OATPP_LOGd(TAG, "Waiting...")
std::this_thread::sleep_for(std::chrono::seconds(10));
OATPP_LOGD(TAG, "TestPool counter=%ld", pool->getCounter())
OATPP_LOGd(TAG, "TestPool counter={}", pool->getCounter())
OATPP_ASSERT(pool->getCounter() == 0)
OATPP_LOGD(TAG, "Run 2")
OATPP_LOGd(TAG, "Run 2")
for(v_int32 i = 0; i < 100; i ++ ) {
threads.push_back(std::thread(clientMethod, pool, false));
executor.execute<ClientCoroutine>(pool, false);
@ -204,11 +204,11 @@ void PoolTest::onRun() {
std::this_thread::sleep_for(std::chrono::milliseconds (200));
OATPP_LOGD(TAG, "2) pool->getCounter() == %ld", pool->getCounter())
OATPP_LOGd(TAG, "2) pool->getCounter() == {}", pool->getCounter())
OATPP_ASSERT(pool->getCounter() == 10)
OATPP_LOGD(TAG, "Waiting...")
OATPP_LOGd(TAG, "Waiting...")
std::this_thread::sleep_for(std::chrono::seconds(10));
OATPP_LOGD(TAG, "TestPool counter=%ld", pool->getCounter())
OATPP_LOGd(TAG, "TestPool counter={}", pool->getCounter())
OATPP_ASSERT(pool->getCounter() == 0)
for(std::thread& thread : threads) {
@ -217,7 +217,7 @@ void PoolTest::onRun() {
executor.waitTasksFinished();
OATPP_LOGD(TAG, "counter=%ld", provider->getIdCounter())
OATPP_LOGd(TAG, "counter={}", provider->getIdCounter())
OATPP_ASSERT(provider->getIdCounter() == 20)
pool->stop();

View File

@ -137,7 +137,7 @@ void runServer(v_uint16 port, v_int32 delaySeconds, v_int32 iterations, bool sta
std::this_thread::sleep_for(std::chrono::seconds(delaySeconds));
if(!stable) {
controller->available = !controller->available;
OATPP_LOGI("Server", "Available=%d", static_cast<v_int32>(controller->available.load()))
OATPP_LOGi("Server", "Available={}", static_cast<v_int32>(controller->available.load()))
}
}
@ -160,7 +160,7 @@ void ClientRetryTest::onRun() {
{
OATPP_LOGI(TAG, "Test: no server available")
OATPP_LOGi(TAG, "Test: no server available")
oatpp::test::PerformanceChecker checker("test: no server available");
auto retryPolicy = std::make_shared<oatpp::web::client::SimpleRetryPolicy>(2, std::chrono::seconds(1));
@ -170,7 +170,7 @@ void ClientRetryTest::onRun() {
auto response = client->getRoot();
auto ticks = checker.getElapsedTicks();
OATPP_LOGD(TAG, "ticks=%ld", ticks)
OATPP_LOGd(TAG, "ticks={}", ticks)
if(m_port == 0) {
@ -195,7 +195,7 @@ void ClientRetryTest::onRun() {
{
OATPP_LOGI(TAG, "Test: server pops up")
OATPP_LOGi(TAG, "Test: server pops up")
oatpp::test::PerformanceChecker checker("test: server pops up");
auto retryPolicy = std::make_shared<oatpp::web::client::SimpleRetryPolicy>(10 * 10, std::chrono::milliseconds(100));
@ -214,7 +214,7 @@ void ClientRetryTest::onRun() {
}));
}
OATPP_LOGD(TAG, "Waiting for server to start...")
OATPP_LOGd(TAG, "Waiting for server to start...")
std::this_thread::sleep_for(std::chrono::seconds(3));
runServer(m_port, 2, 2, true, controller);
@ -230,7 +230,7 @@ void ClientRetryTest::onRun() {
{
OATPP_LOGI(TAG, "Test: unstable server!")
OATPP_LOGi(TAG, "Test: unstable server!")
auto retryPolicy = std::make_shared<oatpp::web::client::SimpleRetryPolicy>(-1, std::chrono::seconds(1));
auto connectionPool = oatpp::network::ClientConnectionPool::createShared(connectionProvider, 10, std::chrono::seconds(1));
@ -255,7 +255,7 @@ void ClientRetryTest::onRun() {
counter ++;
if(counter % 1000 == 0) {
OATPP_LOGD("client", "requests=%ld", counter)
OATPP_LOGd("client", "requests={}", counter)
}
}

View File

@ -155,11 +155,12 @@ public:
Action handleError(Error* error) override {
if(error->is<oatpp::AsyncIOError>()) {
auto e = static_cast<oatpp::AsyncIOError*>(error);
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "AsyncIOError. %s, %ld", e->what(), e->getCode())
OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "AsyncIOError. {}, {}", e->what(), e->getCode())
} else {
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "Error. %s", error->what())
OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "Error. {}", error->what())
}
OATPP_ASSERT(!"Error")
return error;
}
};
@ -196,11 +197,12 @@ public:
Action handleError(Error* error) override {
if(error->is<oatpp::AsyncIOError>()) {
auto e = static_cast<oatpp::AsyncIOError*>(error);
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "AsyncIOError. %s, %ld", e->what(), e->getCode())
OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "AsyncIOError. {}, {}", e->what(), e->getCode())
} else {
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "Error. %s", error->what())
OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "Error. {}", error->what())
}
OATPP_ASSERT(!"Error")
return error;
}
};
@ -242,12 +244,13 @@ public:
if(error) {
if(error->is<oatpp::AsyncIOError>()) {
auto e = static_cast<oatpp::AsyncIOError*>(error);
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. %s, %ld", e->what(), e->getCode())
OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. {}, {}", e->what(), e->getCode())
} else {
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what())
OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. {}", error->what())
}
}
OATPP_ASSERT(!"Error")
return error;
}
};
@ -286,7 +289,7 @@ void FullAsyncClientTest::onRun() {
ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER != -1
) {
OATPP_LOGV("Client", "Root=%d, postBody=%d, echoBody=%d",
OATPP_LOGv("Client", "Root={}, postBody={}, echoBody={}",
ClientCoroutine_getRootAsync::SUCCESS_COUNTER.load(),
ClientCoroutine_postBodyAsync::SUCCESS_COUNTER.load(),
ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER.load()
@ -296,15 +299,15 @@ void FullAsyncClientTest::onRun() {
if(ClientCoroutine_getRootAsync::SUCCESS_COUNTER == iterations){
ClientCoroutine_getRootAsync::SUCCESS_COUNTER = -1;
OATPP_LOGV("Client", "getRootAsync - DONE!")
OATPP_LOGv("Client", "getRootAsync - DONE!")
}
if(ClientCoroutine_postBodyAsync::SUCCESS_COUNTER == iterations){
ClientCoroutine_postBodyAsync::SUCCESS_COUNTER = -1;
OATPP_LOGV("Client", "postBodyAsync - DONE!")
OATPP_LOGv("Client", "postBodyAsync - DONE!")
}
if(ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER == iterations){
ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER = -1;
OATPP_LOGV("Client", "echoBodyAsync - DONE!")
OATPP_LOGv("Client", "echoBodyAsync - DONE!")
}
}

View File

@ -164,7 +164,7 @@ void FullAsyncTest::onRun() {
for(v_int32 i = 0; i < iterationsStep * 10; i ++) {
//OATPP_LOGV("i", "%d", i)
//OATPP_LOGv("i", "{}", i)
{ // test simple GET
auto response = client->getRoot(connection);
@ -281,7 +281,7 @@ void FullAsyncTest::onRun() {
if((i + 1) % iterationsStep == 0) {
auto ticks = oatpp::Environment::getMicroTickCount() - lastTick;
lastTick = oatpp::Environment::getMicroTickCount();
OATPP_LOGV("i", "%d, tick=%ld", i + 1, ticks)
OATPP_LOGv("i", "{}, tick={}", i + 1, ticks)
}
}

View File

@ -545,7 +545,7 @@ void FullTest::onRun() {
if((i + 1) % iterationsStep == 0) {
auto ticks = oatpp::Environment::getMicroTickCount() - lastTick;
lastTick = oatpp::Environment::getMicroTickCount();
OATPP_LOGV("i", "%d, tick=%ld", i + 1, ticks)
OATPP_LOGv("i", "{}, tick={}", i + 1, ticks)
}
{ // test bundle

View File

@ -145,7 +145,7 @@ void PipelineTest::onRun() {
}
auto dataToSend = pipelineStream.toString();
OATPP_LOGD(TAG, "Sending %lu bytes", dataToSend->size())
OATPP_LOGd(TAG, "Sending {} bytes", dataToSend->size())
oatpp::data::stream::BufferInputStream inputStream(dataToSend);
@ -163,7 +163,7 @@ void PipelineTest::onRun() {
v_io_size transferSize = static_cast<v_io_size>(sample->size() * static_cast<size_t>(m_pipelineSize));
OATPP_LOGD(TAG, "want to Receive %ld bytes", transferSize)
OATPP_LOGd(TAG, "want to Receive {} bytes", transferSize)
oatpp::data::stream::transfer(connection.object.get(), &receiveStream, transferSize, ioBuffer.getData(), ioBuffer.getSize());
auto result = receiveStream.toString();

View File

@ -70,16 +70,16 @@ public:
std::atomic<bool> available;
ENDPOINT("GET", "/", root) {
//OATPP_LOGD(TAG, "GET ROOT")
//OATPP_LOGd(TAG, "GET ROOT")
return createResponse(Status::CODE_200, "Hello World!!!");
}
ENDPOINT("GET", "/availability", availability) {
//OATPP_LOGV(TAG, "GET '/availability'")
//OATPP_LOGv(TAG, "GET '/availability'")
if(available) {
return createResponse(Status::CODE_200, "Hello World!!!");
}
OATPP_LOGI(TAG, "GET '/availability'. Service unavailable.")
OATPP_LOGi(TAG, "GET '/availability'. Service unavailable.")
OATPP_ASSERT_HTTP(false, Status::CODE_503, "Service unavailable")
}
@ -105,7 +105,7 @@ public:
ENDPOINT("GET", "params/{param}", getWithParams,
PATH(String, param)) {
//OATPP_LOGV(TAG, "GET params/%s", param->c_str())
//OATPP_LOGv(TAG, "GET params/{}", param)
auto dto = TestDto::createShared();
dto->testValue = param;
return createDtoResponse(Status::CODE_200, dto);
@ -137,7 +137,7 @@ public:
ENDPOINT("GET", "headers", getWithHeaders,
HEADER(String, param, "X-TEST-HEADER")) {
//OATPP_LOGV(TAG, "GET headers {X-TEST-HEADER: %s}", param->c_str())
//OATPP_LOGv(TAG, "GET headers {X-TEST-HEADER: {}}", param)
auto dto = TestDto::createShared();
dto->testValue = param;
return createDtoResponse(Status::CODE_200, dto);
@ -145,7 +145,7 @@ public:
ENDPOINT("POST", "body", postBody,
BODY_STRING(String, body)) {
//OATPP_LOGV(TAG, "POST body %s", body->c_str())
//OATPP_LOGv(TAG, "POST body {}", body)
auto dto = TestDto::createShared();
dto->testValue = body;
return createDtoResponse(Status::CODE_200, dto);
@ -153,13 +153,13 @@ public:
ENDPOINT("POST", "body-dto", postBodyDto,
BODY_DTO(Object<TestDto>, body)) {
//OATPP_LOGV(TAG, "POST body %s", body->c_str())
//OATPP_LOGv(TAG, "POST body {}", body->c_str())
return createDtoResponse(Status::CODE_200, body);
}
ENDPOINT("POST", "echo", echo,
BODY_STRING(String, body)) {
//OATPP_LOGV(TAG, "POST body(echo) size=%d", body->getSize())
//OATPP_LOGv(TAG, "POST body(echo) size={}", body->getSize())
return createResponse(Status::CODE_200, body);
}
@ -283,14 +283,14 @@ public:
request->transferBody(&multipartReader);
/* Print number of uploaded parts */
OATPP_LOGD("Multipart", "parts_count=%ld", multipart->count())
OATPP_LOGd("Multipart", "parts_count={}", multipart->count())
/* Print value of "part1" */
auto part1 = multipart->getNamedPart("part1");
OATPP_ASSERT_HTTP(part1, Status::CODE_400, "part1 is empty")
OATPP_LOGD("Multipart", "part1='%s'", part1->getPayload()->getInMemoryData()->c_str())
OATPP_LOGd("Multipart", "part1='{}'", part1->getPayload()->getInMemoryData())
/* Get part by name "part2"*/
auto filePart = multipart->getNamedPart("part2");
@ -344,7 +344,7 @@ public:
++ counter;
OATPP_LOGD("Multipart", "Frame sent!")
OATPP_LOGd("Multipart", "Frame sent!")
return part;

View File

@ -69,7 +69,7 @@ public:
ENDPOINT_ASYNC_INIT(Root)
Action act() override {
//OATPP_LOGV(TAG, "GET '/'")
//OATPP_LOGv(TAG, "GET '/'")
return _return(controller->createResponse(Status::CODE_200, "Hello World Async!!!"));
}
@ -81,7 +81,7 @@ public:
Action act() override {
auto param = request->getPathVariable("param");
//OATPP_LOGV(TAG, "GET params/%s", param->c_str())
//OATPP_LOGv(TAG, "GET params/{}", param)
auto dto = TestDto::createShared();
dto->testValue = param;
return _return(controller->createDtoResponse(Status::CODE_200, dto));
@ -95,7 +95,7 @@ public:
Action act() override {
auto param = request->getHeader("X-TEST-HEADER");
//OATPP_LOGV(TAG, "GET headers {X-TEST-HEADER: %s}", param->c_str())
//OATPP_LOGv(TAG, "GET headers {X-TEST-HEADER: {}}", param)
auto dto = TestDto::createShared();
dto->testValue = param;
return _return(controller->createDtoResponse(Status::CODE_200, dto));
@ -108,12 +108,12 @@ public:
ENDPOINT_ASYNC_INIT(PostBody)
Action act() override {
//OATPP_LOGV(TAG, "POST body. Reading body...")
//OATPP_LOGv(TAG, "POST body. Reading body...")
return request->readBodyToStringAsync().callbackTo(&PostBody::onBodyRead);
}
Action onBodyRead(const String& body) {
//OATPP_LOGV(TAG, "POST body %s", body->c_str())
//OATPP_LOGv(TAG, "POST body {}", body)
auto dto = TestDto::createShared();
dto->testValue = body;
return _return(controller->createDtoResponse(Status::CODE_200, dto));
@ -126,12 +126,12 @@ public:
ENDPOINT_ASYNC_INIT(Echo)
Action act() override {
//OATPP_LOGV(TAG, "POST body(echo). Reading body...")
//OATPP_LOGv(TAG, "POST body(echo). Reading body...")
return request->readBodyToStringAsync().callbackTo(&Echo::onBodyRead);
}
Action onBodyRead(const String& body) {
//OATPP_LOGV(TAG, "POST echo size=%d", body->getSize())
//OATPP_LOGv(TAG, "POST echo size={}", body->getSize())
return _return(controller->createResponse(Status::CODE_200, body));
}
@ -259,7 +259,7 @@ public:
Action onUploaded() {
/* Print number of uploaded parts */
OATPP_LOGD("Multipart", "parts_count=%ld", m_multipart->count())
OATPP_LOGd("Multipart", "parts_count={}", m_multipart->count())
/* Get multipart by name */
auto part1 = m_multipart->getNamedPart("part1");
@ -268,7 +268,7 @@ public:
OATPP_ASSERT_HTTP(part1, Status::CODE_400, "part1 is empty")
/* Print value of "part1" */
OATPP_LOGD("Multipart", "part1='%s'", part1->getPayload()->getInMemoryData()->c_str())
OATPP_LOGd("Multipart", "part1='{}'", part1->getPayload()->getInMemoryData())
/* Get multipart by name */
auto filePart = m_multipart->getNamedPart("part2");
@ -333,7 +333,7 @@ public:
++ counter;
OATPP_LOGD("Multipart", "Frame sent!")
OATPP_LOGd("Multipart", "Frame sent!")
return part;

View File

@ -56,7 +56,7 @@ public:
void ContentMappersTest::onRun() {
{
OATPP_LOGD(TAG, "case 1 - default mapper")
OATPP_LOGd(TAG, "case 1 - default mapper")
ContentMappers mappers;
mappers.putMapper(std::make_shared<FakeMapper>("application", "json"));
auto m = mappers.getMapper("APPLICATION/JSON");
@ -66,7 +66,7 @@ void ContentMappersTest::onRun() {
}
{
OATPP_LOGD(TAG, "case 2 - default mapper")
OATPP_LOGd(TAG, "case 2 - default mapper")
ContentMappers mappers;
mappers.putMapper(std::make_shared<FakeMapper>("application", "json"));
mappers.putMapper(std::make_shared<FakeMapper>("text", "html"));
@ -79,7 +79,7 @@ void ContentMappersTest::onRun() {
}
{
OATPP_LOGD(TAG, "case 3 - default mapper")
OATPP_LOGd(TAG, "case 3 - default mapper")
ContentMappers mappers;
mappers.putMapper(std::make_shared<FakeMapper>("application", "json"));
mappers.putMapper(std::make_shared<FakeMapper>("text", "html"));
@ -95,7 +95,7 @@ void ContentMappersTest::onRun() {
{
OATPP_LOGD(TAG, "case 4 - select mapper")
OATPP_LOGd(TAG, "case 4 - select mapper")
ContentMappers mappers;
mappers.putMapper(std::make_shared<FakeMapper>("application", "json"));
mappers.putMapper(std::make_shared<FakeMapper>("text", "html"));
@ -108,7 +108,7 @@ void ContentMappersTest::onRun() {
}
{
OATPP_LOGD(TAG, "case 5 - select mapper")
OATPP_LOGd(TAG, "case 5 - select mapper")
ContentMappers mappers;
mappers.putMapper(std::make_shared<FakeMapper>("application", "json"));
mappers.putMapper(std::make_shared<FakeMapper>("text", "html"));
@ -121,7 +121,7 @@ void ContentMappersTest::onRun() {
}
{
OATPP_LOGD(TAG, "case 6 - select mapper")
OATPP_LOGd(TAG, "case 6 - select mapper")
ContentMappers mappers;
mappers.putMapper(std::make_shared<FakeMapper>("application", "json"));
mappers.putMapper(std::make_shared<FakeMapper>("text", "html"));
@ -134,7 +134,7 @@ void ContentMappersTest::onRun() {
}
{
OATPP_LOGD(TAG, "case 7 - select mapper - corrupted input")
OATPP_LOGd(TAG, "case 7 - select mapper - corrupted input")
ContentMappers mappers;
mappers.putMapper(std::make_shared<FakeMapper>("application", "json"));
mappers.putMapper(std::make_shared<FakeMapper>("text", "html"));
@ -156,7 +156,7 @@ void ContentMappersTest::onRun() {
richMappers.putMapper(std::make_shared<FakeMapper>("text", "html"));
{
OATPP_LOGD(TAG, "case 8 - select mapper - empty")
OATPP_LOGd(TAG, "case 8 - select mapper - empty")
auto m = richMappers.selectMapper(
""
);
@ -164,7 +164,7 @@ void ContentMappersTest::onRun() {
}
{
OATPP_LOGD(TAG, "case 9 - select mapper - corrupted input")
OATPP_LOGd(TAG, "case 9 - select mapper - corrupted input")
auto m = richMappers.selectMapper(
"application/*;q=0.8, text/*;q=0.9, *.*"
);
@ -172,7 +172,7 @@ void ContentMappersTest::onRun() {
}
{
OATPP_LOGD(TAG, "case 10 - select mapper ")
OATPP_LOGd(TAG, "case 10 - select mapper ")
auto m = richMappers.selectMapper(
"application/*;q=0.8, text/*;q=0.9, */*"
);
@ -180,7 +180,7 @@ void ContentMappersTest::onRun() {
}
{
OATPP_LOGD(TAG, "case 11 - select mapper ")
OATPP_LOGd(TAG, "case 11 - select mapper ")
auto m = richMappers.selectMapper(
"application/*;q=0.9, text/*;q=0.8"
);

View File

@ -94,8 +94,8 @@ namespace {
OATPP_ASSERT(payload->getInMemoryData())
OATPP_ASSERT(payload->getInMemoryData() == value)
v_int64 bufferSize = 16;
std::unique_ptr<v_char8[]> buffer(new v_char8[bufferSize]);
v_buff_size bufferSize = 16;
std::unique_ptr<v_char8[]> buffer(new v_char8[static_cast<unsigned long>(bufferSize)]);
oatpp::data::stream::BufferOutputStream stream;
oatpp::data::stream::transfer(payload->openInputStream(), &stream, 0, buffer.get(), bufferSize);
@ -122,7 +122,7 @@ void StatefulParserTest::onRun() {
parseStepByStep(text, "12345", listener, i);
if(multipart.count() != 5) {
OATPP_LOGD(TAG, "TEST_DATA_1 itearation %lu", i)
OATPP_LOGd(TAG, "TEST_DATA_1 itearation {}", i)
}
OATPP_ASSERT(multipart.count() == 5)

View File

@ -94,7 +94,7 @@ void ChunkedTest::onRun() {
auto count = oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer, bufferSize, &decoder);
decoded = outStream.toString();
OATPP_ASSERT(count == static_cast<v_io_size>(encoded->size()))
OATPP_LOGD(TAG, "decoded='%s'", decoded->c_str())
OATPP_LOGd(TAG, "decoded='{}'", decoded)
OATPP_ASSERT(decoded == data)
}
@ -115,7 +115,7 @@ void ChunkedTest::onRun() {
auto count = oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer, bufferSize, &pipeline);
auto result = outStream.toString();
OATPP_ASSERT(count == static_cast<v_io_size>(data->size()))
OATPP_LOGD(TAG, "result='%s'", result->c_str())
OATPP_LOGd(TAG, "result='{}'", result)
OATPP_ASSERT(result == data)
}

View File

@ -49,7 +49,7 @@ void HttpRouterTest::onRun() {
router.route("POST", "*", -100);
{
OATPP_LOGI(TAG, "Case 1")
OATPP_LOGi(TAG, "Case 1")
auto r = router.getRoute("GET", "ints/1");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -57,7 +57,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 2")
OATPP_LOGi(TAG, "Case 2")
auto r = router.getRoute("GET", "/ints/1");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -65,7 +65,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 3")
OATPP_LOGi(TAG, "Case 3")
auto r = router.getRoute("GET", "ints/1//");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -73,7 +73,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 4")
OATPP_LOGi(TAG, "Case 4")
auto r = router.getRoute("GET", "//ints///1//");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -81,14 +81,14 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 5")
OATPP_LOGi(TAG, "Case 5")
auto r = router.getRoute("GET", "ints/1/*");
OATPP_ASSERT(r.isValid() == false)
OATPP_ASSERT(!r)
}
{
OATPP_LOGI(TAG, "Case 6")
OATPP_LOGi(TAG, "Case 6")
auto r = router.getRoute("GET", "ints/2");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -96,7 +96,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 7")
OATPP_LOGi(TAG, "Case 7")
auto r = router.getRoute("GET", "ints/all/10");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -106,7 +106,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 8")
OATPP_LOGi(TAG, "Case 8")
auto r = router.getRoute("GET", "//ints//all//10//");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -116,14 +116,14 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 9")
OATPP_LOGi(TAG, "Case 9")
auto r = router.getRoute("GET", "//ints//all//10//*");
OATPP_ASSERT(r.isValid() == false)
OATPP_ASSERT(!r)
}
{
OATPP_LOGI(TAG, "Case 10")
OATPP_LOGi(TAG, "Case 10")
auto r = router.getRoute("POST", "ints/1");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -131,7 +131,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 11")
OATPP_LOGi(TAG, "Case 11")
auto r = router.getRoute("POST", "ints/2");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -139,7 +139,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 12")
OATPP_LOGi(TAG, "Case 12")
auto r = router.getRoute("POST", "ints/3");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -149,7 +149,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 13")
OATPP_LOGi(TAG, "Case 13")
auto r = router.getRoute("POST", "ints/3/10");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -158,7 +158,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 14")
OATPP_LOGi(TAG, "Case 14")
auto r = router.getRoute("POST", "abc");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -167,7 +167,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 15")
OATPP_LOGi(TAG, "Case 15")
auto r = router.getRoute("GET", "ints/1?q1=1&q2=2");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
@ -176,7 +176,7 @@ void HttpRouterTest::onRun() {
}
{
OATPP_LOGI(TAG, "Case 16")
OATPP_LOGi(TAG, "Case 16")
auto r = router.getRoute("GET", "ints/all/3?q1=1&q2=2");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)

Some files were not shown because too many files have changed in this diff Show More