Celexa For Sale

CPPUnit Lite是一个非常简单的C++ UnitTest库,比较适合做一些小型的UT。基本概念来说,也是”期待与实际相比较“的经典JUnit模式,不过如何在C++上实现还是比较有意思的。


1) Sample

Celexa For Sale, [code lang="cpp"]
int main(int argc, char **argv)
{
if(argc == 0)
printf("%s", argv[0]);
TestResult tr;
TestRegistry::runAllTests(tr);
return 0;
}

TEST(AddTest, Caculator)
{
int iResult = 1+1;
CHECK(iResult==2);
}
[/code]

TestRegistry::runAllTests是一个静态函数,它会执行注册的所有测试用例。问题是,下面的测试用例(AddTest)是怎么加进TestRegistry的呢?


2) How it works?


[code lang="cpp"]
class Test
{
public:
Test (const SimpleString& testName);

virtual void run (TestResult& result) = 0;

void setNext(Test *test);
Test *getNext () const;

protected:

bool check (long expected, long actual, TestResult& result);
bool check (const SimpleString& expected, const SimpleString& actual, TestResult& result);

SimpleString name_;
Test *next_;

};

Test::Test (const SimpleString& testName)
: name_ (testName)
{
TestRegistry::addTest (this);
}

#define TEST(testName, testGroup)\
class testGroup##testName##Test : public Test \
{ public: testGroup##testName##Test () : Test (#testName "Test") {} \
void run (TestResult& result_); } \
testGroup##testName##Instance; \
void testGroup##testName##Test::run (TestResult& result_)

[/code]

嗯,关键就在TEST宏。可以看到,它干了三件事儿:



  1. 定义了一个Test的派生类;

  2. 定义了这个类的一个实例(这将会触发构造函数,从而将这个测试用例加入到TestRegistry中);

  3. 将TEST后面的{}展开成这个类的run函数,这个函数将在后面执行测试的时候用到。


还要注意的是,TEST宏的第一个参数是TestName,第二个是TestGroup,它用这种方式来进行测试用例的组织。


最后来看看TestRegistry:


[code lang="cpp"]
void TestRegistry::addTest (Test *test)
{
instance ().add (test);
}

void TestRegistry::runAllTests (TestResult& result)
{
instance ().run (result);
}

TestRegistry& TestRegistry::instance ()
{
static TestRegistry registry;
return registry;
}

void TestRegistry::run (TestResult& result)
{
result.testsStarted ();

for (Test *test = tests; test != 0; test = test->getNext ())
test->run (result);
result.testsEnded ();
}
[/code]

Instance函数调用的时候会生成一个静态的TestRegistry变量,很简单,对吧。其它的TestResult什么的就更简单了,做一些测试结果的汇总,CHECK等宏也都是展开成相应的函数。


[code lang="cpp"]
#define CHECK(condition)\
{ if (!(condition)) \
{ result_.addFailure (Failure (name_, __FILE__,__LINE__, #condition)); return; } }
[/code]

3) Where to get?


Here


是不是很简单?我现在用它来做一些小工具的UT,很方便。当然,经典的UTer都有绿条、红条情节,据说CPPUnit是支持的。可以去SourceForge看看。

. Celexa samples. Celexa pics. Celexa recreational. Where can i order Celexa without prescription. Rx free Celexa. Buy Celexa online cod. Celexa street price. Order Celexa online overnight delivery no prescription. Celexa cost. Celexa without a prescription. Japan, craiglist, ebay, overseas, paypal. Get Celexa. Celexa class. Discount Celexa. Celexa australia, uk, us, usa. Celexa over the counter. Buy Celexa from canada. Online buying Celexa hcl. Canada, mexico, india. Buy Celexa without a prescription. Celexa forum. Celexa dosage. Celexa from mexico. Buying Celexa online over the counter. Is Celexa safe. Where can i find Celexa online. Celexa from canada. Generic Celexa. Buy cheap Celexa. Celexa gel, ointment, cream, pill, spray, continuous-release, extended-release. Buy generic Celexa. My Celexa experience. Celexa treatment. Buy Celexa without prescription. Fast shipping Celexa.

Similar posts: Buy Allopurinol Without Prescription. Hydrochlorothiazide For Sale. Aldactone For Sale. Levaquin For Sale. Buy Soma Without Prescription. Discount Toradol. Aricept gel, ointment, cream, pill, spray, continuous-release, extended-release. Order Lipitor online c.o.d. Fast shipping Flagyl. Nasonex online cod.
Trackbacks from: Celexa For Sale. Celexa For Sale. Celexa For Sale. Celexa For Sale. Celexa For Sale. Buy Celexa no prescription. Online buying Celexa hcl. Macrobid coupon. Lumigan long term. Generic Lexapro.

Related entries:

3 Responses to “Celexa For Sale”

  1. Hercule Li Says:

    Actually, I don’t support developer to do the test themselves, especially for UT. Of course, he needs to let the application up to let QA to do the test smoothly. Nomally, QA has more testcases than you to check your code, it is systemic.

    Someone tells me that there is a TDD — test drive development. So when developers do some simple test, they can find out how frail their code is, then solidify them. But what I know is most developers don’t like to do that. :-)

  2. Hercule Says:

    Personally, I don’t suggest the developer to do the test more himself. You know, QA has more testcases, that means he can do the test better than you. Of course, you need to let your application up. :-)

    Someone said TDD(test drive development) is very useful to the developer or to the project, but I suspect they don’t like to do that. :-)

  3. Meng Yan Says:

    Hercule, sorry for the late reply. It’s a bug for my blog system so I cannot see the comments. If i have Unit Test cases…:P

    I am the fan of UT and even TDD, it really help me a lot. From interface design, debugging, to the refactoring…

    UT can save a lot of your time from debugging, and it can give you confidence for refactoring. The most important, it can help you to design the architecture.

Leave a comment

(required)

(required)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.


RSS feed for comments on this post | TrackBack URI