Repository navigation
Expand file tree
/
Copy pathtest_main.cpp
More file actions
67 lines (51 loc) · 1.42 KB
/
Copy pathtest_main.cpp
File metadata and controls
67 lines (51 loc) · 1.42 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* @author Jamie (jamie.lim@kakaocorp.com)
* @copyright Copyright (C) 2017-, Kakao Corp. All rights reserved.
*/
//////////////
// includes //
//////////////
#include <iostream>
#include "cxxopts.hpp"
#include "fmt/printf.h"
#ifdef PROFILER
#include "gperftools/profiler.h"
#endif
#include "gtest/gtest.h"
#include "spdlog/spdlog.h"
#include "khaiii/khaiii_dev.h"
using std::cerr;
using std::string;
///////////////
// variables //
///////////////
// global variable for program arguments
cxxopts::ParseResult* prog_args;
//////////
// main //
//////////
int main(int argc, char** argv) {
cxxopts::Options options(argv[0], argv[0]);
testing::InitGoogleTest(&argc, argv);
auto _log = spdlog::stderr_color_mt("console");
spdlog::set_level(spdlog::level::warn);
options.add_options()
("h,help", "print this help")
("rsc-dir", "resource directory", cxxopts::value<string>()->default_value("./share/khaiii"))
("set-log", "set log level", cxxopts::value<string>()->default_value("all:warn"));
auto args = options.parse(argc, argv);
if (args.count("help")) {
fmt::fprintf(cerr, "%s\n", options.help());
return 0;
}
prog_args = &args;
khaiii_set_log_levels(args["set-log"].as<string>().c_str());
#ifdef PROFILER
ProfilerStart("/tmp/test_khaiii.prof");
#endif
int ret = RUN_ALL_TESTS();
#ifdef PROFILER
ProfilerStop();
#endif
return ret;
}