-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogo_UnitTest.cpp
More file actions
77 lines (66 loc) · 2 KB
/
Logo_UnitTest.cpp
File metadata and controls
77 lines (66 loc) · 2 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
#include "stdafx.h"
#include <CppUnit\TestCase.h>
#include <CppUnit\TestCaller.h>
#include <CppUnit\TestResult.h>
#include <CppUnit\TestSuite.h>
#include <CppUnit\TestRunner.h>
#include "Logo_unitTest.h"
#include "Logo_common.h"
using namespace CppUnit;
namespace LogRec
{
void CLogoTestFrame::setUp()
{//init operation for resource
}
void CLogoTestFrame::tearDown()
{//release operation of resource
}
//
void CLogoTestFrame::testCutBlank()
{
std::string str = " libiao ";
LogRec::LogoCutBlankBE(str);
assert(str == "libiao");
}
void CLogoTestFrame::testIsDigit()
{
assert(LogRec::LogoIsDigit("34223"));
}
void CLogoTestFrame::testIsAllAlpha()
{
assert(LogRec::LogoIsAllAlpha("libiao"));
}
//...
CLogoTestFrame::CLogoTestFrame(std::string name) : CppUnit::TestCase(name)
{
}
Test* CLogoTestFrame::suite()
{// add test task here
TestSuite *suiteOfTest = new TestSuite;
suiteOfTest->addTest(new TestCaller<CLogoTestFrame> ("testCutBlank ",&CLogoTestFrame::testCutBlank));
suiteOfTest->addTest(new TestCaller<CLogoTestFrame> ("testIsDigit ",&CLogoTestFrame::testIsDigit));
suiteOfTest->addTest(new TestCaller<CLogoTestFrame> ("testIsAllAlpha ",&CLogoTestFrame::testIsAllAlpha));
return suiteOfTest;
}
Test* CLogoTestFrame::suite1()
{// add test task here
TestSuite *suiteOfTest = new TestSuite;
suiteOfTest->addTest(new TestCaller<CLogoTestFrame> ("testCutBlank ",&CLogoTestFrame::testCutBlank));
suiteOfTest->addTest(new TestCaller<CLogoTestFrame> ("testIsDigit ",&CLogoTestFrame::testIsDigit));
suiteOfTest->addTest(new TestCaller<CLogoTestFrame> ("testIsAllAlpha ",&CLogoTestFrame::testIsAllAlpha));
return suiteOfTest;
}
bool startUnitTest()
{
TestRunner runner;
runner.addTest("test calss 1",CLogoTestFrame::suite());
runner.addTest("test calss 2",CLogoTestFrame::suite());
//...
std::vector<std::string> args;
args.push_back("UnitTest");
args.push_back("-all");
args.push_back("-wait");
args.push_back("-print");
return runner.run(args);// ? 0 : 1;
}
}