Loggers.cpp
Go to the documentation of this file.
1 #include "../utest.h"
2 
3 using namespace std;
4 using namespace PointMatcherSupport;
5 
6 //---------------------------
7 // Loggers
8 //---------------------------
9 
10 TEST(Loggers, FileLogger)
11 {
12  string infoFileName = "utest_info";
13  string warningFileName = "utest_warn";
14 
15  std::shared_ptr<Logger> fileLog =
16  PM::get().REG(Logger).create(
17  "FileLogger", {
18  {"infoFileName", infoFileName},
19  { "warningFileName", warningFileName },
20  { "displayLocation", "1" }
21  }
22  );
23 
24  fileLog.reset(); // The logger needs to release the files to allow them to be removed
25 
26  EXPECT_TRUE(boost::filesystem::remove(boost::filesystem::path(infoFileName)));
27  EXPECT_TRUE(boost::filesystem::remove(boost::filesystem::path(warningFileName)));
28 }
29 
30 TEST(Loggers, FileLoggerInfoToConsole)
31 {
32  std::shared_ptr<Logger> fileLog =
33  PM::get().REG(Logger).create(
34  "FileLogger", {
35  { "displayLocation", "1" }
36  }
37  );
38  EXPECT_NO_THROW((*fileLog->infoStream()) << "TEST\n");
39 }
40 
41 TEST(Loggers, FileLoggerWarningToConsole)
42 {
43  std::shared_ptr<Logger> fileLog =
44  PM::get().REG(Logger).create(
45  "FileLogger", {
46  { "displayLocation", "1" }
47  }
48  );
49  EXPECT_NO_THROW((*fileLog->warningStream()) << "TEST\n");
50 }
51 
52 TEST(Loggers, FileLoggerInfoToFile)
53 {
54  string infoFileName = "utest_info";
55 
56  std::shared_ptr<Logger> fileLog =
57  PM::get().REG(Logger).create(
58  "FileLogger", {
59  {"infoFileName", infoFileName},
60  { "displayLocation", "1" }
61  }
62  );
63 
64  EXPECT_NO_THROW((*fileLog->infoStream()) << "TEST");
65 
66  fileLog.reset(); // The logger needs to release the file to allow it to be removed
67 
68  EXPECT_TRUE(boost::filesystem::remove(boost::filesystem::path(infoFileName)));
69 }
70 
71 TEST(Loggers, FileLoggerWarningToFile)
72 {
73  string warningFileName = "utest_warn";
74 
75  std::shared_ptr<Logger> fileLog =
76  PM::get().REG(Logger).create(
77  "FileLogger", {
78  { "warningFileName", warningFileName },
79  { "displayLocation", "1" }
80  }
81  );
82 
83  EXPECT_NO_THROW((*fileLog->warningStream()) << "TEST");
84 
85  fileLog.reset(); // The logger needs to release the file to allow it to be removed
86 
87  EXPECT_TRUE(boost::filesystem::remove(boost::filesystem::path(warningFileName)));
88 }
PointMatcherSupport::FileLogger
Definition: LoggerImpl.h:55
PointMatcherSupport::Logger
The logger interface, used to output warnings and informations.
Definition: PointMatcher.h:104
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: gtest.h:19327
TEST
TEST(Loggers, FileLogger)
Definition: Loggers.cpp:10
EXPECT_NO_THROW
#define EXPECT_NO_THROW(statement)
Definition: gtest.h:19313
std
PointMatcher< float >::get
static const PointMatcher & get()
Return instances.
Definition: Registry.cpp:146
PointMatcherSupport
Functions and classes that are not dependant on scalar type are defined in this namespace.
Definition: Bibliography.cpp:45


libpointmatcher
Author(s):
autogenerated on Mon Sep 16 2024 02:24:09