14 Commits

Author SHA1 Message Date
Michael Krasnitski
a4a1a1ac9e Add tests for parsing lists from conf/cmdline. 2020-04-05 15:29:28 -04:00
Nikos Tsipinakis
d6bd506669 Fix parsing of comments after a quoted string in the config
Quoted values can still have a trailing comment that we need to remove
before calling `add_value`. Otherwise, when trying to strip the quotes
from the value `string_strip_quotes` only looks at the end which
is inside the comment and so it won't find a matching end quote to
strip.

Fixes #626
2019-04-27 10:30:02 +03:00
Benedikt Heine
ec3e47abb5 Skip tests requiring extended precision if not avail
Alpine is running with Musl libc and musl uses extended precision
doubles, while valgrind can't handle extended precision,
2.3 == atof("2.3") won't be true under valgrind.

And therefore the option retrieval methods *_get_double would fail.

Also we have to increase the test verbosity, as `SKIPm` doesn't print
the message when skipping the tests.
See: silentbicycle/greatest#85
2018-11-26 12:07:50 +01:00
Benedikt Heine
a6abfdf7c5 Include all local files relatively 2018-11-15 15:17:48 +01:00
Benedikt Heine
8c192f3c28 Make tests runnable from everywhere 2018-11-15 15:17:46 +01:00
Benedikt Heine
2e9d8300de Include full c source to assert static objects
To assert static objects, we either have to add a method into the
object under test itself and recompile on a test run with the activated test
method (but also recompile after tests, so that method is gone on
release builds).

Alternatively we can include the whole .c file in our test
infrastructure and save the object in the test directory. So there's no
necessity to clean it up prior to a release build and it's contained
away.

This requires, that the test folder isn't excluded in coveralls.
2018-11-15 15:17:21 +01:00
Benedikt Heine
6cc7ca361a Allow half quoted values
Previously config lines like

[rule]
script = mail -s "New notif"

were only possible to get written with additional full quotes,
which makes no sense in command line expressions.
2018-10-08 18:27:11 +02:00
Benedikt Heine
f4fb95c827 Do not make explicit NULL checks on elements
Most of the NULL checks are actually doubly false logic. Turning the
logic around and removing the NULL check makes the program easier to
read.
2018-07-10 13:23:12 +02:00
Benedikt Heine
554c873808 Mark constant strings as const
It's hard to trace back, which methods in option parser require freeing
the result and which prohibit it. Marking all non-freeable values as
const lets this problem solve the compiler.
2017-09-25 02:26:11 +02:00
Benedikt Heine
7eb99ea64d add tests for *_get_path functions 2017-08-15 23:51:14 +02:00
Nikos Tsipinakis
d8d267e1f0 ASSERT_FALSE(expr == NULL) -> ASSERT(expr)
Simplify assert calls to improve code readability.
2017-02-23 20:45:09 +02:00
Nikos Tsipinakis
f34b846041 Fix memory leaks in the unit tests
Making valgrind complain less should help finding actual memory leaks in
the long run.
2017-01-29 15:32:36 +02:00
Nikos Tsipinakis
187d3f9ab9 Invalid boolean values should fall back to the default
Previously, an invalid value was always false
2016-12-15 19:13:08 +02:00
Nikos Tsipinakis
b9619a1460 Add option parser test suite 2016-12-03 19:33:40 +02:00