OSDN Git Service

Reduce the number of #include <Windows.h> and <tchar.h>.
[winmerge-jp/winmerge-jp.git] / Testing / GoogleTest / OptionsMgr / RegOptionsMgr_test.cpp
1 #include "pch.h"\r
2 #include <gtest/gtest.h>\r
3 #include <vector>\r
4 #include "UnicodeString.h"\r
5 #include "RegOptionsMgr.h"\r
6 \r
7 using std::vector;\r
8 \r
9 // TODO:\r
10 // - add helper functions for checking the changes in registry\r
11 \r
12 namespace\r
13 {\r
14         // The fixture for testing command line parsing.\r
15         class RegOptionsMgrTest : public testing::Test\r
16         {\r
17         protected:\r
18                 // You can remove any or all of the following functions if its body\r
19                 // is   empty.\r
20 \r
21                 RegOptionsMgrTest()\r
22                 {\r
23                         // You can do set-up work for each test here.\r
24                 }\r
25 \r
26                 virtual ~RegOptionsMgrTest()\r
27                 {\r
28                         // You can do clean-up work     that doesn't throw exceptions here.\r
29                 }\r
30 \r
31                 // If   the     constructor     and     destructor are not enough for setting up\r
32                 // and cleaning up each test, you can define the following methods:\r
33 \r
34                 virtual void SetUp()\r
35                 {\r
36                         // Code here will be called     immediately     after the constructor (right\r
37                         // before each test).\r
38                 }\r
39 \r
40                 virtual void TearDown()\r
41                 {\r
42                         // Code here will be called     immediately     after each test (right\r
43                         // before the destructor).\r
44                 }\r
45 \r
46                 // Objects declared here can be used by all tests in the test case for Foo.\r
47         };\r
48 \r
49         // Read option that does not exist\r
50         // This causes exception in debug builds\r
51 #if 0\r
52         TEST_F(RegOptionsMgrTest, ReadNonexistingBool1)\r
53         {\r
54                 CRegOptionsMgr mgr;\r
55                 mgr.SetRegRootKey(_T("Thingamahoochie\\WinMerge\\UnitTesting"));\r
56                 EXPECT_EQ(true, mgr.GetBool(_T("BoolOpt2"));\r
57         }\r
58 #endif\r
59 \r
60         // Add new bool option with false default value\r
61         TEST_F(RegOptionsMgrTest, AddBoolOption1)\r
62         {\r
63                 CRegOptionsMgr mgr;\r
64                 mgr.SetRegRootKey(_T("Thingamahoochie\\WinMerge\\UnitTesting"));\r
65                 EXPECT_EQ(COption::OPT_OK, mgr.InitOption(_T("BoolOpt1"), false));\r
66                 EXPECT_EQ(false, mgr.GetBool(_T("BoolOpt1")));\r
67         }\r
68 \r
69         // Add new bool option with true default value\r
70         TEST_F(RegOptionsMgrTest, AddBoolOption2)\r
71         {\r
72                 CRegOptionsMgr mgr;\r
73                 mgr.SetRegRootKey(_T("Thingamahoochie\\WinMerge\\UnitTesting"));\r
74                 EXPECT_EQ(COption::OPT_OK, mgr.InitOption(_T("BoolOpt2"), true));\r
75                 EXPECT_EQ(true, mgr.GetBool(_T("BoolOpt2")));\r
76         }\r
77 }