Welcome to mirror list, hosted at ThFree Co, Russian Federation.

logging_test.cpp « base_tests « base - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff5e50ad1671949239e5767046aa62d9ed031abb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "testing/testing.hpp"

#include "base/logging.hpp"

#include <utility>
#include <vector>


namespace
{
  void TestLogMessage(my::LogLevel, my::SrcPoint const &, std::string const &)
  {
  }

  bool g_SomeFunctionCalled;
  int SomeFunction()
  {
    g_SomeFunctionCalled = true;
    return 3;
  }
}

UNIT_TEST(Logging_Level)
{
  my::LogLevel const logLevelSaved = my::g_LogLevel;
  my::g_LogLevel = LWARNING;

  g_SomeFunctionCalled = false;
  my::LogMessageFn logMessageSaved = my::SetLogMessageFn(&TestLogMessage);

  LOG(LINFO, ("This should not pass", SomeFunction()));
  TEST(!g_SomeFunctionCalled, ());

  LOG(LWARNING, ("This should pass", SomeFunction()));
  TEST(g_SomeFunctionCalled, ());

  my::SetLogMessageFn(logMessageSaved);
  my::g_LogLevel = logLevelSaved;
}

UNIT_TEST(NullMessage)
{
  char const * ptr = 0;
  LOG(LINFO, ("Null message test", ptr));
}