| | | |

???(h)
?CSND.NET ?samlet [2003/11/11]


j???L????????ô???ãh¡?ö?

?h??CC++?(WindowsLinux)²?JavaJ2EE?

1. ?
????J ??; ?????

2. ÷?
CC++??

3.
3.1 C++?
3.1.1?'Visual C++Windows?ó
3.1.1.1j?'CppUnit1.6.2??·?x:\\cppunit-1.6.2

?lò?'û??l·x:\\cppunit-1.6.2\include?l·x:\\cppunit-1.6.2\lib

DEBUG??

??l??gtestrunnercd.lib?????cppunitcd.lib??

Add-ins?x:\\cppunit-1.6.2\lib\TestRunnerDSPlugInD.dll

Project Settings/C++/C++ LanguageRTTI

3.1.1.2

1j?Test??l?CMabStringl?MabString.cpp??l?TestMabString.cpp

2??l???j??lTestMabString?

?ltestmabstring.h

#ifndef CPP_UNIT_TestNode_H

#define CPP_UNIT_TestNode_H

//???l

#include <cppunit/TestCase.h>

#include <cppunit/extensions/HelperMacros.h>

//???l

#include "mabstring.h"

//???

class TestMabString : public CppUnit::TestCase

{

//?????

CPPUNIT_TEST_SUITE( TestMabString );

CPPUNIT_TEST( FindByName );

CPPUNIT_TEST_SUITE_END();

protected:

//

CMabString m_MabStr;

public:

//'??

void setUp ();

//

void tearDown();

protected:

//

void FindByName (void);

};

#endif

ltestmabstring.cpp

#include "TestMabString.h"

#include "iostream.h"

#include "strstrea.h"

//????

CPPUNIT_TEST_SUITE_REGISTRATION( TestMabString );

//

void TestMabString::FindByName ()

{

//????

//normal test

//???

//extra test,

//???

//exception test,

bool bRet=false;

try{

//put the exception code here...

}

//catch(CXXX& e)

catch(...)

{

bRet=true;

}

CPPUNIT_ASSERT(bRet);

//????????·CMabString?CString

//gCMabString?Find???CString?Find//???

//????ò?·

//other test, see the ...

}

void TestMabString::setUp ()

{

//'j?'

m_pNode=new Node();

}

void TestMabString::tearDown()

{

//?

if(m_pNode)

delete m_pNode;

}

3?´???????

#ifdef _DEBUG

//?l

#include <msvc6/testrunner/TestRunner.h>

#include <cppunit/extensions/TestFactoryRegistry.h>

static AFX_EXTENSION_MODULE extTestRunner;

#endif

//???????

#ifdef _DEBUG

TestRunner runner;

runner.addTest ( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );

runner.run ();

#endif

4?

??¹

Project?Release???_DEBUG

???ltestj?l

3.1.2?'Visual C++Windows??ó
3.1.2.1j?'CppUnit1.6.2??·?x:\\cppunit-1.6.2

?lò?'û??l·x:\\cppunit-1.6.2\include?l·x:\\cppunit-1.6.2\lib

DEBUG??

??l??gcppunitcd.lib??

Project Settings/C++/C++ LanguageRTTI

3.1.2.2

1j?Test??l?CMabStringl?MabString.cpp??l?TestMabString.cpp

2??l???j??lTestMabString?

?ltestmabstring.h

3???

3.2 C?
3.2.1?'gccLinux??ó
j?'check0.8.0??·?/xx/check-0.8.0

ò?'û?ñ???'AutoconfAutomakelconfigureMakefile?'?????configureu Makefilel??L???l????l

l ?configure.inllAutoconfconfigure??uconfigure.in??£

dnl lconfigureu

dnl AC_INITxxxx.h?¼h?l

AC_INIT(xxxx.h)

dnl AM_INIT_AUTOMAKE??óI??,

dnl ??AutoconfAutomake???

AM_INIT_AUTOMAKE(xxxx, x.x)

dnl ?l

dnl Checks for programs.

AC_PROG_AWK

AC_PROG_CC

AC_PROG_INSTALL

AC_PROG_LN_S

dnl Checks for libraries.

AC_CHECK_LIB(check,suite_create)

dnl Checks for header files.

AM_CONFIG_HEADER(config.h)

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.

