File: test_imp_log.cpp

package info (click to toggle)
dolphin-emu 2603%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 69,040 kB
  • sloc: cpp: 442,137; ansic: 117,979; python: 6,438; sh: 2,387; asm: 726; makefile: 394; pascal: 257; javascript: 183; perl: 97; objc: 75; xml: 8
file content (46 lines) | stat: -rw-r--r-- 825 bytes parent folder | download
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
46

#include <iostream>
#include <string>

#include "../archive/test.h"

#include "libipc/imp/log.h"

TEST(log, logger) {
  {
    LIBIPC_LOG();
    log.info("hello");
  }
  {
    LIBIPC_LOG();
    log.info("hello 2");
  }
  {
    LIBIPC_LOG();
    log.info("hello ", 3);
  }
  SUCCEED();
}

TEST(log, custom) {
  struct log {
    std::string i;
    std::string e;
  } ll_data;
  auto ll = [&ll_data](auto &&ctx) {
    auto s = ipc::fmt(ctx.params);
    if (ctx.level == ipc::log::level::error) ll_data.e += s + " ";
    else
    if (ctx.level == ipc::log::level::info ) ll_data.i += s + " ";
  };

  LIBIPC_LOG(ll);

  log.info ("hello", " world");
  log.error("failed", ":");
  log.info ("log", '-', "pt");
  log.error("whatever");

  EXPECT_EQ(ll_data.i, "hello world log-pt ");
  EXPECT_EQ(ll_data.e, "failed: whatever ");
}