summaryrefslogtreecommitdiff
path: root/test/unit
Commit message (Collapse)AuthorAgeFilesLines
* Fix copy on write for amount_t::in_place_roundtoMax Nikulin2024-08-062-19/+8
| | | | | | | | | | | | - Copy amount quantity before rounding. - Fix `amount_t::roundto(int)`. - Transform `balance/testRound` into `balance/testRoundto`. It was a mix of `round` and `roundto` operation with unclear purpose and was relying on `in_place_roundto` behavior modifying all copies. There is no unit tests for balance `round` and `unround` any more. Closes #2362
* Fix denominator of roundto resultMax Nikulin2024-08-052-0/+22
| | | | | | | | | | | | | | | | | | Multiprecision rational created from a double value may have large power of 2 denominator since fractional decimal numbers can not be represented as binary floating point numbers. It leads to failed assertion when result is compared to a value converted directly from strings. Use integer multiprecision arithmetics to round numbers to ensure proper denominator. Inspired by python gmpy2 package <https://github.com/aleaxit/gmpy/blob/3e4564ae9d/src/gmpy2_mpq_misc.c#L315> The change makes `roundto` symmetric for positive/negative arguments. Halves are rounded to nearest even. Rounded away from zero are discussed in #1663 and it may be achieved with minimal modification. - See #2329 - Closes #1983
* Fix =regex note query syntaxGwyneth Morgan2023-10-121-2/+2
| | | | | | | | | | | | The manpage documents `=regex` as equivalent to the `note regex` query syntax, but the former does not actually work as the parser only handles an equals sign in the case of `tag type=dining` syntax, and doesn't handle the case where an equals sign starts a note query. Fixing this does break queries like `tag type = dining` with spaces around the equals sign, but that syntax was not intended or documented. Closes: #2275
* format_t::truncate support wide charactersKuang-che Wu2021-01-172-1/+123
| | | | also add unit tests
* py3: ensure python output is not lostAndy Clayton2020-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unbuffer python's stdio to avoid output getting stuck in buffer when stdout is not a TTY. Normally buffers are flushed by `Py_Finalize` but Boost has a long-standing issue preventing the proper shutdown of the interpreter with `Py_Finalize` when embedded [1]. This applies the same fix as 139beba but to any ledger usage rather than only the test suite. I removed `PYTHONUNBUFFERED=1` from tests as there is no expectation that users should need to have this set for ledger to function. For example without this fix piping ledger into cat usually loses any output (unless the output is large enough to cause the buffer to flush): $ ./ledger -f "test/baseline/feat-value_py3.test" reg <class 'bool'> True [...] $ ./ledger -f "test/baseline/feat-value_py3.test" reg | cat $ Interestingly `--verify` causes `python_interpreter_t` to be destroyed -- it doesn't appear to be otherwise -- which does call `Py_Finalize`. As expected this fixes the issue but can also crash due to the boost issue mentioned above: $ ./ledger -f "test/baseline/feat-value_py3.test" --verify reg <class 'bool'> True [...] Segmentation fault (core dumped) $ ./ledger -f "test/baseline/feat-value_py3.test" --verify reg | cat <class 'bool'> True [...] $ 1. https://www.boost.org/doc/libs/1_62_0/libs/python/doc/html/tutorial/tutorial/embedding.html
* fix setting TZ in testsAndy Clayton2020-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was regressed in 139beba which set `PYTHONUNBUFFERED` to fix other test issues. When setting multiple environment variables in this way they need to be delimited with semicolons rather than spaces. As it is `PYTHONUNBUFFERED` is being set to `1 TZ=America/Chicago`. The CMake docs are not as clear about this as they probably should be. This can be verified by throwing together a CTestTestfile.cmake: add_test(incorrect_env "printenv" "PYTHONUNBUFFERED" "TZ") set_tests_properties(incorrect_env PROPERTIES ENVIRONMENT "PYTHONUNBUFFERED=1 TZ=America/Chicago") add_test(correct_env "printenv" "PYTHONUNBUFFERED" "TZ") set_tests_properties(correct_env PROPERTIES ENVIRONMENT "PYTHONUNBUFFERED=1;TZ=America/Chicago") When run with `ctest -V`: 1: Test command: /usr/bin/printenv "PYTHONUNBUFFERED" "TZ" 1: Environment variables: 1: PYTHONUNBUFFERED=1 TZ=America/Chicago 1: Test timeout computed to be: 10000000 1: 1 TZ=America/Chicago 1/2 Test #1: incorrect_env ....................***Failed 0.00 sec test 2 Start 2: correct_env 2: Test command: /usr/bin/printenv "PYTHONUNBUFFERED" "TZ" 2: Environment variables: 2: PYTHONUNBUFFERED=1 2: TZ=America/Chicago 2: Test timeout computed to be: 10000000 2: 1 2: America/Chicago 2/2 Test #2: correct_env ...................... Passed 0.00 sec
* test: Unbreak one more test case with python3 bridgeDimitri John Ledkov2019-12-061-1/+1
| | | | | | | | | | | python3 has buffered output by default, hence testcase option_py returned no output when executed under test harness. I think this is a real problem in the way python interpreter is embeded, and i.e. stdout is not flushed until after test case has died. However, running things unbuffered seems to make everything work. But for some reason I had to adjust 1057.test slightly. I have no idea what those numbers mean, and if running things unbuffered break stuff.
* Modernize CMake using backported FindPython module.Dimitri John Ledkov2019-12-051-4/+4
|
* Do not set dependencies for target checkTim Landscheidt2019-01-221-3/+0
| | | | | | The set_target_properties() commands themselves do not cause the tests to run if the target check is made, and as the target check executes ctest, all tests will be run anyway.
* Fix build under Cygwin.Ivan Vanyushkin2016-09-291-1/+1
|
* Fix build under msys32; add Appveyor continuous buildEvan Mallory2016-09-171-0/+4
| | | | | | | | | | | | * Appveyor is a continuous integration platform for Windows that is free for open source projects. See latest test build here: https://ci.appveyor.com/project/Evan/ledger/build/artifacts * Changed WIN32 to _WIN32 because this article http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system claims that it is defined by the greatest number of compilers. * Modified HAVE_ISATTY and other system defines so that system.hh compiles when cmake fails to find the relevant function. * Add missing include in test/unit/t_value.cc Almost all tests fail when you run them on msys32. I will address that in a future PR.
* [tests] Remove compiler warnings for unit testsAlexis Hildebrandt2015-09-151-1/+1
| | | | | | warning: equality comparison result unused [-Wunused-comparison] BOOST_CHECK_THROW(v8 == v10, value_error); ~~~^~~~~~
* [tests] Fix MathTest failures on Mac OS XAlexis Hildebrandt2015-08-081-15/+12
| | | | due to timezone settings.
* [tests] Set timezone for running testsAlexis Hildebrandt2015-08-071-0/+2
| | | | so that the tests run with a consistent environment.
* Merge remote-tracking branch 'origin/master' into nextJohn Wiegley2015-08-042-1/+715
|\
| * fix minor issuestripun2014-08-181-5/+8
| |
| * add additional tests for sequence_t and fix the old onestripun2014-08-181-22/+50
| |
| * add test for sequenc_t in value_ttripun2014-08-181-0/+32
| |
| * add unit test Negation for valuetripun2014-08-181-0/+46
| |
| * minor additionstripun2014-08-181-0/+1
| |
| * add test for zero for valuetripun2014-08-181-0/+57
| |
| * check Type unit test for valuetripun2014-08-181-0/+50
| |
| * add Division unit test for valuetripun2014-08-181-0/+63
| |
| * remove some statements until sequence multiplication run-time error is fixedtripun2014-08-181-11/+0
| |
| * add Multiplication unit test for valuetripun2014-08-181-0/+79
| |
| * add unit test subtraction for valuetripun2014-08-181-0/+93
| |
| * add whitespacestripun2014-08-171-4/+4
| |
| * add unit test Addition for valuetripun2014-08-171-0/+102
| |
| * add unit test of equality for valuetripun2014-08-171-0/+64
| |
| * add assignment unit test for valuetripun2014-08-171-0/+35
| |
| * add constructors unit test for valuetripun2014-08-171-0/+35
| |
| * initialize value fixturetripun2014-08-161-0/+37
| |
| * add t_value unit testtripun2014-08-152-1/+1
| |
* | [tests] Remove compiler warnings for unit testsAlexis Hildebrandt2015-07-281-0/+1
| | | | | | | | | | | | warning: relational comparison result unused [-Wunused-comparison] BOOST_CHECK_THROW(x6 < x7, amount_error); ~~~^~~~
* | [tests] Fix Util and Math tests on Mac OS XAlexis Hildebrandt2015-07-281-0/+6
| | | | | | | | by explicitly linking the testing targets against Python
* | [tests] Fix compiler warningAlexis Hildebrandt2015-01-111-0/+3
|/
* Revert "add unit test printing for balance_t" until issue is fixed.tripun2014-08-111-31/+0
| | | | | | Getting different output on system than travis-ci. This reverts commit 272e3cb3799937dcd3c379de56b299a3cbde52ca.
* add unit test printing for balance_ttripun2014-08-111-0/+31
|
* add unit test of Zero for balance_ttripun2014-08-111-0/+26
|
* add unit test Truth for balance_ttripun2014-08-111-0/+20
|
* add unit test Round for balance_ttripun2014-08-111-0/+50
|
* add unit test Floor for balance_ttripun2014-08-111-0/+43
|
* add unit test Ceiling for balance_ttripun2014-08-111-0/+43
|
* add unit test Absolute for balance_ttripun2014-08-111-0/+25
|
* add unit test negation for balance_ttripun2014-08-111-0/+35
|
* add unit test for balance divisiontripun2014-08-111-0/+45
|
* add test for multiplicationtripun2014-08-111-0/+45
|
* edited subraction testtripun2014-08-111-1/+1
|
* add Equality unit test for balancetripun2014-08-111-2/+65
|
* added boost subtraction unit testtripun2014-08-111-0/+39
|