Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added unit tests for the GetMIME 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"
22 #include "../common/mime.h"
24 TEST(CommonFunctions, GetUserDir){
25         
26         // Run the unit tests depending on the operating system being used.
27         
28 #if defined(__WIN32__)
29         
30 #elif defined(__APPLE__)
31         
32 #else
33         
34         // Setup for comparison purposes. Should be /home/<user>/.xestiaab
35         
36         wxString UserDirCheck = "";
37         UserDirCheck.Append(wxString::FromUTF8(getenv("HOME")));
38         UserDirCheck.Append(wxT("/.xestiaab/"));
39         
40         wxString UserDir = GetUserDir();
41         
42         ASSERT_EQ(UserDir, UserDirCheck);
43         
44 #endif
45         
46 }
48 TEST(CommonFunctions, GetUserPrefDir){
49         
50         // Run the unit tests depending on the operating system being used.
51         
52 #if defined(__WIN32__)
53         
54 #elif defined(__APPLE__)
55         
56 #else
57         
58         // Setup for comparison purposes. Should be /home/<user>/.xestiaab/preferences
59         
60         wxString UserDirCheck = "";
61         UserDirCheck.Append(wxString::FromUTF8(getenv("HOME")));
62         UserDirCheck.Append(wxT("/.xestiaab/preferences/"));
63         
64         wxString UserDir = GetUserPrefDir();
65         
66         ASSERT_EQ(UserDir, UserDirCheck);
67         
68 #endif
69         
70 }
72 TEST(CommonFunctions, GetAccountDir){
73         
74         // Run the unit tests depending on the operating system being used.
75         
76 #if defined(__WIN32__)
77         
78 #elif defined(__APPLE__)
79         
80 #else
81         
82         // Setup for comparison purposes. Should be /home/<user>/.xestiaab/preferences
83         
84         wxString AccountDirCheck1 = "";
85         wxString AccountDirCheck2 = "";
86         wxString AccountDirCheck3 = "";
87         
88         AccountDirCheck1.Append(wxString::FromUTF8(getenv("HOME")));
89         AccountDirCheck1.Append(wxT("/.xestiaab/accounts/"));
90         AccountDirCheck1.Append("Example1");
91         AccountDirCheck1.Append(wxT("/"));
93         AccountDirCheck2.Append(wxString::FromUTF8(getenv("HOME")));
94         AccountDirCheck2.Append(wxT("/.xestiaab/accounts/"));
95         AccountDirCheck2.Append("Example2");
96         AccountDirCheck2.Append(wxT("/"));      
97         
98         AccountDirCheck3.Append(wxString::FromUTF8(getenv("HOME")));
99         AccountDirCheck3.Append(wxT("/.xestiaab/accounts/"));
100         AccountDirCheck3.Append("Example3");
101         AccountDirCheck3.Append(wxT("/"));
102         
103         wxString AccountDir1 = GetAccountDir("Example1", false);
104         wxString AccountDir2 = GetAccountDir("Example2", false);
105         wxString AccountDir3 = GetAccountDir("Example3", false);
107         ASSERT_EQ(AccountDir1, AccountDirCheck1);
108         ASSERT_EQ(AccountDir2, AccountDirCheck2);
109         ASSERT_EQ(AccountDir3, AccountDirCheck3);
110         
111 #endif
112         
115 TEST(CommonFunctions, GetAccountDirCertificate){
116         
117         // Run the unit tests depending on the operating system being used.
118         
119 #if defined(__WIN32__)
120         
121 #elif defined(__APPLE__)
122         
123 #else
124         
125         // Setup for comparison purposes. Should be /home/<user>/.xestiaab/preferences
126         
127         wxString AccountDirCheck1 = "";
128         wxString AccountDirCheck2 = "";
129         wxString AccountDirCheck3 = "";
130         
131         AccountDirCheck1.Append(wxString::FromUTF8(getenv("HOME")));
132         AccountDirCheck1.Append(wxT("/.xestiaab/accounts/"));
133         AccountDirCheck1.Append("Example1");
134         AccountDirCheck1.Append(wxT("/server.crt"));
136         AccountDirCheck2.Append(wxString::FromUTF8(getenv("HOME")));
137         AccountDirCheck2.Append(wxT("/.xestiaab/accounts/"));
138         AccountDirCheck2.Append("Example2");
139         AccountDirCheck2.Append(wxT("/server.crt"));
140         
141         AccountDirCheck3.Append(wxString::FromUTF8(getenv("HOME")));
142         AccountDirCheck3.Append(wxT("/.xestiaab/accounts/"));
143         AccountDirCheck3.Append("Example3");
144         AccountDirCheck3.Append(wxT("/server.crt"));
145         
146         wxString AccountDir1 = GetAccountDir("Example1", true);
147         wxString AccountDir2 = GetAccountDir("Example2", true);
148         wxString AccountDir3 = GetAccountDir("Example3", true);
150         ASSERT_EQ(AccountDir1, AccountDirCheck1);
151         ASSERT_EQ(AccountDir2, AccountDirCheck2);
152         ASSERT_EQ(AccountDir3, AccountDirCheck3);
153         
154 #endif
155         
158 TEST(CommonFunctions, GetAccountsFile){
159         
160         // Run the unit tests depending on the operating system being used.
161         
162 #if defined(__WIN32__)
163         
164 #elif defined(__APPLE__)
165         
166 #else
167         
168         // Setup for comparison purposes. Should be 
169         // /home/<user>/.xestiaab/preferences/accounts
170         
171         wxString AccountsFileCheck = "";
172         AccountsFileCheck.Clear();
173         AccountsFileCheck.Append(wxString::FromUTF8(getenv("HOME")));
174         AccountsFileCheck.Append(wxT("/.xestiaab/preferences/accounts"));
175         
176         wxString AccountsFile = GetAccountsFile();
177         
178         ASSERT_EQ(AccountsFile, AccountsFileCheck);
179         
180 #endif
181         
184 TEST(CommonFunctions, GetSettingsFile){
185         
186         // Run the unit tests depending on the operating system being used.
187         
188 #if defined(__WIN32__)
189         
190 #elif defined(__APPLE__)
191         
192 #else
193         
194         // Setup for comparison purposes. Should be 
195         // /home/<user>/.xestiaab/preferences/accounts
196         
197         wxString SettingsFileCheck = "";
198         SettingsFileCheck.Clear();
199         SettingsFileCheck.Append(wxString::FromUTF8(getenv("HOME")));
200         SettingsFileCheck.Append(wxT("/.xestiaab/preferences/settings"));
201         
202         wxString SettingsFile = GetSettingsFile();
203         
204         ASSERT_EQ(SettingsFile, SettingsFileCheck);
205         
206 #endif
207         
210 TEST(CommonFunctions, CreateFilenamePath){
211         
212         // Run the unit tests depending on the operating system being used.
213         
214 #if defined(__WIN32__)
215         
216 #elif defined(__APPLE__)
217         
218 #else
219                 
220         ASSERT_EQ("/test", CreateFilenamePath("", "test"));
221         ASSERT_EQ("/example/test", CreateFilenamePath("/example", "test"));
222         ASSERT_EQ("/home/meep/test", CreateFilenamePath("/home/meep", "test"));
223         ASSERT_EQ("/home/meep/moo/test", CreateFilenamePath("/home/meep/moo", "test"));
224         ASSERT_EQ("/home/meep/moo/yargh/test", CreateFilenamePath("/home/meep/moo/yargh", "test"));
225         
226 #endif
227         
230 TEST(CommonFunctions, GetMIME){
231         
232         ASSERT_EQ("text/plain", GetMIME("TextMIMEExample.txt"));
233         ASSERT_EQ("image/png", GetMIME("PictureMIMEExample.png"));
234         
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