Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added unit tests for the CreateFilenamePath function.
[xestiaab/.git] / source / tests / xestiaab_common.h
1  // xestiaab_common.h - Xestia Address Book Common Functions Unit Tests.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <gtest/gtest.h>
20 #include "../common/dirs.h"
21 #include "../common/filename.h"
23 TEST(CommonFunctions, GetUserDir){
24         
25         // Run the unit tests depending on the operating system being used.
26         
27 #if defined(__WIN32__)
28         
29 #elif defined(__APPLE__)
30         
31 #else
32         
33         // Setup for comparison purposes. Should be /home/<user>/.xestiaab
34         
35         wxString UserDirCheck = "";
36         UserDirCheck.Append(wxString::FromUTF8(getenv("HOME")));
37         UserDirCheck.Append(wxT("/.xestiaab/"));
38         
39         wxString UserDir = GetUserDir();
40         
41         ASSERT_EQ(UserDir, UserDirCheck);
42         
43 #endif
44         
45 }
47 TEST(CommonFunctions, GetUserPrefDir){
48         
49         // Run the unit tests depending on the operating system being used.
50         
51 #if defined(__WIN32__)
52         
53 #elif defined(__APPLE__)
54         
55 #else
56         
57         // Setup for comparison purposes. Should be /home/<user>/.xestiaab/preferences
58         
59         wxString UserDirCheck = "";
60         UserDirCheck.Append(wxString::FromUTF8(getenv("HOME")));
61         UserDirCheck.Append(wxT("/.xestiaab/preferences/"));
62         
63         wxString UserDir = GetUserPrefDir();
64         
65         ASSERT_EQ(UserDir, UserDirCheck);
66         
67 #endif
68         
69 }
71 TEST(CommonFunctions, GetAccountDir){
72         
73         // Run the unit tests depending on the operating system being used.
74         
75 #if defined(__WIN32__)
76         
77 #elif defined(__APPLE__)
78         
79 #else
80         
81         // Setup for comparison purposes. Should be /home/<user>/.xestiaab/preferences
82         
83         wxString AccountDirCheck1 = "";
84         wxString AccountDirCheck2 = "";
85         wxString AccountDirCheck3 = "";
86         
87         AccountDirCheck1.Append(wxString::FromUTF8(getenv("HOME")));
88         AccountDirCheck1.Append(wxT("/.xestiaab/accounts/"));
89         AccountDirCheck1.Append("Example1");
90         AccountDirCheck1.Append(wxT("/"));
92         AccountDirCheck2.Append(wxString::FromUTF8(getenv("HOME")));
93         AccountDirCheck2.Append(wxT("/.xestiaab/accounts/"));
94         AccountDirCheck2.Append("Example2");
95         AccountDirCheck2.Append(wxT("/"));      
96         
97         AccountDirCheck3.Append(wxString::FromUTF8(getenv("HOME")));
98         AccountDirCheck3.Append(wxT("/.xestiaab/accounts/"));
99         AccountDirCheck3.Append("Example3");
100         AccountDirCheck3.Append(wxT("/"));
101         
102         wxString AccountDir1 = GetAccountDir("Example1", false);
103         wxString AccountDir2 = GetAccountDir("Example2", false);
104         wxString AccountDir3 = GetAccountDir("Example3", false);
106         ASSERT_EQ(AccountDir1, AccountDirCheck1);
107         ASSERT_EQ(AccountDir2, AccountDirCheck2);
108         ASSERT_EQ(AccountDir3, AccountDirCheck3);
109         
110 #endif
111         
114 TEST(CommonFunctions, GetAccountDirCertificate){
115         
116         // Run the unit tests depending on the operating system being used.
117         
118 #if defined(__WIN32__)
119         
120 #elif defined(__APPLE__)
121         
122 #else
123         
124         // Setup for comparison purposes. Should be /home/<user>/.xestiaab/preferences
125         
126         wxString AccountDirCheck1 = "";
127         wxString AccountDirCheck2 = "";
128         wxString AccountDirCheck3 = "";
129         
130         AccountDirCheck1.Append(wxString::FromUTF8(getenv("HOME")));
131         AccountDirCheck1.Append(wxT("/.xestiaab/accounts/"));
132         AccountDirCheck1.Append("Example1");
133         AccountDirCheck1.Append(wxT("/server.crt"));
135         AccountDirCheck2.Append(wxString::FromUTF8(getenv("HOME")));
136         AccountDirCheck2.Append(wxT("/.xestiaab/accounts/"));
137         AccountDirCheck2.Append("Example2");
138         AccountDirCheck2.Append(wxT("/server.crt"));
139         
140         AccountDirCheck3.Append(wxString::FromUTF8(getenv("HOME")));
141         AccountDirCheck3.Append(wxT("/.xestiaab/accounts/"));
142         AccountDirCheck3.Append("Example3");
143         AccountDirCheck3.Append(wxT("/server.crt"));
144         
145         wxString AccountDir1 = GetAccountDir("Example1", true);
146         wxString AccountDir2 = GetAccountDir("Example2", true);
147         wxString AccountDir3 = GetAccountDir("Example3", true);
149         ASSERT_EQ(AccountDir1, AccountDirCheck1);
150         ASSERT_EQ(AccountDir2, AccountDirCheck2);
151         ASSERT_EQ(AccountDir3, AccountDirCheck3);
152         
153 #endif
154         
157 TEST(CommonFunctions, GetAccountsFile){
158         
159         // Run the unit tests depending on the operating system being used.
160         
161 #if defined(__WIN32__)
162         
163 #elif defined(__APPLE__)
164         
165 #else
166         
167         // Setup for comparison purposes. Should be 
168         // /home/<user>/.xestiaab/preferences/accounts
169         
170         wxString AccountsFileCheck = "";
171         AccountsFileCheck.Clear();
172         AccountsFileCheck.Append(wxString::FromUTF8(getenv("HOME")));
173         AccountsFileCheck.Append(wxT("/.xestiaab/preferences/accounts"));
174         
175         wxString AccountsFile = GetAccountsFile();
176         
177         ASSERT_EQ(AccountsFile, AccountsFileCheck);
178         
179 #endif
180         
183 TEST(CommonFunctions, GetSettingsFile){
184         
185         // Run the unit tests depending on the operating system being used.
186         
187 #if defined(__WIN32__)
188         
189 #elif defined(__APPLE__)
190         
191 #else
192         
193         // Setup for comparison purposes. Should be 
194         // /home/<user>/.xestiaab/preferences/accounts
195         
196         wxString SettingsFileCheck = "";
197         SettingsFileCheck.Clear();
198         SettingsFileCheck.Append(wxString::FromUTF8(getenv("HOME")));
199         SettingsFileCheck.Append(wxT("/.xestiaab/preferences/settings"));
200         
201         wxString SettingsFile = GetSettingsFile();
202         
203         ASSERT_EQ(SettingsFile, SettingsFileCheck);
204         
205 #endif
206         
209 TEST(CommonFunctions, CreateFilenamePath){
210         
211         // Run the unit tests depending on the operating system being used.
212         
213 #if defined(__WIN32__)
214         
215 #elif defined(__APPLE__)
216         
217 #else
218                 
219         ASSERT_EQ("/test", CreateFilenamePath("", "test"));
220         ASSERT_EQ("/example/test", CreateFilenamePath("/example", "test"));
221         ASSERT_EQ("/home/meep/test", CreateFilenamePath("/home/meep", "test"));
222         ASSERT_EQ("/home/meep/moo/test", CreateFilenamePath("/home/meep/moo", "test"));
223         ASSERT_EQ("/home/meep/moo/yargh/test", CreateFilenamePath("/home/meep/moo/yargh", "test"));
224         
225 #endif
226         
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy