lbrycrd/src/test
Wladimir J. van der Laan 8cbe1f4f58
tests: change main and wallet tests to BOOST_FIXTURE_TEST_SUITE
Avoid this travis error:

    test_bitcoin: chainparams.cpp:330: const CChainParams& Params():
    Assertion `pCurrentParams' failed.
    unknown location(0): fatal error in "subsidy_limit_test": signal:
    SIGABRT (application abort requested)
    test/allocator_tests.cpp(116): last checkpoint
2015-03-09 15:04:59 +01:00
..
data Add test for DER-encoding edge case 2015-02-10 13:25:41 -05:00
accounting_tests.cpp Reinitialize state in between individual unit tests. 2015-03-03 09:01:46 -08:00
alert_tests.cpp Reinitialize state in between individual unit tests. 2015-03-03 09:01:46 -08:00
allocator_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
arith_uint256_tests.cpp arith_uint256: remove initialization from byte vector 2015-01-05 15:45:36 +01:00
base32_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
base58_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
base64_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
bctest.py Remove references to X11 licence 2014-12-16 15:56:50 +08:00
bignum.h Remove whitespaces before double colon in errors and logs 2015-01-31 17:38:28 -05:00
bip32_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
bitcoin-util-test.py Remove references to X11 licence 2014-12-16 15:56:50 +08:00
bloom_tests.cpp Merge pull request #5513 2015-01-06 20:32:45 +01:00
buildenv.py.in tests: fix python test-runner for windows 2014-09-30 16:26:22 -04:00
checkblock_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
Checkpoints_tests.cpp String conversions uint256 -> uint256S 2015-01-05 15:45:35 +01:00
coins_tests.cpp Get rid of the dummy CCoinsViewCache constructor arg 2014-09-24 03:19:04 +02:00
compress_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
crypto_tests.cpp Use libsecp256k1's RFC6979 implementation 2015-01-06 00:28:44 +01:00
DoS_tests.cpp Reinitialize state in between individual unit tests. 2015-03-03 09:01:46 -08:00
getarg_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
hash_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
key_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
main_tests.cpp tests: change main and wallet tests to BOOST_FIXTURE_TEST_SUITE 2015-03-09 15:04:59 +01:00
Makefile build: add stub makefiles for easier subdir builds 2014-06-05 16:05:43 -04:00
miner_tests.cpp Reinitialize state in between individual unit tests. 2015-03-03 09:01:46 -08:00
mruset_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
multisig_tests.cpp Avoid storing a reference passed to SignatureChecker constructors 2015-02-02 20:19:46 -08:00
netbase_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
pmt_tests.cpp tests: fix spurious windows test failures after 012598880c 2015-01-06 20:18:12 -05:00
pow_tests.cpp Add unit tests for next difficulty calculations 2015-02-21 13:14:19 +00:00
README.md Removed LevelDB changes 2014-05-01 12:10:06 -04:00
rpc_tests.cpp Reinitialize state in between individual unit tests. 2015-03-03 09:01:46 -08:00
rpc_wallet_tests.cpp Reinitialize state in between individual unit tests. 2015-03-03 09:01:46 -08:00
sanity_tests.cpp tests: run sanity checks in tests too 2015-01-05 22:34:47 -05:00
script_P2SH_tests.cpp Avoid storing a reference passed to SignatureChecker constructors 2015-02-02 20:19:46 -08:00
script_tests.cpp Add test for DER-encoding edge case 2015-02-10 13:25:41 -05:00
scriptnum_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
serialize_tests.cpp Add serialize float/double tests 2015-03-06 17:21:59 +01:00
sighash_tests.cpp Remove whitespaces before double colon in errors and logs 2015-01-31 17:38:28 -05:00
sigopcount_tests.cpp Replace direct use of 0 with SetNull and IsNull 2015-01-05 15:45:34 +01:00
skiplist_tests.cpp Use arith_uint256 where necessary 2015-01-05 15:45:35 +01:00
test_bitcoin.cpp Reinitialize state in between individual unit tests. 2015-03-03 09:01:46 -08:00
test_bitcoin.h Reinitialize state in between individual unit tests. 2015-03-03 09:01:46 -08:00
timedata_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
transaction_tests.cpp Merge pull request #5286 2015-02-03 13:12:44 +01:00
uint256_tests.cpp Add tests for new uint256 2015-01-05 15:45:35 +01:00
univalue_tests.cpp Remove references to X11 licence 2014-12-16 15:56:50 +08:00
util_tests.cpp c++11: These look like user-defined literals. 2015-02-03 23:31:00 -05:00
wallet_tests.cpp tests: change main and wallet tests to BOOST_FIXTURE_TEST_SUITE 2015-03-09 15:04:59 +01:00

Notes

The sources in this directory are unit test cases. Boost includes a unit testing framework, and since bitcoin already uses boost, it makes sense to simply use this framework rather than require developers to configure some other framework (we want as few impediments to creating unit tests as possible).

The build system is setup to compile an executable called "test_bitcoin" that runs all of the unit tests. The main source file is called test_bitcoin.cpp, which simply includes other files that contain the actual unit tests (outside of a couple required preprocessor directives). The pattern is to create one test file for each class or source file for which you want to create unit tests. The file naming convention is "<source_filename>_tests.cpp" and such files should wrap their tests in a test suite called "<source_filename>_tests". For an examples of this pattern, examine uint160_tests.cpp and uint256_tests.cpp.

For further reading, I found the following website to be helpful in explaining how the boost unit test framework works: http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/.