CxxTest User Guide
==================
:doctype: article
:cpp: {basebackend@docbook:c++:cpp}
:makefile: {basebackend@docbook:make:makefile}
:numbered!:
[abstract]
Abstract
--------
CxxTest is a unit testing framework for C\++ that is similar in
spirit to http://junit.org/[JUnit],
http://cppunit.sourceforge.net[CppUnit], and
http://xprogramming.com/software.html[xUnit]. CxxTest is easy to
use because it does not require precompiling a CxxTest testing
library, it employs no advanced features of C++ (e.g. RTTI) and it
supports a very flexible form of test discovery. This documentation
describes CxxTest 4.4, which is an incremental release that includes
a variety of bug fixes and minor enhancements.
:numbered:
Overview
--------
CxxTest is a unit testing framework for C++ that is similar in
spirit to http://junit.org/[JUnit],
http://cppunit.sourceforge.net[CppUnit], and
http://xprogramming.com/software.html[xUnit].
CxxTest is designed to be as portable as possible; it does not require
- RTTI
- Member template functions
- Exception handling
- External libraries (including memory management, file/console I/O, graphics libraries)
In particular, the design of CxxTest was tailored for C\++ compilers
on embedded systems, for which many of these features are not
supported. However, CxxTest can also leverage standard C++ features
when they are supported by a compiler (e.g. catch unhandled
exceptions).
Additionally, CxxTest supports _test discovery_. Tests are defined
in C\++ header files, which are parsed by CxxTest to automatically
generate a test runner. Thus, CxxTest is somewhat easier to use
than alternative C++ testing frameworks, since you do not need to
_register_ tests.
The http://cxxtest.com[CxxTest Home Page] is
http://cxxtest.com[http://cxxtest.com]. This webpage contains links
for https://sourceforge.net/projects/cxxtest/files/[release downloads],
the https://groups.google.com/forum/?hl=en#!forum/cxxtest-forum[CxxTest
discussion list], and documentation in
http://cxxtest.com/guide.html[HTML],
http://cxxtest.com/guide.pdf[PDF], and
http://cxxtest.com/guide.epub[EPUB] formats. The
http://cxxtest.com[CxxTest Home Page] also includes developer
resources (e.g. https://software.sandia.gov/hudson/view/CxxTest/[automated
test results]). CxxTest is available under the
http://www.gnu.org/licenses/lgpl.html[GNU Lesser General Public]
license.
The CxxTest User Guide provides the following documentation:
- <<gettingStarted,Getting Started>>: Some simple examples that illustrate how to use CxxTest
- <<testAssertions,Test Assertions>>: The test assertions supported by CxxTest
- <<cxxtestgen,The CxxTestGen Command>>: Documentation for the +cxxtestgen+ command
- <<runner,Test Runner Syntax>>: Discussion of command line options for test runners
- <<advanced,Advanced Testing Features>>: Advanced features of CxxTest
- <<traits,Value Traits>>: Customizing data traits for error messages
- <<mock,Testing with Mock Objects>>: How to test with mock global functions
- <<installation,Installation>>: How to install CxxTest
- <<discussion,Status and Future Plans>>: Comments on the past, present and future of CxxTest
[[gettingStarted]]
Getting Started
---------------
Testing is performed with CxxTest in a four-step process:
1. Tests are defined in C++ header files
2. The +cxxtestgen+ command processes header files to generate files for the test runner.
3. Compile the test runner.
4. Execute the test runner to run all test suites.
CxxTest supports test automation, sharing of setup
and shutdown code for tests, aggregation of tests into collections,
and independence of the tests from the reporting framework. To
achieve this, CxxTest supports some important concepts that are common to xUnit frameworks (
e.g. http://junit.org/[JUnit], http://cppunit.sourceforge.net[CppUnit], and
http://xprogramming.com/software.html[xUnit]):
test fixture::
A 'test fixture' represents the preparation needed to perform one or more
tests, and any associate cleanup actions. This may involve, for example,
creating temporary or proxy databases, directories, or starting a server
process.
/////
test case::
A 'test case' is the smallest unit of testing. It checks for a specific
response to a particular set of inputs. CxxTest provides a base class,
+TestCase+, which may be used to create new test cases.
/////
test suite::
A 'test suite' is a collection of test cases, which represent
the smallest unit of testing. A test suite is defined by a class
that inherits from the +CxxTest::TestSuite+ class, and the tests
in a test suite are executed together.
test::
A test is a public member function of a test suite whose name
starts with +test+, e.g. +testDirectoryScanner()+,
+test_cool_feature()+ and +TestImportantBugFix()+.
test runner::
A 'test runner' is a component which orchestrates the execution
of tests across one or more test suites and provides the outcome
to the user.
When building test fixtures using +TestSuite+, the +TestSuite.setUp+
and +TestSuite.tearDown+ methods can be overridden to provide
initialization and cleanup for the fixture. The +TestSuite.setUp+
method is run before each test is executed, and the +TestSuite.tearDown+
method is run after each test is executed.
A First Example
~~~~~~~~~~~~~~~
The following is a simple example of a
test suite with a single test, +testAddition+, which perform two test assertions:
[source,{cpp}]
----
include::examples/MyTestSuite1.h[]
----
You use the +cxxtestgen+ script to generate a _test runner_ for test suites in C++ header files:
[source,bash]
----
include::examples/.buildRunner_main.sh[]
----
This command generates the file +runner.cpp+, which can be compiled.
[source,bash]
----
include::examples/.buildRunner_compile.sh[]
----
Note that additional compiler flags may be needed to include headers
and libraries that are used during testing.
This runner can be executed to perform the specified tests:
[source,bash]
----
include::examples/.buildRunner_run.sh[]
----
which generates the following output:
----
include::examples/buildRunner.log[]
----
A Second Example
~~~~~~~~~~~~~~~~
The following header file extends the previous example to
include a test that generates an error:
[source,{cpp}]
----
include::examples/.MyTestSuite2_.h[]
----
The test runner generated by +cxxtestgen+ for this test suite generates the following output:
----
include::examples/buildRunner2.log[]
----
Sample Problems
~~~~~~~~~~~~~~~
CxxTest comes with example test suites in the `cxxtest/sample` subdirectory of
the distribution. If you look in that directory, you will see three
Makefiles: `Makefile.unix`, `Makefile.msvc` and
`Makefile.bcc32` which are for Linux/Unix, MS Visual C\++ and Borland C++, repectively. These files are provided as a starting point,
and some options may need to be tweaked in them for your system.
////
WEH - I think we should omit these command line unless they are tested...
If you are running under Windows, a good guess would be to run
`nmake -fMakefile.msvc run_win32` (you may need to run
`VCVARS32.BAT` first).
Under Linux, `make -fMakefile.unix run_x11` should probably work.
////
[[testAssertions]]
Test Assertions
---------------
The following table summarizes the test assertions supported by CxxTest.
<<appendix_A,Appendix A>> provides examples that illustrate the use of these test assertions.
[options="header"]
|====================================================================================
| Macro | Description
| <<ts_assert,+TS_ASSERT(expr)+>> | Verify +expr+ is true
| xref:ts_assert_delta[+TS_ASSERT_DELTA(x,y,d)+] | Verify that +abs(x-y) < d+
| xref:ts_assert_differs[+TS_ASSERT_DIFFERS(x,y)+] | Verify that +x != y+
| xref:ts_assert_equals[+TS_ASSERT_EQUALS(x,y)+]
没有合适的资源?快使用搜索试试~ 我知道了~
C++ 3D版即时策略游戏源码

共24241个文件
xml:5606个
xmb:5570个
dds:4644个

需积分: 50 52 下载量 130 浏览量
2018-02-05
17:10:30
上传
评论 10
收藏 691.4MB RAR 举报
温馨提示
游戏截图: http://blog.csdn.net/niehanmin/article/details/79260462 C++ 3D版即时策略游戏源码(类似帝国时代) 3D版即时策略游戏源码(类似帝国时代),一款类似帝国时代的3D视觉即时策略游戏,游戏中玩家可以设国家文明争夺世界,古典风格画面,支持Windows, Mac OS X和Linux等,非常的强大
资源推荐
资源详情
资源评论

















收起资源包目录





































































































共 24241 条
- 1
- 2
- 3
- 4
- 5
- 6
- 243
资源评论



niehanmin
- 粉丝: 753
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- (源码)基于嵌入式系统的OSC控制器项目.zip
- (源码)基于Raspberry Pi Pico的USB声卡.zip
- (源码)基于C语言的AVR微控制器游戏手柄固件.zip
- (源码)基于Python的工业蒸汽量预测系统.zip
- (源码)基于vue框架的外卖订餐管理系统.zip
- (源码)基于Arduino的可编程宏垫系统.zip
- (源码)基于ESP32单片机的NETRMSI客户端项目.zip
- (源码)基于AVR微控制器的PS2鼠标到C64128 1351比例鼠标适配器.zip
- (源码)基于QMK固件的Maltron S Edition键盘定制项目.zip
- (源码)基于WickedDevice WildFire核心板的Arduino优化引导加载器项目.zip
- LISP编程语言的操作与应用解析
- 基于卷积神经网络与 CIFAR10 数据集的图像智能分类 Web 应用程序
- 基于卷积神经网络与 CIFAR10 数据集的图像智能分类 Web 应用程序
- 钣金冷热成形技术与应用
- 基于 PyTorch 的 BiLSTM+CRF 与 pysuite 经典 CRF 特征模板的信息抽取
- BiLSTM+CRF by Pytorch and classic CRF by pysuite 基于双向循环神经网络和CRF特征模板的信息抽取
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
