~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to lib/cppunit-1.10.0/contrib/msvc/AddingUnitTestMethod.dsm

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'Made by bloodchen 
 
2
'bloodchen@hotmail.com 
 
3
Sub NewTestClass 
 
4
On Error Resume Next 
 
5
dim proj_path,ext,pos,proj_dir,MyCppFile,MyCppName,MyHFile,MyHName,ClassName,HText,CPPText 
 
6
proj_path = ActiveProject.fullname 
 
7
ext = "" 
 
8
pos = len (proj_path) 
 
9
Do While ext <> "\" 
 
10
ext = Mid(proj_path, pos, 1) 
 
11
pos = pos -1 
 
12
Loop 
 
13
proj_dir = left(proj_path, pos+1) 
 
14
ClassName=InputBox("Enter the class name:", "Class Name") 
 
15
if ActiveProject.Type <> "Build" then 
 
16
MsgBox "This project is not valid. Ending macro." 
 
17
Exit Sub 
 
18
end if 
 
19
if (len(ClassName) <= 0) then 
 
20
MsgBox "Invalid class name. Ending macro." 
 
21
Exit Sub 
 
22
end if 
 
23
 
 
24
' ClassName="CTest" 
 
25
MyCppName=proj_dir+ClassName+".cpp" 
 
26
MyHName=proj_dir+ClassName+".h" 
 
27
ActiveProject.AddFile MyCppName 
 
28
ActiveProject.AddFile MyHName 
 
29
Documents.Add "Text" 
 
30
ActiveDocument.Selection.StartOfDocument 
 
31
 
 
32
HText= "#ifndef "+ClassName+"DEF"+VbCrLf& _ 
 
33
"#define "+ClassName+"DEF"+VbCrLf& _ 
 
34
""+VbCrLf& _ 
 
35
"#include <cppunit\testcase.h>"+VbCrLf& _ 
 
36
"#include <cppunit\extensions\HelperMacros.h>"+VbCrLf& _ 
 
37
"class "+ClassName+":public CppUnit::TestCase"+VbCrLf& _ 
 
38
"{"+VbCrLf& _ 
 
39
" CPPUNIT_TEST_SUITE( "+ClassName+" );"+VbCrLf& _ 
 
40
" CPPUNIT_TEST_SUITE_END();"+VbCrLf& _ 
 
41
"public:"+VbCrLf& _ 
 
42
" "+ClassName+"();"+VbCrLf& _ 
 
43
" virtual ~"+ClassName+"();"+VbCrLf& _ 
 
44
"};"+VbCrLf& _ 
 
45
"#endif"+VbCrLf 
 
46
ActiveDocument.Selection = HText 
 
47
ActiveDocument.Save MyHName 
 
48
' WriteFile MyHName,HText 
 
49
Documents.Add "Text" 
 
50
ActiveDocument.Selection.StartOfDocument 
 
51
CPPText = "#include "+chr(34)+"stdafx.h"+chr(34)+VbCrLf& _ 
 
52
"#include "+chr(34)+ClassName+".h"+chr(34)+VbCrLf& _ 
 
53
""+VbCrLf& _ 
 
54
""+VbCrLf& _ 
 
55
"CPPUNIT_TEST_SUITE_REGISTRATION( "+ClassName+ " );"+VbCrLf& _ 
 
56
""+VbCrLf& _ 
 
57
""+VbCrLf& _ 
 
58
ClassName+"::"+ClassName+"()"+VbCrLf& _ 
 
59
"{"+VbCrLf& _ 
 
60
"}"+VbCrLf& _ 
 
61
""+VbCrLf& _ 
 
62
""+VbCrLf& _ 
 
63
ClassName+"::~"+ClassName+"()"+VbCrLf& _ 
 
64
"{"+VbCrLf& _ 
 
65
"}" 
 
66
' WriteFile MyCppName,CPPText 
 
67
ActiveDocument.Selection = CPPText 
 
68
ActiveDocument.Save MyCppName 
 
69
 
 
70
End Sub 
 
71
 
 
72
 
 
73
Sub ToggleHandCPP() 
 
74
'DESCRIPTION: Opens the .cpp or .h file for the current document. 
 
75
'Toggles between the .cpp & .h file 
 
76
ext = ActiveDocument.FullName 
 
77
If ext = "" Then 
 
78
msgbox ("Error, not a .cpp or .h file") 
 
79
exit sub 
 
80
End If 
 
81
DocName = UCase(ext) 
 