dnl Automake?Makefile.inl?Makefilel

AC_OUTPUT(Makefile)

(?autoscanconfigure.inlL???configure.scanlL???configure.in)

l ?Makefile.amlAutomakeMakefile.inlMakefile.amlJ¿£(xxxx??ólprogram.cl??l??check_program.c)

TESTS = check_xxxx

noinst_PROGRAMS=check_xxxx

frame_path=xx/check-0.8.0

xxxx_docs =\

srcfilelist_1\

srcfilelist_2\

.......\

.....

xxxx_SOURCES=\

srcfilelist_1\

srcfilelist_2\

.......

EXTRA_DIST = $(xxxx_docs)

INCLUDES = -I$(frame_path)/src -I$(other_path)/include

LDADD= \$(frame_path)/src/libcheck.a

CLEANFILES=*.*~

Makefile.am????jõ?noinst_PROGRAMS????lxxxx_SOURCES?ó?_SOURCES??l?EXTRA_DIST???l?(ô??l?)INCLUDES???l·check?l????¼µsrc?LDADD????llibcheck.a?check???l

l 'Automake Ca C-foreignMakefile.inl--foreign???linstall.sh??l?

l 'Autoconfconfigure??u??./configureMakefilel

l ?make???

3.2.2

1?lj?check_??lmoney.cl???l?check_money.c

2??l???j??lcheck_money?

?lmoney.h?lmoney.c??lcheck_money.c

#include <stdlib.h>

#include <check.h>

#include "money.h"

/*???Money?money.h?L?struct money*/

Money *five_dollars;

/*??'*/

void setup (void)

{

five_dollars = money_create(5, "USD");

}

/*??*/

void teardown (void)

{

money_free (five_dollars);

}

/*??test_create*/

/*test functions: money_amout()*/

START_TEST(test_create)

{

/*????*/

/*normal test*/

fail_unless (money_amount(five_dollars) = = 5,

"Amount not set correctly on creation");

fail_unless (strcmp(money_currency(five_dollars),"USD") = = 0,

"Currency not set correctly on creation");

/*·???*/

/*extra test*/

}

END_TEST

/*??test_net_create*/

START_TEST(test_neg_create)

{

Money *m = money_create(-1, "USD");

fail_unless (m = = NULL, "NULL should be returned on attempt to create with a negative amount");

}

END_TEST

/*??test_net_create*/

START_TEST(test_zero_create)

{

Money *m = money_create(0, "USD");

fail_unless (money_amount(m) = = 0,

"Zero is a valid amount of money");

}

END_TEST

/*?????h????Money*/

Suite *money_suite (void)

{

Suite *s = suite_create("Money");

/**/

TCase *tc_core = tcase_create("Core");

TCase *tc_limits = tcase_create("Limits");

/*??

suite_add_tcase (s, tc_core);

suite_add_tcase (s, tc_limits);

/*????*/

tcase_add_test (tc_core, test_create);

tcase_add_checked_fixture (tc_core, setup, teardown); /*?'?*/

/*?'?*/

tcase_add_test (tc_limits, test_neg_create);

tcase_add_test (tc_limits, test_zero_create);

return s;

}

/*??*/

int main (void)

{

int nf;

Suite *s = money_suite();

SRunner *sr = srunner_create(s);

srunner_run_all (sr, CK_NORMAL);

nf = srunner_ntests_failed(sr);

srunner_free(sr);

suite_free(s);

return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;

}

3.2.3 ??

??hMakefile.am?l??l????ómainl??Makefile.am???ã??????


  <>

? | ? | | ? | ? | | | ? | ? | ??

Copyright® 2003 Test Engineer, Inc. All rights reserved.

 

| | | ??Rill | ??Rill | ??Rill | ??Rill | ??Rill - Rill?????????!Ri | ??Rill - Rill?????????!Ri | ??Rill - Rill?????????!Ri | ??Rill - Rill?????????!Ri | ??Rill - Rill?????????!Ri | ??Rill - Rill?????????!Ri | ??Rill - ???? | Rill ??? | ???Rill????? | ??Rill | ??Rill | ? | ? | ? | ? | ? | ArrayArrayArrayArrayKomatsu Parts - Voip Pbx - ForumArrayArrayArrayArray