add by edsoncy@yahoo.com.cn
sub AddTestSuiteClass()
On Error Resume Next
dim proj_path,ext,pos,proj_dir,MyCppFile,MyCppName,MyHFile,MyHName,ClassName,HText,CPPText
proj_path = ActiveProject.fullname
ext =
pos = len (proj_path)
Do While ext <> \
ext = Mid(proj_path, pos, 1)
pos = pos -1
Loop
proj_dir = left(proj_path, pos+1)
ClassName=InputBox(Enter the Suite name[not include Suite]:, Suite Name)
if ActiveProject.Type <> Build then
MsgBox This project is not valid. Ending macro.
Exit Sub
end if
if (len(ClassName) <= 0) then
MsgBox Invalid suite name. Ending macro.
Exit Sub
end if
WriteFile MyCppName,CPPText
ActiveDocument.Selection = CPPText
ActiveDocument.Save MyCppName
End sub
Sub AddTestClass()
On Error Resume Next
dim proj_path,ext,pos,proj_dir,MyCppFile,MyCppName,MyHFile,MyHName,ClassName,HText,CPPText
proj_path = ActiveProject.fullname
ext =
pos = len (proj_path)
Do While ext <> \
ext = Mid(proj_path, pos, 1)
pos = pos -1
Loop
proj_dir = left(proj_path, pos+1)
ClassName=InputBox(Enter the class name:, Class Name)
if ActiveProject.Type <> Build then
MsgBox This project is not valid. Ending macro.
Exit Sub
end if
if (len(ClassName) <= 0) then
MsgBox Invalid class name. Ending macro.
Exit Sub
end if
WriteFile MyCppName,CPPText
ActiveDocument.Selection = CPPText
ActiveDocument.Save MyCppName
End Sub
Sub ToggleHandCPP()
DEs criptION: Opens the .cpp or .h file for the current document.
Toggles between the .cpp & .h file
ext = ActiveDocument.FullName
If ext = Then
msgbox (Error, not a .cpp or .h file)
exit sub
End If
DocName = UCase(ext)
If Right(DocName,4) = .CPP Then
fn = left(DocName, Len(DocName)-3) & h
ElseIf Right(DocName,2) = .H Then
fn = Left(DocName, Len(DocName)-1) & cpp
Else
msgbox (Error, not a .cpp or a .h file)
exit sub
End If
msgbox (fn)
on error resume next
Documents.Open (fn)
End Sub
Sub AddTestMethod()
strHpt = ActiveDocument.FullName
if right(strHpt,3) = CPP Or right (strHpt,3) = cpp Then
ActiveDocument.Selection.SelectLine
strText = ActiveDocument.Selection.Text
if (Instr(strText, :: ) = 0) Then
MsgBox(Line not valid !!)
Exit Sub
End If
else
exit sub
end if
ActiveDocument.Selection.SelectAll
strHead = ActiveDocument.Selection.Text
if (instr(strHead,strClass) = 0) Then
MsgBox( Cant find class & strClass & !!)
ToggleHandCPP
Exit Sub
End If
while (instr(strLine, CPPUNIT_TEST_SUITE_END(); ) = 0 And ActiveDocument.Selection.CurrentLine <> lineBottom)
ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.LineDown dsMove
ActiveDocument.Selection.SelectLine
strLine = ActiveDocument.Selection.Text
Wend
if (ActiveDocument.Selection.CurrentLine < lineBottom) Then
ActiveDocument.Selection.EndOfLine
ActiveDocument.Selection.LineUp
ActiveDocument.Selection.EndOfLine
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = CPPUNIT_TEST( &strName& );
else
MsgBox(CPPUNIT_TEST_SUITE_END not found)
end if