-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
108 lines (99 loc) · 3.07 KB
/
main.cpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "ToolsDefine.h"
#include "FileTools.h"
#include "LogTools.h"
#include "StringTools.h"
#include "TimeTools.h"
#include "ThreadTools.h"
#include <iostream>
#include <gtest/gtest.h>
#include <vector>
using namespace DTools;
// FileTools
TEST(FileTools, ExtractDirectory)
{
EXPECT_EQ("/foo/bar/", FileTools::extractDirectory("/foo/bar/baz.txt"));
}
TEST(FileTools, ExtractFilename)
{
EXPECT_EQ("baz.txt", FileTools::extractFilename("/foo/bar/baz.txt"));
}
TEST(FileTools, ExtractFileExtension)
{
EXPECT_EQ(".txt", FileTools::extractFileExtension("/foo/bar/baz.txt"));
EXPECT_EQ("", FileTools::extractFileExtension("/foo/bar/baz"));
}
TEST(FileTools, ChangeFileExtension)
{
EXPECT_EQ("/foo/bar/baz.dat", FileTools::changeFileExtension("/foo/bar/baz.txt", ".dat"));
EXPECT_EQ("/foo/bar/baz", FileTools::changeFileExtension("/foo/bar/baz.txt", ""));
EXPECT_EQ("/foo/bar/baz.txt", FileTools::changeFileExtension("/foo/bar/baz", ".txt"));
}
//TEST(FileTools, MakeDirectory)
//{
//#ifdef WIN32
// EXPECT_EQ(true, FileTools::makeDirectory("C:\\logs\\"));
// EXPECT_EQ(true, FileTools::makeDirectory("C:\\logs\\"));
// EXPECT_EQ(false, FileTools::makeDirectory(""));
// EXPECT_EQ(false, FileTools::makeDirectory("C:\\logs/a"));
// EXPECT_EQ(false, FileTools::makeDirectory("/home/logs\a"));
// EXPECT_EQ(false, FileTools::makeDirectory("/home/logs"));
//#else
// EXPECT_EQ(false, FileTools::makeDirectory("C:\\logs\\"));
// EXPECT_EQ(false, FileTools::makeDirectory(""));
// EXPECT_EQ(false, FileTools::makeDirectory("C:\\logs/a"));
// EXPECT_EQ(false, FileTools::makeDirectory("/home/logs\a"));
// EXPECT_EQ(true, FileTools::makeDirectory("/home/logs"));
// EXPECT_EQ(true, FileTools::makeDirectory("/home/logs"));
//#endif
//}
// TimeTools
TEST(TimeTools, GetTZOffsetByZonename)
{
DFloat8 zoneOffset = 0;
ASSERT_TRUE(TimeTools::getLocalTZOffset(zoneOffset));
EXPECT_EQ(28800, zoneOffset);
}
// StringTools
TEST(StringTools, ValueToString)
{
EXPECT_EQ("123.456", StringTools::valueToString(123.456));
EXPECT_EQ("123", StringTools::valueToString(123));
}
int printLog(void *)
{
for (;;)
{
DLOGGER << "22222222222222222222222222222222222" << std::endl;
}
return 0;
}
int main(int argc, char * argv[])
{
// log test start
//DLOGGER_INIT;
// flow id function test.
//DTools::ThreadTools::CREATE_THREAD(printLog, NULL);
// base write log function test.
//DLOGGER << 12312412 << "asdfasdfa" << std::endl;
//DLOGGER << "asdfas" << std::endl;
//std::vector<std::string> tmp_vecTest;
//tmp_vecTest.push_back("Show me the money.");
//tmp_vecTest.push_back("Black sheep wall.");
//DLOGGER << "tmp_vecTest:\n";
//for (std::vector<std::string>::size_type i = 0; i < tmp_vecTest.size(); ++i)
//{
// DLOGGER << "\t" + DTools::StringTools::valueToString(i + 1) + ". " << tmp_vecTest.at(i) << "\n";
//}
//DLOGGER << std::endl;
//DLOGGER << "test" << std::endl;
// file partition function test.
//for (;;)
//{
// DLOGGER << "11111111111111111111111111111111111" << std::endl;
//}
//DLOGGER_END;
// log test end
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
return 0;
}