forked from RaptDept/ptparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpowertabobjecttestsuite.cpp
More file actions
107 lines (88 loc) · 3.1 KB
/
powertabobjecttestsuite.cpp
File metadata and controls
107 lines (88 loc) · 3.1 KB
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
/////////////////////////////////////////////////////////////////////////////
// Name: powertabobjecttestsuite.cpp
// Purpose: Performs unit testing on the PowerTabObject class
// Author: Brad Larsen
// Modified by:
// Created: Dec 24, 2004
// RCS-ID:
// Copyright: (c) Brad Larsen
// License: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include "stdwx.h"
#include "powertabobjecttestsuite.h"
#include "powertabobject.h" // Test class
#include "powertabfileheader.h" // Needed for file version constants
#include "floatingtext.h" // Test class used during serialization
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNAMIC_CLASS(PowerTabObjectTestSuite, TestSuite)
/// Default Constructor
PowerTabObjectTestSuite::PowerTabObjectTestSuite()
{
//------Last Checked------//
// - Dec 24, 2004
}
/// Destructor
PowerTabObjectTestSuite::~PowerTabObjectTestSuite()
{
//------Last Checked------//
// - Dec 24, 2004
}
/// Gets the total number of tests in the test suite
/// @return The total number of tests in the test suite
size_t PowerTabObjectTestSuite::GetTestCount() const
{
//------Last Checked------//
// - Dec 27, 2004
return (2);
}
/// Executes all test cases in the test suite
/// @return True if all tests were executed, false if not
bool PowerTabObjectTestSuite::RunTestCases()
{
//------Last Checked------//
// - Dec 27, 2004
if (!TestCaseCreateObject())
return (false);
if (!TestCaseMFCClassInformation())
return (false);
return (true);
}
/// Tests the CreateObject Function
/// @return True if all tests were executed, false it not
bool PowerTabObjectTestSuite::TestCaseCreateObject()
{
//------Last Checked------//
// - Dec 27, 2004
TEST(wxT("CreateObject - invalid class id"),
(PowerTabObject::CreateObject(wxT("Dummy")) == NULL));
return (true);
}
/// Tests the MFC Class Information Functions
/// @return True if all tests were executed, false if not
bool PowerTabObjectTestSuite::TestCaseMFCClassInformation()
{
//------Last Checked------//
// - Dec 24, 2004
bool ok = false;
TestStream testStream;
PowerTabOutputStream streamOut(testStream.GetOutputStream());
// Write test data to stream
FloatingText floatingText;
floatingText.WriteMFCClassInformation(streamOut);
// Output must be OK before using input
if (testStream.CheckOutputState())
{
PowerTabInputStream streamIn(testStream.GetInputStream());
// Read test data back from stream
wxString classId = wxT("");
ok = ((floatingText.ReadMFCClassInformation(streamIn,
PowerTabFileHeader::FILEVERSION_CURRENT, classId)) &&
(classId == wxT("CFloatingText-1")) &&
(streamIn.CheckState())
);
}
TEST(wxT("WriteMFCClassInformation"), ok);
return (true);
}