mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
62
base/base_tests/logging_test.cpp
Normal file
62
base/base_tests/logging_test.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void TestLogMessage(base::LogLevel, base::SrcPoint const &, std::string const &)
|
||||
{
|
||||
}
|
||||
|
||||
bool g_SomeFunctionCalled;
|
||||
int SomeFunction()
|
||||
{
|
||||
g_SomeFunctionCalled = true;
|
||||
return 3;
|
||||
}
|
||||
|
||||
bool BoolFunction(bool result, bool & called)
|
||||
{
|
||||
called = true;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(Logging_Level)
|
||||
{
|
||||
base::LogLevel const logLevelSaved = base::g_LogLevel;
|
||||
base::g_LogLevel = LWARNING;
|
||||
|
||||
g_SomeFunctionCalled = false;
|
||||
base::LogMessageFn logMessageSaved = base::SetLogMessageFn(&TestLogMessage);
|
||||
|
||||
LOG(LINFO, ("This should not pass", SomeFunction()));
|
||||
TEST(!g_SomeFunctionCalled, ());
|
||||
|
||||
LOG(LWARNING, ("This should pass", SomeFunction()));
|
||||
TEST(g_SomeFunctionCalled, ());
|
||||
|
||||
base::SetLogMessageFn(logMessageSaved);
|
||||
base::g_LogLevel = logLevelSaved;
|
||||
}
|
||||
|
||||
UNIT_TEST(NullMessage)
|
||||
{
|
||||
char const * ptr = 0;
|
||||
LOG(LINFO, ("Null message test", ptr));
|
||||
}
|
||||
|
||||
UNIT_TEST(Logging_ConditionalLog)
|
||||
{
|
||||
bool isCalled = false;
|
||||
CLOG(LINFO, BoolFunction(true, isCalled), ("This should not be displayed"));
|
||||
TEST(isCalled, ());
|
||||
|
||||
isCalled = false;
|
||||
CLOG(LWARNING, BoolFunction(false, isCalled), ("This should be displayed"));
|
||||
TEST(isCalled, ());
|
||||
}
|
||||
Reference in New Issue
Block a user