21 Commits

Author SHA1 Message Date
Luke Shumaker
a7b3ff1ea8 Handle "\n" -> newline expansion in the option_parser.
It makes more sense to handle escapes in configuration strings when we
parse them, rather than after-the-fact when we handle notifications that
use the relevant config options.

Do this in the proper backslash handler; rather than a naive string
replace which doesn't allow the backslash to be escaped (`\\n` => 0x5C0x0A
rather than 0x5C0x6E).
it to the proper backslash handler
2017-02-28 16:49:09 -05:00
Luke Shumaker
82fa79c786 option_parser.c: Allow comments on lines with quoted strings.
The current behavior is
 - If the value contains a double-quote:
   - 1. Verify that it must contains at least two quotes.
   - 2. If one of the quotes is the first character, trim it.
   - 3. If one of the quotes is the last character, trim it.
 - Else:
   - 1. Trim a trailing comment from the value.

This has the effect that

    `key = "value" # comment` => `value" #comment`

This is surprising and almost certainly not what the user wants.

However, it allows simple nested quotes like:

    `key = "A string "with quotes""` => `A string "with quotes"`

Fix the brokenness of the first example at the expense of breaking the
second.  A user seeking that value will now have to type:

    key = "A string \"with quotes\""

Do this by treating double-quote as a toggle that simply changes whether
`;` and `#` start comments (not too different than Bash using it to toggle
field separation).

In order to have strings that contain a literal double-quote, add
rudimentary support for backslash-escaping.  For now, only recognize
double-quote and backslash-itself; anything else is undefined; and the
program is free to do whatever it likes with them; for now, silently treat
the backslash as an ordinary character.

Note that this formulation of quoting implies that backslash-escaping works
identically both inside and outside of quotes.
2017-02-26 09:35:06 -05: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
0c49b49254 Replace string_to_argv util function with g_shell_parse_argv
string_to_argv parsing was very simplistic and didn't properly handle
quotations. Since we are already using glib, g_shell_parse_argv serves
the same purpose with much better parsing and error handling.
2017-02-05 13:00:59 +02:00
Nikos Tsipinakis
38856bc705 Fix wrong config path in notification test suite 2017-02-05 13:00:59 +02:00
Nikos Tsipinakis
d445661031 Add simple test for notification_replace_format 2017-02-04 22:10:51 +02:00
Nikos Tsipinakis
0deff4412e Add initial notification test suite
The beginnings of the notification test suite, currently only includes
tests for `notification_is_duplicate`.
2017-01-29 15:32:36 +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
2614b4d06e Move functional tests to a different subdirectory 2017-01-04 11:13:21 +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
Nikos Tsipinakis
9333d68656 Use the suite_ prefix for test suites 2016-12-03 19:19:10 +02:00
Nikos Tsipinakis
256440b25a Implement tests for most of the util functions
Also improved the implementation of the test_string_replace_char test.
2016-11-22 18:47:38 +02:00
Nikos Tsipinakis
d441e950d8 Implement test target and add the first test
make test will now compile the tests to test/test.
The first test, testing string_replace_char from utils.c, was added.
2016-11-19 12:26:00 +02:00
Nikos Tsipinakis
7ba0fe03ae Add 'greatest' testing framework
Never used this framework before but it seems promising.
2016-11-19 12:17:23 +02:00
Josh Brown
d3ae6c5951 Remove trailing spaces from all other files 2014-08-03 15:47:59 +00:00
Sascha Kruse
3127bb9198 test.sh: echp what test is currently run 2013-03-08 04:20:55 +01:00
Sascha Kruse
c2a5b526e2 fix expanding window across the screen
test case included
2013-03-02 17:22:12 +01:00
Sascha Kruse
de4db5e559 test.sh fix typo 2013-02-25 22:12:46 +01:00
Sascha Kruse
71d95394fd replace notify.py with dunstify 2013-02-23 04:51:37 +00:00
Sascha Kruse
23f0230baa basic testing framework 2013-02-23 00:35:02 +00:00