forked from RaptDept/ptparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpowertabdocumenttestsuite.cpp
207 lines (185 loc) · 6.58 KB
/
powertabdocumenttestsuite.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/////////////////////////////////////////////////////////////////////////////
// Name: powertabdocumenttestsuite.cpp
// Purpose: Performs unit testing on the PowerTabDocument class
// Author: Brad Larsen
// Modified by:
// Created: Jan 27, 2005
// RCS-ID:
// Copyright: (c) Brad Larsen
// License: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include "stdwx.h"
#include "powertabdocumenttestsuite.h"
#include "powertabdocument.h"
#include "powertabfileheader.h" // Needed for file version constants
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNAMIC_CLASS(PowerTabDocumentTestSuite, TestSuite)
/// Default Constructor
PowerTabDocumentTestSuite::PowerTabDocumentTestSuite()
{
//------Last Checked------//
// - Jan 27, 2005
}
/// Destructor
PowerTabDocumentTestSuite::~PowerTabDocumentTestSuite()
{
//------Last Checked------//
// - Jan 27, 2005
}
/// Gets the total number of tests in the test suite
/// @return The total number of tests in the test suite
size_t PowerTabDocumentTestSuite::GetTestCount() const
{
//------Last Checked------//
// - Jan 27, 2005
return (27);
}
/// Executes all test cases in the test suite
/// @return True if all tests were executed, false if not
bool PowerTabDocumentTestSuite::RunTestCases()
{
//------Last Checked------//
// - Jan 27, 2005
if (!TestCaseConstructor())
return (false);
if (!TestCaseScore())
return (false);
if (!TestCaseChordNameFontSetting())
return (false);
if (!TestCaseSetTablatureNumbersFontSetting())
return (false);
if (!TestCaseFadeIn())
return (false);
if (!TestCaseFadeOut())
return (false);
if (!TestCaseTablatureStaffLineSpacing())
return (false);
return (true);
}
/// Tests the Constructors
/// @return True if all tests were executed, false if not
bool PowerTabDocumentTestSuite::TestCaseConstructor()
{
//------Last Checked------//
// - Jan 27, 2005
// TEST CASE: Default constructor
{
PowerTabDocument powerTabDocument;
TEST(wxT("Default Constructor"),
(powerTabDocument.m_tablatureStaffLineSpacing ==
PowerTabDocument::DEFAULT_TABLATURE_STAFF_LINE_SPACING) &&
(powerTabDocument.m_fadeIn == PowerTabDocument::DEFAULT_FADE_IN) &&
(powerTabDocument.m_fadeOut == PowerTabDocument::DEFAULT_FADE_OUT)
);
}
return (true);
}
/// Tests the Score Functions
/// @return True if all tests were executed, false if not
bool PowerTabDocumentTestSuite::TestCaseScore()
{
//------Last Checked------//
// - Jan 27, 2005
PowerTabDocument document;
TEST(wxT("GetGuitarScore - invalid"),
(document.GetGuitarScore() == NULL)
);
TEST(wxT("GetBassScore - invalid"),
(document.GetBassScore() == NULL)
);
return (true);
}
/// Tests the Chord Name Font Setting Functions
/// @return True if all tests were executed, false if not
bool PowerTabDocumentTestSuite::TestCaseChordNameFontSetting()
{
//------Last Checked------//
// - Jan 27, 2005
PowerTabDocument document;
FontSetting fontSetting(wxT("Arial"), 12, FontSetting::weightBold, true,
true, true, wxColour(25,25,25));
document.SetChordNameFontSetting(fontSetting);
TEST(wxT("SetChordNameFontSetting"),
(document.GetChordNameFontSettingConstRef() == fontSetting)
);
return (true);
}
/// Tests the Tablature Numbers Font Setting Functions
/// @return True if all tests were executed, false if not
bool PowerTabDocumentTestSuite::TestCaseSetTablatureNumbersFontSetting()
{
//------Last Checked------//
// - Jan 27, 2005
PowerTabDocument document;
FontSetting fontSetting(wxT("Arial"), 12, FontSetting::weightBold, true,
true, true, wxColour(25,25,25));
document.SetTablatureNumbersFontSetting(fontSetting);
TEST(wxT("SetTablatureNumbersFontSetting"),
(document.GetTablatureNumbersFontSettingConstRef() == fontSetting)
);
return (true);
}
/// Tests the Tablature Staff Line Spacing Functions
/// @return True if all tests were executed, false if not
bool PowerTabDocumentTestSuite::TestCaseTablatureStaffLineSpacing()
{
//------Last Checked------//
// - Jan 27, 2005
// TEST CASE: IsValidTablatureStaffLineSpacing
{
wxInt32 i = PowerTabDocument::MIN_TABLATURE_STAFF_LINE_SPACING - 1;
for (; i < (PowerTabDocument::MAX_TABLATURE_STAFF_LINE_SPACING + 1); i++)
{
TEST(wxString::Format(wxT("IsValidTablatureStaffLineSpacing - %d"), i),
(PowerTabDocument::IsValidTablatureStaffLineSpacing(i) ==
((i >= PowerTabDocument::MIN_TABLATURE_STAFF_LINE_SPACING) &&
(PowerTabDocument::MAX_TABLATURE_STAFF_LINE_SPACING)))
);
}
}
PowerTabDocument document;
{
wxInt32 i = PowerTabDocument::MIN_TABLATURE_STAFF_LINE_SPACING - 1;
for (; i < (PowerTabDocument::MAX_TABLATURE_STAFF_LINE_SPACING + 1); i++)
{
TEST(wxString::Format(wxT("SetTablatureStaffLineSpacing - %d"), i),
(document.SetTablatureStaffLineSpacing(i) ==
((i >= PowerTabDocument::MIN_TABLATURE_STAFF_LINE_SPACING) &&
(i <= PowerTabDocument::MAX_TABLATURE_STAFF_LINE_SPACING))) &&
((i < PowerTabDocument::MIN_TABLATURE_STAFF_LINE_SPACING) ||
(i > PowerTabDocument::MAX_TABLATURE_STAFF_LINE_SPACING)) ?
1 :
(document.GetTablatureStaffLineSpacing() == i)
);
}
}
return (true);
}
/// Tests the Fade In Functions
/// @return True if all tests were executed, false if not
bool PowerTabDocumentTestSuite::TestCaseFadeIn()
{
//------Last Checked------//
// - Jan 27, 2005
PowerTabDocument document;
document.SetFadeIn(1000);
TEST(wxT("SetFadeIn"),
(document.GetFadeIn() == 1000)
);
return (true);
}
/// Tests the Fade Out Functions
/// @return True if all tests were executed, false if not
bool PowerTabDocumentTestSuite::TestCaseFadeOut()
{
//------Last Checked------//
// - Jan 27, 2005
PowerTabDocument document;
document.SetFadeOut(2000);
TEST(wxT("SetFadeOut"),
(document.GetFadeOut() == 2000)
);
return (true);
}