82
 
 
83
If Right(DocName,4) = ".CPP" Then 
 
84
fn = left(DocName, Len(DocName)-3) & "h" 
 
85
ElseIf Right(DocName,2) = ".H" Then 
 
86
fn = Left(DocName, Len(DocName)-1) & "cpp" 
 
87
Else 
 
88
msgbox ("Error, not a .cpp or a .h file") 
 
89
exit sub 
 
90
End If 
 
91
'msgbox (fn) 
 
92
on error resume next 
 
93
Documents.Open (fn) 
 
94
End Sub 
 
95
 
 
96
Sub ADDTestMethod() 
 
97
strHpt = ActiveDocument.FullName 
 
98
if right(strHpt,3) = "CPP" Or right (strHpt,3) = "cpp" Then 
 
99
ActiveDocument.Selection.SelectLine 
 
100
strText = ActiveDocument.Selection.Text 
 
101
if (Instr(strText, "::" ) = 0) Then 
 
102
MsgBox("Line not valid !!") 
 
103
Exit Sub 
 
104
End If 
 
105
else exit sub 
 
106
end if 
 
107
 
 
108
pos = Instr(strText, "::") 
 
109
strName = Right(strText, (Len(strText) - (pos+1))) 
 
110
pos = Instr(strName,"(") 
 
111
strName = Left(strName,pos-1) 
 
112
strClass = Left(strText,pos - 1) 
 
113
while (instr(strClass, " ") > 0) 
 
114
pos = instr(strClass, " ") 
 
115
strTyp = strTyp & Left(strClass, pos) 
 
116
strClass = Right(strClass, Len(strClass) - (pos) ) 
 
117
wend 
 
118
ToggleHandCPP 
 
119
 
 
120
ActiveDocument.Selection.SelectAll 
 
121
strHead = ActiveDocument.Selection.Text 
 
122
 
 
123
if (instr(strHead,strClass) = 0) Then 
 
124
MsgBox(" Can't find class " & strClass & " !!") 
 
125
ToggleHandCPP 
 
126
Exit Sub 
 
127
End If 
 
128
ActiveDocument.Selection.EndOfDocument 
 
129
lineBottom = ActiveDocument.Selection.CurrentLine 
 
130
 
 
131
ActiveDocument.Selection.StartOfDocument 
 
132
ActiveDocument.Selection.StartOfLine 
 
133
ActiveDocument.Selection.SelectLine 
 
134
strLine = ActiveDocument.Selection.Text 
 
135
while (instr(strLine, strName) = 0 And ActiveDocument.Selection.CurrentLine <> lineBottom) 
 
136
ActiveDocument.Selection.StartOfLine 
 
137
ActiveDocument.Selection.LineDown dsMove 
 
138
ActiveDocument.Selection.SelectLine 
 
139
strLine = ActiveDocument.Selection.Text 
 
140
Wend 
 
141
if (ActiveDocument.Selection.CurrentLine < lineBottom) Then 
 
142
if( instr(strLine, "CPPUNIT_TEST" ) <> 0 )Then 
 
143
ToggleHandCPP 
 
144
Exit Sub 
 
145
end if 
 
146
End If 
 
147
 
 
148
ActiveDocument.Selection.StartOfDocument 
 
149
ActiveDocument.Selection.StartOfLine 
 
150
ActiveDocument.Selection.SelectLine 
 
151
strLine = ActiveDocument.Selection.Text 
 
152
while (instr(strLine, " CPPUNIT_TEST_SUITE_END();" ) = 0 And ActiveDocument.Selection.CurrentLine <> lineBottom) 
 
153
ActiveDocument.Selection.StartOfLine 
 
154
ActiveDocument.Selection.LineDown dsMove 
 
155
ActiveDocument.Selection.SelectLine 
 
156
strLine = ActiveDocument.Selection.Text 
 
157
Wend 
 
158
if (ActiveDocument.Selection.CurrentLine < lineBottom) Then 
 
159
ActiveDocument.Selection.EndOfLine 
 
160
ActiveDocument.Selection.LineUp 
 
161
ActiveDocument.Selection.EndOfLine 
 
162
ActiveDocument.Selection.NewLine 
 
163
ActiveDocument.Selection = "CPPUNIT_TEST( "&strName&" );" 
 
164
else 
 
165
MsgBox("CPPUNIT_TEST_SUITE_END not found") 
 
166
end if 
 
167
ToggleHandCPP 
 
168
 
 
169
End Sub 
 
170
 
 
 
b'\\ No newline at end of file'