OSDN Git Service

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