diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3fe07592..cad944d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,9 +55,9 @@ jobs: run: | grep -P 'auto_(char|gchar|gcharv|gerror|guchar|jid|sqlite|gfd|FILE)[\w *]*;$' -r src && exit -1 || true - name: Run clang-format - uses: jidicula/clang-format-action@v4.11.0 + uses: jidicula/clang-format-action@v4.15.0 with: - clang-format-version: '16' + clang-format-version: '21' check-path: 'src' spell-check: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 55f70a90..2fa5be33 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,42 @@ # Contributing to Profanity ## Build +Profanity can be built using either **Autotools** or **Meson**. -Please follow the [build section](https://profanity-im.github.io/guide/latest/build.html) in our user guide. +### Build Options +Both build systems support several features that can be enabled or disabled. + +**Important Difference:** +- **Autotools**: Features are **auto-enabled** if the required dependencies are found on your system during the `./configure` step. +- **Meson**: Features must be **explicitly enabled**. Nothing is auto-enabled; if you want a feature, you must pass the corresponding `-Doption=enabled` flag. + +| Feature | Description | Autotools flag | Meson option | +| :--- | :--- | :--- | :--- | +| **Notifications** | Desktop notifications support | `--enable-notifications` | `-Dnotifications=enabled` | +| **Python Plugins** | Support for Python plugins | `--enable-python-plugins` | `-Dpython-plugins=enabled` | +| **C Plugins** | Support for C plugins | `--enable-c-plugins` | `-Dc-plugins=enabled` | +| **OTR** | Off-the-Record encryption | `--enable-otr` | `-Dotr=enabled` | +| **PGP** | PGP encryption support | `--enable-pgp` | `-Dpgp=enabled` | +| **OMEMO** | OMEMO encryption support | `--enable-omemo` | `-Domemo=enabled` | +| **QR Code** | OMEMO QR code display | `--enable-omemo-qrcode` | `-Domemo-qrcode=enabled` | +| **Icons/Clipboard** | GTK tray icons & clipboard | `--enable-icons-and-clipboard` | `-Dicons-and-clipboard=enabled` | +| **GDK Pixbuf** | Avatar scaling support | `--enable-gdk-pixbuf` | `-Dgdk-pixbuf=enabled` | +| **XScreenSaver** | Idle time detection | `--with-xscreensaver` | `-Dxscreensaver=enabled` | +| **Tests** | Build unit tests | *Built by default* | `-Dtests=true` | +| **Sanitizers** | Run-time error detection | *Via CFLAGS* | `-Db_sanitize=address,undefined` | + +### Using Autotools +1. Generate configuration files: `./bootstrap.sh` +2. Configure: `./configure --enable-otr --enable-omemo` +3. Build: `make` +4. Run: `./profanity` + +### Using Meson +1. Setup build directory: `meson setup build_run -Domemo=enabled -Dotr=enabled` +2. Build: `meson compile -C build_run` +3. Run: `./build_run/profanity` + +We also have a [build section](https://profanity-im.github.io/guide/latest/build.html) in our user guide. You might also take a look at the `Dockerfile.*` in the root directory. ## Submitting patches @@ -41,8 +75,9 @@ Then our team can easily request reviews. And we have the history of the review If using GitHub is out of the question but you are okay using another service (i.e.: GitLab, codeberg) then please message us in the MUC or send us an email. We will then pull from your repository and merge manually. -### Rules +## Rules & Guidelines +### Contribution Rules * When fixing a bug, describe it and how your patch fixes it. * When fixing a reported issue add an `Fixes https://github.com/profanity-im/profanity/issues/23` in the commit body. * When adding a new feature add a description of the feature and how it should be used (workflow). @@ -54,16 +89,16 @@ We will then pull from your repository and merge manually. * Squash fixup commits into one * If applicable, document how to test the functionality -## Hints and Pitfalls - +### Hints and Pitfalls * When adding a new hotkey/shortcut make sure it's not registered in Profanity already. And also that it's not a default shortcut of readline. * We ship a `.git-blame-ignore-revs` file containing banal commits which you will most likely want to ignore when using `git blame`. In case you are using vim and [fugitive](https://github.com/tpope/vim-fugitive) `command Gblame Git blame --ignore-revs-file=.git-blame-ignore-revs` might be helpful in your vimrc. You can also set the `blame.ignoreRevsFile` option in your git config to have `git blame` generally ignore the listed commits. -## Coding style +## Coding Style + Follow the style already present ;-) To make this easier for you we created a `.clang-format` file. -You'll need to have `clang-format` installed. +You'll need to have `clang-format` installed. We currently use **version 21**, which is also the version enforced by our CI in `.github/workflows/main.yml`. Then just run `make format` before you do any commit. @@ -98,14 +133,45 @@ and the `pre-push` hook will be skipped. *Note:* We provide a config file that describes our coding style for clang. But due to a mistake on their side it might happen that you can get a different result that what we expect. See [here](https://github.com/profanity-im/profanity/pull/1774) and [here](https://github.com/profanity-im/profanity/pull/1828) for details. We will try to always run latest clang-format. -## Finding mistakes -Test your changes with the following tools to find mistakes. +In cases where you want to disable automatic formatting for a specific block of code (e.g. a complex lookup table), you can use the following comments: +```c +/* clang-format off */ +// your code +/* clang-format on */ +``` -### unit tests +## Verification & Testing +### Running unit tests Run `make check` to run the unit tests with your current configuration or `./ci-build.sh` to check with different switches passed to configure. -### valgrind +### Writing unit tests +We use the [cmocka](https://cmocka.org/) testing framework for unit tests. + +Test files are located in `tests/unittests` and should mirror the directory structure of the `src/` directory. For example, if you are testing `src/xmpp/jid.c`, the corresponding test file should be `tests/unittests/xmpp/test_jid.c`. + +#### Naming Convention +Test functions must follow a behavior-driven naming convention using double underscores (`__`) as semantic separators: + +`[unit]__[verb]__[scenario]` + +- **unit**: The name of the function or module being tested. +- **verb**: A descriptive verb of the outcome (`returns`, `is`, `updates`, `shows`, `triggers`, `fails`). +- **scenario**: The specific condition or input being tested. + +Examples: +- `jid_create__returns__null_from_null` +- `p_contact_is_available__is__false_when_offline` +- `cmd_connect__shows__usage_when_no_server_value` +- `str_replace__returns__one_substr` + +#### Adding a new test +When adding a new test file: +1. Create the `.c` and `.h` files in the appropriate subdirectory of `tests/unittests`. +2. Register the test functions in `tests/unittests/unittests.c` within the `all_tests` array. +3. Add the new source file to `unittest_sources` in both `meson.build` and `Makefile.am`. + +### Valgrind We provide a suppressions file `prof.supp`. It is a combination of the suppressions for shipped with glib2, python and custom rules. `G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --track-origins=yes --leak-check=full --leak-resolution=high --num-callers=30 --show-leak-kinds=definite --log-file=profval --suppressions=prof.supp ./profanity` @@ -116,8 +182,7 @@ There's also the option to create a "personalized" suppression file with the up- After executing this, you can replace the `--suppressions=prof.supp` argument in the above call, by `--suppressions=my-prof.supp`. -### clang - +### Clang Static Analyzer Running the clang static code analyzer helps improving the quality too. ``` @@ -127,13 +192,39 @@ scan-view ... ``` ### Finding typos - We include a `.codespellrc` configuration file for `codespell` in the root directory. Before committing it might make sense to run `codespell` to see if you made any typos. You can run the `make spell` command for this. -### Check everything +### Full check +Run the central quality check script before submitting a patch. This runs the spell checker, code formatter, and unit tests. -`make doublecheck` will run the code formatter, spell checker and unit tests. +If using Autotools: +``` +make doublecheck +``` +If using Meson: +``` +meson compile doublecheck +``` +*Note: The script expects the build directory to be named `build_run` as specified in the Meson build instructions above.* + +Alternatively, you can run the script directly: +``` +./scripts/quality-check.sh --fix-formatting --meson # or --autotools +``` + +### Pre-commit hook +It is highly recommended to install the quality check script as a git pre-commit hook. This will automatically check your staged changes for spelling and formatting issues every time you commit. + +To install the hook: +``` +./scripts/quality-check.sh --install +``` + +If you need to bypass the formatting check (e.g. due to a `clang-format` version mismatch), you can set the `SKIP_FORMAT` environment variable: +``` +SKIP_FORMAT=1 git commit +``` diff --git a/Makefile.am b/Makefile.am index f2abd8ed..411efa54 100644 --- a/Makefile.am +++ b/Makefile.am @@ -142,31 +142,31 @@ unittest_sources = \ tests/unittests/tools/stub_aesgcm_download.c \ tests/unittests/tools/stub_plugin_download.c \ tests/unittests/helpers.c tests/unittests/helpers.h \ - tests/unittests/test_form.c tests/unittests/test_form.h \ + tests/unittests/xmpp/test_form.c tests/unittests/xmpp/test_form.h \ tests/unittests/test_common.c tests/unittests/test_common.h \ - tests/unittests/test_autocomplete.c tests/unittests/test_autocomplete.h \ - tests/unittests/test_jid.c tests/unittests/test_jid.h \ - tests/unittests/test_parser.c tests/unittests/test_parser.h \ - tests/unittests/test_roster_list.c tests/unittests/test_roster_list.h \ - tests/unittests/test_chat_session.c tests/unittests/test_chat_session.h \ - tests/unittests/test_contact.c tests/unittests/test_contact.h \ - tests/unittests/test_preferences.c tests/unittests/test_preferences.h \ - tests/unittests/test_server_events.c tests/unittests/test_server_events.h \ - tests/unittests/test_muc.c tests/unittests/test_muc.h \ - tests/unittests/test_cmd_presence.c tests/unittests/test_cmd_presence.h \ - tests/unittests/test_cmd_alias.c tests/unittests/test_cmd_alias.h \ - tests/unittests/test_cmd_connect.c tests/unittests/test_cmd_connect.h \ - tests/unittests/test_cmd_rooms.c tests/unittests/test_cmd_rooms.h \ - tests/unittests/test_cmd_account.c tests/unittests/test_cmd_account.h \ - tests/unittests/test_cmd_sub.c tests/unittests/test_cmd_sub.h \ - tests/unittests/test_cmd_bookmark.c tests/unittests/test_cmd_bookmark.h \ - tests/unittests/test_cmd_otr.c tests/unittests/test_cmd_otr.h \ - tests/unittests/test_cmd_pgp.c tests/unittests/test_cmd_pgp.h \ - tests/unittests/test_cmd_join.c tests/unittests/test_cmd_join.h \ - tests/unittests/test_cmd_roster.c tests/unittests/test_cmd_roster.h \ - tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \ - tests/unittests/test_callbacks.c tests/unittests/test_callbacks.h \ - tests/unittests/test_plugins_disco.c tests/unittests/test_plugins_disco.h \ + tests/unittests/tools/test_autocomplete.c tests/unittests/tools/test_autocomplete.h \ + tests/unittests/xmpp/test_jid.c tests/unittests/xmpp/test_jid.h \ + tests/unittests/tools/test_parser.c tests/unittests/tools/test_parser.h \ + tests/unittests/xmpp/test_roster_list.c tests/unittests/xmpp/test_roster_list.h \ + tests/unittests/xmpp/test_chat_session.c tests/unittests/xmpp/test_chat_session.h \ + tests/unittests/xmpp/test_contact.c tests/unittests/xmpp/test_contact.h \ + tests/unittests/config/test_preferences.c tests/unittests/config/test_preferences.h \ + tests/unittests/event/test_server_events.c tests/unittests/event/test_server_events.h \ + tests/unittests/xmpp/test_muc.c tests/unittests/xmpp/test_muc.h \ + tests/unittests/command/test_cmd_presence.c tests/unittests/command/test_cmd_presence.h \ + tests/unittests/command/test_cmd_alias.c tests/unittests/command/test_cmd_alias.h \ + tests/unittests/command/test_cmd_connect.c tests/unittests/command/test_cmd_connect.h \ + tests/unittests/command/test_cmd_rooms.c tests/unittests/command/test_cmd_rooms.h \ + tests/unittests/command/test_cmd_account.c tests/unittests/command/test_cmd_account.h \ + tests/unittests/command/test_cmd_sub.c tests/unittests/command/test_cmd_sub.h \ + tests/unittests/command/test_cmd_bookmark.c tests/unittests/command/test_cmd_bookmark.h \ + tests/unittests/command/test_cmd_otr.c tests/unittests/command/test_cmd_otr.h \ + tests/unittests/command/test_cmd_pgp.c tests/unittests/command/test_cmd_pgp.h \ + tests/unittests/command/test_cmd_join.c tests/unittests/command/test_cmd_join.h \ + tests/unittests/command/test_cmd_roster.c tests/unittests/command/test_cmd_roster.h \ + tests/unittests/command/test_cmd_disconnect.c tests/unittests/command/test_cmd_disconnect.h \ + tests/unittests/plugins/test_callbacks.c tests/unittests/plugins/test_callbacks.h \ + tests/unittests/plugins/test_plugins_disco.c tests/unittests/plugins/test_plugins_disco.h \ tests/unittests/unittests.c functionaltest_sources = \ @@ -285,7 +285,7 @@ endif TESTS = tests/unittests/unittests check_PROGRAMS = tests/unittests/unittests -tests_unittests_unittests_CPPFLAGS = -I$(srcdir)/tests/ +tests_unittests_unittests_CPPFLAGS = -I$(srcdir)/tests/ -I$(srcdir)/tests/unittests tests_unittests_unittests_SOURCES = $(unittest_sources) tests_unittests_unittests_LDADD = -lcmocka @@ -374,4 +374,5 @@ format-sources: $(core_sources) $(main_source) spell: codespell -doublecheck: format check spell +doublecheck: + @./scripts/quality-check.sh --fix-formatting --autotools diff --git a/meson.build b/meson.build index 3f718192..7c5f31b1 100644 --- a/meson.build +++ b/meson.build @@ -606,31 +606,31 @@ if get_option('tests') 'tests/unittests/tools/stub_aesgcm_download.c', 'tests/unittests/tools/stub_plugin_download.c', 'tests/unittests/helpers.c', - 'tests/unittests/test_form.c', + 'tests/unittests/xmpp/test_form.c', 'tests/unittests/test_common.c', - 'tests/unittests/test_autocomplete.c', - 'tests/unittests/test_jid.c', - 'tests/unittests/test_parser.c', - 'tests/unittests/test_roster_list.c', - 'tests/unittests/test_chat_session.c', - 'tests/unittests/test_contact.c', - 'tests/unittests/test_preferences.c', - 'tests/unittests/test_server_events.c', - 'tests/unittests/test_muc.c', - 'tests/unittests/test_cmd_presence.c', - 'tests/unittests/test_cmd_alias.c', - 'tests/unittests/test_cmd_connect.c', - 'tests/unittests/test_cmd_rooms.c', - 'tests/unittests/test_cmd_account.c', - 'tests/unittests/test_cmd_sub.c', - 'tests/unittests/test_cmd_bookmark.c', - 'tests/unittests/test_cmd_otr.c', - 'tests/unittests/test_cmd_pgp.c', - 'tests/unittests/test_cmd_join.c', - 'tests/unittests/test_cmd_roster.c', - 'tests/unittests/test_cmd_disconnect.c', - 'tests/unittests/test_callbacks.c', - 'tests/unittests/test_plugins_disco.c', + 'tests/unittests/tools/test_autocomplete.c', + 'tests/unittests/xmpp/test_jid.c', + 'tests/unittests/tools/test_parser.c', + 'tests/unittests/xmpp/test_roster_list.c', + 'tests/unittests/xmpp/test_chat_session.c', + 'tests/unittests/xmpp/test_contact.c', + 'tests/unittests/config/test_preferences.c', + 'tests/unittests/event/test_server_events.c', + 'tests/unittests/xmpp/test_muc.c', + 'tests/unittests/command/test_cmd_presence.c', + 'tests/unittests/command/test_cmd_alias.c', + 'tests/unittests/command/test_cmd_connect.c', + 'tests/unittests/command/test_cmd_rooms.c', + 'tests/unittests/command/test_cmd_account.c', + 'tests/unittests/command/test_cmd_sub.c', + 'tests/unittests/command/test_cmd_bookmark.c', + 'tests/unittests/command/test_cmd_otr.c', + 'tests/unittests/command/test_cmd_pgp.c', + 'tests/unittests/command/test_cmd_join.c', + 'tests/unittests/command/test_cmd_roster.c', + 'tests/unittests/command/test_cmd_disconnect.c', + 'tests/unittests/plugins/test_callbacks.c', + 'tests/unittests/plugins/test_plugins_disco.c', 'tests/unittests/unittests.c', ) @@ -667,7 +667,7 @@ if get_option('tests') 'unittests', unittest_sources, dependencies: profanity_deps + [cmocka_dep], - include_directories: [inc, include_directories('tests')], + include_directories: [inc, include_directories('tests'), include_directories('tests/unittests')], build_by_default: false, ) @@ -677,6 +677,10 @@ if get_option('tests') endif endif +run_target('doublecheck', + command: ['scripts/quality-check.sh', '--fix-formatting', '--meson'] +) + summary({ 'Platform': platform, 'Package status': get_option('buildtype'), diff --git a/scripts/quality-check.sh b/scripts/quality-check.sh new file mode 100755 index 00000000..dfda561a --- /dev/null +++ b/scripts/quality-check.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash + +# Central quality check script for Profanity + +set -e + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +# Go to project root +cd "$(dirname "$0")/.." + +usage() { + echo "Usage: $0 [options]" + echo "" + echo "Description:" + echo " Code quality checks (spelling, formatting, and unit tests)." + echo " Works with autotools and meson and can be used as a git" + echo " pre-commit hook." + echo "" + echo "Options:" + echo " --fix-formatting Apply formatting fixes (default is check only)" + echo " --no-format Skip the formatting check/fix entirely. Use this if your local" + echo " clang-format version produces different results than the CI." + echo " Can also be set via SKIP_FORMAT=1 environment variable." + echo " --autotools Run unit tests using Autotools (make check-unit)" + echo " --meson Run unit tests using Meson (meson test)" + echo " --hook Git hook mode: Checks only staged files for spelling and" + echo " formatting. Does not run tests to ensure fast commits." + echo " --install Install this script as a git pre-commit hook" + echo " --help Show this help message" +} + +run_tests() { + local system=$1 + echo -e "${YELLOW}---> Running unit tests...${NC}" + + if [ "$system" == "autotools" ]; then + echo "Using Autotools..." + make check-unit + elif [ "$system" == "meson" ]; then + echo "Using Meson..." + # Uses build_run + meson test -C build_run "unit tests" + fi +} + +run_format() { + local mode=$1 + local hook_mode=$2 + local skip=$3 + local files + + if [ "$skip" = true ]; then + echo -e "${YELLOW}---> Skipping formatting check.${NC}" + return + fi + + if [ "$hook_mode" = true ]; then + echo -e "${YELLOW}---> Checking staged files for formatting...${NC}" + # Only added/modified C files + files=$(git diff --cached --name-only --diff-filter=ACMR | grep -E "\.(c|h)$" || true) + else + echo -e "${YELLOW}---> Checking all files for formatting...${NC}" + files=$(find src tests -name "*.[ch]" || true) + fi + + if [ -z "$files" ]; then + echo "No C files to check." + return + fi + + if [ "$mode" = "fix" ]; then + clang-format -i $files + echo -e "${GREEN}Formatting applied.${NC}" + else + # --Werror makes it return non-zero on diff + if ! clang-format --dry-run --Werror $files; then + echo -e "${RED}Error: Style violations found. Run '$0 --fix-formatting' to resolve.${NC}" + echo -e "${RED}If this is due to a clang-format version mismatch, use --no-format or SKIP_FORMAT=1.${NC}" + exit 1 + fi + echo -e "${GREEN}Style check passed.${NC}" + fi +} + +run_spell() { + echo -e "${YELLOW}---> Running spell check...${NC}" + if command -v codespell >/dev/null 2>&1; then + codespell + echo -e "${GREEN}Spell check passed.${NC}" + else + echo -e "${YELLOW}Warning: codespell not found, skipping.${NC}" + fi +} + +MODE="check" +BUILD_SYSTEM="none" +HOOK=false + +# Support environment variable override +if [[ "$SKIP_FORMAT" == "1" || "$SKIP_FORMAT" == "true" ]]; then + INTERNAL_SKIP_FORMAT=true +else + INTERNAL_SKIP_FORMAT=false +fi + +while [[ "$#" -gt 0 ]]; do + case $1 in + --fix-formatting) MODE="fix" ;; + --no-format) INTERNAL_SKIP_FORMAT=true ;; + --autotools) BUILD_SYSTEM="autotools" ;; + --meson) BUILD_SYSTEM="meson" ;; + --hook) HOOK=true ;; + --install) + echo "Installing pre-commit hook..." + mkdir -p .git/hooks + echo "#!/usr/bin/env bash" > .git/hooks/pre-commit + echo "./scripts/quality-check.sh --hook" >> .git/hooks/pre-commit + chmod +x .git/hooks/pre-commit + echo "Hook installed." + exit 0 + ;; + --help) usage; exit 0 ;; + *) echo "Unknown parameter: $1"; usage; exit 1 ;; + esac + shift +done + +# Always run spell check +run_spell + +# Run format check unless skipped +run_format "$MODE" "$HOOK" "$INTERNAL_SKIP_FORMAT" + +# Run tests if a build system was specified +if [ "$BUILD_SYSTEM" != "none" ]; then + run_tests "$BUILD_SYSTEM" +fi + +echo -e "${GREEN}Quality check successful!${NC}" diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 74d1357a..f7841323 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -1789,7 +1789,7 @@ _bytes_from_hex(const char* hex, size_t hex_size, const unsigned char ht[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567 0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89:;<=>? - 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, // @ABCDEFG + 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00 // @ABCDEFG }; const size_t ht_size = sizeof(ht); diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c index ea957e49..10e89521 100644 --- a/tests/functionaltests/functionaltests.c +++ b/tests/functionaltests/functionaltests.c @@ -22,7 +22,9 @@ #define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test) -int main(int argc, char* argv[]) { +int +main(int argc, char* argv[]) +{ const struct CMUnitTest all_tests[] = { diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c index 29c1d4f4..40d99d81 100644 --- a/tests/functionaltests/proftest.c +++ b/tests/functionaltests/proftest.c @@ -14,13 +14,13 @@ #include "proftest.h" -char *config_orig; -char *data_orig; +char* config_orig; +char* data_orig; int fd = 0; gboolean -_create_dir(const char *name) +_create_dir(const char* name) { struct stat sb; @@ -38,14 +38,14 @@ _create_dir(const char *name) } gboolean -_mkdir_recursive(const char *dir) +_mkdir_recursive(const char* dir) { int i; gboolean result = TRUE; for (i = 1; i <= strlen(dir); i++) { if (dir[i] == '/' || dir[i] == '\0') { - gchar *next_dir = g_strndup(dir, i); + gchar* next_dir = g_strndup(dir, i); result = _create_dir(next_dir); g_free(next_dir); if (!result) { @@ -60,7 +60,7 @@ _mkdir_recursive(const char *dir) void _create_config_dir(void) { - GString *profanity_dir = g_string_new(XDG_CONFIG_HOME); + GString* profanity_dir = g_string_new(XDG_CONFIG_HOME); g_string_append(profanity_dir, "/profanity"); if (!_mkdir_recursive(profanity_dir->str)) { @@ -73,7 +73,7 @@ _create_config_dir(void) void _create_data_dir(void) { - GString *profanity_dir = g_string_new(XDG_DATA_HOME); + GString* profanity_dir = g_string_new(XDG_DATA_HOME); g_string_append(profanity_dir, "/profanity"); if (!_mkdir_recursive(profanity_dir->str)) { @@ -86,7 +86,7 @@ _create_data_dir(void) void _create_chatlogs_dir(void) { - GString *chatlogs_dir = g_string_new(XDG_DATA_HOME); + GString* chatlogs_dir = g_string_new(XDG_DATA_HOME); g_string_append(chatlogs_dir, "/profanity/chatlogs"); if (!_mkdir_recursive(chatlogs_dir->str)) { @@ -99,7 +99,7 @@ _create_chatlogs_dir(void) void _create_logs_dir(void) { - GString *logs_dir = g_string_new(XDG_DATA_HOME); + GString* logs_dir = g_string_new(XDG_DATA_HOME); g_string_append(logs_dir, "/profanity/logs"); if (!_mkdir_recursive(logs_dir->str)) { @@ -124,21 +124,21 @@ prof_start(void) // helper script sets terminal columns, avoids assertions failing // based on the test runner terminal size fd = exp_spawnl("sh", - "sh", - "-c", - "./tests/functionaltests/start_profanity.sh", - NULL); - FILE *fp = fdopen(fd, "r+"); + "sh", + "-c", + "./tests/functionaltests/start_profanity.sh", + NULL); + FILE* fp = fdopen(fd, "r+"); assert_true(fp != NULL); - setbuf(fp, (char *)0); + setbuf(fp, (char*)0); } int -init_prof_test(void **state) +init_prof_test(void** state) { - if (stbbr_start(STBBR_LOGDEBUG ,5230, 0) != 0) { + if (stbbr_start(STBBR_LOGDEBUG, 5230, 0) != 0) { assert_true(FALSE); return -1; } @@ -191,7 +191,7 @@ init_prof_test(void **state) } int -close_prof_test(void **state) +close_prof_test(void** state) { prof_input("/quit"); waitpid(exp_pid, NULL, 0); @@ -205,48 +205,45 @@ close_prof_test(void **state) } void -prof_input(const char *input) +prof_input(const char* input) { - GString *inp_str = g_string_new(input); + GString* inp_str = g_string_new(input); g_string_append(inp_str, "\r"); write(fd, inp_str->str, inp_str->len); g_string_free(inp_str, TRUE); } int -prof_output_exact(const char *text) +prof_output_exact(const char* text) { return (1 == exp_expectl(fd, exp_exact, text, 1, exp_end)); } int -prof_output_regex(const char *text) +prof_output_regex(const char* text) { return (1 == exp_expectl(fd, exp_regexp, text, 1, exp_end)); } void -prof_connect_with_roster(const char *roster) +prof_connect_with_roster(const char* roster) { - GString *roster_str = g_string_new( + GString* roster_str = g_string_new( "" - "" - ); + ""); g_string_append(roster_str, roster); g_string_append(roster_str, - "" - "" - ); + "" + ""); stbbr_for_query("jabber:iq:roster", roster_str->str); g_string_free(roster_str, TRUE); stbbr_for_id("prof_presence_1", - "" - "0" - "" - "" - ); + "" + "0" + "" + ""); prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow"); prof_input("password"); @@ -275,6 +272,5 @@ prof_connect(void) { prof_connect_with_roster( "" - "" - ); + ""); } diff --git a/tests/functionaltests/proftest.h b/tests/functionaltests/proftest.h index a3ff07e9..ef1968b1 100644 --- a/tests/functionaltests/proftest.h +++ b/tests/functionaltests/proftest.h @@ -4,16 +4,16 @@ #define XDG_CONFIG_HOME "./tests/functionaltests/files/xdg_config_home" #define XDG_DATA_HOME "./tests/functionaltests/files/xdg_data_home" -int init_prof_test(void **state); -int close_prof_test(void **state); +int init_prof_test(void** state); +int close_prof_test(void** state); void prof_start(void); void prof_connect(void); -void prof_connect_with_roster(const char *roster); -void prof_input(const char *input); +void prof_connect_with_roster(const char* roster); +void prof_input(const char* input); -int prof_output_exact(const char *text); -int prof_output_regex(const char *text); +int prof_output_exact(const char* text); +int prof_output_regex(const char* text); void prof_timeout(int timeout); void prof_timeout_reset(void); diff --git a/tests/functionaltests/test_carbons.c b/tests/functionaltests/test_carbons.c index ddf6194d..41e9a9f5 100644 --- a/tests/functionaltests/test_carbons.c +++ b/tests/functionaltests/test_carbons.c @@ -9,31 +9,29 @@ #include "proftest.h" void -send_enable_carbons(void **state) +send_enable_carbons(void** state) { prof_connect(); prof_input("/carbons on"); assert_true(stbbr_received( - "" - )); + "")); } void -connect_with_carbons_enabled(void **state) +connect_with_carbons_enabled(void** state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( - "" - )); + "")); } void -send_disable_carbons(void **state) +send_disable_carbons(void** state) { prof_input("/carbons on"); @@ -42,106 +40,96 @@ send_disable_carbons(void **state) prof_input("/carbons off"); assert_true(stbbr_received( - "" - )); + "")); } void -receive_carbon(void **state) +receive_carbon(void** state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( - "" - )); + "")); stbbr_send( "" - "10" - "On my mobile" - "" - ); + "10" + "On my mobile" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" - "" - "" - "" - "test carbon from recipient" - "" - "" - "" + "" + "" + "" + "test carbon from recipient" "" - ); + "" + "" + ""); assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient")); } void -receive_self_carbon(void **state) +receive_self_carbon(void** state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( - "" - )); + "")); stbbr_send( "" - "10" - "On my mobile" - "" - ); + "10" + "On my mobile" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" - "" - "" - "" - "self sent carbon" - "" - "" - "" + "" + "" + "" + "self sent carbon" "" - ); + "" + "" + ""); assert_true(prof_output_regex("me: .+self sent carbon")); } void -receive_private_carbon(void **state) +receive_private_carbon(void** state) { prof_input("/carbons on"); prof_connect(); assert_true(stbbr_received( - "" - )); + "")); stbbr_send( "" - "10" - "On my mobile" - "" - ); + "10" + "On my mobile" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); prof_input("/msg Buddy1"); assert_true(prof_output_exact("unencrypted")); stbbr_send( "" - "Private carbon" - "" - "" - ); + "Private carbon" + "" + ""); assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon")); } diff --git a/tests/functionaltests/test_carbons.h b/tests/functionaltests/test_carbons.h index c724e38c..1096bb84 100644 --- a/tests/functionaltests/test_carbons.h +++ b/tests/functionaltests/test_carbons.h @@ -1,6 +1,6 @@ -void send_enable_carbons(void **state); -void connect_with_carbons_enabled(void **state); -void send_disable_carbons(void **state); -void receive_carbon(void **state); -void receive_self_carbon(void **state); -void receive_private_carbon(void **state); +void send_enable_carbons(void** state); +void connect_with_carbons_enabled(void** state); +void send_disable_carbons(void** state); +void receive_carbon(void** state); +void receive_self_carbon(void** state); +void receive_private_carbon(void** state); diff --git a/tests/functionaltests/test_chat_session.c b/tests/functionaltests/test_chat_session.c index 355b977f..b26a224a 100644 --- a/tests/functionaltests/test_chat_session.c +++ b/tests/functionaltests/test_chat_session.c @@ -9,7 +9,7 @@ #include "proftest.h" void -sends_message_to_barejid_when_contact_offline(void **state) +sends_message_to_barejid_when_contact_offline(void** state) { prof_connect(); @@ -17,188 +17,166 @@ sends_message_to_barejid_when_contact_offline(void **state) assert_true(stbbr_received( "" - "Hi there" - "" - )); + "Hi there" + "")); } void -sends_message_to_barejid_when_contact_online(void **state) +sends_message_to_barejid_when_contact_online(void** state) { prof_connect(); stbbr_send( "" - "10" - "" - ); + "10" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online")); prof_input("/msg buddy1@localhost Hi there"); assert_true(stbbr_received( "" - "Hi there" - "" - )); + "Hi there" + "")); } void -sends_message_to_fulljid_when_received_from_fulljid(void **state) +sends_message_to_fulljid_when_received_from_fulljid(void** state) { prof_connect(); stbbr_send( "" - "10" - "" - ); + "10" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online")); stbbr_send( "" - "First message" - "" - ); + "First message" + ""); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); prof_input("/msg buddy1@localhost Hi there"); assert_true(stbbr_received( "" - "Hi there" - "" - )); + "Hi there" + "")); } void -sends_subsequent_messages_to_fulljid(void **state) +sends_subsequent_messages_to_fulljid(void** state) { prof_connect(); stbbr_send( "" - "10" - "" - ); + "10" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online")); stbbr_send( "" - "First message" - "" - ); + "First message" + ""); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); prof_input("/msg buddy1@localhost Outgoing 1"); assert_true(stbbr_received( "" - "Outgoing 1" - "" - )); + "Outgoing 1" + "")); prof_input("/msg buddy1@localhost Outgoing 2"); assert_true(stbbr_received( "" - "Outgoing 2" - "" - )); + "Outgoing 2" + "")); prof_input("/msg buddy1@localhost Outgoing 3"); assert_true(stbbr_received( "" - "Outgoing 3" - "" - )); + "Outgoing 3" + "")); } void -resets_to_barejid_after_presence_received(void **state) +resets_to_barejid_after_presence_received(void** state) { prof_connect(); stbbr_send( "" - "10" - "" - ); + "10" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online")); stbbr_send( "" - "First message" - "" - ); + "First message" + ""); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); prof_input("/msg buddy1@localhost Outgoing 1"); assert_true(stbbr_received( "" - "Outgoing 1" - "" - )); + "Outgoing 1" + "")); stbbr_send( "" - "5" - "dnd" - "" - ); + "5" + "dnd" + ""); assert_true(prof_output_exact("Buddy1 (laptop) is dnd")); prof_input("/msg buddy1@localhost Outgoing 2"); assert_true(stbbr_received( "" - "Outgoing 2" - "" - )); + "Outgoing 2" + "")); } void -new_session_when_message_received_from_different_fulljid(void **state) +new_session_when_message_received_from_different_fulljid(void** state) { prof_connect(); stbbr_send( "" - "10" - "" - ); + "10" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online")); stbbr_send( "" - "8" - "away" - "" - ); + "8" + "away" + ""); assert_true(prof_output_exact("Buddy1 (laptop) is away")); stbbr_send( "" - "From first resource" - "" - ); + "From first resource" + ""); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); prof_input("/msg buddy1@localhost Outgoing 1"); assert_true(stbbr_received( "" - "Outgoing 1" - "" - )); + "Outgoing 1" + "")); stbbr_send( "" - "From second resource" - "" - ); + "From second resource" + ""); assert_true(prof_output_regex("Buddy1/laptop:.+From second resource")); prof_input("/msg buddy1@localhost Outgoing 2"); assert_true(stbbr_received( "" - "Outgoing 2" - "" - )); + "Outgoing 2" + "")); } diff --git a/tests/functionaltests/test_chat_session.h b/tests/functionaltests/test_chat_session.h index 245bbb11..3bd62fbc 100644 --- a/tests/functionaltests/test_chat_session.h +++ b/tests/functionaltests/test_chat_session.h @@ -1,6 +1,6 @@ -void sends_message_to_barejid_when_contact_offline(void **state); -void sends_message_to_barejid_when_contact_online(void **state); -void sends_message_to_fulljid_when_received_from_fulljid(void **state); -void sends_subsequent_messages_to_fulljid(void **state); -void resets_to_barejid_after_presence_received(void **state); -void new_session_when_message_received_from_different_fulljid(void **state); +void sends_message_to_barejid_when_contact_offline(void** state); +void sends_message_to_barejid_when_contact_online(void** state); +void sends_message_to_fulljid_when_received_from_fulljid(void** state); +void sends_subsequent_messages_to_fulljid(void** state); +void resets_to_barejid_after_presence_received(void** state); +void new_session_when_message_received_from_different_fulljid(void** state); diff --git a/tests/functionaltests/test_connect.c b/tests/functionaltests/test_connect.c index 571293dc..43f6e98c 100644 --- a/tests/functionaltests/test_connect.c +++ b/tests/functionaltests/test_connect.c @@ -9,43 +9,40 @@ #include "proftest.h" void -connect_jid_requests_roster(void **state) +connect_jid_requests_roster(void** state) { prof_connect(); assert_true(stbbr_received( - "" - )); + "")); } void -connect_jid_sends_presence_after_receiving_roster(void **state) +connect_jid_sends_presence_after_receiving_roster(void** state) { prof_connect(); assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); } void -connect_jid_requests_bookmarks(void **state) +connect_jid_requests_bookmarks(void** state) { prof_connect(); assert_true(stbbr_received( "" - "" - "" - "" - "" - )); + "" + "" + "" + "")); } void -connect_bad_password(void **state) +connect_bad_password(void** state) { prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow"); prof_input("badpassword"); @@ -54,39 +51,35 @@ connect_bad_password(void **state) } void -connect_shows_presence_updates(void **state) +connect_shows_presence_updates(void** state) { prof_connect(); stbbr_send( "" - "dnd" - "busy!" - "" - ); + "dnd" + "busy!" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is dnd, \"busy!\"")); stbbr_send( "" - "chat" - "Talk to me!" - "" - ); + "chat" + "Talk to me!" + ""); assert_true(prof_output_exact("Buddy1 (laptop) is chat, \"Talk to me!\"")); stbbr_send( "" - "away" - "Out of office" - "" - ); + "away" + "Out of office" + ""); assert_true(prof_output_exact("Buddy2 (work) is away, \"Out of office\"")); stbbr_send( "" - "xa" - "Gone :(" - "" - ); + "xa" + "Gone :(" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is xa, \"Gone :(\"")); } diff --git a/tests/functionaltests/test_connect.h b/tests/functionaltests/test_connect.h index d82d9364..889ea7c0 100644 --- a/tests/functionaltests/test_connect.h +++ b/tests/functionaltests/test_connect.h @@ -1,5 +1,5 @@ -void connect_jid_requests_roster(void **state); -void connect_jid_sends_presence_after_receiving_roster(void **state); -void connect_jid_requests_bookmarks(void **state); -void connect_bad_password(void **state); -void connect_shows_presence_updates(void **state); +void connect_jid_requests_roster(void** state); +void connect_jid_sends_presence_after_receiving_roster(void** state); +void connect_jid_requests_bookmarks(void** state); +void connect_bad_password(void** state); +void connect_shows_presence_updates(void** state); diff --git a/tests/functionaltests/test_disconnect.c b/tests/functionaltests/test_disconnect.c index 2827805f..b90af3cd 100644 --- a/tests/functionaltests/test_disconnect.c +++ b/tests/functionaltests/test_disconnect.c @@ -9,7 +9,7 @@ #include "proftest.h" void -disconnect_ends_session(void **state) +disconnect_ends_session(void** state) { prof_connect(); diff --git a/tests/functionaltests/test_disconnect.h b/tests/functionaltests/test_disconnect.h index 2024269a..b65f5766 100644 --- a/tests/functionaltests/test_disconnect.h +++ b/tests/functionaltests/test_disconnect.h @@ -1 +1 @@ -void disconnect_ends_session(void **state); +void disconnect_ends_session(void** state); diff --git a/tests/functionaltests/test_message.c b/tests/functionaltests/test_message.c index 9260813e..84fb22cb 100644 --- a/tests/functionaltests/test_message.c +++ b/tests/functionaltests/test_message.c @@ -9,7 +9,7 @@ #include "proftest.h" void -message_send(void **state) +message_send(void** state) { prof_connect(); @@ -17,29 +17,27 @@ message_send(void **state) assert_true(stbbr_received( "" - "Hi there" - "" - )); + "Hi there" + "")); assert_true(prof_output_regex("me: .+Hi there")); } void -message_receive_console(void **state) +message_receive_console(void** state) { prof_connect(); stbbr_send( "" - "How are you?" - "" - ); + "How are you?" + ""); assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)")); } void -message_receive_chatwin(void **state) +message_receive_chatwin(void** state) { prof_connect(); @@ -48,9 +46,8 @@ message_receive_chatwin(void **state) stbbr_send( "" - "How are you?" - "" - ); + "How are you?" + ""); assert_true(prof_output_regex("someuser@chatserv.org/laptop: .+How are you?")); } diff --git a/tests/functionaltests/test_message.h b/tests/functionaltests/test_message.h index d3a1987c..c0b4c559 100644 --- a/tests/functionaltests/test_message.h +++ b/tests/functionaltests/test_message.h @@ -1,3 +1,3 @@ -void message_send(void **state); -void message_receive_console(void **state); -void message_receive_chatwin(void **state); +void message_send(void** state); +void message_receive_console(void** state); +void message_receive_chatwin(void** state); diff --git a/tests/functionaltests/test_muc.c b/tests/functionaltests/test_muc.c index 43910936..0d1d1e7b 100644 --- a/tests/functionaltests/test_muc.c +++ b/tests/functionaltests/test_muc.c @@ -9,7 +9,7 @@ #include "proftest.h" void -sends_room_join(void **state) +sends_room_join(void** state) { prof_connect(); @@ -17,14 +17,13 @@ sends_room_join(void **state) assert_true(stbbr_last_received( "" - "" - "" - "" - )); + "" + "" + "")); } void -sends_room_join_with_nick(void **state) +sends_room_join_with_nick(void** state) { prof_connect(); @@ -32,14 +31,13 @@ sends_room_join_with_nick(void **state) assert_true(stbbr_last_received( "" - "" - "" - "" - )); + "" + "" + "")); } void -sends_room_join_with_password(void **state) +sends_room_join_with_password(void** state) { prof_connect(); @@ -47,16 +45,15 @@ sends_room_join_with_password(void **state) assert_true(stbbr_last_received( "" - "" - "testpassword" - "" - "" - "" - )); + "" + "testpassword" + "" + "" + "")); } void -sends_room_join_with_nick_and_password(void **state) +sends_room_join_with_nick_and_password(void** state) { prof_connect(); @@ -64,28 +61,26 @@ sends_room_join_with_nick_and_password(void **state) assert_true(stbbr_last_received( "" - "" - "testpassword" - "" - "" - "" - )); + "" + "testpassword" + "" + "" + "")); } void -shows_role_and_affiliation_on_join(void **state) +shows_role_and_affiliation_on_join(void** state) { prof_connect(); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); @@ -93,186 +88,173 @@ shows_role_and_affiliation_on_join(void **state) } void -shows_subject_on_join(void **state) +shows_subject_on_join(void** state) { prof_connect(); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); stbbr_send( "" - "Test room subject" - "anothernick has set the subject to: Test room subject" - "" - ); + "Test room subject" + "anothernick has set the subject to: Test room subject" + ""); assert_true(prof_output_regex("Room subject: .+Test room subject")); } void -shows_history_message(void **state) +shows_history_message(void** state) { prof_connect(); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); stbbr_send( "" - "an old message" - "" - "" - "" - ); + "an old message" + "" + "" + ""); assert_true(prof_output_regex("testoccupant: an old message")); } void -shows_occupant_join(void **state) +shows_occupant_join(void** state) { prof_connect(); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); stbbr_send( "" - "" - "" - "" - "" - ); + "" + "" + "" + ""); assert_true(prof_output_exact("-> testoccupant has joined the room, role: participant, affiliation: none")); } void -shows_message(void **state) +shows_message(void** state) { prof_connect(); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); stbbr_send( "" - "a new message" - "" - ); + "a new message" + ""); assert_true(prof_output_regex("testoccupant: .+a new message")); } void -shows_me_message_from_occupant(void **state) +shows_me_message_from_occupant(void** state) { prof_connect(); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); stbbr_send( "" - "/me did something" - "" - ); + "/me did something" + ""); assert_true(prof_output_exact("*testoccupant did something")); } void -shows_me_message_from_self(void **state) +shows_me_message_from_self(void** state) { prof_connect(); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); stbbr_send( "" - "/me did something" - "" - ); + "/me did something" + ""); assert_true(prof_output_exact("*stabber did something")); } void -shows_all_messages_in_console_when_window_not_focussed(void **state) +shows_all_messages_in_console_when_window_not_focussed(void** state) { prof_connect(); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); @@ -282,23 +264,21 @@ shows_all_messages_in_console_when_window_not_focussed(void **state) stbbr_send( "" - "a new message" - "" - ); + "a new message" + ""); assert_true(prof_output_exact("<< room message: testoccupant in testroom@conference.localhost (win 2)")); stbbr_send( "" - "some other message" - "" - ); + "some other message" + ""); assert_true(prof_output_exact("<< room message: anotheroccupant in testroom@conference.localhost (win 2)")); } void -shows_first_message_in_console_when_window_not_focussed(void **state) +shows_first_message_in_console_when_window_not_focussed(void** state) { prof_connect(); @@ -306,14 +286,13 @@ shows_first_message_in_console_when_window_not_focussed(void **state) assert_true(prof_output_exact("Console MUC messages set: first")); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); @@ -323,9 +302,8 @@ shows_first_message_in_console_when_window_not_focussed(void **state) stbbr_send( "" - "a new message" - "" - ); + "a new message" + ""); assert_true(prof_output_exact("<< room message: testroom@conference.localhost (win 2)")); prof_input("/clear"); @@ -334,9 +312,8 @@ shows_first_message_in_console_when_window_not_focussed(void **state) stbbr_send( "" - "some other message" - "" - ); + "some other message" + ""); prof_timeout(2); assert_false(prof_output_exact("<< room message: testroom@conference.localhost (win 2)")); @@ -344,7 +321,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state) } void -shows_no_message_in_console_when_window_not_focussed(void **state) +shows_no_message_in_console_when_window_not_focussed(void** state) { prof_connect(); @@ -352,14 +329,13 @@ shows_no_message_in_console_when_window_not_focussed(void **state) assert_true(prof_output_exact("Console MUC messages set: none")); stbbr_for_id("prof_join_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_input("/join testroom@conference.localhost"); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); @@ -369,9 +345,8 @@ shows_no_message_in_console_when_window_not_focussed(void **state) stbbr_send( "" - "a new message" - "" - ); + "a new message" + ""); prof_timeout(2); assert_false(prof_output_exact("testroom@conference.localhost (win 2)")); diff --git a/tests/functionaltests/test_muc.h b/tests/functionaltests/test_muc.h index 1636bd05..31df8944 100644 --- a/tests/functionaltests/test_muc.h +++ b/tests/functionaltests/test_muc.h @@ -1,14 +1,14 @@ -void sends_room_join(void **state); -void sends_room_join_with_nick(void **state); -void sends_room_join_with_password(void **state); -void sends_room_join_with_nick_and_password(void **state); -void shows_role_and_affiliation_on_join(void **state); -void shows_subject_on_join(void **state); -void shows_history_message(void **state); -void shows_occupant_join(void **state); -void shows_message(void **state); -void shows_me_message_from_occupant(void **state); -void shows_me_message_from_self(void **state); -void shows_all_messages_in_console_when_window_not_focussed(void **state); -void shows_first_message_in_console_when_window_not_focussed(void **state); -void shows_no_message_in_console_when_window_not_focussed(void **state); +void sends_room_join(void** state); +void sends_room_join_with_nick(void** state); +void sends_room_join_with_password(void** state); +void sends_room_join_with_nick_and_password(void** state); +void shows_role_and_affiliation_on_join(void** state); +void shows_subject_on_join(void** state); +void shows_history_message(void** state); +void shows_occupant_join(void** state); +void shows_message(void** state); +void shows_me_message_from_occupant(void** state); +void shows_me_message_from_self(void** state); +void shows_all_messages_in_console_when_window_not_focussed(void** state); +void shows_first_message_in_console_when_window_not_focussed(void** state); +void shows_no_message_in_console_when_window_not_focussed(void** state); diff --git a/tests/functionaltests/test_ping.c b/tests/functionaltests/test_ping.c index a5aeba3b..03c14b2b 100644 --- a/tests/functionaltests/test_ping.c +++ b/tests/functionaltests/test_ping.c @@ -9,53 +9,47 @@ #include "proftest.h" void -ping_server(void **state) +ping_server(void** state) { stbbr_for_id("prof_disco_info_onconnect_2", - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + ""); stbbr_for_id("prof_ping_4", - "" - ); + ""); stbbr_for_id("prof_ping_5", - "" - ); + ""); prof_connect(); prof_input("/ping"); assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); assert_true(prof_output_exact("Ping response from server")); prof_input("/ping"); assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); assert_true(prof_output_exact("Ping response from server")); } void -ping_server_not_supported(void **state) +ping_server_not_supported(void** state) { stbbr_for_id("prof_disco_info_onconnect_2", - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + ""); prof_connect(); @@ -64,103 +58,95 @@ ping_server_not_supported(void **state) } void -ping_responds_to_server_request(void **state) +ping_responds_to_server_request(void** state) { prof_connect(); stbbr_send( "" - "" - "" - ); + "" + ""); assert_true(stbbr_received( - "" - )); + "")); } -void ping_jid(void **state) +void +ping_jid(void** state) { stbbr_for_id("prof_caps_4", - "" - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + "" + ""); prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - "" - ); + "10" + "I'm here" + "" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); stbbr_for_id("prof_ping_5", - "" - ); + ""); prof_input("/ping buddy1@localhost/mobile"); assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile")); } -void ping_jid_not_supported(void **state) +void +ping_jid_not_supported(void** state) { stbbr_for_id("prof_caps_4", - "" - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + "" + ""); prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - "" - ); + "10" + "I'm here" + "" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); prof_input("/ping buddy1@localhost/mobile"); assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests.")); diff --git a/tests/functionaltests/test_ping.h b/tests/functionaltests/test_ping.h index 1f2eeb91..90598598 100644 --- a/tests/functionaltests/test_ping.h +++ b/tests/functionaltests/test_ping.h @@ -1,5 +1,5 @@ -void ping_server(void **state); -void ping_server_not_supported(void **state); -void ping_responds_to_server_request(void **state); -void ping_jid(void **state); -void ping_jid_not_supported(void **state); +void ping_server(void** state); +void ping_server_not_supported(void** state); +void ping_responds_to_server_request(void** state); +void ping_jid(void** state); +void ping_jid_not_supported(void** state); diff --git a/tests/functionaltests/test_presence.c b/tests/functionaltests/test_presence.c index 0bd1915d..884e4db6 100644 --- a/tests/functionaltests/test_presence.c +++ b/tests/functionaltests/test_presence.c @@ -9,7 +9,7 @@ #include "proftest.h" void -presence_online(void **state) +presence_online(void** state) { prof_connect(); @@ -17,15 +17,14 @@ presence_online(void **state) assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); assert_true(prof_output_exact("Status set to online (priority 0)")); } void -presence_online_with_message(void **state) +presence_online_with_message(void** state) { prof_connect(); @@ -33,16 +32,15 @@ presence_online_with_message(void **state) assert_true(stbbr_received( "" - "Hi there" - "" - "" - )); + "Hi there" + "" + "")); assert_true(prof_output_exact("Status set to online (priority 0), \"Hi there\".")); } void -presence_away(void **state) +presence_away(void** state) { prof_connect(); @@ -50,16 +48,15 @@ presence_away(void **state) assert_true(stbbr_received( "" - "away" - "" - "" - )); + "away" + "" + "")); assert_true(prof_output_exact("Status set to away (priority 0)")); } void -presence_away_with_message(void **state) +presence_away_with_message(void** state) { prof_connect(); @@ -67,17 +64,16 @@ presence_away_with_message(void **state) assert_true(stbbr_received( "" - "away" - "I'm not here for a bit" - "" - "" - )); + "away" + "I'm not here for a bit" + "" + "")); assert_true(prof_output_exact("Status set to away (priority 0), \"I'm not here for a bit\".")); } void -presence_xa(void **state) +presence_xa(void** state) { prof_connect(); @@ -85,16 +81,15 @@ presence_xa(void **state) assert_true(stbbr_received( "" - "xa" - "" - "" - )); + "xa" + "" + "")); assert_true(prof_output_exact("Status set to xa (priority 0)")); } void -presence_xa_with_message(void **state) +presence_xa_with_message(void** state) { prof_connect(); @@ -102,17 +97,16 @@ presence_xa_with_message(void **state) assert_true(stbbr_received( "" - "xa" - "Gone to the shops" - "" - "" - )); + "xa" + "Gone to the shops" + "" + "")); assert_true(prof_output_exact("Status set to xa (priority 0), \"Gone to the shops\".")); } void -presence_dnd(void **state) +presence_dnd(void** state) { prof_connect(); @@ -120,16 +114,15 @@ presence_dnd(void **state) assert_true(stbbr_received( "" - "dnd" - "" - "" - )); + "dnd" + "" + "")); assert_true(prof_output_exact("Status set to dnd (priority 0)")); } void -presence_dnd_with_message(void **state) +presence_dnd_with_message(void** state) { prof_connect(); @@ -137,17 +130,16 @@ presence_dnd_with_message(void **state) assert_true(stbbr_received( "" - "dnd" - "Working" - "" - "" - )); + "dnd" + "Working" + "" + "")); assert_true(prof_output_exact("Status set to dnd (priority 0), \"Working\".")); } void -presence_chat(void **state) +presence_chat(void** state) { prof_connect(); @@ -155,16 +147,15 @@ presence_chat(void **state) assert_true(stbbr_received( "" - "chat" - "" - "" - )); + "chat" + "" + "")); assert_true(prof_output_exact("Status set to chat (priority 0)")); } void -presence_chat_with_message(void **state) +presence_chat_with_message(void** state) { prof_connect(); @@ -172,17 +163,16 @@ presence_chat_with_message(void **state) assert_true(stbbr_received( "" - "chat" - "Free to talk" - "" - "" - )); + "chat" + "Free to talk" + "" + "")); assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\".")); } void -presence_set_priority(void **state) +presence_set_priority(void** state) { prof_connect(); @@ -190,94 +180,87 @@ presence_set_priority(void **state) assert_true(stbbr_received( "" - "25" - "" - "" - )); + "25" + "" + "")); assert_true(prof_output_exact("Priority set to 25.")); } void -presence_includes_priority(void **state) +presence_includes_priority(void** state) { prof_connect(); prof_input("/priority 25"); assert_true(stbbr_received( "" - "25" - "" - "" - )); + "25" + "" + "")); assert_true(prof_output_exact("Priority set to 25.")); prof_input("/chat \"Free to talk\""); assert_true(stbbr_received( "" - "25" - "chat" - "Free to talk" - "" - "" - )); + "25" + "chat" + "Free to talk" + "" + "")); assert_true(prof_output_exact("Status set to chat (priority 25), \"Free to talk\".")); } void -presence_keeps_status(void **state) +presence_keeps_status(void** state) { prof_connect(); prof_input("/chat \"Free to talk\""); assert_true(stbbr_received( "" - "chat" - "Free to talk" - "" - "" - )); + "chat" + "Free to talk" + "" + "")); assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\".")); prof_input("/priority 25"); assert_true(stbbr_received( "" - "chat" - "Free to talk" - "25" - "" - "" - )); + "chat" + "Free to talk" + "25" + "" + "")); assert_true(prof_output_exact("Priority set to 25.")); } void -presence_received(void **state) +presence_received(void** state) { prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - ); + "10" + "I'm here" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); } // Typical use case for gateways that don't support resources void -presence_missing_resource_defaults(void **state) +presence_missing_resource_defaults(void** state) { prof_connect(); stbbr_send( "" - "15" - "My status" - "" - ); + "15" + "My status" + ""); assert_true(prof_output_exact("Buddy1 is online, \"My status\"")); diff --git a/tests/functionaltests/test_presence.h b/tests/functionaltests/test_presence.h index 107fa794..0efd9ead 100644 --- a/tests/functionaltests/test_presence.h +++ b/tests/functionaltests/test_presence.h @@ -1,15 +1,15 @@ -void presence_away(void **state); -void presence_away_with_message(void **state); -void presence_online(void **state); -void presence_online_with_message(void **state); -void presence_xa(void **state); -void presence_xa_with_message(void **state); -void presence_dnd(void **state); -void presence_dnd_with_message(void **state); -void presence_chat(void **state); -void presence_chat_with_message(void **state); -void presence_set_priority(void **state); -void presence_includes_priority(void **state); -void presence_keeps_status(void **state); -void presence_received(void **state); -void presence_missing_resource_defaults(void **state); +void presence_away(void** state); +void presence_away_with_message(void** state); +void presence_online(void** state); +void presence_online_with_message(void** state); +void presence_xa(void** state); +void presence_xa_with_message(void** state); +void presence_dnd(void** state); +void presence_dnd_with_message(void** state); +void presence_chat(void** state); +void presence_chat_with_message(void** state); +void presence_set_priority(void** state); +void presence_includes_priority(void** state); +void presence_keeps_status(void** state); +void presence_received(void** state); +void presence_missing_resource_defaults(void** state); diff --git a/tests/functionaltests/test_receipts.c b/tests/functionaltests/test_receipts.c index 3debd977..cb8485e8 100644 --- a/tests/functionaltests/test_receipts.c +++ b/tests/functionaltests/test_receipts.c @@ -9,7 +9,7 @@ #include "proftest.h" void -does_not_send_receipt_request_to_barejid(void **state) +does_not_send_receipt_request_to_barejid(void** state) { prof_input("/receipts request on"); @@ -19,34 +19,31 @@ does_not_send_receipt_request_to_barejid(void **state) assert_true(stbbr_received( "" - "Hi there" - "" - )); + "Hi there" + "")); } void -send_receipt_request(void **state) +send_receipt_request(void** state) { prof_input("/receipts request on"); prof_connect(); stbbr_for_id("prof_caps_4", - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + ""); stbbr_send( "" - "15" - "My status" - "" - "" - ); + "15" + "My status" + "" + ""); prof_output_exact("Buddy1 is online, \"My status\""); @@ -56,14 +53,13 @@ send_receipt_request(void **state) assert_true(stbbr_received( "" - "Hi there, where is my receipt?" - "" - "" - )); + "Hi there, where is my receipt?" + "" + "")); } void -send_receipt_on_request(void **state) +send_receipt_on_request(void** state) { prof_input("/receipts send on"); @@ -71,14 +67,12 @@ send_receipt_on_request(void **state) stbbr_send( "" - "Wants a receipt" - "" - "" - ); + "Wants a receipt" + "" + ""); assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); } diff --git a/tests/functionaltests/test_receipts.h b/tests/functionaltests/test_receipts.h index bead28a9..a62cfc63 100644 --- a/tests/functionaltests/test_receipts.h +++ b/tests/functionaltests/test_receipts.h @@ -1,3 +1,3 @@ -void does_not_send_receipt_request_to_barejid(void **state); -void send_receipt_request(void **state); -void send_receipt_on_request(void **state); +void does_not_send_receipt_request_to_barejid(void** state); +void send_receipt_request(void** state); +void send_receipt_on_request(void** state); diff --git a/tests/functionaltests/test_rooms.c b/tests/functionaltests/test_rooms.c index dbe861e1..37348e10 100644 --- a/tests/functionaltests/test_rooms.c +++ b/tests/functionaltests/test_rooms.c @@ -9,16 +9,15 @@ #include "proftest.h" void -rooms_query(void **state) +rooms_query(void** state) { stbbr_for_id("prof_confreq_4", - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + ""); prof_connect(); @@ -29,7 +28,6 @@ rooms_query(void **state) assert_true(stbbr_last_received( "" - "" - "" - )); + "" + "")); } diff --git a/tests/functionaltests/test_rooms.h b/tests/functionaltests/test_rooms.h index e2dcac5d..eec4cb5f 100644 --- a/tests/functionaltests/test_rooms.h +++ b/tests/functionaltests/test_rooms.h @@ -1 +1 @@ -void rooms_query(void **state); +void rooms_query(void** state); diff --git a/tests/functionaltests/test_roster.c b/tests/functionaltests/test_roster.c index e6453fe1..46875b2a 100644 --- a/tests/functionaltests/test_roster.c +++ b/tests/functionaltests/test_roster.c @@ -9,121 +9,110 @@ #include "proftest.h" void -sends_new_item(void **state) +sends_new_item(void** state) { prof_connect(); stbbr_for_query("jabber:iq:roster", - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + ""); prof_input("/roster add bob@localhost"); assert_true(stbbr_received( "" - "" - "" - "" - "" - )); + "" + "" + "" + "")); assert_true(prof_output_exact("Roster item added: bob@localhost")); } void -sends_new_item_nick(void **state) +sends_new_item_nick(void** state) { prof_connect(); stbbr_for_query("jabber:iq:roster", - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + ""); prof_input("/roster add bob@localhost Bobby"); assert_true(stbbr_received( "" - "" - "" - "" - "" - )); + "" + "" + "" + "")); assert_true(prof_output_exact("Roster item added: bob@localhost (Bobby)")); } void -sends_remove_item(void **state) +sends_remove_item(void** state) { prof_connect_with_roster( "" - "" - ); + ""); stbbr_for_query("jabber:iq:roster", - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + ""); prof_input("/roster remove buddy1@localhost"); assert_true(stbbr_received( "" - "" - "" - "" - "" - )); + "" + "" + "" + "")); assert_true(prof_output_exact("Roster item removed: buddy1@localhost")); } void -sends_remove_item_nick(void **state) +sends_remove_item_nick(void** state) { prof_connect_with_roster( "" - "" - ); + ""); stbbr_for_query("jabber:iq:roster", - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + ""); prof_input("/roster remove Bobby"); assert_true(stbbr_received( "" - "" - "" - "" - "" - )); + "" + "" + "" + "")); assert_true(prof_output_exact("Roster item removed: buddy1@localhost")); } void -sends_nick_change(void **state) +sends_nick_change(void** state) { prof_connect_with_roster( - "" - ); + ""); prof_input("/roster nick buddy1@localhost Buddy1"); @@ -131,9 +120,8 @@ sends_nick_change(void **state) assert_true(stbbr_received( "" - "" - "" - "" - "" - )); + "" + "" + "" + "")); } diff --git a/tests/functionaltests/test_roster.h b/tests/functionaltests/test_roster.h index 885dfc55..51daea81 100644 --- a/tests/functionaltests/test_roster.h +++ b/tests/functionaltests/test_roster.h @@ -1,5 +1,5 @@ -void sends_new_item(void **state); -void sends_new_item_nick(void **state); -void sends_remove_item(void **state); -void sends_remove_item_nick(void **state); -void sends_nick_change(void **state); +void sends_new_item(void** state); +void sends_new_item_nick(void** state); +void sends_remove_item(void** state); +void sends_remove_item_nick(void** state); +void sends_nick_change(void** state); diff --git a/tests/functionaltests/test_software.c b/tests/functionaltests/test_software.c index c382d290..be8f3ebd 100644 --- a/tests/functionaltests/test_software.c +++ b/tests/functionaltests/test_software.c @@ -9,72 +9,66 @@ #include "proftest.h" void -send_software_version_request(void **state) +send_software_version_request(void** state) { prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - ); + "10" + "I'm here" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); prof_input("/software buddy1@localhost/mobile"); assert_true(stbbr_received( "" - "" - "" - )); + "" + "")); } void -display_software_version_result(void **state) +display_software_version_result(void** state) { prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - ); + "10" + "I'm here" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); stbbr_for_query("jabber:iq:version", - "" - "" - "Profanity" - "0.4.7dev.master.2cb2f83" - "" - "" - ); + "" + "" + "Profanity" + "0.4.7dev.master.2cb2f83" + "" + ""); prof_input("/software buddy1@localhost/mobile"); -// assert_true(prof_output_exact("buddy1@localhost/mobile:")); -// assert_true(prof_output_exact("Name : Profanity")); + // assert_true(prof_output_exact("buddy1@localhost/mobile:")); + // assert_true(prof_output_exact("Name : Profanity")); assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83")); } void -shows_message_when_software_version_error(void **state) +shows_message_when_software_version_error(void** state) { prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - ); + "10" + "I'm here" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); stbbr_for_query("jabber:iq:version", - "" - "" - "" - "" - "" - "" - ); + "" + "" + "" + "" + "" + ""); prof_input("/software buddy1@localhost/laptop"); assert_true(prof_output_exact("Could not get software version: service-unavailable")); @@ -82,42 +76,39 @@ shows_message_when_software_version_error(void **state) // Typical use case for gateways that don't support resources void -display_software_version_result_when_from_domainpart(void **state) +display_software_version_result_when_from_domainpart(void** state) { prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - ); + "10" + "I'm here" + ""); assert_true(prof_output_exact("Buddy1 is online, \"I'm here\"")); stbbr_for_query("jabber:iq:version", - "" - "" - "Some Gateway" - "1.0" - "" - "" - ); + "" + "" + "Some Gateway" + "1.0" + "" + ""); prof_input("/software buddy1@localhost/__prof_default"); -// assert_true(prof_output_exact("buddy1@localhost/__prof_default:")); -// assert_true(prof_output_exact("Name : Some Gateway")); + // assert_true(prof_output_exact("buddy1@localhost/__prof_default:")); + // assert_true(prof_output_exact("Name : Some Gateway")); assert_true(prof_output_exact("Version : 1.0")); } void -show_message_in_chat_window_when_no_resource(void **state) +show_message_in_chat_window_when_no_resource(void** state) { prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - ); + "10" + "I'm here" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); prof_input("/msg Buddy1"); @@ -127,37 +118,34 @@ show_message_in_chat_window_when_no_resource(void **state) } void -display_software_version_result_in_chat(void **state) +display_software_version_result_in_chat(void** state) { prof_connect(); stbbr_send( "" - "10" - "I'm here" - "" - ); + "10" + "I'm here" + ""); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); prof_input("/msg Buddy1"); stbbr_send( "" - "Here's a message" - "" - ); + "Here's a message" + ""); assert_true(prof_output_exact("Here's a message")); stbbr_for_query("jabber:iq:version", - "" - "" - "Profanity" - "0.4.7dev.master.2cb2f83" - "" - "" - ); + "" + "" + "Profanity" + "0.4.7dev.master.2cb2f83" + "" + ""); prof_input("/software"); -// assert_true(prof_output_exact("buddy1@localhost/mobile:")); -// assert_true(prof_output_exact("Name : Profanity")); + // assert_true(prof_output_exact("buddy1@localhost/mobile:")); + // assert_true(prof_output_exact("Name : Profanity")); assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83")); } diff --git a/tests/functionaltests/test_software.h b/tests/functionaltests/test_software.h index 60a644fd..bae351e7 100644 --- a/tests/functionaltests/test_software.h +++ b/tests/functionaltests/test_software.h @@ -1,6 +1,6 @@ -void send_software_version_request(void **state); -void display_software_version_result(void **state); -void shows_message_when_software_version_error(void **state); -void display_software_version_result_when_from_domainpart(void **state); -void show_message_in_chat_window_when_no_resource(void **state); -void display_software_version_result_in_chat(void **state); +void send_software_version_request(void** state); +void display_software_version_result(void** state); +void shows_message_when_software_version_error(void** state); +void display_software_version_result_when_from_domainpart(void** state); +void show_message_in_chat_window_when_no_resource(void** state); +void display_software_version_result_in_chat(void** state); diff --git a/tests/unittests/test_cmd_account.c b/tests/unittests/command/test_cmd_account.c similarity index 87% rename from tests/unittests/test_cmd_account.c rename to tests/unittests/command/test_cmd_account.c index dd607408..085c089f 100644 --- a/tests/unittests/test_cmd_account.c +++ b/tests/unittests/command/test_cmd_account.c @@ -15,7 +15,7 @@ #define CMD_ACCOUNT "/account" void -cmd_account_shows_usage_when_not_connected_and_no_args(void** state) +cmd_account__shows__usage_when_not_connected_and_no_args(void** state) { gchar* args[] = { NULL }; @@ -28,7 +28,7 @@ cmd_account_shows_usage_when_not_connected_and_no_args(void** state) } void -cmd_account_shows_account_when_connected_and_no_args(void** state) +cmd_account__shows__account_when_connected_and_no_args(void** state) { ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0); @@ -46,7 +46,7 @@ cmd_account_shows_account_when_connected_and_no_args(void** state) } void -cmd_account_list_shows_accounts(void** state) +cmd_account_list__shows__accounts(void** state) { gchar* args[] = { "list", NULL }; @@ -65,7 +65,7 @@ cmd_account_list_shows_accounts(void** state) } void -cmd_account_show_shows_usage_when_no_arg(void** state) +cmd_account_show__shows__usage_when_no_arg(void** state) { gchar* args[] = { "show", NULL }; @@ -76,7 +76,7 @@ cmd_account_show_shows_usage_when_no_arg(void** state) } void -cmd_account_show_shows_message_when_account_does_not_exist(void** state) +cmd_account_show__shows__message_when_account_does_not_exist(void** state) { gchar* args[] = { "show", "account_name", NULL }; @@ -91,7 +91,7 @@ cmd_account_show_shows_message_when_account_does_not_exist(void** state) } void -cmd_account_show_shows_account_when_exists(void** state) +cmd_account_show__shows__account_when_exists(void** state) { gchar* args[] = { "show", "account_name", NULL }; ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL, @@ -107,7 +107,7 @@ cmd_account_show_shows_account_when_exists(void** state) } void -cmd_account_add_shows_usage_when_no_arg(void** state) +cmd_account_add__shows__usage_when_no_arg(void** state) { gchar* args[] = { "add", NULL }; @@ -118,7 +118,7 @@ cmd_account_add_shows_usage_when_no_arg(void** state) } void -cmd_account_add_adds_account(void** state) +cmd_account_add__updates__adds_account(void** state) { gchar* args[] = { "add", "new_account", NULL }; @@ -133,7 +133,7 @@ cmd_account_add_adds_account(void** state) } void -cmd_account_enable_shows_usage_when_no_arg(void** state) +cmd_account_enable__shows__usage_when_no_arg(void** state) { gchar* args[] = { "enable", NULL }; @@ -144,7 +144,7 @@ cmd_account_enable_shows_usage_when_no_arg(void** state) } void -cmd_account_enable_enables_account(void** state) +cmd_account_enable__updates__enables_account(void** state) { gchar* args[] = { "enable", "account_name", NULL }; @@ -159,7 +159,7 @@ cmd_account_enable_enables_account(void** state) } void -cmd_account_enable_shows_message_when_account_doesnt_exist(void** state) +cmd_account_enable__shows__message_when_account_doesnt_exist(void** state) { gchar* args[] = { "enable", "account_name", NULL }; @@ -174,7 +174,7 @@ cmd_account_enable_shows_message_when_account_doesnt_exist(void** state) } void -cmd_account_disable_shows_usage_when_no_arg(void** state) +cmd_account_disable__shows__usage_when_no_arg(void** state) { gchar* args[] = { "disable", NULL }; @@ -185,7 +185,7 @@ cmd_account_disable_shows_usage_when_no_arg(void** state) } void -cmd_account_disable_disables_account(void** state) +cmd_account_disable__updates__disables_account(void** state) { gchar* args[] = { "disable", "account_name", NULL }; @@ -200,7 +200,7 @@ cmd_account_disable_disables_account(void** state) } void -cmd_account_disable_shows_message_when_account_doesnt_exist(void** state) +cmd_account_disable__shows__message_when_account_doesnt_exist(void** state) { gchar* args[] = { "disable", "account_name", NULL }; @@ -215,7 +215,7 @@ cmd_account_disable_shows_message_when_account_doesnt_exist(void** state) } void -cmd_account_rename_shows_usage_when_no_args(void** state) +cmd_account_rename__shows__usage_when_no_args(void** state) { gchar* args[] = { "rename", NULL }; @@ -226,7 +226,7 @@ cmd_account_rename_shows_usage_when_no_args(void** state) } void -cmd_account_rename_shows_usage_when_one_arg(void** state) +cmd_account_rename__shows__usage_when_one_arg(void** state) { gchar* args[] = { "rename", "original_name", NULL }; @@ -237,7 +237,7 @@ cmd_account_rename_shows_usage_when_one_arg(void** state) } void -cmd_account_rename_renames_account(void** state) +cmd_account_rename__updates__renames_account(void** state) { gchar* args[] = { "rename", "original_name", "new_name", NULL }; @@ -253,7 +253,7 @@ cmd_account_rename_renames_account(void** state) } void -cmd_account_rename_shows_message_when_not_renamed(void** state) +cmd_account_rename__shows__message_when_not_renamed(void** state) { gchar* args[] = { "rename", "original_name", "new_name", NULL }; @@ -269,7 +269,7 @@ cmd_account_rename_shows_message_when_not_renamed(void** state) } void -cmd_account_set_shows_usage_when_no_args(void** state) +cmd_account_set__shows__usage_when_no_args(void** state) { gchar* args[] = { "set", NULL }; @@ -280,7 +280,7 @@ cmd_account_set_shows_usage_when_no_args(void** state) } void -cmd_account_set_shows_usage_when_one_arg(void** state) +cmd_account_set__shows__usage_when_one_arg(void** state) { gchar* args[] = { "set", "a_account", NULL }; @@ -291,7 +291,7 @@ cmd_account_set_shows_usage_when_one_arg(void** state) } void -cmd_account_set_shows_usage_when_two_args(void** state) +cmd_account_set__shows__usage_when_two_args(void** state) { gchar* args[] = { "set", "a_account", "a_property", NULL }; @@ -302,7 +302,7 @@ cmd_account_set_shows_usage_when_two_args(void** state) } void -cmd_account_set_shows_message_when_account_doesnt_exist(void** state) +cmd_account_set__shows__message_when_account_doesnt_exist(void** state) { gchar* args[] = { "set", "a_account", "a_property", "a_value", NULL }; @@ -317,7 +317,7 @@ cmd_account_set_shows_message_when_account_doesnt_exist(void** state) } void -cmd_account_set_jid_shows_message_for_malformed_jid(void** state) +cmd_account_set__shows__message_for_malformed_jid(void** state) { gchar* args[] = { "set", "a_account", "jid", "@malformed", NULL }; @@ -331,7 +331,7 @@ cmd_account_set_jid_shows_message_for_malformed_jid(void** state) } void -cmd_account_set_jid_sets_barejid(void** state) +cmd_account_set__updates__jid_sets_barejid(void** state) { gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL }; @@ -349,7 +349,7 @@ cmd_account_set_jid_sets_barejid(void** state) } void -cmd_account_set_jid_sets_resource(void** state) +cmd_account_set__updates__jid_sets_resource(void** state) { gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL }; @@ -372,7 +372,7 @@ cmd_account_set_jid_sets_resource(void** state) } void -cmd_account_set_server_sets_server(void** state) +cmd_account_set__updates__server_sets_server(void** state) { gchar* args[] = { "set", "a_account", "server", "a_server", NULL }; @@ -390,7 +390,7 @@ cmd_account_set_server_sets_server(void** state) } void -cmd_account_set_resource_sets_resource(void** state) +cmd_account_set__updates__resource_sets_resource(void** state) { gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL }; @@ -410,7 +410,7 @@ cmd_account_set_resource_sets_resource(void** state) } void -cmd_account_set_resource_sets_resource_with_online_message(void** state) +cmd_account_set__shows__resource_sets_resource_with_online_message(void** state) { gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL }; @@ -430,7 +430,7 @@ cmd_account_set_resource_sets_resource_with_online_message(void** state) } void -cmd_account_set_password_sets_password(void** state) +cmd_account_set__updates__password_sets_password(void** state) { gchar* args[] = { "set", "a_account", "password", "a_password", NULL }; ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, NULL, @@ -453,7 +453,7 @@ cmd_account_set_password_sets_password(void** state) } void -cmd_account_set_eval_password_sets_eval_password(void** state) +cmd_account_set__updates__eval_password_sets_eval_password(void** state) { gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL }; ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, NULL, @@ -476,7 +476,7 @@ cmd_account_set_eval_password_sets_eval_password(void** state) } void -cmd_account_set_password_when_eval_password_set(void** state) +cmd_account_set__shows__password_when_eval_password_set(void** state) { gchar* args[] = { "set", "a_account", "password", "a_password", NULL }; ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, g_strdup("a_password"), @@ -495,7 +495,7 @@ cmd_account_set_password_when_eval_password_set(void** state) } void -cmd_account_set_eval_password_when_password_set(void** state) +cmd_account_set__shows__eval_password_when_password_set(void** state) { gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL }; ProfAccount* account = account_new(g_strdup("a_account"), NULL, g_strdup("a_password"), NULL, @@ -514,7 +514,7 @@ cmd_account_set_eval_password_when_password_set(void** state) } void -cmd_account_set_muc_sets_muc(void** state) +cmd_account_set__updates__muc_sets_muc(void** state) { gchar* args[] = { "set", "a_account", "muc", "a_muc", NULL }; @@ -532,7 +532,7 @@ cmd_account_set_muc_sets_muc(void** state) } void -cmd_account_set_nick_sets_nick(void** state) +cmd_account_set__updates__nick_sets_nick(void** state) { gchar* args[] = { "set", "a_account", "nick", "a_nick", NULL }; @@ -550,7 +550,7 @@ cmd_account_set_nick_sets_nick(void** state) } void -cmd_account_show_message_for_missing_otr_policy(void** state) +cmd_account_set__shows__message_for_missing_otr_policy(void** state) { gchar* args[] = { "set", "a_account", "otr", NULL }; @@ -561,7 +561,7 @@ cmd_account_show_message_for_missing_otr_policy(void** state) } void -cmd_account_show_message_for_invalid_otr_policy(void** state) +cmd_account_set__shows__message_for_invalid_otr_policy(void** state) { gchar* args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL }; @@ -576,7 +576,7 @@ cmd_account_show_message_for_invalid_otr_policy(void** state) } void -cmd_account_set_otr_sets_otr(void** state) +cmd_account_set__updates__otr_sets_otr(void** state) { gchar* args[] = { "set", "a_account", "otr", "opportunistic", NULL }; @@ -594,7 +594,7 @@ cmd_account_set_otr_sets_otr(void** state) } void -cmd_account_set_status_shows_message_when_invalid_status(void** state) +cmd_account_set__shows__message_when_invalid_status(void** state) { gchar* args[] = { "set", "a_account", "status", "bad_status", NULL }; @@ -609,7 +609,7 @@ cmd_account_set_status_shows_message_when_invalid_status(void** state) } void -cmd_account_set_status_sets_status_when_valid(void** state) +cmd_account_set__updates__status_sets_status_when_valid(void** state) { gchar* args[] = { "set", "a_account", "status", "away", NULL }; @@ -627,7 +627,7 @@ cmd_account_set_status_sets_status_when_valid(void** state) } void -cmd_account_set_status_sets_status_when_last(void** state) +cmd_account_set__updates__status_sets_status_when_last(void** state) { gchar* args[] = { "set", "a_account", "status", "last", NULL }; @@ -645,7 +645,7 @@ cmd_account_set_status_sets_status_when_last(void** state) } void -cmd_account_set_invalid_presence_string_priority_shows_message(void** state) +cmd_account_set__shows__invalid_presence_string_priority_message(void** state) { gchar* args[] = { "set", "a_account", "blah", "10", NULL }; @@ -660,7 +660,7 @@ cmd_account_set_invalid_presence_string_priority_shows_message(void** state) } void -cmd_account_set_last_priority_shows_message(void** state) +cmd_account_set__shows__last_priority_message(void** state) { gchar* args[] = { "set", "a_account", "last", "10", NULL }; @@ -675,7 +675,7 @@ cmd_account_set_last_priority_shows_message(void** state) } void -cmd_account_set_online_priority_sets_preference(void** state) +cmd_account_set__updates__online_priority_sets_preference(void** state) { gchar* args[] = { "set", "a_account", "online", "10", NULL }; @@ -695,7 +695,7 @@ cmd_account_set_online_priority_sets_preference(void** state) } void -cmd_account_set_chat_priority_sets_preference(void** state) +cmd_account_set__updates__chat_priority_sets_preference(void** state) { gchar* args[] = { "set", "a_account", "chat", "10", NULL }; @@ -715,7 +715,7 @@ cmd_account_set_chat_priority_sets_preference(void** state) } void -cmd_account_set_away_priority_sets_preference(void** state) +cmd_account_set__updates__away_priority_sets_preference(void** state) { gchar* args[] = { "set", "a_account", "away", "10", NULL }; @@ -735,7 +735,7 @@ cmd_account_set_away_priority_sets_preference(void** state) } void -cmd_account_set_xa_priority_sets_preference(void** state) +cmd_account_set__updates__xa_priority_sets_preference(void** state) { gchar* args[] = { "set", "a_account", "xa", "10", NULL }; @@ -755,7 +755,7 @@ cmd_account_set_xa_priority_sets_preference(void** state) } void -cmd_account_set_dnd_priority_sets_preference(void** state) +cmd_account_set__updates__dnd_priority_sets_preference(void** state) { gchar* args[] = { "set", "a_account", "dnd", "10", NULL }; @@ -775,7 +775,7 @@ cmd_account_set_dnd_priority_sets_preference(void** state) } void -cmd_account_set_priority_too_low_shows_message(void** state) +cmd_account_set__shows__priority_too_low_message(void** state) { gchar* args[] = { "set", "a_account", "online", "-150", NULL }; @@ -789,7 +789,7 @@ cmd_account_set_priority_too_low_shows_message(void** state) } void -cmd_account_set_priority_too_high_shows_message(void** state) +cmd_account_set__shows__priority_too_high_message(void** state) { gchar* args[] = { "set", "a_account", "online", "150", NULL }; @@ -803,7 +803,7 @@ cmd_account_set_priority_too_high_shows_message(void** state) } void -cmd_account_set_priority_when_not_number_shows_message(void** state) +cmd_account_set__shows__priority_when_not_number_message(void** state) { gchar* args[] = { "set", "a_account", "online", "abc", NULL }; @@ -817,7 +817,7 @@ cmd_account_set_priority_when_not_number_shows_message(void** state) } void -cmd_account_set_priority_when_empty_shows_message(void** state) +cmd_account_set__shows__priority_when_empty_message(void** state) { gchar* args[] = { "set", "a_account", "online", "", NULL }; @@ -831,7 +831,7 @@ cmd_account_set_priority_when_empty_shows_message(void** state) } void -cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void** state) +cmd_account_set__updates__priority_updates_presence_when_connected(void** state) { gchar* args[] = { "set", "a_account", "online", "10", NULL }; @@ -868,7 +868,7 @@ cmd_account_set_priority_updates_presence_when_account_connected_with_presence(v } void -cmd_account_clear_shows_usage_when_no_args(void** state) +cmd_account_clear__shows__usage_when_no_args(void** state) { gchar* args[] = { "clear", NULL }; @@ -879,7 +879,7 @@ cmd_account_clear_shows_usage_when_no_args(void** state) } void -cmd_account_clear_shows_usage_when_one_arg(void** state) +cmd_account_clear__shows__usage_when_one_arg(void** state) { gchar* args[] = { "clear", "a_account", NULL }; @@ -890,7 +890,7 @@ cmd_account_clear_shows_usage_when_one_arg(void** state) } void -cmd_account_clear_shows_message_when_account_doesnt_exist(void** state) +cmd_account_clear__shows__message_when_account_doesnt_exist(void** state) { gchar* args[] = { "clear", "a_account", "a_property", NULL }; @@ -905,7 +905,7 @@ cmd_account_clear_shows_message_when_account_doesnt_exist(void** state) } void -cmd_account_clear_shows_message_when_invalid_property(void** state) +cmd_account_clear__shows__message_when_invalid_property(void** state) { gchar* args[] = { "clear", "a_account", "badproperty", NULL }; diff --git a/tests/unittests/command/test_cmd_account.h b/tests/unittests/command/test_cmd_account.h new file mode 100644 index 00000000..65fc0c32 --- /dev/null +++ b/tests/unittests/command/test_cmd_account.h @@ -0,0 +1,61 @@ +#ifndef TESTS_TEST_CMD_ACCOUNT_H +#define TESTS_TEST_CMD_ACCOUNT_H + +void cmd_account__shows__usage_when_not_connected_and_no_args(void** state); +void cmd_account__shows__account_when_connected_and_no_args(void** state); +void cmd_account_list__shows__accounts(void** state); +void cmd_account_show__shows__usage_when_no_arg(void** state); +void cmd_account_show__shows__message_when_account_does_not_exist(void** state); +void cmd_account_show__shows__account_when_exists(void** state); +void cmd_account_add__shows__usage_when_no_arg(void** state); +void cmd_account_add__updates__adds_account(void** state); +void cmd_account_enable__shows__usage_when_no_arg(void** state); +void cmd_account_enable__updates__enables_account(void** state); +void cmd_account_enable__shows__message_when_account_doesnt_exist(void** state); +void cmd_account_disable__shows__usage_when_no_arg(void** state); +void cmd_account_disable__updates__disables_account(void** state); +void cmd_account_disable__shows__message_when_account_doesnt_exist(void** state); +void cmd_account_rename__shows__usage_when_no_args(void** state); +void cmd_account_rename__shows__usage_when_one_arg(void** state); +void cmd_account_rename__updates__renames_account(void** state); +void cmd_account_rename__shows__message_when_not_renamed(void** state); +void cmd_account_set__shows__usage_when_no_args(void** state); +void cmd_account_set__shows__usage_when_one_arg(void** state); +void cmd_account_set__shows__usage_when_two_args(void** state); +void cmd_account_set__shows__message_when_account_doesnt_exist(void** state); +void cmd_account_set__shows__message_for_malformed_jid(void** state); +void cmd_account_set__updates__jid_sets_barejid(void** state); +void cmd_account_set__updates__jid_sets_resource(void** state); +void cmd_account_set__updates__server_sets_server(void** state); +void cmd_account_set__updates__resource_sets_resource(void** state); +void cmd_account_set__shows__resource_sets_resource_with_online_message(void** state); +void cmd_account_set__updates__password_sets_password(void** state); +void cmd_account_set__updates__eval_password_sets_eval_password(void** state); +void cmd_account_set__shows__password_when_eval_password_set(void** state); +void cmd_account_set__shows__eval_password_when_password_set(void** state); +void cmd_account_set__updates__muc_sets_muc(void** state); +void cmd_account_set__updates__nick_sets_nick(void** state); +void cmd_account_set__shows__message_for_missing_otr_policy(void** state); +void cmd_account_set__shows__message_for_invalid_otr_policy(void** state); +void cmd_account_set__updates__otr_sets_otr(void** state); +void cmd_account_set__shows__message_when_invalid_status(void** state); +void cmd_account_set__updates__status_sets_status_when_valid(void** state); +void cmd_account_set__updates__status_sets_status_when_last(void** state); +void cmd_account_set__shows__invalid_presence_string_priority_message(void** state); +void cmd_account_set__shows__last_priority_message(void** state); +void cmd_account_set__updates__online_priority_sets_preference(void** state); +void cmd_account_set__updates__chat_priority_sets_preference(void** state); +void cmd_account_set__updates__away_priority_sets_preference(void** state); +void cmd_account_set__updates__xa_priority_sets_preference(void** state); +void cmd_account_set__updates__dnd_priority_sets_preference(void** state); +void cmd_account_set__shows__priority_too_low_message(void** state); +void cmd_account_set__shows__priority_too_high_message(void** state); +void cmd_account_set__shows__priority_when_not_number_message(void** state); +void cmd_account_set__shows__priority_when_empty_message(void** state); +void cmd_account_set__updates__priority_updates_presence_when_connected(void** state); +void cmd_account_clear__shows__usage_when_no_args(void** state); +void cmd_account_clear__shows__usage_when_one_arg(void** state); +void cmd_account_clear__shows__message_when_account_doesnt_exist(void** state); +void cmd_account_clear__shows__message_when_invalid_property(void** state); + +#endif diff --git a/tests/unittests/test_cmd_alias.c b/tests/unittests/command/test_cmd_alias.c similarity index 84% rename from tests/unittests/test_cmd_alias.c rename to tests/unittests/command/test_cmd_alias.c index 69081012..ee9df0f7 100644 --- a/tests/unittests/test_cmd_alias.c +++ b/tests/unittests/command/test_cmd_alias.c @@ -17,7 +17,7 @@ #define CMD_ALIAS "/alias" void -cmd_alias_add_shows_usage_when_no_args(void** state) +cmd_alias__shows__usage_when_add_no_args(void** state) { gchar* args[] = { "add", NULL }; @@ -28,7 +28,7 @@ cmd_alias_add_shows_usage_when_no_args(void** state) } void -cmd_alias_add_shows_usage_when_no_value(void** state) +cmd_alias__shows__usage_when_add_no_value(void** state) { gchar* args[] = { "add", "alias", NULL }; @@ -39,7 +39,7 @@ cmd_alias_add_shows_usage_when_no_value(void** state) } void -cmd_alias_remove_shows_usage_when_no_args(void** state) +cmd_alias__shows__usage_when_remove_no_args(void** state) { gchar* args[] = { "remove", NULL }; @@ -50,7 +50,7 @@ cmd_alias_remove_shows_usage_when_no_args(void** state) } void -cmd_alias_show_usage_when_invalid_subcmd(void** state) +cmd_alias__shows__usage_when_invalid_subcmd(void** state) { gchar* args[] = { "blah", NULL }; @@ -61,7 +61,7 @@ cmd_alias_show_usage_when_invalid_subcmd(void** state) } void -cmd_alias_add_adds_alias(void** state) +cmd_alias__updates__adds_alias(void** state) { gchar* args[] = { "add", "hc", "/help commands", NULL }; @@ -77,7 +77,7 @@ cmd_alias_add_adds_alias(void** state) } void -cmd_alias_add_shows_message_when_exists(void** state) +cmd_alias__shows__message_when_add_exists(void** state) { gchar* args[] = { "add", "hc", "/help commands", NULL }; @@ -91,7 +91,7 @@ cmd_alias_add_shows_message_when_exists(void** state) } void -cmd_alias_remove_removes_alias(void** state) +cmd_alias__updates__removes_alias(void** state) { gchar* args[] = { "remove", "hn", NULL }; @@ -109,7 +109,7 @@ cmd_alias_remove_removes_alias(void** state) } void -cmd_alias_remove_shows_message_when_no_alias(void** state) +cmd_alias__shows__message_when_remove_no_alias(void** state) { gchar* args[] = { "remove", "hn", NULL }; @@ -120,7 +120,7 @@ cmd_alias_remove_shows_message_when_no_alias(void** state) } void -cmd_alias_list_shows_all_aliases(void** state) +cmd_alias__shows__all_aliases(void** state) { gchar* args[] = { "list", NULL }; diff --git a/tests/unittests/command/test_cmd_alias.h b/tests/unittests/command/test_cmd_alias.h new file mode 100644 index 00000000..d3bae139 --- /dev/null +++ b/tests/unittests/command/test_cmd_alias.h @@ -0,0 +1,14 @@ +#ifndef TESTS_TEST_CMD_ALIAS_H +#define TESTS_TEST_CMD_ALIAS_H + +void cmd_alias__shows__usage_when_add_no_args(void** state); +void cmd_alias__shows__usage_when_add_no_value(void** state); +void cmd_alias__shows__usage_when_remove_no_args(void** state); +void cmd_alias__shows__usage_when_invalid_subcmd(void** state); +void cmd_alias__updates__adds_alias(void** state); +void cmd_alias__shows__message_when_add_exists(void** state); +void cmd_alias__updates__removes_alias(void** state); +void cmd_alias__shows__message_when_remove_no_alias(void** state); +void cmd_alias__shows__all_aliases(void** state); + +#endif diff --git a/tests/unittests/test_cmd_bookmark.c b/tests/unittests/command/test_cmd_bookmark.c similarity index 90% rename from tests/unittests/test_cmd_bookmark.c rename to tests/unittests/command/test_cmd_bookmark.c index 849561ba..cb7c2d42 100644 --- a/tests/unittests/test_cmd_bookmark.c +++ b/tests/unittests/command/test_cmd_bookmark.c @@ -32,25 +32,25 @@ test_with_connection_status(jabber_conn_status_t status) } void -cmd_bookmark_shows_message_when_disconnected(void** state) +cmd_bookmark__shows__message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } void -cmd_bookmark_shows_message_when_disconnecting(void** state) +cmd_bookmark__shows__message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } void -cmd_bookmark_shows_message_when_connecting(void** state) +cmd_bookmark__shows__message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } void -cmd_bookmark_shows_usage_when_no_args(void** state) +cmd_bookmark__shows__usage_when_no_args(void** state) { gchar* args[] = { NULL }; ProfWin window; @@ -90,7 +90,7 @@ _cmp_bookmark(Bookmark* bm1, Bookmark* bm2) } void -cmd_bookmark_list_shows_bookmarks(void** state) +cmd_bookmark_list__shows__bookmarks(void** state) { gchar* args[] = { "list", NULL }; GList* bookmarks = NULL; @@ -152,7 +152,7 @@ cmd_bookmark_list_shows_bookmarks(void** state) } void -cmd_bookmark_add_shows_message_when_invalid_jid(void** state) +cmd_bookmark_add__shows__message_when_invalid_jid(void** state) { char* jid = "room"; gchar* args[] = { "add", jid, NULL }; @@ -169,7 +169,7 @@ cmd_bookmark_add_shows_message_when_invalid_jid(void** state) } void -cmd_bookmark_add_adds_bookmark_with_jid(void** state) +cmd_bookmark_add__updates__bookmark_with_jid(void** state) { char* jid = "room@conf.server"; gchar* args[] = { "add", jid, NULL }; @@ -191,7 +191,7 @@ cmd_bookmark_add_adds_bookmark_with_jid(void** state) } void -cmd_bookmark_uses_roomjid_in_room(void** state) +cmd_bookmark__tests__uses_roomjid_in_room(void** state) { gchar* args[] = { NULL }; ProfMucWin muc_win; @@ -214,7 +214,7 @@ cmd_bookmark_uses_roomjid_in_room(void** state) } void -cmd_bookmark_add_uses_roomjid_in_room(void** state) +cmd_bookmark_add__tests__uses_roomjid_in_room(void** state) { gchar* args[] = { "add", NULL }; ProfMucWin muc_win; @@ -237,7 +237,7 @@ cmd_bookmark_add_uses_roomjid_in_room(void** state) } void -cmd_bookmark_add_uses_supplied_jid_in_room(void** state) +cmd_bookmark_add__tests__uses_supplied_jid_in_room(void** state) { char* jid = "room1@conf.server"; gchar* args[] = { "add", jid, NULL }; @@ -261,7 +261,7 @@ cmd_bookmark_add_uses_supplied_jid_in_room(void** state) } void -cmd_bookmark_add_adds_bookmark_with_jid_nick(void** state) +cmd_bookmark_add__updates__bookmark_with_jid_nick(void** state) { char* jid = "room@conf.server"; char* nick = "bob"; @@ -284,7 +284,7 @@ cmd_bookmark_add_adds_bookmark_with_jid_nick(void** state) } void -cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void** state) +cmd_bookmark_add__updates__bookmark_with_jid_autojoin(void** state) { char* jid = "room@conf.server"; gchar* args[] = { "add", jid, "autojoin", "on", NULL }; @@ -306,7 +306,7 @@ cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void** state) } void -cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void** state) +cmd_bookmark_add__updates__bookmark_with_jid_nick_autojoin(void** state) { char* jid = "room@conf.server"; char* nick = "bob"; @@ -329,7 +329,7 @@ cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void** state) } void -cmd_bookmark_remove_removes_bookmark(void** state) +cmd_bookmark_remove__updates__removes_bookmark(void** state) { char* jid = "room@conf.server"; gchar* args[] = { "remove", jid, NULL }; @@ -348,7 +348,7 @@ cmd_bookmark_remove_removes_bookmark(void** state) } void -cmd_bookmark_remove_shows_message_when_no_bookmark(void** state) +cmd_bookmark_remove__shows__message_when_no_bookmark(void** state) { char* jid = "room@conf.server"; gchar* args[] = { "remove", jid, NULL }; @@ -367,7 +367,7 @@ cmd_bookmark_remove_shows_message_when_no_bookmark(void** state) } void -cmd_bookmark_remove_uses_roomjid_in_room(void** state) +cmd_bookmark_remove__tests__uses_roomjid_in_room(void** state) { gchar* args[] = { "remove", NULL }; ProfMucWin muc_win; @@ -387,7 +387,7 @@ cmd_bookmark_remove_uses_roomjid_in_room(void** state) } void -cmd_bookmark_remove_uses_supplied_jid_in_room(void** state) +cmd_bookmark_remove__tests__uses_supplied_jid_in_room(void** state) { char* jid = "room1@conf.server"; gchar* args[] = { "remove", jid, NULL }; diff --git a/tests/unittests/command/test_cmd_bookmark.h b/tests/unittests/command/test_cmd_bookmark.h new file mode 100644 index 00000000..b6e9cbd1 --- /dev/null +++ b/tests/unittests/command/test_cmd_bookmark.h @@ -0,0 +1,23 @@ +#ifndef TESTS_TEST_CMD_BOOKMARK_H +#define TESTS_TEST_CMD_BOOKMARK_H + +void cmd_bookmark__shows__message_when_disconnected(void** state); +void cmd_bookmark__shows__message_when_disconnecting(void** state); +void cmd_bookmark__shows__message_when_connecting(void** state); +void cmd_bookmark__shows__message_when_undefined(void** state); +void cmd_bookmark__shows__usage_when_no_args(void** state); +void cmd_bookmark_list__shows__bookmarks(void** state); +void cmd_bookmark_add__shows__message_when_invalid_jid(void** state); +void cmd_bookmark_add__updates__bookmark_with_jid(void** state); +void cmd_bookmark__tests__uses_roomjid_in_room(void** state); +void cmd_bookmark_add__tests__uses_roomjid_in_room(void** state); +void cmd_bookmark_add__tests__uses_supplied_jid_in_room(void** state); +void cmd_bookmark_remove__tests__uses_roomjid_in_room(void** state); +void cmd_bookmark_remove__tests__uses_supplied_jid_in_room(void** state); +void cmd_bookmark_add__updates__bookmark_with_jid_nick(void** state); +void cmd_bookmark_add__updates__bookmark_with_jid_autojoin(void** state); +void cmd_bookmark_add__updates__bookmark_with_jid_nick_autojoin(void** state); +void cmd_bookmark_remove__updates__removes_bookmark(void** state); +void cmd_bookmark_remove__shows__message_when_no_bookmark(void** state); + +#endif diff --git a/tests/unittests/test_cmd_connect.c b/tests/unittests/command/test_cmd_connect.c similarity index 89% rename from tests/unittests/test_cmd_connect.c rename to tests/unittests/command/test_cmd_connect.c index be37ef07..6ebc7d0e 100644 --- a/tests/unittests/test_cmd_connect.c +++ b/tests/unittests/command/test_cmd_connect.c @@ -25,25 +25,25 @@ test_with_connection_status(jabber_conn_status_t status) } void -cmd_connect_shows_message_when_disconnecting(void** state) +cmd_connect__shows__message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } void -cmd_connect_shows_message_when_connecting(void** state) +cmd_connect__shows__message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } void -cmd_connect_shows_message_when_connected(void** state) +cmd_connect__shows__message_when_connected(void** state) { test_with_connection_status(JABBER_CONNECTED); } void -cmd_connect_when_no_account(void** state) +cmd_connect__tests__no_account(void** state) { gchar* args[] = { "user@server.org", NULL }; @@ -67,7 +67,7 @@ cmd_connect_when_no_account(void** state) } void -cmd_connect_fail_message(void** state) +cmd_connect__shows__fail_message(void** state) { gchar* args[] = { "user@server.org", NULL }; @@ -93,7 +93,7 @@ cmd_connect_fail_message(void** state) } void -cmd_connect_lowercases_argument_with_no_account(void** state) +cmd_connect__tests__lowercases_argument_with_no_account(void** state) { gchar* args[] = { "USER@server.ORG", NULL }; @@ -117,7 +117,7 @@ cmd_connect_lowercases_argument_with_no_account(void** state) } void -cmd_connect_lowercases_argument_with_account(void** state) +cmd_connect__tests__lowercases_argument_with_account(void** state) { gchar* args[] = { "Jabber_org", NULL }; ProfAccount* account = account_new(g_strdup("Jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), NULL, @@ -138,7 +138,7 @@ cmd_connect_lowercases_argument_with_account(void** state) } void -cmd_connect_asks_password_when_not_in_account(void** state) +cmd_connect__tests__asks_password_when_not_in_account(void** state) { gchar* args[] = { "jabber_org", NULL }; ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL, @@ -161,7 +161,7 @@ cmd_connect_asks_password_when_not_in_account(void** state) } void -cmd_connect_shows_usage_when_no_server_value(void** state) +cmd_connect__shows__usage_when_no_server_value(void** state) { gchar* args[] = { "user@server.org", "server", NULL }; @@ -175,7 +175,7 @@ cmd_connect_shows_usage_when_no_server_value(void** state) } void -cmd_connect_shows_usage_when_server_no_port_value(void** state) +cmd_connect__shows__usage_when_server_no_port_value(void** state) { gchar* args[] = { "user@server.org", "server", "aserver", "port", NULL }; @@ -189,7 +189,7 @@ cmd_connect_shows_usage_when_server_no_port_value(void** state) } void -cmd_connect_shows_usage_when_no_port_value(void** state) +cmd_connect__shows__usage_when_no_port_value(void** state) { gchar* args[] = { "user@server.org", "port", NULL }; @@ -203,7 +203,7 @@ cmd_connect_shows_usage_when_no_port_value(void** state) } void -cmd_connect_shows_usage_when_port_no_server_value(void** state) +cmd_connect__shows__usage_when_port_no_server_value(void** state) { gchar* args[] = { "user@server.org", "port", "5678", "server", NULL }; @@ -217,7 +217,7 @@ cmd_connect_shows_usage_when_port_no_server_value(void** state) } void -cmd_connect_shows_message_when_port_0(void** state) +cmd_connect__shows__message_when_port_0(void** state) { gchar* args[] = { "user@server.org", "port", "0", NULL }; @@ -231,7 +231,7 @@ cmd_connect_shows_message_when_port_0(void** state) } void -cmd_connect_shows_message_when_port_minus1(void** state) +cmd_connect__shows__message_when_port_minus1(void** state) { gchar* args[] = { "user@server.org", "port", "-1", NULL }; @@ -245,7 +245,7 @@ cmd_connect_shows_message_when_port_minus1(void** state) } void -cmd_connect_shows_message_when_port_65536(void** state) +cmd_connect__shows__message_when_port_65536(void** state) { gchar* args[] = { "user@server.org", "port", "65536", NULL }; @@ -259,7 +259,7 @@ cmd_connect_shows_message_when_port_65536(void** state) } void -cmd_connect_shows_message_when_port_contains_chars(void** state) +cmd_connect__shows__message_when_port_contains_chars(void** state) { gchar* args[] = { "user@server.org", "port", "52f66", NULL }; @@ -273,7 +273,7 @@ cmd_connect_shows_message_when_port_contains_chars(void** state) } void -cmd_connect_shows_usage_when_server_provided_twice(void** state) +cmd_connect__shows__usage_when_server_provided_twice(void** state) { gchar* args[] = { "user@server.org", "server", "server1", "server", "server2", NULL }; @@ -287,7 +287,7 @@ cmd_connect_shows_usage_when_server_provided_twice(void** state) } void -cmd_connect_shows_usage_when_port_provided_twice(void** state) +cmd_connect__shows__usage_when_port_provided_twice(void** state) { gchar* args[] = { "user@server.org", "port", "1111", "port", "1111", NULL }; @@ -301,7 +301,7 @@ cmd_connect_shows_usage_when_port_provided_twice(void** state) } void -cmd_connect_shows_usage_when_invalid_first_property(void** state) +cmd_connect__shows__usage_when_invalid_first_property(void** state) { gchar* args[] = { "user@server.org", "wrong", "server", NULL }; @@ -315,7 +315,7 @@ cmd_connect_shows_usage_when_invalid_first_property(void** state) } void -cmd_connect_shows_usage_when_invalid_second_property(void** state) +cmd_connect__shows__usage_when_invalid_second_property(void** state) { gchar* args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL }; @@ -329,7 +329,7 @@ cmd_connect_shows_usage_when_invalid_second_property(void** state) } void -cmd_connect_with_server_when_provided(void** state) +cmd_connect__tests__with_server_when_provided(void** state) { gchar* args[] = { "user@server.org", "server", "aserver", NULL }; @@ -353,7 +353,7 @@ cmd_connect_with_server_when_provided(void** state) } void -cmd_connect_with_port_when_provided(void** state) +cmd_connect__tests__with_port_when_provided(void** state) { gchar* args[] = { "user@server.org", "port", "5432", NULL }; @@ -377,7 +377,7 @@ cmd_connect_with_port_when_provided(void** state) } void -cmd_connect_with_server_and_port_when_provided(void** state) +cmd_connect__tests__with_server_and_port_when_provided(void** state) { gchar* args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL }; @@ -401,7 +401,7 @@ cmd_connect_with_server_and_port_when_provided(void** state) } void -cmd_connect_shows_message_when_connecting_with_account(void** state) +cmd_connect__shows__message_when_connecting_with_account(void** state) { gchar* args[] = { "jabber_org", NULL }; ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("user@jabber.org"), g_strdup("password"), NULL, @@ -422,7 +422,7 @@ cmd_connect_shows_message_when_connecting_with_account(void** state) } void -cmd_connect_connects_with_account(void** state) +cmd_connect__tests__connects_with_account(void** state) { gchar* args[] = { "jabber_org", NULL }; ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), NULL, diff --git a/tests/unittests/command/test_cmd_connect.h b/tests/unittests/command/test_cmd_connect.h new file mode 100644 index 00000000..a3968b9c --- /dev/null +++ b/tests/unittests/command/test_cmd_connect.h @@ -0,0 +1,32 @@ +#ifndef TESTS_TEST_CMD_CONNECT_H +#define TESTS_TEST_CMD_CONNECT_H + +void cmd_connect__shows__message_when_disconnecting(void** state); +void cmd_connect__shows__message_when_connecting(void** state); +void cmd_connect__shows__message_when_connected(void** state); +void cmd_connect__shows__message_when_undefined(void** state); +void cmd_connect__tests__no_account(void** state); +void cmd_connect__tests__with_altdomain_when_provided(void** state); +void cmd_connect__shows__fail_message(void** state); +void cmd_connect__tests__lowercases_argument_with_no_account(void** state); +void cmd_connect__tests__lowercases_argument_with_account(void** state); +void cmd_connect__tests__asks_password_when_not_in_account(void** state); +void cmd_connect__shows__message_when_connecting_with_account(void** state); +void cmd_connect__tests__connects_with_account(void** state); +void cmd_connect__shows__usage_when_no_server_value(void** state); +void cmd_connect__shows__usage_when_server_no_port_value(void** state); +void cmd_connect__shows__usage_when_no_port_value(void** state); +void cmd_connect__shows__usage_when_port_no_server_value(void** state); +void cmd_connect__shows__message_when_port_0(void** state); +void cmd_connect__shows__message_when_port_minus1(void** state); +void cmd_connect__shows__message_when_port_65536(void** state); +void cmd_connect__shows__message_when_port_contains_chars(void** state); +void cmd_connect__tests__with_server_when_provided(void** state); +void cmd_connect__tests__with_port_when_provided(void** state); +void cmd_connect__tests__with_server_and_port_when_provided(void** state); +void cmd_connect__shows__usage_when_server_provided_twice(void** state); +void cmd_connect__shows__usage_when_port_provided_twice(void** state); +void cmd_connect__shows__usage_when_invalid_first_property(void** state); +void cmd_connect__shows__usage_when_invalid_second_property(void** state); + +#endif diff --git a/tests/unittests/test_cmd_disconnect.c b/tests/unittests/command/test_cmd_disconnect.c similarity index 93% rename from tests/unittests/test_cmd_disconnect.c rename to tests/unittests/command/test_cmd_disconnect.c index e524577a..d621ceaf 100644 --- a/tests/unittests/test_cmd_disconnect.c +++ b/tests/unittests/command/test_cmd_disconnect.c @@ -12,7 +12,7 @@ #define CMD_DISCONNECT "/disconnect" void -clears_chat_sessions(void** state) +cmd_disconnect__updates__clears_chat_sessions(void** state) { chat_sessions_init(); roster_create(); diff --git a/tests/unittests/command/test_cmd_disconnect.h b/tests/unittests/command/test_cmd_disconnect.h new file mode 100644 index 00000000..757714ec --- /dev/null +++ b/tests/unittests/command/test_cmd_disconnect.h @@ -0,0 +1,6 @@ +#ifndef TESTS_TEST_CMD_DISCONNECT_H +#define TESTS_TEST_CMD_DISCONNECT_H + +void cmd_disconnect__updates__clears_chat_sessions(void** state); + +#endif diff --git a/tests/unittests/test_cmd_join.c b/tests/unittests/command/test_cmd_join.c similarity index 91% rename from tests/unittests/test_cmd_join.c rename to tests/unittests/command/test_cmd_join.c index 75440332..563d7f14 100644 --- a/tests/unittests/test_cmd_join.c +++ b/tests/unittests/command/test_cmd_join.c @@ -27,25 +27,25 @@ test_with_connection_status(jabber_conn_status_t status) } void -cmd_join_shows_message_when_disconnecting(void** state) +cmd_join__shows__message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } void -cmd_join_shows_message_when_connecting(void** state) +cmd_join__shows__message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } void -cmd_join_shows_message_when_disconnected(void** state) +cmd_join__shows__message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } void -cmd_join_shows_error_message_when_invalid_room_jid(void** state) +cmd_join__shows__error_message_when_invalid_room_jid(void** state) { gchar* args[] = { "//@@/", NULL }; @@ -59,7 +59,7 @@ cmd_join_shows_error_message_when_invalid_room_jid(void** state) } void -cmd_join_uses_account_mucservice_when_no_service_specified(void** state) +cmd_join__tests__uses_account_mucservice_when_no_service_specified(void** state) { gchar* account_name = g_strdup("an_account"); char* room = "room"; @@ -85,7 +85,7 @@ cmd_join_uses_account_mucservice_when_no_service_specified(void** state) } void -cmd_join_uses_supplied_nick(void** state) +cmd_join__tests__uses_supplied_nick(void** state) { gchar* account_name = g_strdup("an_account"); char* room = "room@conf.server.org"; @@ -109,7 +109,7 @@ cmd_join_uses_supplied_nick(void** state) } void -cmd_join_uses_account_nick_when_not_supplied(void** state) +cmd_join__tests__uses_account_nick_when_not_supplied(void** state) { gchar* account_name = g_strdup("an_account"); char* room = "room2@conf.server.org"; @@ -133,7 +133,7 @@ cmd_join_uses_account_nick_when_not_supplied(void** state) } void -cmd_join_uses_password_when_supplied(void** state) +cmd_join__tests__uses_password_when_supplied(void** state) { gchar* account_name = g_strdup("an_account"); char* room = "room"; diff --git a/tests/unittests/command/test_cmd_join.h b/tests/unittests/command/test_cmd_join.h new file mode 100644 index 00000000..d5b282a3 --- /dev/null +++ b/tests/unittests/command/test_cmd_join.h @@ -0,0 +1,14 @@ +#ifndef TESTS_TEST_CMD_JOIN_H +#define TESTS_TEST_CMD_JOIN_H + +void cmd_join__shows__message_when_disconnecting(void** state); +void cmd_join__shows__message_when_connecting(void** state); +void cmd_join__shows__message_when_disconnected(void** state); +void cmd_join__shows__message_when_undefined(void** state); +void cmd_join__shows__error_message_when_invalid_room_jid(void** state); +void cmd_join__tests__uses_account_mucservice_when_no_service_specified(void** state); +void cmd_join__tests__uses_supplied_nick(void** state); +void cmd_join__tests__uses_account_nick_when_not_supplied(void** state); +void cmd_join__tests__uses_password_when_supplied(void** state); + +#endif diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/command/test_cmd_otr.c similarity index 86% rename from tests/unittests/test_cmd_otr.c rename to tests/unittests/command/test_cmd_otr.c index 832f5e2f..465eece5 100644 --- a/tests/unittests/test_cmd_otr.c +++ b/tests/unittests/command/test_cmd_otr.c @@ -24,7 +24,7 @@ #ifdef HAVE_LIBOTR void -cmd_otr_log_shows_usage_when_no_args(void** state) +cmd_otr_log__shows__usage_when_no_args(void** state) { gchar* args[] = { "log", NULL }; @@ -35,7 +35,7 @@ cmd_otr_log_shows_usage_when_no_args(void** state) } void -cmd_otr_log_shows_usage_when_invalid_subcommand(void** state) +cmd_otr_log__shows__usage_when_invalid_subcommand(void** state) { gchar* args[] = { "log", "wrong", NULL }; @@ -46,7 +46,7 @@ cmd_otr_log_shows_usage_when_invalid_subcommand(void** state) } void -cmd_otr_log_on_enables_logging(void** state) +cmd_otr_log__updates__enables_logging(void** state) { gchar* args[] = { "log", "on", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); @@ -62,7 +62,7 @@ cmd_otr_log_on_enables_logging(void** state) } void -cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state) +cmd_otr_log__shows__warning_when_chlog_disabled(void** state) { gchar* args[] = { "log", "on", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); @@ -76,7 +76,7 @@ cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state) } void -cmd_otr_log_off_disables_logging(void** state) +cmd_otr_log__updates__disables_logging(void** state) { gchar* args[] = { "log", "off", NULL }; prefs_set_string(PREF_OTR_LOG, "on"); @@ -92,7 +92,7 @@ cmd_otr_log_off_disables_logging(void** state) } void -cmd_otr_redact_redacts_logging(void** state) +cmd_otr_log__updates__redacts_logging(void** state) { gchar* args[] = { "log", "redact", NULL }; prefs_set_string(PREF_OTR_LOG, "on"); @@ -108,7 +108,7 @@ cmd_otr_redact_redacts_logging(void** state) } void -cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state) +cmd_otr_log__shows__redact_warning_when_chlog_disabled(void** state) { gchar* args[] = { "log", "redact", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); @@ -122,7 +122,7 @@ cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state) } void -cmd_otr_libver_shows_libotr_version(void** state) +cmd_otr_libver__shows__libotr_version(void** state) { gchar* args[] = { "libver", NULL }; char* version = "9.9.9"; @@ -140,7 +140,7 @@ cmd_otr_libver_shows_libotr_version(void** state) } void -cmd_otr_gen_shows_message_when_not_connected(void** state) +cmd_otr_gen__shows__message_when_not_connected(void** state) { gchar* args[] = { "gen", NULL }; @@ -167,25 +167,25 @@ test_with_command_and_connection_status(char* command, void* cmd_func, jabber_co } void -cmd_otr_gen_shows_message_when_disconnected(void** state) +cmd_otr_gen__shows__message_when_disconnected(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTED); } void -cmd_otr_gen_shows_message_when_connecting(void** state) +cmd_otr_gen__shows__message_when_connecting(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_CONNECTING); } void -cmd_otr_gen_shows_message_when_disconnecting(void** state) +cmd_otr_gen__shows__message_when_disconnecting(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTING); } void -cmd_otr_gen_generates_key_for_connected_account(void** state) +cmd_otr_gen__tests__generates_key_for_connected_account(void** state) { gchar* args[] = { "gen", NULL }; gchar* account_name = g_strdup("myaccount"); @@ -206,25 +206,25 @@ cmd_otr_gen_generates_key_for_connected_account(void** state) } void -cmd_otr_myfp_shows_message_when_disconnected(void** state) +cmd_otr_myfp__shows__message_when_disconnected(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTED); } void -cmd_otr_myfp_shows_message_when_connecting(void** state) +cmd_otr_myfp__shows__message_when_connecting(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_CONNECTING); } void -cmd_otr_myfp_shows_message_when_disconnecting(void** state) +cmd_otr_myfp__shows__message_when_disconnecting(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTING); } void -cmd_otr_myfp_shows_message_when_no_key(void** state) +cmd_otr_myfp__shows__message_when_no_key(void** state) { gchar* args[] = { "myfp", NULL }; @@ -238,7 +238,7 @@ cmd_otr_myfp_shows_message_when_no_key(void** state) } void -cmd_otr_myfp_shows_my_fingerprint(void** state) +cmd_otr_myfp__shows__my_fingerprint(void** state) { char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; gchar* args[] = { "myfp", NULL }; @@ -277,25 +277,25 @@ test_cmd_otr_theirfp_from_wintype(win_type_t wintype) } void -cmd_otr_theirfp_shows_message_when_in_console(void** state) +cmd_otr_theirfp__shows__message_when_in_console(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_CONSOLE); } void -cmd_otr_theirfp_shows_message_when_in_muc(void** state) +cmd_otr_theirfp__shows__message_when_in_muc(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_MUC); } void -cmd_otr_theirfp_shows_message_when_in_private(void** state) +cmd_otr_theirfp__shows__message_when_in_private(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_PRIVATE); } void -cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state) +cmd_otr_theirfp__shows__message_when_non_otr_chat_window(void** state) { gchar* args[] = { "theirfp", NULL }; @@ -320,7 +320,7 @@ cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state) } void -cmd_otr_theirfp_shows_fingerprint(void** state) +cmd_otr_theirfp__shows__fingerprint(void** state) { char* recipient = "someone@chat.com"; char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; @@ -373,25 +373,25 @@ test_cmd_otr_start_from_wintype(win_type_t wintype) } void -cmd_otr_start_shows_message_when_in_console(void** state) +cmd_otr_start__shows__message_when_in_console(void** state) { test_cmd_otr_start_from_wintype(WIN_CONSOLE); } void -cmd_otr_start_shows_message_when_in_muc(void** state) +cmd_otr_start__shows__message_when_in_muc(void** state) { test_cmd_otr_start_from_wintype(WIN_MUC); } void -cmd_otr_start_shows_message_when_in_private(void** state) +cmd_otr_start__shows__message_when_in_private(void** state) { test_cmd_otr_start_from_wintype(WIN_PRIVATE); } void -cmd_otr_start_shows_message_when_already_started(void** state) +cmd_otr_start__shows__message_when_already_started(void** state) { char* recipient = "someone@server.org"; gchar* args[] = { "start", NULL }; @@ -417,7 +417,7 @@ cmd_otr_start_shows_message_when_already_started(void** state) } void -cmd_otr_start_shows_message_when_no_key(void** state) +cmd_otr_start__shows__message_when_no_key(void** state) { char* recipient = "someone@server.org"; gchar* args[] = { "start", NULL }; @@ -444,7 +444,7 @@ cmd_otr_start_shows_message_when_no_key(void** state) } void -cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state) +cmd_otr_start__tests__sends_otr_query_message_to_current_recipeint(void** state) { char* recipient = "buddy@chat.com"; char* query_message = "?OTR?"; @@ -475,7 +475,7 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state) #else void -cmd_otr_shows_message_when_otr_unsupported(void** state) +cmd_otr__shows__message_when_otr_unsupported(void** state) { gchar* args[] = { "gen", NULL }; diff --git a/tests/unittests/command/test_cmd_otr.h b/tests/unittests/command/test_cmd_otr.h new file mode 100644 index 00000000..7543e4e4 --- /dev/null +++ b/tests/unittests/command/test_cmd_otr.h @@ -0,0 +1,42 @@ +#ifndef TESTS_TEST_CMD_OTR_H +#define TESTS_TEST_CMD_OTR_H + +#include "config.h" + +#ifdef HAVE_LIBOTR +void cmd_otr_log__shows__usage_when_no_args(void** state); +void cmd_otr_log__shows__usage_when_invalid_subcommand(void** state); +void cmd_otr_log__updates__enables_logging(void** state); +void cmd_otr_log__updates__disables_logging(void** state); +void cmd_otr_log__updates__redacts_logging(void** state); +void cmd_otr_log__shows__warning_when_chlog_disabled(void** state); +void cmd_otr_log__shows__redact_warning_when_chlog_disabled(void** state); +void cmd_otr_libver__shows__libotr_version(void** state); +void cmd_otr_gen__shows__message_when_not_connected(void** state); +void cmd_otr_gen__tests__generates_key_for_connected_account(void** state); +void cmd_otr_gen__shows__message_when_disconnected(void** state); +void cmd_otr_gen__shows__message_when_undefined(void** state); +void cmd_otr_gen__shows__message_when_connecting(void** state); +void cmd_otr_gen__shows__message_when_disconnecting(void** state); +void cmd_otr_myfp__shows__message_when_disconnected(void** state); +void cmd_otr_myfp__shows__message_when_undefined(void** state); +void cmd_otr_myfp__shows__message_when_connecting(void** state); +void cmd_otr_myfp__shows__message_when_disconnecting(void** state); +void cmd_otr_myfp__shows__message_when_no_key(void** state); +void cmd_otr_myfp__shows__my_fingerprint(void** state); +void cmd_otr_theirfp__shows__message_when_in_console(void** state); +void cmd_otr_theirfp__shows__message_when_in_muc(void** state); +void cmd_otr_theirfp__shows__message_when_in_private(void** state); +void cmd_otr_theirfp__shows__message_when_non_otr_chat_window(void** state); +void cmd_otr_theirfp__shows__fingerprint(void** state); +void cmd_otr_start__shows__message_when_in_console(void** state); +void cmd_otr_start__shows__message_when_in_muc(void** state); +void cmd_otr_start__shows__message_when_in_private(void** state); +void cmd_otr_start__shows__message_when_already_started(void** state); +void cmd_otr_start__shows__message_when_no_key(void** state); +void cmd_otr_start__tests__sends_otr_query_message_to_current_recipeint(void** state); +#else +void cmd_otr__shows__message_when_otr_unsupported(void** state); +#endif + +#endif diff --git a/tests/unittests/test_cmd_pgp.c b/tests/unittests/command/test_cmd_pgp.c similarity index 50% rename from tests/unittests/test_cmd_pgp.c rename to tests/unittests/command/test_cmd_pgp.c index 71253c49..377952be 100644 --- a/tests/unittests/test_cmd_pgp.c +++ b/tests/unittests/command/test_cmd_pgp.c @@ -14,7 +14,7 @@ #ifdef HAVE_LIBGPGME void -cmd_pgp_shows_usage_when_no_args(void** state) +cmd_pgp__shows__usage_when_no_args(void** state) { gchar* args[] = { NULL }; @@ -25,7 +25,7 @@ cmd_pgp_shows_usage_when_no_args(void** state) } void -cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status) +cmd_pgp_start__shows__message_when_connection(jabber_conn_status_t conn_status) { gchar* args[] = { "start", NULL }; ProfWin window; @@ -40,25 +40,25 @@ cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status) } void -cmd_pgp_start_shows_message_when_disconnected(void** state) +cmd_pgp_start__shows__message_when_disconnected(void** state) { - cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTED); + cmd_pgp_start__shows__message_when_connection(JABBER_DISCONNECTED); } void -cmd_pgp_start_shows_message_when_disconnecting(void** state) +cmd_pgp_start__shows__message_when_disconnecting(void** state) { - cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTING); + cmd_pgp_start__shows__message_when_connection(JABBER_DISCONNECTING); } void -cmd_pgp_start_shows_message_when_connecting(void** state) +cmd_pgp_start__shows__message_when_connecting(void** state) { - cmd_pgp_start_shows_message_when_connection(JABBER_CONNECTING); + cmd_pgp_start__shows__message_when_connection(JABBER_CONNECTING); } void -cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) +cmd_pgp_start__shows__message_when_no_arg_in_wintype(win_type_t wintype) { gchar* args[] = { "start", NULL }; ProfWin window; @@ -73,38 +73,38 @@ cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) } void -cmd_pgp_start_shows_message_when_no_arg_in_console(void** state) +cmd_pgp_start__shows__message_when_no_arg_in_console(void** state) { - cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONSOLE); + cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_CONSOLE); } void -cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state) +cmd_pgp_start__shows__message_when_no_arg_in_muc(void** state) { - cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC); + cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_MUC); } void -cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state) +cmd_pgp_start__shows__message_when_no_arg_in_conf(void** state) { - cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONFIG); + cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_CONFIG); } void -cmd_pgp_start_shows_message_when_no_arg_in_private(void** state) +cmd_pgp_start__shows__message_when_no_arg_in_private(void** state) { - cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_PRIVATE); + cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_PRIVATE); } void -cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state) +cmd_pgp_start__shows__message_when_no_arg_in_xmlconsole(void** state) { - cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_XML); + cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_XML); } #else void -cmd_pgp_shows_message_when_pgp_unsupported(void** state) +cmd_pgp__shows__message_when_pgp_unsupported(void** state) { gchar* args[] = { "gen", NULL }; diff --git a/tests/unittests/command/test_cmd_pgp.h b/tests/unittests/command/test_cmd_pgp.h new file mode 100644 index 00000000..f8e829f4 --- /dev/null +++ b/tests/unittests/command/test_cmd_pgp.h @@ -0,0 +1,21 @@ +#ifndef TESTS_TEST_CMD_PGP_H +#define TESTS_TEST_CMD_PGP_H + +#include "config.h" + +#ifdef HAVE_LIBGPGME +void cmd_pgp__shows__usage_when_no_args(void** state); +void cmd_pgp_start__shows__message_when_disconnected(void** state); +void cmd_pgp_start__shows__message_when_disconnecting(void** state); +void cmd_pgp_start__shows__message_when_connecting(void** state); +void cmd_pgp_start__shows__message_when_undefined(void** state); +void cmd_pgp_start__shows__message_when_no_arg_in_console(void** state); +void cmd_pgp_start__shows__message_when_no_arg_in_muc(void** state); +void cmd_pgp_start__shows__message_when_no_arg_in_conf(void** state); +void cmd_pgp_start__shows__message_when_no_arg_in_private(void** state); +void cmd_pgp_start__shows__message_when_no_arg_in_xmlconsole(void** state); +#else +void cmd_pgp__shows__message_when_pgp_unsupported(void** state); +#endif + +#endif diff --git a/tests/unittests/test_cmd_presence.c b/tests/unittests/command/test_cmd_presence.c similarity index 86% rename from tests/unittests/test_cmd_presence.c rename to tests/unittests/command/test_cmd_presence.c index 8d386097..8224bd21 100644 --- a/tests/unittests/test_cmd_presence.c +++ b/tests/unittests/command/test_cmd_presence.c @@ -13,7 +13,7 @@ #define CMD_PRESENCE "/presence" void -cmd_presence_shows_usage_when_bad_subcmd(void** state) +cmd_presence__shows__usage_when_bad_subcmd(void** state) { gchar* args[] = { "badcmd", NULL }; @@ -24,7 +24,7 @@ cmd_presence_shows_usage_when_bad_subcmd(void** state) } void -cmd_presence_shows_usage_when_bad_console_setting(void** state) +cmd_presence__shows__usage_when_bad_console_setting(void** state) { gchar* args[] = { "console", "badsetting", NULL }; @@ -35,7 +35,7 @@ cmd_presence_shows_usage_when_bad_console_setting(void** state) } void -cmd_presence_shows_usage_when_bad_chat_setting(void** state) +cmd_presence__shows__usage_when_bad_chat_setting(void** state) { gchar* args[] = { "chat", "badsetting", NULL }; @@ -46,7 +46,7 @@ cmd_presence_shows_usage_when_bad_chat_setting(void** state) } void -cmd_presence_shows_usage_when_bad_muc_setting(void** state) +cmd_presence__shows__usage_when_bad_muc_setting(void** state) { gchar* args[] = { "muc", "badsetting", NULL }; @@ -57,7 +57,7 @@ cmd_presence_shows_usage_when_bad_muc_setting(void** state) } void -cmd_presence_console_sets_all(void** state) +cmd_presence__updates__console_all(void** state) { gchar* args[] = { "console", "all", NULL }; @@ -72,7 +72,7 @@ cmd_presence_console_sets_all(void** state) } void -cmd_presence_console_sets_online(void** state) +cmd_presence__updates__console_online(void** state) { gchar* args[] = { "console", "online", NULL }; @@ -87,7 +87,7 @@ cmd_presence_console_sets_online(void** state) } void -cmd_presence_console_sets_none(void** state) +cmd_presence__updates__console_none(void** state) { gchar* args[] = { "console", "none", NULL }; @@ -102,7 +102,7 @@ cmd_presence_console_sets_none(void** state) } void -cmd_presence_chat_sets_all(void** state) +cmd_presence__updates__chat_all(void** state) { gchar* args[] = { "chat", "all", NULL }; @@ -117,7 +117,7 @@ cmd_presence_chat_sets_all(void** state) } void -cmd_presence_chat_sets_online(void** state) +cmd_presence__updates__chat_online(void** state) { gchar* args[] = { "chat", "online", NULL }; @@ -132,7 +132,7 @@ cmd_presence_chat_sets_online(void** state) } void -cmd_presence_chat_sets_none(void** state) +cmd_presence__updates__chat_none(void** state) { gchar* args[] = { "chat", "none", NULL }; @@ -147,7 +147,7 @@ cmd_presence_chat_sets_none(void** state) } void -cmd_presence_room_sets_all(void** state) +cmd_presence__updates__room_all(void** state) { gchar* args[] = { "room", "all", NULL }; @@ -162,7 +162,7 @@ cmd_presence_room_sets_all(void** state) } void -cmd_presence_room_sets_online(void** state) +cmd_presence__updates__room_online(void** state) { gchar* args[] = { "room", "online", NULL }; @@ -177,7 +177,7 @@ cmd_presence_room_sets_online(void** state) } void -cmd_presence_room_sets_none(void** state) +cmd_presence__updates__room_none(void** state) { gchar* args[] = { "room", "none", NULL }; diff --git a/tests/unittests/command/test_cmd_presence.h b/tests/unittests/command/test_cmd_presence.h new file mode 100644 index 00000000..569a254a --- /dev/null +++ b/tests/unittests/command/test_cmd_presence.h @@ -0,0 +1,18 @@ +#ifndef TESTS_TEST_CMD_PRESENCE_H +#define TESTS_TEST_CMD_PRESENCE_H + +void cmd_presence__shows__usage_when_bad_subcmd(void** state); +void cmd_presence__shows__usage_when_bad_console_setting(void** state); +void cmd_presence__shows__usage_when_bad_chat_setting(void** state); +void cmd_presence__shows__usage_when_bad_muc_setting(void** state); +void cmd_presence__updates__console_all(void** state); +void cmd_presence__updates__console_online(void** state); +void cmd_presence__updates__console_none(void** state); +void cmd_presence__updates__chat_all(void** state); +void cmd_presence__updates__chat_online(void** state); +void cmd_presence__updates__chat_none(void** state); +void cmd_presence__updates__room_all(void** state); +void cmd_presence__updates__room_online(void** state); +void cmd_presence__updates__room_none(void** state); + +#endif diff --git a/tests/unittests/test_cmd_rooms.c b/tests/unittests/command/test_cmd_rooms.c similarity index 88% rename from tests/unittests/test_cmd_rooms.c rename to tests/unittests/command/test_cmd_rooms.c index ef2e6b48..cffec0ba 100644 --- a/tests/unittests/test_cmd_rooms.c +++ b/tests/unittests/command/test_cmd_rooms.c @@ -25,25 +25,25 @@ test_with_connection_status(jabber_conn_status_t status) } void -cmd_rooms_shows_message_when_disconnected(void** state) +cmd_rooms__shows__message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } void -cmd_rooms_shows_message_when_disconnecting(void** state) +cmd_rooms__shows__message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } void -cmd_rooms_shows_message_when_connecting(void** state) +cmd_rooms__shows__message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } void -cmd_rooms_uses_account_default_when_no_arg(void** state) +cmd_rooms__tests__account_default_when_no_arg(void** state) { gchar* args[] = { NULL }; @@ -66,7 +66,7 @@ cmd_rooms_uses_account_default_when_no_arg(void** state) } void -cmd_rooms_service_arg_used_when_passed(void** state) +cmd_rooms__tests__service_arg_used_when_passed(void** state) { gchar* args[] = { "service", "conf_server_arg", NULL }; @@ -83,7 +83,7 @@ cmd_rooms_service_arg_used_when_passed(void** state) } void -cmd_rooms_filter_arg_used_when_passed(void** state) +cmd_rooms__tests__filter_arg_used_when_passed(void** state) { gchar* args[] = { "filter", "text", NULL }; diff --git a/tests/unittests/command/test_cmd_rooms.h b/tests/unittests/command/test_cmd_rooms.h new file mode 100644 index 00000000..918a7f86 --- /dev/null +++ b/tests/unittests/command/test_cmd_rooms.h @@ -0,0 +1,12 @@ +#ifndef TESTS_TEST_CMD_ROOMS_H +#define TESTS_TEST_CMD_ROOMS_H + +void cmd_rooms__shows__message_when_disconnected(void** state); +void cmd_rooms__shows__message_when_disconnecting(void** state); +void cmd_rooms__shows__message_when_connecting(void** state); +void cmd_rooms__shows__message_when_undefined(void** state); +void cmd_rooms__tests__account_default_when_no_arg(void** state); +void cmd_rooms__tests__service_arg_used_when_passed(void** state); +void cmd_rooms__tests__filter_arg_used_when_passed(void** state); + +#endif diff --git a/tests/unittests/test_cmd_roster.c b/tests/unittests/command/test_cmd_roster.c similarity index 83% rename from tests/unittests/test_cmd_roster.c rename to tests/unittests/command/test_cmd_roster.c index 74ba7a98..99c64d9c 100644 --- a/tests/unittests/test_cmd_roster.c +++ b/tests/unittests/command/test_cmd_roster.c @@ -26,25 +26,25 @@ test_with_connection_status(jabber_conn_status_t status) } void -cmd_roster_shows_message_when_disconnecting(void** state) +cmd_roster__shows__message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } void -cmd_roster_shows_message_when_connecting(void** state) +cmd_roster__shows__message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } void -cmd_roster_shows_message_when_disconnected(void** state) +cmd_roster__shows__message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } void -cmd_roster_shows_roster_when_no_args(void** state) +cmd_roster__shows__roster_when_no_args(void** state) { gchar* args[] = { NULL }; @@ -64,7 +64,7 @@ cmd_roster_shows_roster_when_no_args(void** state) } void -cmd_roster_add_shows_message_when_no_jid(void** state) +cmd_roster__shows__message_when_add_no_jid(void** state) { gchar* args[] = { "add", NULL }; @@ -77,7 +77,7 @@ cmd_roster_add_shows_message_when_no_jid(void** state) } void -cmd_roster_add_sends_roster_add_request(void** state) +cmd_roster__tests__add_sends_roster_add_request(void** state) { char* jid = "bob@server.org"; char* nick = "bob"; @@ -93,7 +93,7 @@ cmd_roster_add_sends_roster_add_request(void** state) } void -cmd_roster_remove_shows_message_when_no_jid(void** state) +cmd_roster__shows__message_when_remove_no_jid(void** state) { gchar* args[] = { "remove", NULL }; @@ -106,7 +106,7 @@ cmd_roster_remove_shows_message_when_no_jid(void** state) } void -cmd_roster_remove_sends_roster_remove_request(void** state) +cmd_roster__tests__remove_sends_roster_remove_request(void** state) { char* jid = "bob@server.org"; gchar* args[] = { "remove", jid, NULL }; @@ -124,13 +124,14 @@ cmd_roster_remove_sends_roster_remove_request(void** state) } void -cmd_roster_remove_nickname_sends_roster_remove_request(void** state) +cmd_roster__tests__remove_nickname_sends_roster_remove_request(void** state) { char* jid = "bob@server.org"; - gchar* args[] = { "remove", "bob", NULL }; + char* nick = "bob"; + gchar* args[] = { "remove", nick, NULL }; roster_create(); - roster_add("bob@server.org", "bob", NULL, "both", FALSE); + roster_add(jid, nick, NULL, "both", FALSE); will_return(connection_get_status, JABBER_CONNECTED); @@ -142,7 +143,7 @@ cmd_roster_remove_nickname_sends_roster_remove_request(void** state) } void -cmd_roster_nick_shows_message_when_no_jid(void** state) +cmd_roster__shows__message_when_nick_no_jid(void** state) { gchar* args[] = { "nick", NULL }; @@ -155,7 +156,7 @@ cmd_roster_nick_shows_message_when_no_jid(void** state) } void -cmd_roster_nick_shows_message_when_no_nick(void** state) +cmd_roster__shows__message_when_nick_no_nick(void** state) { gchar* args[] = { "nick", "bob@server.org", NULL }; @@ -168,7 +169,7 @@ cmd_roster_nick_shows_message_when_no_nick(void** state) } void -cmd_roster_nick_shows_message_when_no_contact_exists(void** state) +cmd_roster__shows__message_when_nick_no_contact_exists(void** state) { gchar* args[] = { "nick", "bob@server.org", "bobster", NULL }; @@ -185,7 +186,7 @@ cmd_roster_nick_shows_message_when_no_contact_exists(void** state) } void -cmd_roster_nick_sends_name_change_request(void** state) +cmd_roster__tests__nick_sends_name_change_request(void** state) { char* jid = "bob@server.org"; char* nick = "bobster"; @@ -214,7 +215,7 @@ cmd_roster_nick_sends_name_change_request(void** state) } void -cmd_roster_clearnick_shows_message_when_no_jid(void** state) +cmd_roster__shows__message_when_clearnick_no_jid(void** state) { gchar* args[] = { "clearnick", NULL }; @@ -227,7 +228,7 @@ cmd_roster_clearnick_shows_message_when_no_jid(void** state) } void -cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state) +cmd_roster__shows__message_when_clearnick_no_contact_exists(void** state) { gchar* args[] = { "clearnick", "bob@server.org", NULL }; @@ -244,7 +245,7 @@ cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state) } void -cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void** state) +cmd_roster__tests__clearnick_sends_name_change_request_with_empty_nick(void** state) { char* jid = "bob@server.org"; gchar* args[] = { "clearnick", jid, NULL }; diff --git a/tests/unittests/command/test_cmd_roster.h b/tests/unittests/command/test_cmd_roster.h new file mode 100644 index 00000000..06690b42 --- /dev/null +++ b/tests/unittests/command/test_cmd_roster.h @@ -0,0 +1,21 @@ +#ifndef TESTS_TEST_CMD_ROSTER_H +#define TESTS_TEST_CMD_ROSTER_H + +void cmd_roster__shows__message_when_disconnecting(void** state); +void cmd_roster__shows__message_when_connecting(void** state); +void cmd_roster__shows__message_when_disconnected(void** state); +void cmd_roster__shows__roster_when_no_args(void** state); +void cmd_roster__shows__message_when_add_no_jid(void** state); +void cmd_roster__tests__add_sends_roster_add_request(void** state); +void cmd_roster__shows__message_when_remove_no_jid(void** state); +void cmd_roster__tests__remove_sends_roster_remove_request(void** state); +void cmd_roster__tests__remove_nickname_sends_roster_remove_request(void** state); +void cmd_roster__shows__message_when_nick_no_jid(void** state); +void cmd_roster__shows__message_when_nick_no_nick(void** state); +void cmd_roster__shows__message_when_nick_no_contact_exists(void** state); +void cmd_roster__tests__nick_sends_name_change_request(void** state); +void cmd_roster__shows__message_when_clearnick_no_jid(void** state); +void cmd_roster__shows__message_when_clearnick_no_contact_exists(void** state); +void cmd_roster__tests__clearnick_sends_name_change_request_with_empty_nick(void** state); + +#endif diff --git a/tests/unittests/test_cmd_sub.c b/tests/unittests/command/test_cmd_sub.c similarity index 86% rename from tests/unittests/test_cmd_sub.c rename to tests/unittests/command/test_cmd_sub.c index a24e13aa..a9120643 100644 --- a/tests/unittests/test_cmd_sub.c +++ b/tests/unittests/command/test_cmd_sub.c @@ -13,7 +13,7 @@ #define CMD_SUB "/sub" void -cmd_sub_shows_message_when_not_connected(void** state) +cmd_sub__shows__message_when_not_connected(void** state) { gchar* args[] = { NULL }; @@ -26,7 +26,7 @@ cmd_sub_shows_message_when_not_connected(void** state) } void -cmd_sub_shows_usage_when_no_arg(void** state) +cmd_sub__shows__usage_when_no_arg(void** state) { gchar* args[] = { NULL }; diff --git a/tests/unittests/command/test_cmd_sub.h b/tests/unittests/command/test_cmd_sub.h new file mode 100644 index 00000000..528c9147 --- /dev/null +++ b/tests/unittests/command/test_cmd_sub.h @@ -0,0 +1,7 @@ +#ifndef TESTS_TEST_CMD_SUB_H +#define TESTS_TEST_CMD_SUB_H + +void cmd_sub__shows__message_when_not_connected(void** state); +void cmd_sub__shows__usage_when_no_arg(void** state); + +#endif diff --git a/tests/unittests/test_preferences.c b/tests/unittests/config/test_preferences.c similarity index 76% rename from tests/unittests/test_preferences.c rename to tests/unittests/config/test_preferences.c index 7c662a34..446b4666 100644 --- a/tests/unittests/test_preferences.c +++ b/tests/unittests/config/test_preferences.c @@ -6,7 +6,7 @@ #include "config/preferences.h" void -statuses_console_defaults_to_all(void** state) +prefs_get_string__returns__all_for_console_default(void** state) { gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE); @@ -16,7 +16,7 @@ statuses_console_defaults_to_all(void** state) } void -statuses_chat_defaults_to_all(void** state) +prefs_get_string__returns__none_for_chat_default(void** state) { gchar* setting = prefs_get_string(PREF_STATUSES_CHAT); @@ -26,7 +26,7 @@ statuses_chat_defaults_to_all(void** state) } void -statuses_muc_defaults_to_all(void** state) +prefs_get_string__returns__none_for_muc_default(void** state) { gchar* setting = prefs_get_string(PREF_STATUSES_MUC); diff --git a/tests/unittests/config/test_preferences.h b/tests/unittests/config/test_preferences.h new file mode 100644 index 00000000..7a8fa69a --- /dev/null +++ b/tests/unittests/config/test_preferences.h @@ -0,0 +1,8 @@ +#ifndef TESTS_TEST_PREFERENCES_H +#define TESTS_TEST_PREFERENCES_H + +void prefs_get_string__returns__all_for_console_default(void** state); +void prefs_get_string__returns__none_for_chat_default(void** state); +void prefs_get_string__returns__none_for_muc_default(void** state); + +#endif diff --git a/tests/unittests/test_server_events.c b/tests/unittests/event/test_server_events.c similarity index 90% rename from tests/unittests/test_server_events.c rename to tests/unittests/event/test_server_events.c index 37d46620..29fabf88 100644 --- a/tests/unittests/test_server_events.c +++ b/tests/unittests/event/test_server_events.c @@ -15,7 +15,7 @@ #include "ui/window_list.h" void -console_shows_online_presence_when_set_online(void** state) +sv_ev_contact_online__shows__presence_in_console_when_set_online(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "online"); plugins_init(); @@ -35,7 +35,7 @@ console_shows_online_presence_when_set_online(void** state) } void -console_shows_online_presence_when_set_all(void** state) +sv_ev_contact_online__shows__presence_in_console_when_set_all(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "all"); plugins_init(); @@ -55,7 +55,7 @@ console_shows_online_presence_when_set_all(void** state) } void -console_shows_dnd_presence_when_set_all(void** state) +sv_ev_contact_online__shows__dnd_presence_in_console_when_set_all(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "all"); plugins_init(); @@ -75,7 +75,7 @@ console_shows_dnd_presence_when_set_all(void** state) } void -handle_offline_removes_chat_session(void** state) +sv_ev_contact_offline__updates__removes_chat_session(void** state) { plugins_init(); roster_create(); @@ -100,7 +100,7 @@ handle_offline_removes_chat_session(void** state) } void -lost_connection_clears_chat_sessions(void** state) +sv_ev_lost_connection__updates__clears_chat_sessions(void** state) { roster_create(); roster_process_pending_presence(); diff --git a/tests/unittests/event/test_server_events.h b/tests/unittests/event/test_server_events.h new file mode 100644 index 00000000..6173cb1d --- /dev/null +++ b/tests/unittests/event/test_server_events.h @@ -0,0 +1,10 @@ +#ifndef TESTS_TEST_SERVER_EVENTS_H +#define TESTS_TEST_SERVER_EVENTS_H + +void sv_ev_contact_online__shows__presence_in_console_when_set_online(void** state); +void sv_ev_contact_online__shows__presence_in_console_when_set_all(void** state); +void sv_ev_contact_online__shows__dnd_presence_in_console_when_set_all(void** state); +void sv_ev_contact_offline__updates__removes_chat_session(void** state); +void sv_ev_lost_connection__updates__clears_chat_sessions(void** state); + +#endif diff --git a/tests/unittests/omemo/stub_omemo.c b/tests/unittests/omemo/stub_omemo.c index a0d6da2f..a19c6b71 100644 --- a/tests/unittests/omemo/stub_omemo.c +++ b/tests/unittests/omemo/stub_omemo.c @@ -109,7 +109,7 @@ omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res) { return NULL; }; -void omemo_free(void* a){}; +void omemo_free(void* a) {}; uint32_t omemo_device_id() diff --git a/tests/unittests/test_callbacks.c b/tests/unittests/plugins/test_callbacks.c similarity index 91% rename from tests/unittests/test_callbacks.c rename to tests/unittests/plugins/test_callbacks.c index 005ce82a..c0970c8f 100644 --- a/tests/unittests/test_callbacks.c +++ b/tests/unittests/plugins/test_callbacks.c @@ -7,7 +7,7 @@ #include "plugins/plugins.h" void -returns_no_commands(void** state) +plugins_get_command_names__returns__no_commands(void** state) { plugins_init(); GList* commands = plugins_get_command_names(); @@ -16,7 +16,7 @@ returns_no_commands(void** state) } void -returns_commands(void** state) +plugins_get_command_names__returns__commands_when_added(void** state) { plugins_init(); PluginCommand* command1 = g_new0(PluginCommand, 1); diff --git a/tests/unittests/plugins/test_callbacks.h b/tests/unittests/plugins/test_callbacks.h new file mode 100644 index 00000000..d1bd1f8f --- /dev/null +++ b/tests/unittests/plugins/test_callbacks.h @@ -0,0 +1,7 @@ +#ifndef TESTS_TEST_CALLBACKS_H +#define TESTS_TEST_CALLBACKS_H + +void plugins_get_command_names__returns__no_commands(void** state); +void plugins_get_command_names__returns__commands_when_added(void** state); + +#endif diff --git a/tests/unittests/test_plugins_disco.c b/tests/unittests/plugins/test_plugins_disco.c similarity index 87% rename from tests/unittests/test_plugins_disco.c rename to tests/unittests/plugins/test_plugins_disco.c index a21ae94c..0d8704b2 100644 --- a/tests/unittests/test_plugins_disco.c +++ b/tests/unittests/plugins/test_plugins_disco.c @@ -4,7 +4,7 @@ #include "plugins/disco.h" void -returns_empty_list_when_none(void** state) +disco_get_features__returns__empty_list_when_none(void** state) { disco_close(); GList* features = disco_get_features(); @@ -16,7 +16,7 @@ returns_empty_list_when_none(void** state) } void -returns_added_feature(void** state) +disco_add_feature__updates__added_feature(void** state) { disco_close(); disco_add_feature("my_plugin", "some:feature:example"); @@ -31,7 +31,7 @@ returns_added_feature(void** state) } void -resets_features_on_close(void** state) +disco_close__updates__resets_features(void** state) { disco_close(); disco_add_feature("my_plugin", "some:feature:example"); @@ -49,7 +49,7 @@ resets_features_on_close(void** state) } void -returns_all_added_features(void** state) +disco_get_features__returns__all_added_features(void** state) { disco_close(); disco_add_feature("first_plugin", "first:feature"); @@ -72,7 +72,7 @@ returns_all_added_features(void** state) } void -does_not_add_duplicate_feature(void** state) +disco_add_feature__updates__not_duplicate_feature(void** state) { disco_close(); disco_add_feature("my_plugin", "my:feature"); @@ -86,7 +86,7 @@ does_not_add_duplicate_feature(void** state) } void -removes_plugin_features(void** state) +disco_remove_features__updates__removes_plugin_features(void** state) { disco_close(); disco_add_feature("plugin1", "plugin1:feature1"); @@ -107,7 +107,7 @@ removes_plugin_features(void** state) } void -does_not_remove_feature_when_more_than_one_reference(void** state) +disco_remove_features__updates__not_remove_when_more_than_one_reference(void** state) { disco_close(); disco_add_feature("plugin1", "feature1"); diff --git a/tests/unittests/plugins/test_plugins_disco.h b/tests/unittests/plugins/test_plugins_disco.h new file mode 100644 index 00000000..82f2799b --- /dev/null +++ b/tests/unittests/plugins/test_plugins_disco.h @@ -0,0 +1,12 @@ +#ifndef TESTS_TEST_PLUGINS_DISCO_H +#define TESTS_TEST_PLUGINS_DISCO_H + +void disco_get_features__returns__empty_list_when_none(void** state); +void disco_add_feature__updates__added_feature(void** state); +void disco_close__updates__resets_features(void** state); +void disco_get_features__returns__all_added_features(void** state); +void disco_add_feature__updates__not_duplicate_feature(void** state); +void disco_remove_features__updates__removes_plugin_features(void** state); +void disco_remove_features__updates__not_remove_when_more_than_one_reference(void** state); + +#endif diff --git a/tests/unittests/test_autocomplete.h b/tests/unittests/test_autocomplete.h deleted file mode 100644 index 3fac7038..00000000 --- a/tests/unittests/test_autocomplete.h +++ /dev/null @@ -1,16 +0,0 @@ -void clear_empty(void** state); -void reset_after_create(void** state); -void find_after_create(void** state); -void get_after_create_returns_null(void** state); -void add_one_and_complete(void** state); -void add_two_and_complete_returns_first(void** state); -void add_two_and_complete_returns_second(void** state); -void add_two_adds_two(void** state); -void add_two_same_adds_one(void** state); -void add_two_same_updates(void** state); -void complete_accented_with_accented(void** state); -void complete_accented_with_base(void** state); -void complete_both_with_accented(void** state); -void complete_both_with_base(void** state); -void complete_ignores_case(void** state); -void complete_previous(void** state); diff --git a/tests/unittests/test_callbacks.h b/tests/unittests/test_callbacks.h deleted file mode 100644 index 27130241..00000000 --- a/tests/unittests/test_callbacks.h +++ /dev/null @@ -1,2 +0,0 @@ -void returns_no_commands(void** state); -void returns_commands(void** state); diff --git a/tests/unittests/test_chat_session.h b/tests/unittests/test_chat_session.h deleted file mode 100644 index f2201be8..00000000 --- a/tests/unittests/test_chat_session.h +++ /dev/null @@ -1,4 +0,0 @@ -void returns_false_when_chat_session_does_not_exist(void** state); -void creates_chat_session_on_recipient_activity(void** state); -void replaces_chat_session_on_recipient_activity_with_different_resource(void** state); -void removes_chat_session(void** state); diff --git a/tests/unittests/test_cmd_account.h b/tests/unittests/test_cmd_account.h deleted file mode 100644 index 7a8d1b42..00000000 --- a/tests/unittests/test_cmd_account.h +++ /dev/null @@ -1,56 +0,0 @@ -void cmd_account_shows_usage_when_not_connected_and_no_args(void** state); -void cmd_account_shows_account_when_connected_and_no_args(void** state); -void cmd_account_list_shows_accounts(void** state); -void cmd_account_show_shows_usage_when_no_arg(void** state); -void cmd_account_show_shows_message_when_account_does_not_exist(void** state); -void cmd_account_show_shows_account_when_exists(void** state); -void cmd_account_add_shows_usage_when_no_arg(void** state); -void cmd_account_add_adds_account(void** state); -void cmd_account_enable_shows_usage_when_no_arg(void** state); -void cmd_account_enable_enables_account(void** state); -void cmd_account_enable_shows_message_when_account_doesnt_exist(void** state); -void cmd_account_disable_shows_usage_when_no_arg(void** state); -void cmd_account_disable_disables_account(void** state); -void cmd_account_disable_shows_message_when_account_doesnt_exist(void** state); -void cmd_account_rename_shows_usage_when_no_args(void** state); -void cmd_account_rename_shows_usage_when_one_arg(void** state); -void cmd_account_rename_renames_account(void** state); -void cmd_account_rename_shows_message_when_not_renamed(void** state); -void cmd_account_set_shows_usage_when_no_args(void** state); -void cmd_account_set_shows_usage_when_one_arg(void** state); -void cmd_account_set_shows_usage_when_two_args(void** state); -void cmd_account_set_shows_message_when_account_doesnt_exist(void** state); -void cmd_account_set_jid_shows_message_for_malformed_jid(void** state); -void cmd_account_set_jid_sets_barejid(void** state); -void cmd_account_set_jid_sets_resource(void** state); -void cmd_account_set_server_sets_server(void** state); -void cmd_account_set_resource_sets_resource(void** state); -void cmd_account_set_resource_sets_resource_with_online_message(void** state); -void cmd_account_set_password_sets_password(void** state); -void cmd_account_set_eval_password_sets_eval_password(void** state); -void cmd_account_set_password_when_eval_password_set(void** state); -void cmd_account_set_eval_password_when_password_set(void** state); -void cmd_account_set_muc_sets_muc(void** state); -void cmd_account_set_nick_sets_nick(void** state); -void cmd_account_show_message_for_missing_otr_policy(void** state); -void cmd_account_show_message_for_invalid_otr_policy(void** state); -void cmd_account_set_otr_sets_otr(void** state); -void cmd_account_set_status_shows_message_when_invalid_status(void** state); -void cmd_account_set_status_sets_status_when_valid(void** state); -void cmd_account_set_status_sets_status_when_last(void** state); -void cmd_account_set_invalid_presence_string_priority_shows_message(void** state); -void cmd_account_set_last_priority_shows_message(void** state); -void cmd_account_set_online_priority_sets_preference(void** state); -void cmd_account_set_chat_priority_sets_preference(void** state); -void cmd_account_set_away_priority_sets_preference(void** state); -void cmd_account_set_xa_priority_sets_preference(void** state); -void cmd_account_set_dnd_priority_sets_preference(void** state); -void cmd_account_set_priority_too_low_shows_message(void** state); -void cmd_account_set_priority_too_high_shows_message(void** state); -void cmd_account_set_priority_when_not_number_shows_message(void** state); -void cmd_account_set_priority_when_empty_shows_message(void** state); -void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void** state); -void cmd_account_clear_shows_usage_when_no_args(void** state); -void cmd_account_clear_shows_usage_when_one_arg(void** state); -void cmd_account_clear_shows_message_when_account_doesnt_exist(void** state); -void cmd_account_clear_shows_message_when_invalid_property(void** state); diff --git a/tests/unittests/test_cmd_alias.h b/tests/unittests/test_cmd_alias.h deleted file mode 100644 index b674d479..00000000 --- a/tests/unittests/test_cmd_alias.h +++ /dev/null @@ -1,9 +0,0 @@ -void cmd_alias_add_shows_usage_when_no_args(void** state); -void cmd_alias_add_shows_usage_when_no_value(void** state); -void cmd_alias_remove_shows_usage_when_no_args(void** state); -void cmd_alias_show_usage_when_invalid_subcmd(void** state); -void cmd_alias_add_adds_alias(void** state); -void cmd_alias_add_shows_message_when_exists(void** state); -void cmd_alias_remove_removes_alias(void** state); -void cmd_alias_remove_shows_message_when_no_alias(void** state); -void cmd_alias_list_shows_all_aliases(void** state); diff --git a/tests/unittests/test_cmd_bookmark.h b/tests/unittests/test_cmd_bookmark.h deleted file mode 100644 index d8e598bb..00000000 --- a/tests/unittests/test_cmd_bookmark.h +++ /dev/null @@ -1,18 +0,0 @@ -void cmd_bookmark_shows_message_when_disconnected(void** state); -void cmd_bookmark_shows_message_when_disconnecting(void** state); -void cmd_bookmark_shows_message_when_connecting(void** state); -void cmd_bookmark_shows_message_when_undefined(void** state); -void cmd_bookmark_shows_usage_when_no_args(void** state); -void cmd_bookmark_list_shows_bookmarks(void** state); -void cmd_bookmark_add_shows_message_when_invalid_jid(void** state); -void cmd_bookmark_add_adds_bookmark_with_jid(void** state); -void cmd_bookmark_uses_roomjid_in_room(void** state); -void cmd_bookmark_add_uses_roomjid_in_room(void** state); -void cmd_bookmark_add_uses_supplied_jid_in_room(void** state); -void cmd_bookmark_remove_uses_roomjid_in_room(void** state); -void cmd_bookmark_remove_uses_supplied_jid_in_room(void** state); -void cmd_bookmark_add_adds_bookmark_with_jid_nick(void** state); -void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void** state); -void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void** state); -void cmd_bookmark_remove_removes_bookmark(void** state); -void cmd_bookmark_remove_shows_message_when_no_bookmark(void** state); diff --git a/tests/unittests/test_cmd_connect.h b/tests/unittests/test_cmd_connect.h deleted file mode 100644 index 14e7f7b2..00000000 --- a/tests/unittests/test_cmd_connect.h +++ /dev/null @@ -1,27 +0,0 @@ -void cmd_connect_shows_message_when_disconnecting(void** state); -void cmd_connect_shows_message_when_connecting(void** state); -void cmd_connect_shows_message_when_connected(void** state); -void cmd_connect_shows_message_when_undefined(void** state); -void cmd_connect_when_no_account(void** state); -void cmd_connect_with_altdomain_when_provided(void** state); -void cmd_connect_fail_message(void** state); -void cmd_connect_lowercases_argument_with_no_account(void** state); -void cmd_connect_lowercases_argument_with_account(void** state); -void cmd_connect_asks_password_when_not_in_account(void** state); -void cmd_connect_shows_message_when_connecting_with_account(void** state); -void cmd_connect_connects_with_account(void** state); -void cmd_connect_shows_usage_when_no_server_value(void** state); -void cmd_connect_shows_usage_when_server_no_port_value(void** state); -void cmd_connect_shows_usage_when_no_port_value(void** state); -void cmd_connect_shows_usage_when_port_no_server_value(void** state); -void cmd_connect_shows_message_when_port_0(void** state); -void cmd_connect_shows_message_when_port_minus1(void** state); -void cmd_connect_shows_message_when_port_65536(void** state); -void cmd_connect_shows_message_when_port_contains_chars(void** state); -void cmd_connect_with_server_when_provided(void** state); -void cmd_connect_with_port_when_provided(void** state); -void cmd_connect_with_server_and_port_when_provided(void** state); -void cmd_connect_shows_usage_when_server_provided_twice(void** state); -void cmd_connect_shows_usage_when_port_provided_twice(void** state); -void cmd_connect_shows_usage_when_invalid_first_property(void** state); -void cmd_connect_shows_usage_when_invalid_second_property(void** state); diff --git a/tests/unittests/test_cmd_disconnect.h b/tests/unittests/test_cmd_disconnect.h deleted file mode 100644 index 0988bd25..00000000 --- a/tests/unittests/test_cmd_disconnect.h +++ /dev/null @@ -1 +0,0 @@ -void clears_chat_sessions(void** state); diff --git a/tests/unittests/test_cmd_join.h b/tests/unittests/test_cmd_join.h deleted file mode 100644 index c22d9847..00000000 --- a/tests/unittests/test_cmd_join.h +++ /dev/null @@ -1,9 +0,0 @@ -void cmd_join_shows_message_when_disconnecting(void** state); -void cmd_join_shows_message_when_connecting(void** state); -void cmd_join_shows_message_when_disconnected(void** state); -void cmd_join_shows_message_when_undefined(void** state); -void cmd_join_shows_error_message_when_invalid_room_jid(void** state); -void cmd_join_uses_account_mucservice_when_no_service_specified(void** state); -void cmd_join_uses_supplied_nick(void** state); -void cmd_join_uses_account_nick_when_not_supplied(void** state); -void cmd_join_uses_password_when_supplied(void** state); diff --git a/tests/unittests/test_cmd_otr.h b/tests/unittests/test_cmd_otr.h deleted file mode 100644 index a9ffb1e1..00000000 --- a/tests/unittests/test_cmd_otr.h +++ /dev/null @@ -1,37 +0,0 @@ -#include "config.h" - -#ifdef HAVE_LIBOTR -void cmd_otr_log_shows_usage_when_no_args(void** state); -void cmd_otr_log_shows_usage_when_invalid_subcommand(void** state); -void cmd_otr_log_on_enables_logging(void** state); -void cmd_otr_log_off_disables_logging(void** state); -void cmd_otr_redact_redacts_logging(void** state); -void cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state); -void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state); -void cmd_otr_libver_shows_libotr_version(void** state); -void cmd_otr_gen_shows_message_when_not_connected(void** state); -void cmd_otr_gen_generates_key_for_connected_account(void** state); -void cmd_otr_gen_shows_message_when_disconnected(void** state); -void cmd_otr_gen_shows_message_when_undefined(void** state); -void cmd_otr_gen_shows_message_when_connecting(void** state); -void cmd_otr_gen_shows_message_when_disconnecting(void** state); -void cmd_otr_myfp_shows_message_when_disconnected(void** state); -void cmd_otr_myfp_shows_message_when_undefined(void** state); -void cmd_otr_myfp_shows_message_when_connecting(void** state); -void cmd_otr_myfp_shows_message_when_disconnecting(void** state); -void cmd_otr_myfp_shows_message_when_no_key(void** state); -void cmd_otr_myfp_shows_my_fingerprint(void** state); -void cmd_otr_theirfp_shows_message_when_in_console(void** state); -void cmd_otr_theirfp_shows_message_when_in_muc(void** state); -void cmd_otr_theirfp_shows_message_when_in_private(void** state); -void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state); -void cmd_otr_theirfp_shows_fingerprint(void** state); -void cmd_otr_start_shows_message_when_in_console(void** state); -void cmd_otr_start_shows_message_when_in_muc(void** state); -void cmd_otr_start_shows_message_when_in_private(void** state); -void cmd_otr_start_shows_message_when_already_started(void** state); -void cmd_otr_start_shows_message_when_no_key(void** state); -void cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state); -#else -void cmd_otr_shows_message_when_otr_unsupported(void** state); -#endif diff --git a/tests/unittests/test_cmd_pgp.h b/tests/unittests/test_cmd_pgp.h deleted file mode 100644 index 60110beb..00000000 --- a/tests/unittests/test_cmd_pgp.h +++ /dev/null @@ -1,16 +0,0 @@ -#include "config.h" - -#ifdef HAVE_LIBGPGME -void cmd_pgp_shows_usage_when_no_args(void** state); -void cmd_pgp_start_shows_message_when_disconnected(void** state); -void cmd_pgp_start_shows_message_when_disconnecting(void** state); -void cmd_pgp_start_shows_message_when_connecting(void** state); -void cmd_pgp_start_shows_message_when_undefined(void** state); -void cmd_pgp_start_shows_message_when_no_arg_in_console(void** state); -void cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state); -void cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state); -void cmd_pgp_start_shows_message_when_no_arg_in_private(void** state); -void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state); -#else -void cmd_pgp_shows_message_when_pgp_unsupported(void** state); -#endif diff --git a/tests/unittests/test_cmd_presence.h b/tests/unittests/test_cmd_presence.h deleted file mode 100644 index 96668db2..00000000 --- a/tests/unittests/test_cmd_presence.h +++ /dev/null @@ -1,13 +0,0 @@ -void cmd_presence_shows_usage_when_bad_subcmd(void** state); -void cmd_presence_shows_usage_when_bad_console_setting(void** state); -void cmd_presence_shows_usage_when_bad_chat_setting(void** state); -void cmd_presence_shows_usage_when_bad_muc_setting(void** state); -void cmd_presence_console_sets_all(void** state); -void cmd_presence_console_sets_online(void** state); -void cmd_presence_console_sets_none(void** state); -void cmd_presence_chat_sets_all(void** state); -void cmd_presence_chat_sets_online(void** state); -void cmd_presence_chat_sets_none(void** state); -void cmd_presence_room_sets_all(void** state); -void cmd_presence_room_sets_online(void** state); -void cmd_presence_room_sets_none(void** state); diff --git a/tests/unittests/test_cmd_rooms.h b/tests/unittests/test_cmd_rooms.h deleted file mode 100644 index d1107d78..00000000 --- a/tests/unittests/test_cmd_rooms.h +++ /dev/null @@ -1,7 +0,0 @@ -void cmd_rooms_shows_message_when_disconnected(void** state); -void cmd_rooms_shows_message_when_disconnecting(void** state); -void cmd_rooms_shows_message_when_connecting(void** state); -void cmd_rooms_shows_message_when_undefined(void** state); -void cmd_rooms_uses_account_default_when_no_arg(void** state); -void cmd_rooms_service_arg_used_when_passed(void** state); -void cmd_rooms_filter_arg_used_when_passed(void** state); diff --git a/tests/unittests/test_cmd_roster.h b/tests/unittests/test_cmd_roster.h deleted file mode 100644 index bc57f267..00000000 --- a/tests/unittests/test_cmd_roster.h +++ /dev/null @@ -1,17 +0,0 @@ -void cmd_roster_shows_message_when_disconnecting(void** state); -void cmd_roster_shows_message_when_connecting(void** state); -void cmd_roster_shows_message_when_disconnected(void** state); -void cmd_roster_shows_message_when_undefined(void** state); -void cmd_roster_shows_roster_when_no_args(void** state); -void cmd_roster_add_shows_message_when_no_jid(void** state); -void cmd_roster_add_sends_roster_add_request(void** state); -void cmd_roster_remove_shows_message_when_no_jid(void** state); -void cmd_roster_remove_sends_roster_remove_request(void** state); -void cmd_roster_remove_nickname_sends_roster_remove_request(void** state); -void cmd_roster_nick_shows_message_when_no_jid(void** state); -void cmd_roster_nick_shows_message_when_no_nick(void** state); -void cmd_roster_nick_shows_message_when_no_contact_exists(void** state); -void cmd_roster_nick_sends_name_change_request(void** state); -void cmd_roster_clearnick_shows_message_when_no_jid(void** state); -void cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state); -void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void** state); diff --git a/tests/unittests/test_cmd_sub.h b/tests/unittests/test_cmd_sub.h deleted file mode 100644 index 6cebf649..00000000 --- a/tests/unittests/test_cmd_sub.h +++ /dev/null @@ -1,2 +0,0 @@ -void cmd_sub_shows_message_when_not_connected(void** state); -void cmd_sub_shows_usage_when_no_arg(void** state); diff --git a/tests/unittests/test_common.c b/tests/unittests/test_common.c index aed343c2..822ea7e5 100644 --- a/tests/unittests/test_common.c +++ b/tests/unittests/test_common.c @@ -5,7 +5,7 @@ #include "tests/unittests/ui/stub_ui.h" // Include for mocking cons_show void -replace_one_substr(void** state) +str_replace__returns__one_substr(void** state) { char* string = "it is a string"; char* sub = "is"; @@ -19,7 +19,7 @@ replace_one_substr(void** state) } void -replace_one_substr_beginning(void** state) +str_replace__returns__one_substr_beginning(void** state) { char* string = "it is a string"; char* sub = "it"; @@ -33,7 +33,7 @@ replace_one_substr_beginning(void** state) } void -replace_one_substr_end(void** state) +str_replace__returns__one_substr_end(void** state) { char* string = "it is a string"; char* sub = "string"; @@ -47,7 +47,7 @@ replace_one_substr_end(void** state) } void -replace_two_substr(void** state) +str_replace__returns__two_substr(void** state) { char* string = "it is a is string"; char* sub = "is"; @@ -61,7 +61,7 @@ replace_two_substr(void** state) } void -replace_char(void** state) +str_replace__returns__char(void** state) { char* string = "some & a thing & something else"; char* sub = "&"; @@ -75,7 +75,7 @@ replace_char(void** state) } void -replace_when_none(void** state) +str_replace__returns__original_when_none(void** state) { char* string = "its another string"; char* sub = "haha"; @@ -89,7 +89,7 @@ replace_when_none(void** state) } void -replace_when_match(void** state) +str_replace__returns__replaced_when_match(void** state) { char* string = "hello"; char* sub = "hello"; @@ -103,7 +103,7 @@ replace_when_match(void** state) } void -replace_when_string_empty(void** state) +str_replace__returns__empty_when_string_empty(void** state) { char* string = ""; char* sub = "hello"; @@ -117,7 +117,7 @@ replace_when_string_empty(void** state) } void -replace_when_string_null(void** state) +str_replace__returns__null_when_string_null(void** state) { char* string = NULL; char* sub = "hello"; @@ -129,7 +129,7 @@ replace_when_string_null(void** state) } void -replace_when_sub_empty(void** state) +str_replace__returns__original_when_sub_empty(void** state) { char* string = "hello"; char* sub = ""; @@ -143,7 +143,7 @@ replace_when_sub_empty(void** state) } void -replace_when_sub_null(void** state) +str_replace__returns__original_when_sub_null(void** state) { char* string = "hello"; char* sub = NULL; @@ -157,7 +157,7 @@ replace_when_sub_null(void** state) } void -replace_when_new_empty(void** state) +str_replace__returns__empty_when_new_empty(void** state) { char* string = "hello"; char* sub = "hello"; @@ -171,7 +171,7 @@ replace_when_new_empty(void** state) } void -replace_when_new_null(void** state) +str_replace__returns__original_when_new_null(void** state) { char* string = "hello"; char* sub = "hello"; @@ -185,55 +185,55 @@ replace_when_new_null(void** state) } void -test_online_is_valid_resource_presence_string(void** state) +valid_resource_presence_string__is__true_for_online(void** state) { assert_true(valid_resource_presence_string("online")); } void -test_chat_is_valid_resource_presence_string(void** state) +valid_resource_presence_string__is__true_for_chat(void** state) { assert_true(valid_resource_presence_string("chat")); } void -test_away_is_valid_resource_presence_string(void** state) +valid_resource_presence_string__is__true_for_away(void** state) { assert_true(valid_resource_presence_string("away")); } void -test_xa_is_valid_resource_presence_string(void** state) +valid_resource_presence_string__is__true_for_xa(void** state) { assert_true(valid_resource_presence_string("xa")); } void -test_dnd_is_valid_resource_presence_string(void** state) +valid_resource_presence_string__is__true_for_dnd(void** state) { assert_true(valid_resource_presence_string("dnd")); } void -test_available_is_not_valid_resource_presence_string(void** state) +valid_resource_presence_string__is__false_for_available(void** state) { assert_false(valid_resource_presence_string("available")); } void -test_unavailable_is_not_valid_resource_presence_string(void** state) +valid_resource_presence_string__is__false_for_unavailable(void** state) { assert_false(valid_resource_presence_string("unavailable")); } void -test_blah_is_not_valid_resource_presence_string(void** state) +valid_resource_presence_string__is__false_for_blah(void** state) { assert_false(valid_resource_presence_string("blah")); } void -utf8_display_len_null_str(void** state) +utf8_display_len__returns__0_for_null(void** state) { int result = utf8_display_len(NULL); @@ -241,7 +241,7 @@ utf8_display_len_null_str(void** state) } void -utf8_display_len_1_non_wide(void** state) +utf8_display_len__returns__1_for_non_wide(void** state) { int result = utf8_display_len("1"); @@ -249,7 +249,7 @@ utf8_display_len_1_non_wide(void** state) } void -utf8_display_len_1_wide(void** state) +utf8_display_len__returns__2_for_wide(void** state) { int result = utf8_display_len("四"); @@ -257,7 +257,7 @@ utf8_display_len_1_wide(void** state) } void -utf8_display_len_non_wide(void** state) +utf8_display_len__returns__correct_for_non_wide(void** state) { int result = utf8_display_len("123456789abcdef"); @@ -265,7 +265,7 @@ utf8_display_len_non_wide(void** state) } void -utf8_display_len_wide(void** state) +utf8_display_len__returns__correct_for_wide(void** state) { int result = utf8_display_len("12三四56"); @@ -273,7 +273,7 @@ utf8_display_len_wide(void** state) } void -utf8_display_len_all_wide(void** state) +utf8_display_len__returns__correct_for_all_wide(void** state) { int result = utf8_display_len("ひらがな"); @@ -281,7 +281,7 @@ utf8_display_len_all_wide(void** state) } void -strip_quotes_does_nothing_when_no_quoted(void** state) +strip_arg_quotes__returns__original_when_no_quotes(void** state) { char* input = "/cmd test string"; @@ -293,7 +293,7 @@ strip_quotes_does_nothing_when_no_quoted(void** state) } void -strip_quotes_strips_first(void** state) +strip_arg_quotes__returns__stripped_first(void** state) { char* input = "/cmd \"test string"; @@ -305,7 +305,7 @@ strip_quotes_strips_first(void** state) } void -strip_quotes_strips_last(void** state) +strip_arg_quotes__returns__stripped_last(void** state) { char* input = "/cmd test string\""; @@ -317,7 +317,7 @@ strip_quotes_strips_last(void** state) } void -strip_quotes_strips_both(void** state) +strip_arg_quotes__returns__stripped_both(void** state) { char* input = "/cmd \"test string\""; @@ -328,7 +328,9 @@ strip_quotes_strips_both(void** state) free(result); } -void test_valid_tls_policy_option(void** state) { +void +valid_tls_policy_option__is__correct_for_various_inputs(void** state) +{ // Valid inputs assert_true(valid_tls_policy_option("force")); assert_true(valid_tls_policy_option("allow")); @@ -348,11 +350,13 @@ void test_valid_tls_policy_option(void** state) { expect_any_cons_show(); // For "TLS policy must be one of: 'force', 'allow', 'trust', 'disable', 'legacy', or 'direct'." assert_false(valid_tls_policy_option("")); - // NULL + // NULL assert_true(valid_tls_policy_option(NULL)); } -void test_get_expanded_path(void** state) { +void +get_expanded_path__returns__expanded(void** state) +{ gchar* expanded_path; // `file://` prefix @@ -378,7 +382,9 @@ void test_get_expanded_path(void** state) { g_free(expanded_path); } -void test_strtoi_range_valid_input(void** state) { +void +strtoi_range__returns__true_for_valid_input(void** state) +{ int value; gchar* err_msg = NULL; gboolean result; @@ -404,7 +410,9 @@ void test_strtoi_range_valid_input(void** state) { assert_null(err_msg); } -void test_strtoi_range_out_of_range(void** state) { +void +strtoi_range__returns__false_for_out_of_range(void** state) +{ int value; gchar* err_msg = NULL; gboolean result; @@ -431,7 +439,9 @@ void test_strtoi_range_out_of_range(void** state) { err_msg = NULL; } -void test_strtoi_range_invalid_input(void** state) { +void +strtoi_range__returns__false_for_invalid_input(void** state) +{ int value; gchar* err_msg = NULL; gboolean result; @@ -451,7 +461,9 @@ void test_strtoi_range_invalid_input(void** state) { err_msg = NULL; } -void test_strtoi_range_null_empty_input(void** state) { +void +strtoi_range__returns__false_for_null_empty_input(void** state) +{ int value; gchar* err_msg = NULL; gboolean result; @@ -471,7 +483,9 @@ void test_strtoi_range_null_empty_input(void** state) { err_msg = NULL; } -void test_strtoi_range_null_err_msg(void** state) { +void +strtoi_range__returns__correct_values_when_err_msg_null(void** state) +{ int value; gboolean result; @@ -485,7 +499,9 @@ void test_strtoi_range_null_err_msg(void** state) { assert_false(result); } -void test_string_to_verbosity(void** state) { +void +string_to_verbosity__returns__correct_values(void** state) +{ int verbosity; gchar* err_msg = NULL; gboolean result; @@ -495,52 +511,59 @@ void test_string_to_verbosity(void** state) { assert_true(result); assert_int_equal(0, verbosity); assert_null(err_msg); - g_free(err_msg); err_msg = NULL; // Clear for next test + g_free(err_msg); + err_msg = NULL; // Clear for next test // Valid input string (1) result = string_to_verbosity("1", &verbosity, &err_msg); assert_true(result); assert_int_equal(1, verbosity); assert_null(err_msg); - g_free(err_msg); err_msg = NULL; + g_free(err_msg); + err_msg = NULL; // Valid input string (3) result = string_to_verbosity("3", &verbosity, &err_msg); assert_true(result); assert_int_equal(3, verbosity); assert_null(err_msg); - g_free(err_msg); err_msg = NULL; + g_free(err_msg); + err_msg = NULL; // Invalid input string (not a number) result = string_to_verbosity("profanity", &verbosity, &err_msg); assert_false(result); assert_string_equal("Could not convert \"profanity\" to a number.", err_msg); g_free(err_msg); - err_msg = NULL; + err_msg = NULL; // Valid input string, out of range (too low) result = string_to_verbosity("-1", &verbosity, &err_msg); assert_false(result); assert_string_equal("Value -1 out of range. Must be in 0..3.", err_msg); - g_free(err_msg); err_msg = NULL; + g_free(err_msg); + err_msg = NULL; // Valid input string, out of range (too high) result = string_to_verbosity("4", &verbosity, &err_msg); assert_false(result); assert_string_equal("Value 4 out of range. Must be in 0..3.", err_msg); - g_free(err_msg); err_msg = NULL; + g_free(err_msg); + err_msg = NULL; // NULL input string result = string_to_verbosity(NULL, &verbosity, &err_msg); assert_false(result); assert_string_equal("'str' input pointer can not be NULL", err_msg); - g_free(err_msg); err_msg = NULL; + g_free(err_msg); + err_msg = NULL; // Empty input string result = string_to_verbosity("", &verbosity, &err_msg); assert_false(result); assert_string_equal("Could not convert \"\" to a number.", err_msg); - g_free(err_msg); err_msg = NULL; + g_free(err_msg); + err_msg = NULL; // err_msg is NULL result = string_to_verbosity("abc", &verbosity, NULL); @@ -556,7 +579,7 @@ typedef struct } format_call_external_argv_t; void -format_call_external_argv_td(void** state) +format_call_external_argv__tests__table_driven(void** state) { enum table { num_tests = 4 }; @@ -613,7 +636,7 @@ typedef struct } unique_filename_from_url_t; void -unique_filename_from_url_td(void** state) +unique_filename_from_url__tests__table_driven(void** state) { enum table { num_tests = 15 }; @@ -751,7 +774,7 @@ _lists_equal(GSList* a, GSList* b) } void -prof_occurrences_of_large_message_tests(void** state) +prof_occurrences__tests__large_message(void** state) { GSList* actual = NULL; GSList* expected = NULL; @@ -773,7 +796,7 @@ prof_occurrences_of_large_message_tests(void** state) } void -prof_partial_occurrences_tests(void** state) +prof_occurrences__tests__partial(void** state) { GSList* actual = NULL; GSList* expected = NULL; @@ -865,7 +888,7 @@ prof_partial_occurrences_tests(void** state) } void -get_mentions_tests(void** state) +get_mentions__tests__various(void** state) { GSList* actual = NULL; GSList* expected = NULL; @@ -874,70 +897,87 @@ get_mentions_tests(void** state) expected = g_slist_append(expected, GINT_TO_POINTER(6)); actual = get_mentions(FALSE, TRUE, "hello boothj5", "boothj5"); assert_true(_lists_equal(actual, expected)); - g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; // Case insensitive match expected = g_slist_append(expected, GINT_TO_POINTER(6)); actual = get_mentions(FALSE, FALSE, "hello BOOTHJ5", "boothj5"); assert_true(_lists_equal(actual, expected)); - g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; // Whole word match expected = g_slist_append(expected, GINT_TO_POINTER(0)); actual = get_mentions(TRUE, TRUE, "boothj5 hello", "boothj5"); assert_true(_lists_equal(actual, expected)); - g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; // Whole word no match (partial) actual = get_mentions(TRUE, TRUE, "boothj5hello", "boothj5"); assert_true(_lists_equal(actual, expected)); // expected is NULL - g_slist_free(actual); actual = NULL; + g_slist_free(actual); + actual = NULL; // Multiple matches expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(14)); actual = get_mentions(FALSE, TRUE, "boothj5 hello boothj5", "boothj5"); assert_true(_lists_equal(actual, expected)); - g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; // Nick with punctuation (whole word) expected = g_slist_append(expected, GINT_TO_POINTER(0)); actual = get_mentions(TRUE, TRUE, "boothj5: hi", "boothj5"); assert_true(_lists_equal(actual, expected)); - g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; // Nick surrounded by punctuation expected = g_slist_append(expected, GINT_TO_POINTER(1)); actual = get_mentions(TRUE, TRUE, "(boothj5)", "boothj5"); assert_true(_lists_equal(actual, expected)); - g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; // Empty message actual = get_mentions(FALSE, TRUE, "", "boothj5"); assert_true(_lists_equal(actual, expected)); // expected is NULL - g_slist_free(actual); actual = NULL; + g_slist_free(actual); + actual = NULL; // Empty nick actual = get_mentions(FALSE, TRUE, "hello", ""); assert_true(_lists_equal(actual, expected)); // expected is NULL - g_slist_free(actual); actual = NULL; + g_slist_free(actual); + actual = NULL; // UTF-8 characters expected = g_slist_append(expected, GINT_TO_POINTER(0)); actual = get_mentions(TRUE, TRUE, "我能 hello", "我能"); assert_true(_lists_equal(actual, expected)); - g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; } void -release_is_new_tests(void** state) +release_is_new__tests__various(void** state) { // Higher major version assert_true(release_is_new("0.16.0", "1.0.0")); @@ -962,9 +1002,9 @@ release_is_new_tests(void** state) assert_true(release_is_new("1.2.3", "2.0.0")); // Malformed version strings - assert_false(release_is_new("0.16.0", "0.16")); // Missing patch in found - assert_false(release_is_new("0.16", "0.16.0")); // Missing patch in curr - assert_false(release_is_new("0.16.0", "0.16.0.1")); // Extra part + assert_false(release_is_new("0.16.0", "0.16")); // Missing patch in found + assert_false(release_is_new("0.16", "0.16.0")); // Missing patch in curr + assert_false(release_is_new("0.16.0", "0.16.0.1")); // Extra part assert_false(release_is_new("0.16.0", "abc.def.ghi")); assert_false(release_is_new("0.16.0", "")); @@ -973,7 +1013,7 @@ release_is_new_tests(void** state) } void -prof_whole_occurrences_tests(void** state) +prof_occurrences__tests__whole(void** state) { GSList* actual = NULL; GSList* expected = NULL; @@ -1175,7 +1215,9 @@ prof_whole_occurrences_tests(void** state) expected = NULL; } -void test_string_matches_one_of_edge_cases(void** state) { +void +string_matches_one_of__tests__edge_cases(void** state) +{ // is is NULL, is_can_be_null is TRUE -> should return TRUE assert_true(string_matches_one_of(NULL, NULL, TRUE, "option1", "option2", NULL)); diff --git a/tests/unittests/test_common.h b/tests/unittests/test_common.h index 6229d54a..0bd72943 100644 --- a/tests/unittests/test_common.h +++ b/tests/unittests/test_common.h @@ -1,47 +1,56 @@ -void replace_one_substr(void** state); -void replace_one_substr_beginning(void** state); -void replace_one_substr_end(void** state); -void replace_two_substr(void** state); -void replace_char(void** state); -void replace_when_none(void** state); -void replace_when_match(void** state); -void replace_when_string_empty(void** state); -void replace_when_string_null(void** state); -void replace_when_sub_empty(void** state); -void replace_when_sub_null(void** state); -void replace_when_new_empty(void** state); -void replace_when_new_null(void** state); -void test_online_is_valid_resource_presence_string(void** state); -void test_chat_is_valid_resource_presence_string(void** state); -void test_away_is_valid_resource_presence_string(void** state); -void test_xa_is_valid_resource_presence_string(void** state); -void test_dnd_is_valid_resource_presence_string(void** state); -void test_available_is_not_valid_resource_presence_string(void** state); -void test_unavailable_is_not_valid_resource_presence_string(void** state); -void test_blah_is_not_valid_resource_presence_string(void** state); -void utf8_display_len_null_str(void** state); -void utf8_display_len_1_non_wide(void** state); -void utf8_display_len_1_wide(void** state); -void utf8_display_len_non_wide(void** state); -void utf8_display_len_wide(void** state); -void utf8_display_len_all_wide(void** state); -void strip_quotes_does_nothing_when_no_quoted(void** state); -void strip_quotes_strips_first(void** state); -void strip_quotes_strips_last(void** state); -void strip_quotes_strips_both(void** state); -void prof_partial_occurrences_tests(void** state); -void prof_whole_occurrences_tests(void** state); -void prof_occurrences_of_large_message_tests(void** state); -void unique_filename_from_url_td(void** state); -void format_call_external_argv_td(void** state); -void test_get_expanded_path(void** state); -void test_string_to_verbosity(void** state); -void test_strtoi_range_valid_input(void** state); -void test_strtoi_range_out_of_range(void** state); -void test_strtoi_range_invalid_input(void** state); -void test_strtoi_range_null_empty_input(void** state); -void test_strtoi_range_null_err_msg(void** state); -void test_string_matches_one_of_edge_cases(void** state); -void test_valid_tls_policy_option(void** state); -void get_mentions_tests(void** state); -void release_is_new_tests(void** state); +#ifndef TESTS_TEST_COMMON_H +#define TESTS_TEST_COMMON_H + +void str_replace__returns__one_substr(void** state); +void str_replace__returns__one_substr_beginning(void** state); +void str_replace__returns__one_substr_end(void** state); +void str_replace__returns__two_substr(void** state); +void str_replace__returns__char(void** state); +void str_replace__returns__original_when_none(void** state); +void str_replace__returns__replaced_when_match(void** state); +void str_replace__returns__empty_when_string_empty(void** state); +void str_replace__returns__null_when_string_null(void** state); +void str_replace__returns__original_when_sub_empty(void** state); +void str_replace__returns__original_when_sub_null(void** state); +void str_replace__returns__empty_when_new_empty(void** state); +void str_replace__returns__original_when_new_null(void** state); + +void valid_resource_presence_string__is__true_for_online(void** state); +void valid_resource_presence_string__is__true_for_chat(void** state); +void valid_resource_presence_string__is__true_for_away(void** state); +void valid_resource_presence_string__is__true_for_xa(void** state); +void valid_resource_presence_string__is__true_for_dnd(void** state); +void valid_resource_presence_string__is__false_for_available(void** state); +void valid_resource_presence_string__is__false_for_unavailable(void** state); +void valid_resource_presence_string__is__false_for_blah(void** state); + +void utf8_display_len__returns__0_for_null(void** state); +void utf8_display_len__returns__1_for_non_wide(void** state); +void utf8_display_len__returns__2_for_wide(void** state); +void utf8_display_len__returns__correct_for_non_wide(void** state); +void utf8_display_len__returns__correct_for_wide(void** state); +void utf8_display_len__returns__correct_for_all_wide(void** state); + +void strip_arg_quotes__returns__original_when_no_quotes(void** state); +void strip_arg_quotes__returns__stripped_first(void** state); +void strip_arg_quotes__returns__stripped_last(void** state); +void strip_arg_quotes__returns__stripped_both(void** state); + +void prof_occurrences__tests__partial(void** state); +void prof_occurrences__tests__whole(void** state); +void prof_occurrences__tests__large_message(void** state); +void unique_filename_from_url__tests__table_driven(void** state); +void format_call_external_argv__tests__table_driven(void** state); +void get_expanded_path__returns__expanded(void** state); +void string_to_verbosity__returns__correct_values(void** state); +void strtoi_range__returns__true_for_valid_input(void** state); +void strtoi_range__returns__false_for_out_of_range(void** state); +void strtoi_range__returns__false_for_invalid_input(void** state); +void strtoi_range__returns__false_for_null_empty_input(void** state); +void strtoi_range__returns__correct_values_when_err_msg_null(void** state); +void string_matches_one_of__tests__edge_cases(void** state); +void valid_tls_policy_option__is__correct_for_various_inputs(void** state); +void get_mentions__tests__various(void** state); +void release_is_new__tests__various(void** state); + +#endif diff --git a/tests/unittests/test_contact.h b/tests/unittests/test_contact.h deleted file mode 100644 index 605573ea..00000000 --- a/tests/unittests/test_contact.h +++ /dev/null @@ -1,24 +0,0 @@ -void contact_in_group(void** state); -void contact_not_in_group(void** state); -void contact_name_when_name_exists(void** state); -void contact_jid_when_name_not_exists(void** state); -void contact_string_when_name_exists(void** state); -void contact_string_when_name_not_exists(void** state); -void contact_string_when_default_resource(void** state); -void contact_presence_offline(void** state); -void contact_presence_uses_highest_priority(void** state); -void contact_presence_chat_when_same_prioroty(void** state); -void contact_presence_online_when_same_prioroty(void** state); -void contact_presence_away_when_same_prioroty(void** state); -void contact_presence_xa_when_same_prioroty(void** state); -void contact_presence_dnd(void** state); -void contact_subscribed_when_to(void** state); -void contact_subscribed_when_both(void** state); -void contact_not_subscribed_when_from(void** state); -void contact_not_subscribed_when_no_subscription_value(void** state); -void contact_not_available(void** state); -void contact_not_available_when_highest_priority_away(void** state); -void contact_not_available_when_highest_priority_xa(void** state); -void contact_not_available_when_highest_priority_dnd(void** state); -void contact_available_when_highest_priority_online(void** state); -void contact_available_when_highest_priority_chat(void** state); diff --git a/tests/unittests/test_form.h b/tests/unittests/test_form.h deleted file mode 100644 index a7ae04c5..00000000 --- a/tests/unittests/test_form.h +++ /dev/null @@ -1,21 +0,0 @@ -void get_form_type_field_returns_null_no_fields(void** state); -void get_form_type_field_returns_null_when_not_present(void** state); -void get_form_type_field_returns_value_when_present(void** state); -void get_field_type_returns_unknown_when_no_fields(void** state); -void get_field_type_returns_correct_type(void** state); -void set_value_adds_when_none(void** state); -void set_value_updates_when_one(void** state); -void add_unique_value_adds_when_none(void** state); -void add_unique_value_does_nothing_when_exists(void** state); -void add_unique_value_adds_when_doesnt_exist(void** state); -void add_value_adds_when_none(void** state); -void add_value_adds_when_some(void** state); -void add_value_adds_when_exists(void** state); -void remove_value_does_nothing_when_none(void** state); -void remove_value_does_nothing_when_doesnt_exist(void** state); -void remove_value_removes_when_one(void** state); -void remove_value_removes_when_many(void** state); -void remove_text_multi_value_does_nothing_when_none(void** state); -void remove_text_multi_value_does_nothing_when_doesnt_exist(void** state); -void remove_text_multi_value_removes_when_one(void** state); -void remove_text_multi_value_removes_when_many(void** state); diff --git a/tests/unittests/test_jid.h b/tests/unittests/test_jid.h deleted file mode 100644 index 000b820a..00000000 --- a/tests/unittests/test_jid.h +++ /dev/null @@ -1,25 +0,0 @@ -void create_jid_from_null_returns_null(void** state); -void create_jid_from_empty_string_returns_null(void** state); -void create_jid_from_full_returns_full(void** state); -void create_jid_from_full_returns_bare(void** state); -void create_jid_from_full_returns_resourcepart(void** state); -void create_jid_from_full_returns_localpart(void** state); -void create_jid_from_full_returns_domainpart(void** state); -void create_jid_from_full_nolocal_returns_full(void** state); -void create_jid_from_full_nolocal_returns_bare(void** state); -void create_jid_from_full_nolocal_returns_resourcepart(void** state); -void create_jid_from_full_nolocal_returns_domainpart(void** state); -void create_jid_from_full_nolocal_returns_null_localpart(void** state); -void create_jid_from_bare_returns_null_full(void** state); -void create_jid_from_bare_returns_null_resource(void** state); -void create_jid_from_bare_returns_bare(void** state); -void create_jid_from_bare_returns_localpart(void** state); -void create_jid_from_bare_returns_domainpart(void** state); -void create_room_jid_returns_room(void** state); -void create_room_jid_returns_nick(void** state); -void create_with_slash_in_resource(void** state); -void create_with_at_in_resource(void** state); -void create_with_at_and_slash_in_resource(void** state); -void create_full_with_trailing_slash(void** state); -void returns_fulljid_when_exists(void** state); -void returns_barejid_when_fulljid_not_exists(void** state); diff --git a/tests/unittests/test_keyhandlers.h b/tests/unittests/test_keyhandlers.h deleted file mode 100644 index 910efe97..00000000 --- a/tests/unittests/test_keyhandlers.h +++ /dev/null @@ -1,47 +0,0 @@ -void append_to_empty(void **state); -void append_wide_to_empty(void **state); -void append_to_single(void **state); -void append_wide_to_single_non_wide(void **state); -void append_non_wide_to_single_wide(void **state); -void append_wide_to_single_wide(void **state); -void append_non_wide_when_overrun(void **state); - -void insert_non_wide_to_non_wide(void **state); -void insert_single_non_wide_when_pad_scrolled(void **state); -void insert_many_non_wide_when_pad_scrolled(void **state); -void insert_single_non_wide_last_column(void **state); -void insert_many_non_wide_last_column(void **state); - -void ctrl_left_when_no_input(void **state); -void ctrl_left_when_at_start(void **state); -void ctrl_left_when_in_first_word(void **state); -void ctrl_left_when_in_first_space(void **state); -void ctrl_left_when_at_start_of_second_word(void **state); -void ctrl_left_when_in_second_word(void **state); -void ctrl_left_when_at_end_of_second_word(void **state); -void ctrl_left_when_in_second_space(void **state); -void ctrl_left_when_at_start_of_third_word(void **state); -void ctrl_left_when_in_third_word(void **state); -void ctrl_left_when_at_end_of_third_word(void **state); -void ctrl_left_when_in_third_space(void **state); -void ctrl_left_when_at_end(void **state); -void ctrl_left_when_in_only_whitespace(void **state); -void ctrl_left_when_start_whitespace_start_of_word(void **state); -void ctrl_left_when_start_whitespace_middle_of_word(void **state); -void ctrl_left_in_whitespace_between_words(void **state); -void ctrl_left_in_whitespace_between_words_start_of_word(void **state); -void ctrl_left_in_whitespace_between_words_middle_of_word(void **state); -void ctrl_left_when_word_overrun_to_left(void **state); - -void ctrl_right_when_no_input(void **state); -void ctrl_right_when_at_end(void **state); -void ctrl_right_one_word_at_start(void **state); -void ctrl_right_one_word_in_middle(void **state); -void ctrl_right_one_word_at_end(void **state); -void ctrl_right_two_words_from_middle_first(void **state); -void ctrl_right_two_words_from_end_first(void **state); -void ctrl_right_two_words_from_space(void **state); -void ctrl_right_two_words_from_start_second(void **state); -void ctrl_right_one_word_leading_whitespace(void **state); -void ctrl_right_two_words_in_whitespace(void **state); -void ctrl_right_trailing_whitespace_from_middle(void **state); diff --git a/tests/unittests/test_muc.h b/tests/unittests/test_muc.h deleted file mode 100644 index df89d6d1..00000000 --- a/tests/unittests/test_muc.h +++ /dev/null @@ -1,9 +0,0 @@ -int muc_before_test(void** state); -int muc_after_test(void** state); - -void test_muc_invites_add(void** state); -void test_muc_remove_invite(void** state); -void test_muc_invites_count_0(void** state); -void test_muc_invites_count_5(void** state); -void test_muc_room_is_not_active(void** state); -void test_muc_active(void** state); diff --git a/tests/unittests/test_parser.h b/tests/unittests/test_parser.h deleted file mode 100644 index 7babb0be..00000000 --- a/tests/unittests/test_parser.h +++ /dev/null @@ -1,50 +0,0 @@ -void parse_null_returns_null(void** state); -void parse_empty_returns_null(void** state); -void parse_space_returns_null(void** state); -void parse_cmd_no_args_returns_null(void** state); -void parse_cmd_with_space_returns_null(void** state); -void parse_cmd_with_too_few_returns_null(void** state); -void parse_cmd_with_too_many_returns_null(void** state); -void parse_cmd_one_arg(void** state); -void parse_cmd_two_args(void** state); -void parse_cmd_three_args(void** state); -void parse_cmd_three_args_with_spaces(void** state); -void parse_cmd_with_freetext(void** state); -void parse_cmd_one_arg_with_freetext(void** state); -void parse_cmd_two_args_with_freetext(void** state); -void parse_cmd_min_zero(void** state); -void parse_cmd_min_zero_with_freetext(void** state); -void parse_cmd_with_quoted(void** state); -void parse_cmd_with_quoted_and_space(void** state); -void parse_cmd_with_quoted_and_many_spaces(void** state); -void parse_cmd_with_many_quoted_and_many_spaces(void** state); -void parse_cmd_freetext_with_quoted(void** state); -void parse_cmd_freetext_with_quoted_and_space(void** state); -void parse_cmd_freetext_with_quoted_and_many_spaces(void** state); -void parse_cmd_freetext_with_many_quoted_and_many_spaces(void** state); -void parse_cmd_with_quoted_freetext(void** state); -void parse_cmd_with_third_arg_quoted_0_min_3_max(void** state); -void parse_cmd_with_second_arg_quoted_0_min_3_max(void** state); -void parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void** state); -void count_one_token(void** state); -void count_one_token_quoted_no_whitespace(void** state); -void count_one_token_quoted_with_whitespace(void** state); -void count_two_tokens(void** state); -void count_two_tokens_first_quoted(void** state); -void count_two_tokens_second_quoted(void** state); -void count_two_tokens_both_quoted(void** state); -void get_first_of_one(void** state); -void get_first_of_two(void** state); -void get_first_two_of_three(void** state); -void get_first_two_of_three_first_quoted(void** state); -void get_first_two_of_three_second_quoted(void** state); -void get_first_two_of_three_first_and_second_quoted(void** state); -void parse_options_when_none_returns_empty_hasmap(void** state); -void parse_options_when_opt1_no_val_sets_error(void** state); -void parse_options_when_one_returns_map(void** state); -void parse_options_when_opt2_no_val_sets_error(void** state); -void parse_options_when_two_returns_map(void** state); -void parse_options_when_opt3_no_val_sets_error(void** state); -void parse_options_when_three_returns_map(void** state); -void parse_options_when_unknown_opt_sets_error(void** state); -void parse_options_with_duplicated_option_sets_error(void** state); diff --git a/tests/unittests/test_plugins_disco.h b/tests/unittests/test_plugins_disco.h deleted file mode 100644 index 4377e28e..00000000 --- a/tests/unittests/test_plugins_disco.h +++ /dev/null @@ -1,7 +0,0 @@ -void returns_empty_list_when_none(void** state); -void returns_added_feature(void** state); -void resets_features_on_close(void** state); -void returns_all_added_features(void** state); -void does_not_add_duplicate_feature(void** state); -void removes_plugin_features(void** state); -void does_not_remove_feature_when_more_than_one_reference(void** state); diff --git a/tests/unittests/test_preferences.h b/tests/unittests/test_preferences.h deleted file mode 100644 index 84438e95..00000000 --- a/tests/unittests/test_preferences.h +++ /dev/null @@ -1,3 +0,0 @@ -void statuses_console_defaults_to_all(void** state); -void statuses_chat_defaults_to_all(void** state); -void statuses_muc_defaults_to_all(void** state); diff --git a/tests/unittests/test_roster_list.h b/tests/unittests/test_roster_list.h deleted file mode 100644 index 81983d46..00000000 --- a/tests/unittests/test_roster_list.h +++ /dev/null @@ -1,35 +0,0 @@ -void empty_list_when_none_added(void** state); -void contains_one_element(void** state); -void first_element_correct(void** state); -void contains_two_elements(void** state); -void first_and_second_elements_correct(void** state); -void contains_three_elements(void** state); -void first_three_elements_correct(void** state); -void add_twice_at_beginning_adds_once(void** state); -void add_twice_in_middle_adds_once(void** state); -void add_twice_at_end_adds_once(void** state); -void find_first_exists(void** state); -void find_second_exists(void** state); -void find_third_exists(void** state); -void find_returns_null(void** state); -void find_on_empty_returns_null(void** state); -void find_twice_returns_second_when_two_match(void** state); -void find_five_times_finds_fifth(void** state); -void find_twice_returns_first_when_two_match_and_reset(void** state); -void add_contact_with_no_group(void** state); -void add_contact_with_group(void** state); -void add_contact_with_two_groups(void** state); -void add_contact_with_three_groups(void** state); -void add_contact_with_three_groups_update_adding_two(void** state); -void add_contact_with_three_groups_update_removing_one(void** state); -void add_contact_with_three_groups_update_removing_two(void** state); -void add_contact_with_three_groups_update_removing_three(void** state); -void add_contact_with_three_groups_update_two_new(void** state); -void add_remove_contact_groups(void** state); -void add_contacts_with_different_groups(void** state); -void add_contacts_with_same_groups(void** state); -void add_contacts_with_overlapping_groups(void** state); -void remove_contact_with_remaining_in_group(void** state); -void get_contact_display_name(void** state); -void get_contact_display_name_is_barejid_if_name_is_empty(void** state); -void get_contact_display_name_is_passed_barejid_if_contact_does_not_exist(void** state); diff --git a/tests/unittests/test_server_events.h b/tests/unittests/test_server_events.h deleted file mode 100644 index 1cac6799..00000000 --- a/tests/unittests/test_server_events.h +++ /dev/null @@ -1,14 +0,0 @@ -void console_doesnt_show_online_presence_when_set_none(void** state); -void console_shows_online_presence_when_set_online(void** state); -void console_shows_online_presence_when_set_all(void** state); -void console_doesnt_show_dnd_presence_when_set_none(void** state); -void console_doesnt_show_dnd_presence_when_set_online(void** state); -void console_shows_dnd_presence_when_set_all(void** state); -void handle_message_error_when_no_recipient(void** state); -void handle_message_error_when_recipient_cancel(void** state); -void handle_message_error_when_recipient_cancel_disables_chat_session(void** state); -void handle_message_error_when_recipient_and_no_type(void** state); -void handle_presence_error_when_no_recipient(void** state); -void handle_presence_error_when_from_recipient(void** state); -void handle_offline_removes_chat_session(void** state); -void lost_connection_clears_chat_sessions(void** state); diff --git a/tests/unittests/tools/stub_aesgcm_download.c b/tests/unittests/tools/stub_aesgcm_download.c index 07f411ca..62c41de8 100644 --- a/tests/unittests/tools/stub_aesgcm_download.c +++ b/tests/unittests/tools/stub_aesgcm_download.c @@ -22,7 +22,7 @@ aesgcm_file_get(void* userdata) return NULL; }; -void aesgcm_download_cancel_processes(ProfWin* window){}; -void aesgcm_download_add_download(AESGCMDownload* download){}; +void aesgcm_download_cancel_processes(ProfWin* window) {}; +void aesgcm_download_add_download(AESGCMDownload* download) {}; #endif diff --git a/tests/unittests/tools/stub_http_download.c b/tests/unittests/tools/stub_http_download.c index aff47200..8acecdff 100644 --- a/tests/unittests/tools/stub_http_download.c +++ b/tests/unittests/tools/stub_http_download.c @@ -27,7 +27,7 @@ http_file_get(void* userdata) return NULL; } -void http_download_cancel_processes(){}; -void http_download_add_download(){}; +void http_download_cancel_processes() {}; +void http_download_add_download() {}; #endif diff --git a/tests/unittests/tools/stub_http_upload.c b/tests/unittests/tools/stub_http_upload.c index 49320f85..d1d0e59c 100644 --- a/tests/unittests/tools/stub_http_upload.c +++ b/tests/unittests/tools/stub_http_upload.c @@ -38,7 +38,7 @@ file_size(int filedes) return 0; } -void http_upload_cancel_processes(){}; -void http_upload_add_upload(){}; +void http_upload_cancel_processes() {}; +void http_upload_add_upload() {}; #endif diff --git a/tests/unittests/test_autocomplete.c b/tests/unittests/tools/test_autocomplete.c similarity index 82% rename from tests/unittests/test_autocomplete.c rename to tests/unittests/tools/test_autocomplete.c index 0377fe87..77a6414d 100644 --- a/tests/unittests/test_autocomplete.c +++ b/tests/unittests/tools/test_autocomplete.c @@ -6,7 +6,7 @@ #include "tools/autocomplete.h" void -clear_empty(void** state) +autocomplete_complete__returns__null_when_empty(void** state) { Autocomplete ac = autocomplete_new(); char* result = autocomplete_complete(ac, "test", TRUE, FALSE); @@ -16,7 +16,7 @@ clear_empty(void** state) } void -reset_after_create(void** state) +autocomplete_reset__updates__after_create(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_reset(ac); @@ -24,7 +24,7 @@ reset_after_create(void** state) } void -find_after_create(void** state) +autocomplete_complete__returns__null_after_create(void** state) { Autocomplete ac = autocomplete_new(); char* result = autocomplete_complete(ac, "hello", TRUE, FALSE); @@ -34,7 +34,7 @@ find_after_create(void** state) } void -get_after_create_returns_null(void** state) +autocomplete_create_list__returns__null_after_create(void** state) { Autocomplete ac = autocomplete_new(); GList* result = autocomplete_create_list(ac); @@ -46,7 +46,7 @@ get_after_create_returns_null(void** state) } void -add_one_and_complete(void** state) +autocomplete_add__updates__one_and_complete(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); @@ -59,7 +59,7 @@ add_one_and_complete(void** state) } void -add_two_and_complete_returns_first(void** state) +autocomplete_complete__returns__first_of_two(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); @@ -73,7 +73,7 @@ add_two_and_complete_returns_first(void** state) } void -add_two_and_complete_returns_second(void** state) +autocomplete_complete__returns__second_of_two(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); @@ -89,7 +89,7 @@ add_two_and_complete_returns_second(void** state) } void -add_two_adds_two(void** state) +autocomplete_add__updates__two_elements(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); @@ -103,7 +103,7 @@ add_two_adds_two(void** state) } void -add_two_same_adds_one(void** state) +autocomplete_add__updates__only_once_for_same_value(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); @@ -117,7 +117,7 @@ add_two_same_adds_one(void** state) } void -add_two_same_updates(void** state) +autocomplete_add__updates__existing_value(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); @@ -135,7 +135,7 @@ add_two_same_updates(void** state) } void -complete_accented_with_accented(void** state) +autocomplete_complete__returns__accented_with_accented(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "èâîô"); @@ -149,7 +149,7 @@ complete_accented_with_accented(void** state) } void -complete_accented_with_base(void** state) +autocomplete_complete__returns__accented_with_base(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "èâîô"); @@ -163,7 +163,7 @@ complete_accented_with_base(void** state) } void -complete_both_with_accented(void** state) +autocomplete_complete__returns__both_with_accented(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "eaooooo"); @@ -180,7 +180,7 @@ complete_both_with_accented(void** state) } void -complete_both_with_base(void** state) +autocomplete_complete__returns__both_with_base(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "eaooooo"); @@ -198,7 +198,7 @@ complete_both_with_base(void** state) } void -complete_ignores_case(void** state) +autocomplete_complete__is__case_insensitive(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "MyBuddy"); @@ -212,7 +212,7 @@ complete_ignores_case(void** state) } void -complete_previous(void** state) +autocomplete_complete__returns__previous(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "MyBuddy1"); diff --git a/tests/unittests/tools/test_autocomplete.h b/tests/unittests/tools/test_autocomplete.h new file mode 100644 index 00000000..047123da --- /dev/null +++ b/tests/unittests/tools/test_autocomplete.h @@ -0,0 +1,21 @@ +#ifndef TESTS_TEST_AUTOCOMPLETE_H +#define TESTS_TEST_AUTOCOMPLETE_H + +void autocomplete_complete__returns__null_when_empty(void** state); +void autocomplete_reset__updates__after_create(void** state); +void autocomplete_complete__returns__null_after_create(void** state); +void autocomplete_create_list__returns__null_after_create(void** state); +void autocomplete_add__updates__one_and_complete(void** state); +void autocomplete_complete__returns__first_of_two(void** state); +void autocomplete_complete__returns__second_of_two(void** state); +void autocomplete_add__updates__two_elements(void** state); +void autocomplete_add__updates__only_once_for_same_value(void** state); +void autocomplete_add__updates__existing_value(void** state); +void autocomplete_complete__returns__accented_with_accented(void** state); +void autocomplete_complete__returns__accented_with_base(void** state); +void autocomplete_complete__returns__both_with_accented(void** state); +void autocomplete_complete__returns__both_with_base(void** state); +void autocomplete_complete__is__case_insensitive(void** state); +void autocomplete_complete__returns__previous(void** state); + +#endif diff --git a/tests/unittests/test_parser.c b/tests/unittests/tools/test_parser.c similarity index 82% rename from tests/unittests/test_parser.c rename to tests/unittests/tools/test_parser.c index b72527f4..3a42c169 100644 --- a/tests/unittests/test_parser.c +++ b/tests/unittests/tools/test_parser.c @@ -4,7 +4,7 @@ #include "tools/parser.h" void -parse_null_returns_null(void** state) +parse_args__returns__null_from_null(void** state) { char* inp = NULL; gboolean result = TRUE; @@ -16,7 +16,7 @@ parse_null_returns_null(void** state) } void -parse_empty_returns_null(void** state) +parse_args__returns__null_from_empty(void** state) { char* inp = ""; gboolean result = TRUE; @@ -28,7 +28,7 @@ parse_empty_returns_null(void** state) } void -parse_space_returns_null(void** state) +parse_args__returns__null_from_space(void** state) { char* inp = " "; gboolean result = TRUE; @@ -40,7 +40,7 @@ parse_space_returns_null(void** state) } void -parse_cmd_no_args_returns_null(void** state) +parse_args__returns__null_when_no_args(void** state) { char* inp = "/cmd"; gboolean result = TRUE; @@ -52,7 +52,7 @@ parse_cmd_no_args_returns_null(void** state) } void -parse_cmd_with_space_returns_null(void** state) +parse_args__returns__null_from_cmd_with_space(void** state) { char* inp = "/cmd "; gboolean result = TRUE; @@ -64,7 +64,7 @@ parse_cmd_with_space_returns_null(void** state) } void -parse_cmd_with_too_few_returns_null(void** state) +parse_args__returns__null_when_too_few(void** state) { char* inp = "/cmd arg1"; gboolean result = TRUE; @@ -76,7 +76,7 @@ parse_cmd_with_too_few_returns_null(void** state) } void -parse_cmd_with_too_many_returns_null(void** state) +parse_args__returns__null_when_too_many(void** state) { char* inp = "/cmd arg1 arg2 arg3 arg4"; gboolean result = TRUE; @@ -88,7 +88,7 @@ parse_cmd_with_too_many_returns_null(void** state) } void -parse_cmd_one_arg(void** state) +parse_args__returns__one_arg(void** state) { char* inp = "/cmd arg1"; gboolean result = FALSE; @@ -101,7 +101,7 @@ parse_cmd_one_arg(void** state) } void -parse_cmd_two_args(void** state) +parse_args__returns__two_args(void** state) { char* inp = "/cmd arg1 arg2"; gboolean result = FALSE; @@ -115,7 +115,7 @@ parse_cmd_two_args(void** state) } void -parse_cmd_three_args(void** state) +parse_args__returns__three_args(void** state) { char* inp = "/cmd arg1 arg2 arg3"; gboolean result = FALSE; @@ -130,7 +130,7 @@ parse_cmd_three_args(void** state) } void -parse_cmd_three_args_with_spaces(void** state) +parse_args__returns__three_args_with_spaces(void** state) { char* inp = " /cmd arg1 arg2 arg3 "; gboolean result = FALSE; @@ -145,7 +145,7 @@ parse_cmd_three_args_with_spaces(void** state) } void -parse_cmd_with_freetext(void** state) +parse_args_with_freetext__returns__freetext(void** state) { char* inp = "/cmd this is some free text"; gboolean result = FALSE; @@ -158,7 +158,7 @@ parse_cmd_with_freetext(void** state) } void -parse_cmd_one_arg_with_freetext(void** state) +parse_args_with_freetext__returns__one_arg_with_freetext(void** state) { char* inp = "/cmd arg1 this is some free text"; gboolean result = FALSE; @@ -172,7 +172,7 @@ parse_cmd_one_arg_with_freetext(void** state) } void -parse_cmd_two_args_with_freetext(void** state) +parse_args_with_freetext__returns__two_args_with_freetext(void** state) { char* inp = "/cmd arg1 arg2 this is some free text"; gboolean result = FALSE; @@ -187,7 +187,7 @@ parse_cmd_two_args_with_freetext(void** state) } void -parse_cmd_min_zero(void** state) +parse_args__returns__zero_args_when_min_zero(void** state) { char* inp = "/cmd"; gboolean result = FALSE; @@ -200,7 +200,7 @@ parse_cmd_min_zero(void** state) } void -parse_cmd_min_zero_with_freetext(void** state) +parse_args_with_freetext__returns__zero_args_when_min_zero(void** state) { char* inp = "/cmd"; gboolean result = FALSE; @@ -213,7 +213,7 @@ parse_cmd_min_zero_with_freetext(void** state) } void -parse_cmd_with_quoted(void** state) +parse_args__returns__quoted_args(void** state) { char* inp = "/cmd \"arg1\" arg2"; gboolean result = FALSE; @@ -227,7 +227,7 @@ parse_cmd_with_quoted(void** state) } void -parse_cmd_with_quoted_and_space(void** state) +parse_args__returns__quoted_args_with_space(void** state) { char* inp = "/cmd \"the arg1\" arg2"; gboolean result = FALSE; @@ -241,7 +241,7 @@ parse_cmd_with_quoted_and_space(void** state) } void -parse_cmd_with_quoted_and_many_spaces(void** state) +parse_args__returns__quoted_args_with_many_spaces(void** state) { char* inp = "/cmd \"the arg1 is here\" arg2"; gboolean result = FALSE; @@ -255,7 +255,7 @@ parse_cmd_with_quoted_and_many_spaces(void** state) } void -parse_cmd_with_many_quoted_and_many_spaces(void** state) +parse_args__returns__many_quoted_args_with_many_spaces(void** state) { char* inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\""; gboolean result = FALSE; @@ -269,7 +269,7 @@ parse_cmd_with_many_quoted_and_many_spaces(void** state) } void -parse_cmd_freetext_with_quoted(void** state) +parse_args_with_freetext__returns__quoted_args(void** state) { char* inp = "/cmd \"arg1\" arg2 hello there what's up"; gboolean result = FALSE; @@ -284,7 +284,7 @@ parse_cmd_freetext_with_quoted(void** state) } void -parse_cmd_freetext_with_quoted_and_space(void** state) +parse_args_with_freetext__returns__quoted_args_with_space(void** state) { char* inp = "/cmd \"the arg1\" arg2 another bit of freetext"; gboolean result = FALSE; @@ -299,7 +299,7 @@ parse_cmd_freetext_with_quoted_and_space(void** state) } void -parse_cmd_freetext_with_quoted_and_many_spaces(void** state) +parse_args_with_freetext__returns__quoted_args_with_many_spaces(void** state) { char* inp = "/cmd \"the arg1 is here\" arg2 some more freetext"; gboolean result = FALSE; @@ -314,7 +314,7 @@ parse_cmd_freetext_with_quoted_and_many_spaces(void** state) } void -parse_cmd_freetext_with_many_quoted_and_many_spaces(void** state) +parse_args_with_freetext__returns__many_quoted_args_with_many_spaces(void** state) { char* inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\" and heres the free text"; gboolean result = FALSE; @@ -329,7 +329,7 @@ parse_cmd_freetext_with_many_quoted_and_many_spaces(void** state) } void -parse_cmd_with_quoted_freetext(void** state) +parse_args_with_freetext__returns__quoted_freetext(void** state) { char* inp = "/cmd arg1 here is \"some\" quoted freetext"; gboolean result = FALSE; @@ -343,7 +343,7 @@ parse_cmd_with_quoted_freetext(void** state) } void -parse_cmd_with_third_arg_quoted_0_min_3_max(void** state) +parse_args_with_freetext__returns__third_arg_quoted(void** state) { char* inp = "/group add friends \"The User\""; gboolean result = FALSE; @@ -359,7 +359,7 @@ parse_cmd_with_third_arg_quoted_0_min_3_max(void** state) } void -parse_cmd_with_second_arg_quoted_0_min_3_max(void** state) +parse_args_with_freetext__returns__second_arg_quoted(void** state) { char* inp = "/group add \"The Group\" friend"; gboolean result = FALSE; @@ -375,7 +375,7 @@ parse_cmd_with_second_arg_quoted_0_min_3_max(void** state) } void -parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void** state) +parse_args_with_freetext__returns__second_and_third_arg_quoted(void** state) { char* inp = "/group add \"The Group\" \"The User\""; gboolean result = FALSE; @@ -391,7 +391,7 @@ parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void** state) } void -count_one_token(void** state) +count_tokens__returns__one_token(void** state) { char* inp = "one"; int result = count_tokens(inp); @@ -400,7 +400,7 @@ count_one_token(void** state) } void -count_one_token_quoted_no_whitespace(void** state) +count_tokens__returns__one_token_quoted_no_whitespace(void** state) { char* inp = "\"one\""; int result = count_tokens(inp); @@ -409,7 +409,7 @@ count_one_token_quoted_no_whitespace(void** state) } void -count_one_token_quoted_with_whitespace(void** state) +count_tokens__returns__one_token_quoted_with_whitespace(void** state) { char* inp = "\"one two\""; int result = count_tokens(inp); @@ -418,7 +418,7 @@ count_one_token_quoted_with_whitespace(void** state) } void -count_two_tokens(void** state) +count_tokens__returns__two_tokens(void** state) { char* inp = "one two"; int result = count_tokens(inp); @@ -427,7 +427,7 @@ count_two_tokens(void** state) } void -count_two_tokens_first_quoted(void** state) +count_tokens__returns__two_tokens_first_quoted(void** state) { char* inp = "\"one and\" two"; int result = count_tokens(inp); @@ -436,7 +436,7 @@ count_two_tokens_first_quoted(void** state) } void -count_two_tokens_second_quoted(void** state) +count_tokens__returns__two_tokens_second_quoted(void** state) { char* inp = "one \"two and\""; int result = count_tokens(inp); @@ -445,7 +445,7 @@ count_two_tokens_second_quoted(void** state) } void -count_two_tokens_both_quoted(void** state) +count_tokens__returns__two_tokens_both_quoted(void** state) { char* inp = "\"one and then\" \"two and\""; int result = count_tokens(inp); @@ -454,7 +454,7 @@ count_two_tokens_both_quoted(void** state) } void -get_first_of_one(void** state) +get_start__returns__first_of_one(void** state) { char* inp = "one"; char* result = get_start(inp, 2); @@ -464,7 +464,7 @@ get_first_of_one(void** state) } void -get_first_of_two(void** state) +get_start__returns__first_of_two(void** state) { char* inp = "one two"; char* result = get_start(inp, 2); @@ -474,7 +474,7 @@ get_first_of_two(void** state) } void -get_first_two_of_three(void** state) +get_start__returns__first_two_of_three(void** state) { char* inp = "one two three"; char* result = get_start(inp, 3); @@ -484,7 +484,7 @@ get_first_two_of_three(void** state) } void -get_first_two_of_three_first_quoted(void** state) +get_start__returns__first_two_of_three_first_quoted(void** state) { char* inp = "\"one\" two three"; char* result = get_start(inp, 3); @@ -494,7 +494,7 @@ get_first_two_of_three_first_quoted(void** state) } void -get_first_two_of_three_second_quoted(void** state) +get_start__returns__first_two_of_three_second_quoted(void** state) { char* inp = "one \"two\" three"; char* result = get_start(inp, 3); @@ -504,7 +504,7 @@ get_first_two_of_three_second_quoted(void** state) } void -get_first_two_of_three_first_and_second_quoted(void** state) +get_start__returns__first_two_of_three_first_and_second_quoted(void** state) { char* inp = "\"one\" \"two\" three"; char* result = get_start(inp, 3); @@ -514,7 +514,7 @@ get_first_two_of_three_first_and_second_quoted(void** state) } void -parse_options_when_none_returns_empty_hasmap(void** state) +parse_options__returns__empty_hashmap_when_none(void** state) { gchar* args[] = { "cmd1", "cmd2", NULL }; gchar* keys[] = { "opt1", NULL }; @@ -531,7 +531,7 @@ parse_options_when_none_returns_empty_hasmap(void** state) } void -parse_options_when_opt1_no_val_sets_error(void** state) +parse_options__returns__error_when_opt1_no_val(void** state) { gchar* args[] = { "cmd1", "cmd2", "opt1", NULL }; gchar* keys[] = { "opt1", NULL }; @@ -547,7 +547,7 @@ parse_options_when_opt1_no_val_sets_error(void** state) } void -parse_options_when_one_returns_map(void** state) +parse_options__returns__map_when_one(void** state) { gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", NULL }; gchar* keys[] = { "opt1", NULL }; @@ -565,7 +565,7 @@ parse_options_when_one_returns_map(void** state) } void -parse_options_when_opt2_no_val_sets_error(void** state) +parse_options__returns__error_when_opt2_no_val(void** state) { gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", NULL }; gchar* keys[] = { "opt1", "opt2", NULL }; @@ -581,7 +581,7 @@ parse_options_when_opt2_no_val_sets_error(void** state) } void -parse_options_when_two_returns_map(void** state) +parse_options__returns__map_when_two(void** state) { gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", NULL }; gchar* keys[] = { "opt1", "opt2", NULL }; @@ -601,7 +601,7 @@ parse_options_when_two_returns_map(void** state) } void -parse_options_when_opt3_no_val_sets_error(void** state) +parse_options__returns__error_when_opt3_no_val(void** state) { gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", NULL }; gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; @@ -617,7 +617,7 @@ parse_options_when_opt3_no_val_sets_error(void** state) } void -parse_options_when_three_returns_map(void** state) +parse_options__returns__map_when_three(void** state) { gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", "val3", NULL }; gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; @@ -639,7 +639,7 @@ parse_options_when_three_returns_map(void** state) } void -parse_options_when_unknown_opt_sets_error(void** state) +parse_options__returns__error_when_unknown_opt(void** state) { gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "oops", "val2", "opt3", "val3", NULL }; gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; @@ -655,7 +655,7 @@ parse_options_when_unknown_opt_sets_error(void** state) } void -parse_options_with_duplicated_option_sets_error(void** state) +parse_options__returns__error_when_duplicated_option(void** state) { gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt1", "val3", NULL }; gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; diff --git a/tests/unittests/tools/test_parser.h b/tests/unittests/tools/test_parser.h new file mode 100644 index 00000000..49cfe784 --- /dev/null +++ b/tests/unittests/tools/test_parser.h @@ -0,0 +1,55 @@ +#ifndef TESTS_TEST_PARSER_H +#define TESTS_TEST_PARSER_H + +void parse_args__returns__null_from_null(void** state); +void parse_args__returns__null_from_empty(void** state); +void parse_args__returns__null_from_space(void** state); +void parse_args__returns__null_when_no_args(void** state); +void parse_args__returns__null_from_cmd_with_space(void** state); +void parse_args__returns__null_when_too_few(void** state); +void parse_args__returns__null_when_too_many(void** state); +void parse_args__returns__one_arg(void** state); +void parse_args__returns__two_args(void** state); +void parse_args__returns__three_args(void** state); +void parse_args__returns__three_args_with_spaces(void** state); +void parse_args_with_freetext__returns__freetext(void** state); +void parse_args_with_freetext__returns__one_arg_with_freetext(void** state); +void parse_args_with_freetext__returns__two_args_with_freetext(void** state); +void parse_args__returns__zero_args_when_min_zero(void** state); +void parse_args_with_freetext__returns__zero_args_when_min_zero(void** state); +void parse_args__returns__quoted_args(void** state); +void parse_args__returns__quoted_args_with_space(void** state); +void parse_args__returns__quoted_args_with_many_spaces(void** state); +void parse_args__returns__many_quoted_args_with_many_spaces(void** state); +void parse_args_with_freetext__returns__quoted_args(void** state); +void parse_args_with_freetext__returns__quoted_args_with_space(void** state); +void parse_args_with_freetext__returns__quoted_args_with_many_spaces(void** state); +void parse_args_with_freetext__returns__many_quoted_args_with_many_spaces(void** state); +void parse_args_with_freetext__returns__quoted_freetext(void** state); +void parse_args_with_freetext__returns__third_arg_quoted(void** state); +void parse_args_with_freetext__returns__second_arg_quoted(void** state); +void parse_args_with_freetext__returns__second_and_third_arg_quoted(void** state); +void count_tokens__returns__one_token(void** state); +void count_tokens__returns__one_token_quoted_no_whitespace(void** state); +void count_tokens__returns__one_token_quoted_with_whitespace(void** state); +void count_tokens__returns__two_tokens(void** state); +void count_tokens__returns__two_tokens_first_quoted(void** state); +void count_tokens__returns__two_tokens_second_quoted(void** state); +void count_tokens__returns__two_tokens_both_quoted(void** state); +void get_start__returns__first_of_one(void** state); +void get_start__returns__first_of_two(void** state); +void get_start__returns__first_two_of_three(void** state); +void get_start__returns__first_two_of_three_first_quoted(void** state); +void get_start__returns__first_two_of_three_second_quoted(void** state); +void get_start__returns__first_two_of_three_first_and_second_quoted(void** state); +void parse_options__returns__empty_hashmap_when_none(void** state); +void parse_options__returns__error_when_opt1_no_val(void** state); +void parse_options__returns__map_when_one(void** state); +void parse_options__returns__error_when_opt2_no_val(void** state); +void parse_options__returns__map_when_two(void** state); +void parse_options__returns__error_when_opt3_no_val(void** state); +void parse_options__returns__map_when_three(void** state); +void parse_options__returns__error_when_unknown_opt(void** state); +void parse_options__returns__error_when_duplicated_option(void** state); + +#endif diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index aed9830c..178ed9d8 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -483,10 +483,10 @@ mucwin_unset_message_char(ProfMucWin* mucwin) { } -void win_update_entry_message(ProfWin* window, const char* const id, const char* const message){}; -void win_mark_received(ProfWin* window, const char* const id){}; -void win_print_http_transfer(ProfWin* window, const char* const message, char* id){}; -void win_print_loading_history(ProfWin* window){}; +void win_update_entry_message(ProfWin* window, const char* const id, const char* const message) {}; +void win_mark_received(ProfWin* window, const char* const id) {}; +void win_print_http_transfer(ProfWin* window, const char* const message, char* id) {}; +void win_print_loading_history(ProfWin* window) {}; void ui_show_roster(void) diff --git a/tests/unittests/test_keyhandlers.c b/tests/unittests/ui/test_keyhandlers.c similarity index 86% rename from tests/unittests/test_keyhandlers.c rename to tests/unittests/ui/test_keyhandlers.c index ff7d6a93..c58f9940 100644 --- a/tests/unittests/test_keyhandlers.c +++ b/tests/unittests/ui/test_keyhandlers.c @@ -12,7 +12,8 @@ static char line[INP_WIN_MAX]; // append -void append_to_empty(void **state) +void +key_printable__updates__append_to_empty(void** state) { setlocale(LC_ALL, ""); line[0] = '\0'; @@ -28,7 +29,8 @@ void append_to_empty(void **state) assert_int_equal(pad_start, 0); } -void append_wide_to_empty(void **state) +void +key_printable__updates__append_wide_to_empty(void** state) { setlocale(LC_ALL, ""); line[0] = '\0'; @@ -44,7 +46,8 @@ void append_wide_to_empty(void **state) assert_int_equal(pad_start, 0); } -void append_to_single(void **state) +void +key_printable__updates__append_to_single(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "a", 1); @@ -61,8 +64,8 @@ void append_to_single(void **state) assert_int_equal(pad_start, 0); } - -void append_wide_to_single_non_wide(void **state) +void +key_printable__updates__append_wide_to_single_non_wide(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "a", 1); @@ -79,7 +82,8 @@ void append_wide_to_single_non_wide(void **state) assert_int_equal(pad_start, 0); } -void append_non_wide_to_single_wide(void **state) +void +key_printable__updates__append_non_wide_to_single_wide(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "四", 1); @@ -96,7 +100,8 @@ void append_non_wide_to_single_wide(void **state) assert_int_equal(pad_start, 0); } -void append_wide_to_single_wide(void **state) +void +key_printable__updates__append_wide_to_single_wide(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "四", 1); @@ -113,7 +118,8 @@ void append_wide_to_single_wide(void **state) assert_int_equal(pad_start, 0); } -void append_non_wide_when_overrun(void **state) +void +key_printable__updates__append_non_wide_when_overrun(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "0123456789四1234567", 18); @@ -132,7 +138,8 @@ void append_non_wide_when_overrun(void **state) assert_int_equal(pad_start, 3); } -void insert_non_wide_to_non_wide(void **state) +void +key_printable__updates__insert_non_wide_to_non_wide(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd", 4); @@ -149,7 +156,8 @@ void insert_non_wide_to_non_wide(void **state) assert_int_equal(pad_start, 0); } -void insert_single_non_wide_when_pad_scrolled(void **state) +void +key_printable__updates__insert_single_non_wide_when_pad_scrolled(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "AAAAAAAAAAAAAAA", 15); @@ -166,7 +174,8 @@ void insert_single_non_wide_when_pad_scrolled(void **state) assert_int_equal(pad_start, 2); } -void insert_many_non_wide_when_pad_scrolled(void **state) +void +key_printable__updates__insert_many_non_wide_when_pad_scrolled(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "AAAAAAAAAAAAAAA", 15); @@ -185,7 +194,8 @@ void insert_many_non_wide_when_pad_scrolled(void **state) assert_int_equal(pad_start, 2); } -void insert_single_non_wide_last_column(void **state) +void +key_printable__updates__insert_single_non_wide_last_column(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcdefghijklmno", 15); @@ -202,7 +212,8 @@ void insert_single_non_wide_last_column(void **state) assert_int_equal(pad_start, 3); } -void insert_many_non_wide_last_column(void **state) +void +key_printable__updates__insert_many_non_wide_last_column(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcdefghijklmno", 15); @@ -220,7 +231,8 @@ void insert_many_non_wide_last_column(void **state) assert_int_equal(pad_start, 4); } -void ctrl_left_when_no_input(void **state) +void +key_ctrl_left__updates__when_no_input(void** state) { setlocale(LC_ALL, ""); line[0] = '\0'; @@ -235,7 +247,8 @@ void ctrl_left_when_no_input(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_at_start(void **state) +void +key_ctrl_left__updates__when_at_start(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -251,7 +264,8 @@ void ctrl_left_when_at_start(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_in_first_word(void **state) +void +key_ctrl_left__updates__when_in_first_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -267,7 +281,8 @@ void ctrl_left_when_in_first_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_in_first_space(void **state) +void +key_ctrl_left__updates__when_in_first_space(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -283,7 +298,8 @@ void ctrl_left_when_in_first_space(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_at_start_of_second_word(void **state) +void +key_ctrl_left__updates__at_start_of_second_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -299,7 +315,8 @@ void ctrl_left_when_at_start_of_second_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_in_second_word(void **state) +void +key_ctrl_left__updates__when_in_second_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -315,7 +332,8 @@ void ctrl_left_when_in_second_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_at_end_of_second_word(void **state) +void +key_ctrl_left__updates__at_end_of_second_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -331,7 +349,8 @@ void ctrl_left_when_at_end_of_second_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_in_second_space(void **state) +void +key_ctrl_left__updates__when_in_second_space(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -347,7 +366,8 @@ void ctrl_left_when_in_second_space(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_at_start_of_third_word(void **state) +void +key_ctrl_left__updates__at_start_of_third_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -363,7 +383,8 @@ void ctrl_left_when_at_start_of_third_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_in_third_word(void **state) +void +key_ctrl_left__updates__when_in_third_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -379,7 +400,8 @@ void ctrl_left_when_in_third_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_at_end_of_third_word(void **state) +void +key_ctrl_left__updates__at_end_of_third_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -395,7 +417,8 @@ void ctrl_left_when_at_end_of_third_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_in_third_space(void **state) +void +key_ctrl_left__updates__when_in_third_space(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -411,7 +434,8 @@ void ctrl_left_when_in_third_space(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_at_end(void **state) +void +key_ctrl_left__updates__when_at_end(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); @@ -427,7 +451,8 @@ void ctrl_left_when_at_end(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_in_only_whitespace(void **state) +void +key_ctrl_left__updates__when_in_only_whitespace(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, " ", 7); @@ -443,7 +468,8 @@ void ctrl_left_when_in_only_whitespace(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_start_whitespace_start_of_word(void **state) +void +key_ctrl_left__updates__when_start_whitespace_start_of_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, " hello", 9); @@ -459,7 +485,8 @@ void ctrl_left_when_start_whitespace_start_of_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_start_whitespace_middle_of_word(void **state) +void +key_ctrl_left__updates__when_start_whitespace_middle_of_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, " hello", 9); @@ -475,7 +502,8 @@ void ctrl_left_when_start_whitespace_middle_of_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_in_whitespace_between_words(void **state) +void +key_ctrl_left__updates__in_whitespace_between_words(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "hey hello", 12); @@ -491,7 +519,8 @@ void ctrl_left_in_whitespace_between_words(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_in_whitespace_between_words_start_of_word(void **state) +void +key_ctrl_left__updates__in_whitespace_between_words_start_of_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "hey hello", 12); @@ -507,7 +536,8 @@ void ctrl_left_in_whitespace_between_words_start_of_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_in_whitespace_between_words_middle_of_word(void **state) +void +key_ctrl_left__updates__in_whitespace_between_words_middle_of_word(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "hey hello", 12); @@ -523,7 +553,8 @@ void ctrl_left_in_whitespace_between_words_middle_of_word(void **state) assert_int_equal(pad_start, 0); } -void ctrl_left_when_word_overrun_to_left(void **state) +void +key_ctrl_left__updates__when_word_overrun_to_left(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword anotherword", 20); @@ -539,7 +570,8 @@ void ctrl_left_when_word_overrun_to_left(void **state) assert_int_equal(pad_start, 9); } -void ctrl_right_when_no_input(void **state) +void +key_ctrl_right__updates__when_no_input(void** state) { setlocale(LC_ALL, ""); line[0] = '\0'; @@ -554,7 +586,8 @@ void ctrl_right_when_no_input(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_when_at_end(void **state) +void +key_ctrl_right__updates__when_at_end(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword anotherword", 20); @@ -570,7 +603,8 @@ void ctrl_right_when_at_end(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_one_word_at_start(void **state) +void +key_ctrl_right__updates__one_word_at_start(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword", 8); @@ -586,7 +620,8 @@ void ctrl_right_one_word_at_start(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_one_word_in_middle(void **state) +void +key_ctrl_right__updates__one_word_in_middle(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword", 8); @@ -602,7 +637,8 @@ void ctrl_right_one_word_in_middle(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_one_word_at_end(void **state) +void +key_ctrl_right__updates__one_word_at_end(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword", 8); @@ -618,7 +654,8 @@ void ctrl_right_one_word_at_end(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_two_words_from_middle_first(void **state) +void +key_ctrl_right__updates__two_words_from_middle_first(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword anotherword", 20); @@ -634,7 +671,8 @@ void ctrl_right_two_words_from_middle_first(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_two_words_from_end_first(void **state) +void +key_ctrl_right__updates__two_words_from_end_first(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword anotherword", 20); @@ -650,7 +688,8 @@ void ctrl_right_two_words_from_end_first(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_two_words_from_space(void **state) +void +key_ctrl_right__updates__two_words_from_space(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword anotherword", 20); @@ -666,7 +705,8 @@ void ctrl_right_two_words_from_space(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_two_words_from_start_second(void **state) +void +key_ctrl_right__updates__two_words_from_start_second(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword anotherword", 20); @@ -682,7 +722,8 @@ void ctrl_right_two_words_from_start_second(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_one_word_leading_whitespace(void **state) +void +key_ctrl_right__updates__one_word_leading_whitespace(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, " someword", 15); @@ -698,7 +739,8 @@ void ctrl_right_one_word_leading_whitespace(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_two_words_in_whitespace(void **state) +void +key_ctrl_right__updates__two_words_in_whitespace(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, " someword adfasdf", 30); @@ -714,7 +756,8 @@ void ctrl_right_two_words_in_whitespace(void **state) assert_int_equal(pad_start, 0); } -void ctrl_right_trailing_whitespace_from_middle(void **state) +void +key_ctrl_right__updates__trailing_whitespace_from_middle(void** state) { setlocale(LC_ALL, ""); g_utf8_strncpy(line, "someword ", 16); diff --git a/tests/unittests/ui/test_keyhandlers.h b/tests/unittests/ui/test_keyhandlers.h new file mode 100644 index 00000000..ff70ee57 --- /dev/null +++ b/tests/unittests/ui/test_keyhandlers.h @@ -0,0 +1,52 @@ +#ifndef TESTS_TEST_KEYHANDLERS_H +#define TESTS_TEST_KEYHANDLERS_H + +void key_printable__updates__append_to_empty(void** state); +void key_printable__updates__append_wide_to_empty(void** state); +void key_printable__updates__append_to_single(void** state); +void key_printable__updates__append_wide_to_single_non_wide(void** state); +void key_printable__updates__append_non_wide_to_single_wide(void** state); +void key_printable__updates__append_wide_to_single_wide(void** state); +void key_printable__updates__append_non_wide_when_overrun(void** state); + +void key_printable__updates__insert_non_wide_to_non_wide(void** state); +void key_printable__updates__insert_single_non_wide_when_pad_scrolled(void** state); +void key_printable__updates__insert_many_non_wide_when_pad_scrolled(void** state); +void key_printable__updates__insert_single_non_wide_last_column(void** state); +void key_printable__updates__insert_many_non_wide_last_column(void** state); + +void key_ctrl_left__updates__when_no_input(void** state); +void key_ctrl_left__updates__when_at_start(void** state); +void key_ctrl_left__updates__when_in_first_word(void** state); +void key_ctrl_left__updates__when_in_first_space(void** state); +void key_ctrl_left__updates__at_start_of_second_word(void** state); +void key_ctrl_left__updates__when_in_second_word(void** state); +void key_ctrl_left__updates__at_end_of_second_word(void** state); +void key_ctrl_left__updates__when_in_second_space(void** state); +void key_ctrl_left__updates__at_start_of_third_word(void** state); +void key_ctrl_left__updates__when_in_third_word(void** state); +void key_ctrl_left__updates__at_end_of_third_word(void** state); +void key_ctrl_left__updates__when_in_third_space(void** state); +void key_ctrl_left__updates__when_at_end(void** state); +void key_ctrl_left__updates__when_in_only_whitespace(void** state); +void key_ctrl_left__updates__when_start_whitespace_start_of_word(void** state); +void key_ctrl_left__updates__when_start_whitespace_middle_of_word(void** state); +void key_ctrl_left__updates__in_whitespace_between_words(void** state); +void key_ctrl_left__updates__in_whitespace_between_words_start_of_word(void** state); +void key_ctrl_left__updates__in_whitespace_between_words_middle_of_word(void** state); +void key_ctrl_left__updates__when_word_overrun_to_left(void** state); + +void key_ctrl_right__updates__when_no_input(void** state); +void key_ctrl_right__updates__when_at_end(void** state); +void key_ctrl_right__updates__one_word_at_start(void** state); +void key_ctrl_right__updates__one_word_in_middle(void** state); +void key_ctrl_right__updates__one_word_at_end(void** state); +void key_ctrl_right__updates__two_words_from_middle_first(void** state); +void key_ctrl_right__updates__two_words_from_end_first(void** state); +void key_ctrl_right__updates__two_words_from_space(void** state); +void key_ctrl_right__updates__two_words_from_start_second(void** state); +void key_ctrl_right__updates__one_word_leading_whitespace(void** state); +void key_ctrl_right__updates__two_words_in_whitespace(void** state); +void key_ctrl_right__updates__trailing_whitespace_from_middle(void** state); + +#endif diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index 8bf25b9b..c0b95a19 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -10,31 +10,31 @@ #include "config.h" #include "xmpp/chat_session.h" #include "helpers.h" -#include "test_autocomplete.h" -#include "test_chat_session.h" +#include "tools/test_autocomplete.h" +#include "xmpp/test_chat_session.h" #include "test_common.h" -#include "test_contact.h" -#include "test_cmd_connect.h" -#include "test_cmd_account.h" -#include "test_cmd_rooms.h" -#include "test_cmd_sub.h" -#include "test_cmd_presence.h" -#include "test_cmd_otr.h" -#include "test_cmd_pgp.h" -#include "test_jid.h" -#include "test_parser.h" -#include "test_roster_list.h" -#include "test_preferences.h" -#include "test_server_events.h" -#include "test_cmd_alias.h" -#include "test_cmd_bookmark.h" -#include "test_cmd_join.h" -#include "test_muc.h" -#include "test_cmd_roster.h" -#include "test_cmd_disconnect.h" -#include "test_form.h" -#include "test_callbacks.h" -#include "test_plugins_disco.h" +#include "xmpp/test_contact.h" +#include "command/test_cmd_connect.h" +#include "command/test_cmd_account.h" +#include "command/test_cmd_rooms.h" +#include "command/test_cmd_sub.h" +#include "command/test_cmd_presence.h" +#include "command/test_cmd_otr.h" +#include "command/test_cmd_pgp.h" +#include "xmpp/test_jid.h" +#include "tools/test_parser.h" +#include "xmpp/test_roster_list.h" +#include "config/test_preferences.h" +#include "event/test_server_events.h" +#include "command/test_cmd_alias.h" +#include "command/test_cmd_bookmark.h" +#include "command/test_cmd_join.h" +#include "xmpp/test_muc.h" +#include "command/test_cmd_roster.h" +#include "command/test_cmd_disconnect.h" +#include "xmpp/test_form.h" +#include "plugins/test_callbacks.h" +#include "plugins/test_plugins_disco.h" #define muc_unit_test(f) cmocka_unit_test_setup_teardown(f, muc_before_test, muc_after_test) @@ -61,596 +61,596 @@ main(int argc, char* argv[]) const struct CMUnitTest all_tests[] = { - cmocka_unit_test(replace_one_substr), - cmocka_unit_test(replace_one_substr_beginning), - cmocka_unit_test(replace_one_substr_end), - cmocka_unit_test(replace_two_substr), - cmocka_unit_test(replace_char), - cmocka_unit_test(replace_when_none), - cmocka_unit_test(replace_when_match), - cmocka_unit_test(replace_when_string_empty), - cmocka_unit_test(replace_when_string_null), - cmocka_unit_test(replace_when_sub_empty), - cmocka_unit_test(replace_when_sub_null), - cmocka_unit_test(replace_when_new_empty), - cmocka_unit_test(replace_when_new_null), - cmocka_unit_test(test_online_is_valid_resource_presence_string), - cmocka_unit_test(test_chat_is_valid_resource_presence_string), - cmocka_unit_test(test_away_is_valid_resource_presence_string), - cmocka_unit_test(test_xa_is_valid_resource_presence_string), - cmocka_unit_test(test_dnd_is_valid_resource_presence_string), - cmocka_unit_test(test_available_is_not_valid_resource_presence_string), - cmocka_unit_test(test_unavailable_is_not_valid_resource_presence_string), - cmocka_unit_test(test_blah_is_not_valid_resource_presence_string), - cmocka_unit_test(utf8_display_len_null_str), - cmocka_unit_test(utf8_display_len_1_non_wide), - cmocka_unit_test(utf8_display_len_1_wide), - cmocka_unit_test(utf8_display_len_non_wide), - cmocka_unit_test(utf8_display_len_wide), - cmocka_unit_test(utf8_display_len_all_wide), - cmocka_unit_test(strip_quotes_does_nothing_when_no_quoted), - cmocka_unit_test(strip_quotes_strips_first), - cmocka_unit_test(strip_quotes_strips_last), - cmocka_unit_test(strip_quotes_strips_both), - cmocka_unit_test(format_call_external_argv_td), - cmocka_unit_test(unique_filename_from_url_td), - cmocka_unit_test(test_string_to_verbosity), - cmocka_unit_test(test_get_expanded_path), - cmocka_unit_test(test_strtoi_range_valid_input), - cmocka_unit_test(test_strtoi_range_out_of_range), - cmocka_unit_test(test_strtoi_range_invalid_input), - cmocka_unit_test(test_strtoi_range_null_empty_input), - cmocka_unit_test(test_strtoi_range_null_err_msg), - cmocka_unit_test(test_string_matches_one_of_edge_cases), - cmocka_unit_test(test_valid_tls_policy_option), - cmocka_unit_test(clear_empty), - cmocka_unit_test(reset_after_create), - cmocka_unit_test(find_after_create), - cmocka_unit_test(get_after_create_returns_null), - cmocka_unit_test(add_one_and_complete), - cmocka_unit_test(add_two_and_complete_returns_first), - cmocka_unit_test(add_two_and_complete_returns_second), - cmocka_unit_test(add_two_adds_two), - cmocka_unit_test(add_two_same_adds_one), - cmocka_unit_test(add_two_same_updates), - cmocka_unit_test(complete_accented_with_accented), - cmocka_unit_test(complete_accented_with_base), - cmocka_unit_test(complete_both_with_accented), - cmocka_unit_test(complete_both_with_base), - cmocka_unit_test(complete_ignores_case), - cmocka_unit_test(complete_previous), + cmocka_unit_test(str_replace__returns__one_substr), + cmocka_unit_test(str_replace__returns__one_substr_beginning), + cmocka_unit_test(str_replace__returns__one_substr_end), + cmocka_unit_test(str_replace__returns__two_substr), + cmocka_unit_test(str_replace__returns__char), + cmocka_unit_test(str_replace__returns__original_when_none), + cmocka_unit_test(str_replace__returns__replaced_when_match), + cmocka_unit_test(str_replace__returns__empty_when_string_empty), + cmocka_unit_test(str_replace__returns__null_when_string_null), + cmocka_unit_test(str_replace__returns__original_when_sub_empty), + cmocka_unit_test(str_replace__returns__original_when_sub_null), + cmocka_unit_test(str_replace__returns__empty_when_new_empty), + cmocka_unit_test(str_replace__returns__original_when_new_null), + cmocka_unit_test(valid_resource_presence_string__is__true_for_online), + cmocka_unit_test(valid_resource_presence_string__is__true_for_chat), + cmocka_unit_test(valid_resource_presence_string__is__true_for_away), + cmocka_unit_test(valid_resource_presence_string__is__true_for_xa), + cmocka_unit_test(valid_resource_presence_string__is__true_for_dnd), + cmocka_unit_test(valid_resource_presence_string__is__false_for_available), + cmocka_unit_test(valid_resource_presence_string__is__false_for_unavailable), + cmocka_unit_test(valid_resource_presence_string__is__false_for_blah), + cmocka_unit_test(utf8_display_len__returns__0_for_null), + cmocka_unit_test(utf8_display_len__returns__1_for_non_wide), + cmocka_unit_test(utf8_display_len__returns__2_for_wide), + cmocka_unit_test(utf8_display_len__returns__correct_for_non_wide), + cmocka_unit_test(utf8_display_len__returns__correct_for_wide), + cmocka_unit_test(utf8_display_len__returns__correct_for_all_wide), + cmocka_unit_test(strip_arg_quotes__returns__original_when_no_quotes), + cmocka_unit_test(strip_arg_quotes__returns__stripped_first), + cmocka_unit_test(strip_arg_quotes__returns__stripped_last), + cmocka_unit_test(strip_arg_quotes__returns__stripped_both), + cmocka_unit_test(format_call_external_argv__tests__table_driven), + cmocka_unit_test(unique_filename_from_url__tests__table_driven), + cmocka_unit_test(string_to_verbosity__returns__correct_values), + cmocka_unit_test(get_expanded_path__returns__expanded), + cmocka_unit_test(strtoi_range__returns__true_for_valid_input), + cmocka_unit_test(strtoi_range__returns__false_for_out_of_range), + cmocka_unit_test(strtoi_range__returns__false_for_invalid_input), + cmocka_unit_test(strtoi_range__returns__false_for_null_empty_input), + cmocka_unit_test(strtoi_range__returns__correct_values_when_err_msg_null), + cmocka_unit_test(string_matches_one_of__tests__edge_cases), + cmocka_unit_test(valid_tls_policy_option__is__correct_for_various_inputs), + cmocka_unit_test(autocomplete_complete__returns__null_when_empty), + cmocka_unit_test(autocomplete_reset__updates__after_create), + cmocka_unit_test(autocomplete_complete__returns__null_after_create), + cmocka_unit_test(autocomplete_create_list__returns__null_after_create), + cmocka_unit_test(autocomplete_add__updates__one_and_complete), + cmocka_unit_test(autocomplete_complete__returns__first_of_two), + cmocka_unit_test(autocomplete_complete__returns__second_of_two), + cmocka_unit_test(autocomplete_add__updates__two_elements), + cmocka_unit_test(autocomplete_add__updates__only_once_for_same_value), + cmocka_unit_test(autocomplete_add__updates__existing_value), + cmocka_unit_test(autocomplete_complete__returns__accented_with_accented), + cmocka_unit_test(autocomplete_complete__returns__accented_with_base), + cmocka_unit_test(autocomplete_complete__returns__both_with_accented), + cmocka_unit_test(autocomplete_complete__returns__both_with_base), + cmocka_unit_test(autocomplete_complete__is__case_insensitive), + cmocka_unit_test(autocomplete_complete__returns__previous), - cmocka_unit_test(create_jid_from_null_returns_null), - cmocka_unit_test(create_jid_from_empty_string_returns_null), - cmocka_unit_test(create_jid_from_full_returns_full), - cmocka_unit_test(create_jid_from_full_returns_bare), - cmocka_unit_test(create_jid_from_full_returns_resourcepart), - cmocka_unit_test(create_jid_from_full_returns_localpart), - cmocka_unit_test(create_jid_from_full_returns_domainpart), - cmocka_unit_test(create_jid_from_full_nolocal_returns_full), - cmocka_unit_test(create_jid_from_full_nolocal_returns_bare), - cmocka_unit_test(create_jid_from_full_nolocal_returns_resourcepart), - cmocka_unit_test(create_jid_from_full_nolocal_returns_domainpart), - cmocka_unit_test(create_jid_from_full_nolocal_returns_null_localpart), - cmocka_unit_test(create_jid_from_bare_returns_null_full), - cmocka_unit_test(create_jid_from_bare_returns_null_resource), - cmocka_unit_test(create_jid_from_bare_returns_bare), - cmocka_unit_test(create_jid_from_bare_returns_localpart), - cmocka_unit_test(create_jid_from_bare_returns_domainpart), - cmocka_unit_test(create_room_jid_returns_room), - cmocka_unit_test(create_room_jid_returns_nick), - cmocka_unit_test(create_with_slash_in_resource), - cmocka_unit_test(create_with_at_in_resource), - cmocka_unit_test(create_with_at_and_slash_in_resource), - cmocka_unit_test(create_full_with_trailing_slash), - cmocka_unit_test(returns_fulljid_when_exists), - cmocka_unit_test(returns_barejid_when_fulljid_not_exists), + cmocka_unit_test(jid_create__returns__null_from_null), + cmocka_unit_test(jid_create__returns__null_from_empty_string), + cmocka_unit_test(jid_create__returns__full_from_full), + cmocka_unit_test(jid_create__returns__bare_from_full), + cmocka_unit_test(jid_create__returns__resourcepart_from_full), + cmocka_unit_test(jid_create__returns__localpart_from_full), + cmocka_unit_test(jid_create__returns__domainpart_from_full), + cmocka_unit_test(jid_create__returns__full_from_full_nolocal), + cmocka_unit_test(jid_create__returns__bare_from_full_nolocal), + cmocka_unit_test(jid_create__returns__resourcepart_from_full_nolocal), + cmocka_unit_test(jid_create__returns__domainpart_from_full_nolocal), + cmocka_unit_test(jid_create__returns__null_localpart_from_full_nolocal), + cmocka_unit_test(jid_create__returns__null_full_from_bare), + cmocka_unit_test(jid_create__returns__null_resource_from_bare), + cmocka_unit_test(jid_create__returns__bare_from_bare), + cmocka_unit_test(jid_create__returns__localpart_from_bare), + cmocka_unit_test(jid_create__returns__domainpart_from_bare), + cmocka_unit_test(jid_create_from_bare_and_resource__returns__room), + cmocka_unit_test(jid_create_from_bare_and_resource__returns__nick), + cmocka_unit_test(jid_create__returns__correct_parts_with_slash_in_resource), + cmocka_unit_test(jid_create__returns__correct_parts_with_at_in_resource), + cmocka_unit_test(jid_create__returns__correct_parts_with_at_and_slash_in_resource), + cmocka_unit_test(jid_create__returns__correct_parts_with_trailing_slash), + cmocka_unit_test(jid_fulljid_or_barejid__returns__fulljid_when_exists), + cmocka_unit_test(jid_fulljid_or_barejid__returns__barejid_when_fulljid_not_exists), - cmocka_unit_test(parse_null_returns_null), - cmocka_unit_test(parse_empty_returns_null), - cmocka_unit_test(parse_space_returns_null), - cmocka_unit_test(parse_cmd_no_args_returns_null), - cmocka_unit_test(parse_cmd_with_space_returns_null), - cmocka_unit_test(parse_cmd_with_too_few_returns_null), - cmocka_unit_test(parse_cmd_with_too_many_returns_null), - cmocka_unit_test(parse_cmd_one_arg), - cmocka_unit_test(parse_cmd_two_args), - cmocka_unit_test(parse_cmd_three_args), - cmocka_unit_test(parse_cmd_three_args_with_spaces), - cmocka_unit_test(parse_cmd_with_freetext), - cmocka_unit_test(parse_cmd_one_arg_with_freetext), - cmocka_unit_test(parse_cmd_two_args_with_freetext), - cmocka_unit_test(parse_cmd_min_zero), - cmocka_unit_test(parse_cmd_min_zero_with_freetext), - cmocka_unit_test(parse_cmd_with_quoted), - cmocka_unit_test(parse_cmd_with_quoted_and_space), - cmocka_unit_test(parse_cmd_with_quoted_and_many_spaces), - cmocka_unit_test(parse_cmd_with_many_quoted_and_many_spaces), - cmocka_unit_test(parse_cmd_freetext_with_quoted), - cmocka_unit_test(parse_cmd_freetext_with_quoted_and_space), - cmocka_unit_test(parse_cmd_freetext_with_quoted_and_many_spaces), - cmocka_unit_test(parse_cmd_freetext_with_many_quoted_and_many_spaces), - cmocka_unit_test(parse_cmd_with_quoted_freetext), - cmocka_unit_test(parse_cmd_with_third_arg_quoted_0_min_3_max), - cmocka_unit_test(parse_cmd_with_second_arg_quoted_0_min_3_max), - cmocka_unit_test(parse_cmd_with_second_and_third_arg_quoted_0_min_3_max), - cmocka_unit_test(count_one_token), - cmocka_unit_test(count_one_token_quoted_no_whitespace), - cmocka_unit_test(count_one_token_quoted_with_whitespace), - cmocka_unit_test(count_two_tokens), - cmocka_unit_test(count_two_tokens_first_quoted), - cmocka_unit_test(count_two_tokens_second_quoted), - cmocka_unit_test(count_two_tokens_both_quoted), - cmocka_unit_test(get_first_of_one), - cmocka_unit_test(get_first_of_two), - cmocka_unit_test(get_first_two_of_three), - cmocka_unit_test(get_first_two_of_three_first_quoted), - cmocka_unit_test(get_first_two_of_three_second_quoted), - cmocka_unit_test(get_first_two_of_three_first_and_second_quoted), - cmocka_unit_test(parse_options_when_none_returns_empty_hasmap), - cmocka_unit_test(parse_options_when_opt1_no_val_sets_error), - cmocka_unit_test(parse_options_when_one_returns_map), - cmocka_unit_test(parse_options_when_opt2_no_val_sets_error), - cmocka_unit_test(parse_options_when_two_returns_map), - cmocka_unit_test(parse_options_when_opt3_no_val_sets_error), - cmocka_unit_test(parse_options_when_three_returns_map), - cmocka_unit_test(parse_options_when_unknown_opt_sets_error), - cmocka_unit_test(parse_options_with_duplicated_option_sets_error), + cmocka_unit_test(parse_args__returns__null_from_null), + cmocka_unit_test(parse_args__returns__null_from_empty), + cmocka_unit_test(parse_args__returns__null_from_space), + cmocka_unit_test(parse_args__returns__null_when_no_args), + cmocka_unit_test(parse_args__returns__null_from_cmd_with_space), + cmocka_unit_test(parse_args__returns__null_when_too_few), + cmocka_unit_test(parse_args__returns__null_when_too_many), + cmocka_unit_test(parse_args__returns__one_arg), + cmocka_unit_test(parse_args__returns__two_args), + cmocka_unit_test(parse_args__returns__three_args), + cmocka_unit_test(parse_args__returns__three_args_with_spaces), + cmocka_unit_test(parse_args_with_freetext__returns__freetext), + cmocka_unit_test(parse_args_with_freetext__returns__one_arg_with_freetext), + cmocka_unit_test(parse_args_with_freetext__returns__two_args_with_freetext), + cmocka_unit_test(parse_args__returns__zero_args_when_min_zero), + cmocka_unit_test(parse_args_with_freetext__returns__zero_args_when_min_zero), + cmocka_unit_test(parse_args__returns__quoted_args), + cmocka_unit_test(parse_args__returns__quoted_args_with_space), + cmocka_unit_test(parse_args__returns__quoted_args_with_many_spaces), + cmocka_unit_test(parse_args__returns__many_quoted_args_with_many_spaces), + cmocka_unit_test(parse_args_with_freetext__returns__quoted_args), + cmocka_unit_test(parse_args_with_freetext__returns__quoted_args_with_space), + cmocka_unit_test(parse_args_with_freetext__returns__quoted_args_with_many_spaces), + cmocka_unit_test(parse_args_with_freetext__returns__many_quoted_args_with_many_spaces), + cmocka_unit_test(parse_args_with_freetext__returns__quoted_freetext), + cmocka_unit_test(parse_args_with_freetext__returns__third_arg_quoted), + cmocka_unit_test(parse_args_with_freetext__returns__second_arg_quoted), + cmocka_unit_test(parse_args_with_freetext__returns__second_and_third_arg_quoted), + cmocka_unit_test(count_tokens__returns__one_token), + cmocka_unit_test(count_tokens__returns__one_token_quoted_no_whitespace), + cmocka_unit_test(count_tokens__returns__one_token_quoted_with_whitespace), + cmocka_unit_test(count_tokens__returns__two_tokens), + cmocka_unit_test(count_tokens__returns__two_tokens_first_quoted), + cmocka_unit_test(count_tokens__returns__two_tokens_second_quoted), + cmocka_unit_test(count_tokens__returns__two_tokens_both_quoted), + cmocka_unit_test(get_start__returns__first_of_one), + cmocka_unit_test(get_start__returns__first_of_two), + cmocka_unit_test(get_start__returns__first_two_of_three), + cmocka_unit_test(get_start__returns__first_two_of_three_first_quoted), + cmocka_unit_test(get_start__returns__first_two_of_three_second_quoted), + cmocka_unit_test(get_start__returns__first_two_of_three_first_and_second_quoted), + cmocka_unit_test(parse_options__returns__empty_hashmap_when_none), + cmocka_unit_test(parse_options__returns__error_when_opt1_no_val), + cmocka_unit_test(parse_options__returns__map_when_one), + cmocka_unit_test(parse_options__returns__error_when_opt2_no_val), + cmocka_unit_test(parse_options__returns__map_when_two), + cmocka_unit_test(parse_options__returns__error_when_opt3_no_val), + cmocka_unit_test(parse_options__returns__map_when_three), + cmocka_unit_test(parse_options__returns__error_when_unknown_opt), + cmocka_unit_test(parse_options__returns__error_when_duplicated_option), - cmocka_unit_test(empty_list_when_none_added), - cmocka_unit_test(contains_one_element), - cmocka_unit_test(first_element_correct), - cmocka_unit_test(contains_two_elements), - cmocka_unit_test(first_and_second_elements_correct), - cmocka_unit_test(contains_three_elements), - cmocka_unit_test(first_three_elements_correct), - cmocka_unit_test(add_twice_at_beginning_adds_once), - cmocka_unit_test(add_twice_in_middle_adds_once), - cmocka_unit_test(add_twice_at_end_adds_once), - cmocka_unit_test(find_first_exists), - cmocka_unit_test(find_second_exists), - cmocka_unit_test(find_third_exists), - cmocka_unit_test(find_returns_null), - cmocka_unit_test(find_on_empty_returns_null), - cmocka_unit_test(find_twice_returns_second_when_two_match), - cmocka_unit_test(find_five_times_finds_fifth), - cmocka_unit_test(find_twice_returns_first_when_two_match_and_reset), - cmocka_unit_test(add_contact_with_no_group), - cmocka_unit_test(add_contact_with_group), - cmocka_unit_test(add_contact_with_two_groups), - cmocka_unit_test(add_contact_with_three_groups), - cmocka_unit_test(add_contact_with_three_groups_update_adding_two), - cmocka_unit_test(add_contact_with_three_groups_update_removing_one), - cmocka_unit_test(add_contact_with_three_groups_update_removing_two), - cmocka_unit_test(add_contact_with_three_groups_update_removing_three), - cmocka_unit_test(add_contact_with_three_groups_update_two_new), - cmocka_unit_test(add_remove_contact_groups), - cmocka_unit_test(add_contacts_with_different_groups), - cmocka_unit_test(add_contacts_with_same_groups), - cmocka_unit_test(add_contacts_with_overlapping_groups), - cmocka_unit_test(remove_contact_with_remaining_in_group), - cmocka_unit_test(get_contact_display_name), - cmocka_unit_test(get_contact_display_name_is_barejid_if_name_is_empty), - cmocka_unit_test(get_contact_display_name_is_passed_barejid_if_contact_does_not_exist), + cmocka_unit_test(roster_get_contacts__returns__empty_list_when_none_added), + cmocka_unit_test(roster_get_contacts__returns__one_element), + cmocka_unit_test(roster_get_contacts__returns__correct_first_element), + cmocka_unit_test(roster_get_contacts__returns__two_elements), + cmocka_unit_test(roster_get_contacts__returns__correct_first_and_second_elements), + cmocka_unit_test(roster_get_contacts__returns__three_elements), + cmocka_unit_test(roster_get_contacts__returns__correct_first_three_elements), + cmocka_unit_test(roster_add__updates__adds_once_when_called_twice_at_beginning), + cmocka_unit_test(roster_add__updates__adds_once_when_called_twice_in_middle), + cmocka_unit_test(roster_add__updates__adds_once_when_called_twice_at_end), + cmocka_unit_test(roster_contact_autocomplete__returns__first_exists), + cmocka_unit_test(roster_contact_autocomplete__returns__second_exists), + cmocka_unit_test(roster_contact_autocomplete__returns__third_exists), + cmocka_unit_test(roster_contact_autocomplete__returns__null_when_no_match), + cmocka_unit_test(roster_contact_autocomplete__returns__null_on_empty_roster), + cmocka_unit_test(roster_contact_autocomplete__returns__second_when_two_match), + cmocka_unit_test(roster_contact_autocomplete__returns__fifth_when_multiple_match), + cmocka_unit_test(roster_contact_autocomplete__returns__first_when_two_match_and_reset), + cmocka_unit_test(roster_get_groups__returns__empty_for_no_group), + cmocka_unit_test(roster_get_groups__returns__one_group), + cmocka_unit_test(roster_get_groups__returns__two_groups), + cmocka_unit_test(roster_get_groups__returns__three_groups), + cmocka_unit_test(roster_update__updates__adding_two_groups), + cmocka_unit_test(roster_update__updates__removing_one_group), + cmocka_unit_test(roster_update__updates__removing_two_groups), + cmocka_unit_test(roster_update__updates__removing_three_groups), + cmocka_unit_test(roster_update__updates__two_new_groups), + cmocka_unit_test(roster_remove__updates__contact_groups), + cmocka_unit_test(roster_add__updates__different_groups), + cmocka_unit_test(roster_add__updates__same_groups), + cmocka_unit_test(roster_add__updates__overlapping_groups), + cmocka_unit_test(roster_remove__updates__remaining_in_group), + cmocka_unit_test(roster_get_display_name__returns__nickname_when_exists), + cmocka_unit_test(roster_get_display_name__returns__barejid_when_nickname_empty), + cmocka_unit_test(roster_get_display_name__returns__barejid_when_not_exists), - cmocka_unit_test_setup_teardown(returns_false_when_chat_session_does_not_exist, + cmocka_unit_test_setup_teardown(chat_session_get__returns__null_when_no_session, init_chat_sessions, close_chat_sessions), - cmocka_unit_test_setup_teardown(creates_chat_session_on_recipient_activity, + cmocka_unit_test_setup_teardown(chat_session_recipient_active__updates__new_session, init_chat_sessions, close_chat_sessions), - cmocka_unit_test_setup_teardown(replaces_chat_session_on_recipient_activity_with_different_resource, + cmocka_unit_test_setup_teardown(chat_session_recipient_active__updates__replace_resource, init_chat_sessions, close_chat_sessions), - cmocka_unit_test_setup_teardown(removes_chat_session, + cmocka_unit_test_setup_teardown(chat_session_remove__updates__session_removed, init_chat_sessions, close_chat_sessions), - cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting, + cmocka_unit_test_setup_teardown(cmd_connect__shows__message_when_disconnecting, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_connecting, + cmocka_unit_test_setup_teardown(cmd_connect__shows__message_when_connecting, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_connected, + cmocka_unit_test_setup_teardown(cmd_connect__shows__message_when_connected, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_when_no_account, + cmocka_unit_test_setup_teardown(cmd_connect__tests__no_account, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_fail_message, + cmocka_unit_test_setup_teardown(cmd_connect__shows__fail_message, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_lowercases_argument_with_account, + cmocka_unit_test_setup_teardown(cmd_connect__tests__lowercases_argument_with_account, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_lowercases_argument_with_no_account, + cmocka_unit_test_setup_teardown(cmd_connect__tests__lowercases_argument_with_no_account, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account, + cmocka_unit_test_setup_teardown(cmd_connect__tests__asks_password_when_not_in_account, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value, + cmocka_unit_test_setup_teardown(cmd_connect__shows__usage_when_no_server_value, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account, + cmocka_unit_test_setup_teardown(cmd_connect__shows__message_when_connecting_with_account, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_connects_with_account, + cmocka_unit_test_setup_teardown(cmd_connect__tests__connects_with_account, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value, + cmocka_unit_test_setup_teardown(cmd_connect__shows__usage_when_server_no_port_value, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_no_port_value, + cmocka_unit_test_setup_teardown(cmd_connect__shows__usage_when_no_port_value, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_port_no_server_value, + cmocka_unit_test_setup_teardown(cmd_connect__shows__usage_when_port_no_server_value, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_port_0, + cmocka_unit_test_setup_teardown(cmd_connect__shows__message_when_port_0, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_port_minus1, + cmocka_unit_test_setup_teardown(cmd_connect__shows__message_when_port_minus1, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_port_65536, + cmocka_unit_test_setup_teardown(cmd_connect__shows__message_when_port_65536, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_port_contains_chars, + cmocka_unit_test_setup_teardown(cmd_connect__shows__message_when_port_contains_chars, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_with_server_when_provided, + cmocka_unit_test_setup_teardown(cmd_connect__tests__with_server_when_provided, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_with_port_when_provided, + cmocka_unit_test_setup_teardown(cmd_connect__tests__with_port_when_provided, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_with_server_and_port_when_provided, + cmocka_unit_test_setup_teardown(cmd_connect__tests__with_server_and_port_when_provided, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_server_provided_twice, + cmocka_unit_test_setup_teardown(cmd_connect__shows__usage_when_server_provided_twice, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_port_provided_twice, + cmocka_unit_test_setup_teardown(cmd_connect__shows__usage_when_port_provided_twice, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_first_property, + cmocka_unit_test_setup_teardown(cmd_connect__shows__usage_when_invalid_first_property, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_second_property, + cmocka_unit_test_setup_teardown(cmd_connect__shows__usage_when_invalid_second_property, load_preferences, close_preferences), - cmocka_unit_test(cmd_rooms_shows_message_when_disconnected), - cmocka_unit_test(cmd_rooms_shows_message_when_disconnecting), - cmocka_unit_test(cmd_rooms_shows_message_when_connecting), - cmocka_unit_test(cmd_rooms_uses_account_default_when_no_arg), - cmocka_unit_test(cmd_rooms_service_arg_used_when_passed), - cmocka_unit_test(cmd_rooms_filter_arg_used_when_passed), + cmocka_unit_test(cmd_rooms__shows__message_when_disconnected), + cmocka_unit_test(cmd_rooms__shows__message_when_disconnecting), + cmocka_unit_test(cmd_rooms__shows__message_when_connecting), + cmocka_unit_test(cmd_rooms__tests__account_default_when_no_arg), + cmocka_unit_test(cmd_rooms__tests__service_arg_used_when_passed), + cmocka_unit_test(cmd_rooms__tests__filter_arg_used_when_passed), - cmocka_unit_test(cmd_account_shows_usage_when_not_connected_and_no_args), - cmocka_unit_test(cmd_account_shows_account_when_connected_and_no_args), - cmocka_unit_test(cmd_account_list_shows_accounts), - cmocka_unit_test(cmd_account_show_shows_usage_when_no_arg), - cmocka_unit_test(cmd_account_show_shows_message_when_account_does_not_exist), - cmocka_unit_test(cmd_account_show_shows_account_when_exists), - cmocka_unit_test(cmd_account_add_shows_usage_when_no_arg), - cmocka_unit_test(cmd_account_add_adds_account), - cmocka_unit_test(cmd_account_enable_shows_usage_when_no_arg), - cmocka_unit_test(cmd_account_enable_enables_account), - cmocka_unit_test(cmd_account_enable_shows_message_when_account_doesnt_exist), - cmocka_unit_test(cmd_account_disable_shows_usage_when_no_arg), - cmocka_unit_test(cmd_account_disable_disables_account), - cmocka_unit_test(cmd_account_disable_shows_message_when_account_doesnt_exist), - cmocka_unit_test(cmd_account_rename_shows_usage_when_no_args), - cmocka_unit_test(cmd_account_rename_shows_usage_when_one_arg), - cmocka_unit_test(cmd_account_rename_renames_account), - cmocka_unit_test(cmd_account_rename_shows_message_when_not_renamed), - cmocka_unit_test(cmd_account_set_shows_usage_when_no_args), - cmocka_unit_test(cmd_account_set_shows_usage_when_one_arg), - cmocka_unit_test(cmd_account_set_shows_usage_when_two_args), - cmocka_unit_test(cmd_account_set_shows_message_when_account_doesnt_exist), - cmocka_unit_test(cmd_account_set_jid_shows_message_for_malformed_jid), - cmocka_unit_test(cmd_account_set_jid_sets_barejid), - cmocka_unit_test(cmd_account_set_jid_sets_resource), - cmocka_unit_test(cmd_account_set_server_sets_server), - cmocka_unit_test(cmd_account_set_resource_sets_resource), - cmocka_unit_test(cmd_account_set_resource_sets_resource_with_online_message), - cmocka_unit_test(cmd_account_set_password_sets_password), - cmocka_unit_test(cmd_account_set_eval_password_sets_eval_password), - cmocka_unit_test(cmd_account_set_password_when_eval_password_set), - cmocka_unit_test(cmd_account_set_eval_password_when_password_set), - cmocka_unit_test(cmd_account_set_muc_sets_muc), - cmocka_unit_test(cmd_account_set_nick_sets_nick), + cmocka_unit_test(cmd_account__shows__usage_when_not_connected_and_no_args), + cmocka_unit_test(cmd_account__shows__account_when_connected_and_no_args), + cmocka_unit_test(cmd_account_list__shows__accounts), + cmocka_unit_test(cmd_account_show__shows__usage_when_no_arg), + cmocka_unit_test(cmd_account_show__shows__message_when_account_does_not_exist), + cmocka_unit_test(cmd_account_show__shows__account_when_exists), + cmocka_unit_test(cmd_account_add__shows__usage_when_no_arg), + cmocka_unit_test(cmd_account_add__updates__adds_account), + cmocka_unit_test(cmd_account_enable__shows__usage_when_no_arg), + cmocka_unit_test(cmd_account_enable__updates__enables_account), + cmocka_unit_test(cmd_account_enable__shows__message_when_account_doesnt_exist), + cmocka_unit_test(cmd_account_disable__shows__usage_when_no_arg), + cmocka_unit_test(cmd_account_disable__updates__disables_account), + cmocka_unit_test(cmd_account_disable__shows__message_when_account_doesnt_exist), + cmocka_unit_test(cmd_account_rename__shows__usage_when_no_args), + cmocka_unit_test(cmd_account_rename__shows__usage_when_one_arg), + cmocka_unit_test(cmd_account_rename__updates__renames_account), + cmocka_unit_test(cmd_account_rename__shows__message_when_not_renamed), + cmocka_unit_test(cmd_account_set__shows__usage_when_no_args), + cmocka_unit_test(cmd_account_set__shows__usage_when_one_arg), + cmocka_unit_test(cmd_account_set__shows__usage_when_two_args), + cmocka_unit_test(cmd_account_set__shows__message_when_account_doesnt_exist), + cmocka_unit_test(cmd_account_set__shows__message_for_malformed_jid), + cmocka_unit_test(cmd_account_set__updates__jid_sets_barejid), + cmocka_unit_test(cmd_account_set__updates__jid_sets_resource), + cmocka_unit_test(cmd_account_set__updates__server_sets_server), + cmocka_unit_test(cmd_account_set__updates__resource_sets_resource), + cmocka_unit_test(cmd_account_set__shows__resource_sets_resource_with_online_message), + cmocka_unit_test(cmd_account_set__updates__password_sets_password), + cmocka_unit_test(cmd_account_set__updates__eval_password_sets_eval_password), + cmocka_unit_test(cmd_account_set__shows__password_when_eval_password_set), + cmocka_unit_test(cmd_account_set__shows__eval_password_when_password_set), + cmocka_unit_test(cmd_account_set__updates__muc_sets_muc), + cmocka_unit_test(cmd_account_set__updates__nick_sets_nick), #ifdef HAVE_LIBOTR - cmocka_unit_test(cmd_account_show_message_for_missing_otr_policy), - cmocka_unit_test(cmd_account_show_message_for_invalid_otr_policy), - cmocka_unit_test(cmd_account_set_otr_sets_otr), + cmocka_unit_test(cmd_account_set__shows__message_for_missing_otr_policy), + cmocka_unit_test(cmd_account_set__shows__message_for_invalid_otr_policy), + cmocka_unit_test(cmd_account_set__updates__otr_sets_otr), #endif - cmocka_unit_test(cmd_account_set_status_shows_message_when_invalid_status), - cmocka_unit_test(cmd_account_set_status_sets_status_when_valid), - cmocka_unit_test(cmd_account_set_status_sets_status_when_last), - cmocka_unit_test(cmd_account_set_invalid_presence_string_priority_shows_message), - cmocka_unit_test(cmd_account_set_last_priority_shows_message), - cmocka_unit_test(cmd_account_set_online_priority_sets_preference), - cmocka_unit_test(cmd_account_set_chat_priority_sets_preference), - cmocka_unit_test(cmd_account_set_away_priority_sets_preference), - cmocka_unit_test(cmd_account_set_xa_priority_sets_preference), - cmocka_unit_test(cmd_account_set_dnd_priority_sets_preference), - cmocka_unit_test(cmd_account_set_priority_too_low_shows_message), - cmocka_unit_test(cmd_account_set_priority_too_high_shows_message), - cmocka_unit_test(cmd_account_set_priority_when_not_number_shows_message), - cmocka_unit_test(cmd_account_set_priority_when_empty_shows_message), - cmocka_unit_test(cmd_account_set_priority_updates_presence_when_account_connected_with_presence), - cmocka_unit_test(cmd_account_clear_shows_usage_when_no_args), - cmocka_unit_test(cmd_account_clear_shows_usage_when_one_arg), - cmocka_unit_test(cmd_account_clear_shows_message_when_account_doesnt_exist), - cmocka_unit_test(cmd_account_clear_shows_message_when_invalid_property), + cmocka_unit_test(cmd_account_set__shows__message_when_invalid_status), + cmocka_unit_test(cmd_account_set__updates__status_sets_status_when_valid), + cmocka_unit_test(cmd_account_set__updates__status_sets_status_when_last), + cmocka_unit_test(cmd_account_set__shows__invalid_presence_string_priority_message), + cmocka_unit_test(cmd_account_set__shows__last_priority_message), + cmocka_unit_test(cmd_account_set__updates__online_priority_sets_preference), + cmocka_unit_test(cmd_account_set__updates__chat_priority_sets_preference), + cmocka_unit_test(cmd_account_set__updates__away_priority_sets_preference), + cmocka_unit_test(cmd_account_set__updates__xa_priority_sets_preference), + cmocka_unit_test(cmd_account_set__updates__dnd_priority_sets_preference), + cmocka_unit_test(cmd_account_set__shows__priority_too_low_message), + cmocka_unit_test(cmd_account_set__shows__priority_too_high_message), + cmocka_unit_test(cmd_account_set__shows__priority_when_not_number_message), + cmocka_unit_test(cmd_account_set__shows__priority_when_empty_message), + cmocka_unit_test(cmd_account_set__updates__priority_updates_presence_when_connected), + cmocka_unit_test(cmd_account_clear__shows__usage_when_no_args), + cmocka_unit_test(cmd_account_clear__shows__usage_when_one_arg), + cmocka_unit_test(cmd_account_clear__shows__message_when_account_doesnt_exist), + cmocka_unit_test(cmd_account_clear__shows__message_when_invalid_property), - cmocka_unit_test(cmd_sub_shows_message_when_not_connected), - cmocka_unit_test(cmd_sub_shows_usage_when_no_arg), + cmocka_unit_test(cmd_sub__shows__message_when_not_connected), + cmocka_unit_test(cmd_sub__shows__usage_when_no_arg), - cmocka_unit_test(contact_in_group), - cmocka_unit_test(contact_not_in_group), - cmocka_unit_test(contact_name_when_name_exists), - cmocka_unit_test(contact_jid_when_name_not_exists), - cmocka_unit_test(contact_string_when_name_exists), - cmocka_unit_test(contact_string_when_name_not_exists), - cmocka_unit_test(contact_string_when_default_resource), - cmocka_unit_test(contact_presence_offline), - cmocka_unit_test(contact_presence_uses_highest_priority), - cmocka_unit_test(contact_presence_chat_when_same_prioroty), - cmocka_unit_test(contact_presence_online_when_same_prioroty), - cmocka_unit_test(contact_presence_away_when_same_prioroty), - cmocka_unit_test(contact_presence_xa_when_same_prioroty), - cmocka_unit_test(contact_presence_dnd), - cmocka_unit_test(contact_subscribed_when_to), - cmocka_unit_test(contact_subscribed_when_both), - cmocka_unit_test(contact_not_subscribed_when_from), - cmocka_unit_test(contact_not_subscribed_when_no_subscription_value), - cmocka_unit_test(contact_not_available), - cmocka_unit_test(contact_not_available_when_highest_priority_away), - cmocka_unit_test(contact_not_available_when_highest_priority_xa), - cmocka_unit_test(contact_not_available_when_highest_priority_dnd), - cmocka_unit_test(contact_available_when_highest_priority_online), - cmocka_unit_test(contact_available_when_highest_priority_chat), + cmocka_unit_test(p_contact_in_group__is__true_when_in_group), + cmocka_unit_test(p_contact_in_group__is__false_when_not_in_group), + cmocka_unit_test(p_contact_name_or_jid__returns__name_when_exists), + cmocka_unit_test(p_contact_name_or_jid__returns__jid_when_name_not_exists), + cmocka_unit_test(p_contact_create_display_string__returns__name_and_resource_when_name_exists), + cmocka_unit_test(p_contact_create_display_string__returns__jid_and_resource_when_name_not_exists), + cmocka_unit_test(p_contact_create_display_string__returns__name_when_default_resource), + cmocka_unit_test(p_contact_presence__returns__offline_when_no_resources), + cmocka_unit_test(p_contact_presence__returns__highest_priority_presence), + cmocka_unit_test(p_contact_presence__returns__chat_when_same_priority), + cmocka_unit_test(p_contact_presence__returns__online_when_same_priority), + cmocka_unit_test(p_contact_presence__returns__away_when_same_priority), + cmocka_unit_test(p_contact_presence__returns__xa_when_same_priority), + cmocka_unit_test(p_contact_presence__returns__dnd), + cmocka_unit_test(p_contact_subscribed__is__true_when_to), + cmocka_unit_test(p_contact_subscribed__is__true_when_both), + cmocka_unit_test(p_contact_subscribed__is__false_when_from), + cmocka_unit_test(p_contact_subscribed__is__false_when_no_subscription_value), + cmocka_unit_test(p_contact_is_available__is__false_when_offline), + cmocka_unit_test(p_contact_is_available__is__false_when_highest_priority_away), + cmocka_unit_test(p_contact_is_available__is__false_when_highest_priority_xa), + cmocka_unit_test(p_contact_is_available__is__false_when_highest_priority_dnd), + cmocka_unit_test(p_contact_is_available__is__true_when_highest_priority_online), + cmocka_unit_test(p_contact_is_available__is__true_when_highest_priority_chat), - cmocka_unit_test(cmd_presence_shows_usage_when_bad_subcmd), - cmocka_unit_test(cmd_presence_shows_usage_when_bad_console_setting), - cmocka_unit_test(cmd_presence_shows_usage_when_bad_chat_setting), - cmocka_unit_test(cmd_presence_shows_usage_when_bad_muc_setting), - cmocka_unit_test_setup_teardown(cmd_presence_console_sets_all, + cmocka_unit_test(cmd_presence__shows__usage_when_bad_subcmd), + cmocka_unit_test(cmd_presence__shows__usage_when_bad_console_setting), + cmocka_unit_test(cmd_presence__shows__usage_when_bad_chat_setting), + cmocka_unit_test(cmd_presence__shows__usage_when_bad_muc_setting), + cmocka_unit_test_setup_teardown(cmd_presence__updates__console_all, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_presence_console_sets_online, + cmocka_unit_test_setup_teardown(cmd_presence__updates__console_online, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_presence_console_sets_none, + cmocka_unit_test_setup_teardown(cmd_presence__updates__console_none, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_presence_chat_sets_all, + cmocka_unit_test_setup_teardown(cmd_presence__updates__chat_all, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_presence_chat_sets_online, + cmocka_unit_test_setup_teardown(cmd_presence__updates__chat_online, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_presence_chat_sets_none, + cmocka_unit_test_setup_teardown(cmd_presence__updates__chat_none, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_presence_room_sets_all, + cmocka_unit_test_setup_teardown(cmd_presence__updates__room_all, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_presence_room_sets_online, + cmocka_unit_test_setup_teardown(cmd_presence__updates__room_online, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_presence_room_sets_none, + cmocka_unit_test_setup_teardown(cmd_presence__updates__room_none, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(statuses_console_defaults_to_all, + cmocka_unit_test_setup_teardown(prefs_get_string__returns__all_for_console_default, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(statuses_chat_defaults_to_all, + cmocka_unit_test_setup_teardown(prefs_get_string__returns__none_for_chat_default, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(statuses_muc_defaults_to_all, + cmocka_unit_test_setup_teardown(prefs_get_string__returns__none_for_muc_default, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(console_shows_online_presence_when_set_online, + cmocka_unit_test_setup_teardown(sv_ev_contact_online__shows__presence_in_console_when_set_online, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(console_shows_online_presence_when_set_all, + cmocka_unit_test_setup_teardown(sv_ev_contact_online__shows__presence_in_console_when_set_all, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(console_shows_dnd_presence_when_set_all, + cmocka_unit_test_setup_teardown(sv_ev_contact_online__shows__dnd_presence_in_console_when_set_all, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(handle_offline_removes_chat_session, + cmocka_unit_test_setup_teardown(sv_ev_contact_offline__updates__removes_chat_session, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(lost_connection_clears_chat_sessions, + cmocka_unit_test_setup_teardown(sv_ev_lost_connection__updates__clears_chat_sessions, load_preferences, close_preferences), - cmocka_unit_test(cmd_alias_add_shows_usage_when_no_args), - cmocka_unit_test(cmd_alias_add_shows_usage_when_no_value), - cmocka_unit_test(cmd_alias_remove_shows_usage_when_no_args), - cmocka_unit_test(cmd_alias_show_usage_when_invalid_subcmd), - cmocka_unit_test_setup_teardown(cmd_alias_add_adds_alias, + cmocka_unit_test(cmd_alias__shows__usage_when_add_no_args), + cmocka_unit_test(cmd_alias__shows__usage_when_add_no_value), + cmocka_unit_test(cmd_alias__shows__usage_when_remove_no_args), + cmocka_unit_test(cmd_alias__shows__usage_when_invalid_subcmd), + cmocka_unit_test_setup_teardown(cmd_alias__updates__adds_alias, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_alias_add_shows_message_when_exists, + cmocka_unit_test_setup_teardown(cmd_alias__shows__message_when_add_exists, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_alias_remove_removes_alias, + cmocka_unit_test_setup_teardown(cmd_alias__updates__removes_alias, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_alias_remove_shows_message_when_no_alias, + cmocka_unit_test_setup_teardown(cmd_alias__shows__message_when_remove_no_alias, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_alias_list_shows_all_aliases, + cmocka_unit_test_setup_teardown(cmd_alias__shows__all_aliases, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(test_muc_invites_add, muc_before_test, muc_after_test), - cmocka_unit_test_setup_teardown(test_muc_remove_invite, muc_before_test, muc_after_test), - cmocka_unit_test_setup_teardown(test_muc_invites_count_0, muc_before_test, muc_after_test), - cmocka_unit_test_setup_teardown(test_muc_invites_count_5, muc_before_test, muc_after_test), - cmocka_unit_test_setup_teardown(test_muc_room_is_not_active, muc_before_test, muc_after_test), - cmocka_unit_test_setup_teardown(test_muc_active, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(muc_invites_add__updates__invites_list, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(muc_invites_remove__updates__invites_list, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(muc_invites_count__returns__0_when_no_invites, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(muc_invites_count__returns__5_when_five_invites_added, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(muc_active__is__false_when_not_joined, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(muc_active__is__true_when_joined, muc_before_test, muc_after_test), - cmocka_unit_test(cmd_bookmark_shows_message_when_disconnected), - cmocka_unit_test(cmd_bookmark_shows_message_when_disconnecting), - cmocka_unit_test(cmd_bookmark_shows_message_when_connecting), - cmocka_unit_test(cmd_bookmark_shows_usage_when_no_args), - cmocka_unit_test(cmd_bookmark_list_shows_bookmarks), - cmocka_unit_test(cmd_bookmark_add_shows_message_when_invalid_jid), - cmocka_unit_test(cmd_bookmark_add_adds_bookmark_with_jid), - muc_unit_test(cmd_bookmark_uses_roomjid_in_room), - muc_unit_test(cmd_bookmark_add_uses_roomjid_in_room), - muc_unit_test(cmd_bookmark_add_uses_supplied_jid_in_room), - muc_unit_test(cmd_bookmark_remove_uses_roomjid_in_room), - muc_unit_test(cmd_bookmark_remove_uses_supplied_jid_in_room), - cmocka_unit_test(cmd_bookmark_add_adds_bookmark_with_jid_nick), - cmocka_unit_test(cmd_bookmark_add_adds_bookmark_with_jid_autojoin), - cmocka_unit_test(cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin), - cmocka_unit_test(cmd_bookmark_remove_removes_bookmark), - cmocka_unit_test(cmd_bookmark_remove_shows_message_when_no_bookmark), + cmocka_unit_test(cmd_bookmark__shows__message_when_disconnected), + cmocka_unit_test(cmd_bookmark__shows__message_when_disconnecting), + cmocka_unit_test(cmd_bookmark__shows__message_when_connecting), + cmocka_unit_test(cmd_bookmark__shows__usage_when_no_args), + cmocka_unit_test(cmd_bookmark_list__shows__bookmarks), + cmocka_unit_test(cmd_bookmark_add__shows__message_when_invalid_jid), + cmocka_unit_test(cmd_bookmark_add__updates__bookmark_with_jid), + muc_unit_test(cmd_bookmark__tests__uses_roomjid_in_room), + muc_unit_test(cmd_bookmark_add__tests__uses_roomjid_in_room), + muc_unit_test(cmd_bookmark_add__tests__uses_supplied_jid_in_room), + muc_unit_test(cmd_bookmark_remove__tests__uses_roomjid_in_room), + muc_unit_test(cmd_bookmark_remove__tests__uses_supplied_jid_in_room), + cmocka_unit_test(cmd_bookmark_add__updates__bookmark_with_jid_nick), + cmocka_unit_test(cmd_bookmark_add__updates__bookmark_with_jid_autojoin), + cmocka_unit_test(cmd_bookmark_add__updates__bookmark_with_jid_nick_autojoin), + cmocka_unit_test(cmd_bookmark_remove__updates__removes_bookmark), + cmocka_unit_test(cmd_bookmark_remove__shows__message_when_no_bookmark), #ifdef HAVE_LIBOTR - cmocka_unit_test(cmd_otr_log_shows_usage_when_no_args), - cmocka_unit_test(cmd_otr_log_shows_usage_when_invalid_subcommand), - cmocka_unit_test_setup_teardown(cmd_otr_log_on_enables_logging, + cmocka_unit_test(cmd_otr_log__shows__usage_when_no_args), + cmocka_unit_test(cmd_otr_log__shows__usage_when_invalid_subcommand), + cmocka_unit_test_setup_teardown(cmd_otr_log__updates__enables_logging, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_otr_log_off_disables_logging, + cmocka_unit_test_setup_teardown(cmd_otr_log__updates__disables_logging, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_otr_redact_redacts_logging, + cmocka_unit_test_setup_teardown(cmd_otr_log__updates__redacts_logging, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_otr_log_on_shows_warning_when_chlog_disabled, + cmocka_unit_test_setup_teardown(cmd_otr_log__shows__warning_when_chlog_disabled, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(cmd_otr_log_redact_shows_warning_when_chlog_disabled, + cmocka_unit_test_setup_teardown(cmd_otr_log__shows__redact_warning_when_chlog_disabled, load_preferences, close_preferences), - cmocka_unit_test(cmd_otr_libver_shows_libotr_version), - cmocka_unit_test(cmd_otr_gen_shows_message_when_not_connected), - cmocka_unit_test(cmd_otr_gen_generates_key_for_connected_account), - cmocka_unit_test(cmd_otr_gen_shows_message_when_disconnected), - cmocka_unit_test(cmd_otr_gen_shows_message_when_connecting), - cmocka_unit_test(cmd_otr_gen_shows_message_when_disconnecting), - cmocka_unit_test(cmd_otr_myfp_shows_message_when_disconnected), - cmocka_unit_test(cmd_otr_myfp_shows_message_when_connecting), - cmocka_unit_test(cmd_otr_myfp_shows_message_when_disconnecting), - cmocka_unit_test(cmd_otr_myfp_shows_message_when_no_key), - cmocka_unit_test(cmd_otr_myfp_shows_my_fingerprint), - cmocka_unit_test(cmd_otr_theirfp_shows_message_when_in_console), - cmocka_unit_test(cmd_otr_theirfp_shows_message_when_in_muc), - cmocka_unit_test(cmd_otr_theirfp_shows_message_when_in_private), - cmocka_unit_test(cmd_otr_theirfp_shows_message_when_non_otr_chat_window), - cmocka_unit_test(cmd_otr_theirfp_shows_fingerprint), - cmocka_unit_test(cmd_otr_start_shows_message_when_in_console), - cmocka_unit_test(cmd_otr_start_shows_message_when_in_muc), - cmocka_unit_test(cmd_otr_start_shows_message_when_in_private), - cmocka_unit_test(cmd_otr_start_shows_message_when_already_started), - cmocka_unit_test(cmd_otr_start_shows_message_when_no_key), - cmocka_unit_test_setup_teardown(cmd_otr_start_sends_otr_query_message_to_current_recipeint, + cmocka_unit_test(cmd_otr_libver__shows__libotr_version), + cmocka_unit_test(cmd_otr_gen__shows__message_when_not_connected), + cmocka_unit_test(cmd_otr_gen__tests__generates_key_for_connected_account), + cmocka_unit_test(cmd_otr_gen__shows__message_when_disconnected), + cmocka_unit_test(cmd_otr_gen__shows__message_when_connecting), + cmocka_unit_test(cmd_otr_gen__shows__message_when_disconnecting), + cmocka_unit_test(cmd_otr_myfp__shows__message_when_disconnected), + cmocka_unit_test(cmd_otr_myfp__shows__message_when_connecting), + cmocka_unit_test(cmd_otr_myfp__shows__message_when_disconnecting), + cmocka_unit_test(cmd_otr_myfp__shows__message_when_no_key), + cmocka_unit_test(cmd_otr_myfp__shows__my_fingerprint), + cmocka_unit_test(cmd_otr_theirfp__shows__message_when_in_console), + cmocka_unit_test(cmd_otr_theirfp__shows__message_when_in_muc), + cmocka_unit_test(cmd_otr_theirfp__shows__message_when_in_private), + cmocka_unit_test(cmd_otr_theirfp__shows__message_when_non_otr_chat_window), + cmocka_unit_test(cmd_otr_theirfp__shows__fingerprint), + cmocka_unit_test(cmd_otr_start__shows__message_when_in_console), + cmocka_unit_test(cmd_otr_start__shows__message_when_in_muc), + cmocka_unit_test(cmd_otr_start__shows__message_when_in_private), + cmocka_unit_test(cmd_otr_start__shows__message_when_already_started), + cmocka_unit_test(cmd_otr_start__shows__message_when_no_key), + cmocka_unit_test_setup_teardown(cmd_otr_start__tests__sends_otr_query_message_to_current_recipeint, load_preferences, close_preferences), #else - cmocka_unit_test(cmd_otr_shows_message_when_otr_unsupported), + cmocka_unit_test(cmd_otr__shows__message_when_otr_unsupported), #endif #ifdef HAVE_LIBGPGME - cmocka_unit_test(cmd_pgp_shows_usage_when_no_args), - cmocka_unit_test(cmd_pgp_start_shows_message_when_disconnected), - cmocka_unit_test(cmd_pgp_start_shows_message_when_disconnecting), - cmocka_unit_test(cmd_pgp_start_shows_message_when_connecting), - cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_console), - cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_muc), - cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_conf), - cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_private), - cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole), + cmocka_unit_test(cmd_pgp__shows__usage_when_no_args), + cmocka_unit_test(cmd_pgp_start__shows__message_when_disconnected), + cmocka_unit_test(cmd_pgp_start__shows__message_when_disconnecting), + cmocka_unit_test(cmd_pgp_start__shows__message_when_connecting), + cmocka_unit_test(cmd_pgp_start__shows__message_when_no_arg_in_console), + cmocka_unit_test(cmd_pgp_start__shows__message_when_no_arg_in_muc), + cmocka_unit_test(cmd_pgp_start__shows__message_when_no_arg_in_conf), + cmocka_unit_test(cmd_pgp_start__shows__message_when_no_arg_in_private), + cmocka_unit_test(cmd_pgp_start__shows__message_when_no_arg_in_xmlconsole), #else - cmocka_unit_test(cmd_pgp_shows_message_when_pgp_unsupported), + cmocka_unit_test(cmd_pgp__shows__message_when_pgp_unsupported), #endif - cmocka_unit_test(cmd_join_shows_message_when_disconnecting), - cmocka_unit_test(cmd_join_shows_message_when_connecting), - cmocka_unit_test(cmd_join_shows_message_when_disconnected), - cmocka_unit_test(cmd_join_shows_error_message_when_invalid_room_jid), - muc_unit_test(cmd_join_uses_account_mucservice_when_no_service_specified), - muc_unit_test(cmd_join_uses_supplied_nick), - muc_unit_test(cmd_join_uses_account_nick_when_not_supplied), - muc_unit_test(cmd_join_uses_password_when_supplied), + cmocka_unit_test(cmd_join__shows__message_when_disconnecting), + cmocka_unit_test(cmd_join__shows__message_when_connecting), + cmocka_unit_test(cmd_join__shows__message_when_disconnected), + cmocka_unit_test(cmd_join__shows__error_message_when_invalid_room_jid), + muc_unit_test(cmd_join__tests__uses_account_mucservice_when_no_service_specified), + muc_unit_test(cmd_join__tests__uses_supplied_nick), + muc_unit_test(cmd_join__tests__uses_account_nick_when_not_supplied), + muc_unit_test(cmd_join__tests__uses_password_when_supplied), - cmocka_unit_test(cmd_roster_shows_message_when_disconnecting), - cmocka_unit_test(cmd_roster_shows_message_when_connecting), - cmocka_unit_test(cmd_roster_shows_message_when_disconnected), - cmocka_unit_test(cmd_roster_shows_roster_when_no_args), - cmocka_unit_test(cmd_roster_add_shows_message_when_no_jid), - cmocka_unit_test(cmd_roster_add_sends_roster_add_request), - cmocka_unit_test(cmd_roster_remove_shows_message_when_no_jid), - cmocka_unit_test(cmd_roster_remove_sends_roster_remove_request), - cmocka_unit_test(cmd_roster_remove_nickname_sends_roster_remove_request), - cmocka_unit_test(cmd_roster_nick_shows_message_when_no_jid), - cmocka_unit_test(cmd_roster_nick_shows_message_when_no_nick), - cmocka_unit_test(cmd_roster_nick_shows_message_when_no_contact_exists), - cmocka_unit_test(cmd_roster_nick_sends_name_change_request), - cmocka_unit_test(cmd_roster_clearnick_shows_message_when_no_jid), - cmocka_unit_test(cmd_roster_clearnick_shows_message_when_no_contact_exists), - cmocka_unit_test(cmd_roster_clearnick_sends_name_change_request_with_empty_nick), + cmocka_unit_test(cmd_roster__shows__message_when_disconnecting), + cmocka_unit_test(cmd_roster__shows__message_when_connecting), + cmocka_unit_test(cmd_roster__shows__message_when_disconnected), + cmocka_unit_test(cmd_roster__shows__roster_when_no_args), + cmocka_unit_test(cmd_roster__shows__message_when_add_no_jid), + cmocka_unit_test(cmd_roster__tests__add_sends_roster_add_request), + cmocka_unit_test(cmd_roster__shows__message_when_remove_no_jid), + cmocka_unit_test(cmd_roster__tests__remove_sends_roster_remove_request), + cmocka_unit_test(cmd_roster__tests__remove_nickname_sends_roster_remove_request), + cmocka_unit_test(cmd_roster__shows__message_when_nick_no_jid), + cmocka_unit_test(cmd_roster__shows__message_when_nick_no_nick), + cmocka_unit_test(cmd_roster__shows__message_when_nick_no_contact_exists), + cmocka_unit_test(cmd_roster__tests__nick_sends_name_change_request), + cmocka_unit_test(cmd_roster__shows__message_when_clearnick_no_jid), + cmocka_unit_test(cmd_roster__shows__message_when_clearnick_no_contact_exists), + cmocka_unit_test(cmd_roster__tests__clearnick_sends_name_change_request_with_empty_nick), - cmocka_unit_test(get_form_type_field_returns_null_no_fields), - cmocka_unit_test(get_form_type_field_returns_null_when_not_present), - cmocka_unit_test(get_form_type_field_returns_value_when_present), - cmocka_unit_test(get_field_type_returns_unknown_when_no_fields), - cmocka_unit_test(get_field_type_returns_correct_type), - cmocka_unit_test(set_value_adds_when_none), - cmocka_unit_test(set_value_updates_when_one), - cmocka_unit_test(add_unique_value_adds_when_none), - cmocka_unit_test(add_unique_value_does_nothing_when_exists), - cmocka_unit_test(add_unique_value_adds_when_doesnt_exist), - cmocka_unit_test(add_value_adds_when_none), - cmocka_unit_test(add_value_adds_when_some), - cmocka_unit_test(add_value_adds_when_exists), - cmocka_unit_test(remove_value_does_nothing_when_none), - cmocka_unit_test(remove_value_does_nothing_when_doesnt_exist), - cmocka_unit_test(remove_value_removes_when_one), - cmocka_unit_test(remove_value_removes_when_many), - cmocka_unit_test(remove_text_multi_value_does_nothing_when_none), - cmocka_unit_test(remove_text_multi_value_does_nothing_when_doesnt_exist), - cmocka_unit_test(remove_text_multi_value_removes_when_one), - cmocka_unit_test(remove_text_multi_value_removes_when_many), + cmocka_unit_test(form_get_form_type_field__returns__null_no_fields), + cmocka_unit_test(form_get_form_type_field__returns__null_when_not_present), + cmocka_unit_test(form_get_form_type_field__returns__value_when_present), + cmocka_unit_test(form_get_field_type__returns__unknown_when_no_fields), + cmocka_unit_test(form_get_field_type__returns__correct_type), + cmocka_unit_test(form_set_value__updates__adds_when_none), + cmocka_unit_test(form_set_value__updates__updates_when_one), + cmocka_unit_test(form_add_unique_value__updates__adds_when_none), + cmocka_unit_test(form_add_unique_value__updates__does_nothing_when_exists), + cmocka_unit_test(form_add_unique_value__updates__adds_when_doesnt_exist), + cmocka_unit_test(form_add_value__updates__adds_when_none), + cmocka_unit_test(form_add_value__updates__adds_when_some), + cmocka_unit_test(form_add_value__updates__adds_when_exists), + cmocka_unit_test(form_remove_value__updates__does_nothing_when_none), + cmocka_unit_test(form_remove_value__updates__does_nothing_when_doesnt_exist), + cmocka_unit_test(form_remove_value__updates__removes_when_one), + cmocka_unit_test(form_remove_value__updates__removes_when_many), + cmocka_unit_test(form_remove_text_multi_value__updates__does_nothing_when_none), + cmocka_unit_test(form_remove_text_multi_value__updates__does_nothing_when_doesnt_exist), + cmocka_unit_test(form_remove_text_multi_value__updates__removes_when_one), + cmocka_unit_test(form_remove_text_multi_value__updates__removes_when_many), - cmocka_unit_test_setup_teardown(clears_chat_sessions, + cmocka_unit_test_setup_teardown(cmd_disconnect__updates__clears_chat_sessions, load_preferences, close_preferences), - cmocka_unit_test(prof_partial_occurrences_tests), - cmocka_unit_test(prof_whole_occurrences_tests), - cmocka_unit_test(prof_occurrences_of_large_message_tests), - cmocka_unit_test(get_mentions_tests), - cmocka_unit_test(release_is_new_tests), + cmocka_unit_test(prof_occurrences__tests__partial), + cmocka_unit_test(prof_occurrences__tests__whole), + cmocka_unit_test(prof_occurrences__tests__large_message), + cmocka_unit_test(get_mentions__tests__various), + cmocka_unit_test(release_is_new__tests__various), - cmocka_unit_test_setup_teardown(returns_no_commands, + cmocka_unit_test_setup_teardown(plugins_get_command_names__returns__no_commands, load_preferences, close_preferences), - cmocka_unit_test_setup_teardown(returns_commands, + cmocka_unit_test_setup_teardown(plugins_get_command_names__returns__commands_when_added, load_preferences, close_preferences), - cmocka_unit_test(returns_empty_list_when_none), - cmocka_unit_test(returns_added_feature), - cmocka_unit_test(resets_features_on_close), - cmocka_unit_test(returns_all_added_features), - cmocka_unit_test(does_not_add_duplicate_feature), - cmocka_unit_test(removes_plugin_features), - cmocka_unit_test(does_not_remove_feature_when_more_than_one_reference), + cmocka_unit_test(disco_get_features__returns__empty_list_when_none), + cmocka_unit_test(disco_add_feature__updates__added_feature), + cmocka_unit_test(disco_close__updates__resets_features), + cmocka_unit_test(disco_get_features__returns__all_added_features), + cmocka_unit_test(disco_add_feature__updates__not_duplicate_feature), + cmocka_unit_test(disco_remove_features__updates__removes_plugin_features), + cmocka_unit_test(disco_remove_features__updates__not_remove_when_more_than_one_reference), }; return cmocka_run_group_tests(all_tests, NULL, NULL); } diff --git a/tests/unittests/xmpp/stub_avatar.c b/tests/unittests/xmpp/stub_avatar.c index 8390077e..022664ac 100644 --- a/tests/unittests/xmpp/stub_avatar.c +++ b/tests/unittests/xmpp/stub_avatar.c @@ -2,7 +2,7 @@ #include #include -void avatar_pep_subscribe(void){}; +void avatar_pep_subscribe(void) {}; gboolean avatar_get_by_nick(const char* nick, gboolean open) diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c index fd47bce2..76a072e9 100644 --- a/tests/unittests/xmpp/stub_xmpp.c +++ b/tests/unittests/xmpp/stub_xmpp.c @@ -309,8 +309,8 @@ presence_sub_request_exists(const char* const bare_jid) } // iq functions -void iq_disable_carbons(){}; -void iq_enable_carbons(){}; +void iq_disable_carbons() {}; +void iq_enable_carbons() {}; void iq_send_software_version(const char* const fulljid) { diff --git a/tests/unittests/test_chat_session.c b/tests/unittests/xmpp/test_chat_session.c similarity index 80% rename from tests/unittests/test_chat_session.c rename to tests/unittests/xmpp/test_chat_session.c index 86ce0743..5ba632d9 100644 --- a/tests/unittests/test_chat_session.c +++ b/tests/unittests/xmpp/test_chat_session.c @@ -5,14 +5,14 @@ #include "xmpp/chat_session.h" void -returns_false_when_chat_session_does_not_exist(void** state) +chat_session_get__returns__null_when_no_session(void** state) { ChatSession* session = chat_session_get("somejid@server.org"); assert_null(session); } void -creates_chat_session_on_recipient_activity(void** state) +chat_session_recipient_active__updates__new_session(void** state) { char* barejid = "myjid@server.org"; char* resource = "tablet"; @@ -25,7 +25,7 @@ creates_chat_session_on_recipient_activity(void** state) } void -replaces_chat_session_on_recipient_activity_with_different_resource(void** state) +chat_session_recipient_active__updates__replace_resource(void** state) { char* barejid = "myjid@server.org"; char* resource1 = "tablet"; @@ -39,7 +39,7 @@ replaces_chat_session_on_recipient_activity_with_different_resource(void** state } void -removes_chat_session(void** state) +chat_session_remove__updates__session_removed(void** state) { char* barejid = "myjid@server.org"; char* resource1 = "laptop"; diff --git a/tests/unittests/xmpp/test_chat_session.h b/tests/unittests/xmpp/test_chat_session.h new file mode 100644 index 00000000..009f4530 --- /dev/null +++ b/tests/unittests/xmpp/test_chat_session.h @@ -0,0 +1,9 @@ +#ifndef TESTS_TEST_CHAT_SESSION_H +#define TESTS_TEST_CHAT_SESSION_H + +void chat_session_get__returns__null_when_no_session(void** state); +void chat_session_recipient_active__updates__new_session(void** state); +void chat_session_recipient_active__updates__replace_resource(void** state); +void chat_session_remove__updates__session_removed(void** state); + +#endif diff --git a/tests/unittests/test_contact.c b/tests/unittests/xmpp/test_contact.c similarity index 88% rename from tests/unittests/test_contact.c rename to tests/unittests/xmpp/test_contact.c index 118ea462..6b538f4f 100644 --- a/tests/unittests/test_contact.c +++ b/tests/unittests/xmpp/test_contact.c @@ -6,7 +6,7 @@ #include "xmpp/contact.h" void -contact_in_group(void** state) +p_contact_in_group__is__true_when_in_group(void** state) { GSList* groups = NULL; groups = g_slist_append(groups, g_strdup("somegroup")); @@ -22,7 +22,7 @@ contact_in_group(void** state) } void -contact_not_in_group(void** state) +p_contact_in_group__is__false_when_not_in_group(void** state) { GSList* groups = NULL; groups = g_slist_append(groups, g_strdup("somegroup")); @@ -38,7 +38,7 @@ contact_not_in_group(void** state) } void -contact_name_when_name_exists(void** state) +p_contact_name_or_jid__returns__name_when_exists(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -51,7 +51,7 @@ contact_name_when_name_exists(void** state) } void -contact_jid_when_name_not_exists(void** state) +p_contact_name_or_jid__returns__jid_when_name_not_exists(void** state) { PContact contact = p_contact_new("bob@server.com", NULL, NULL, "both", "is offline", FALSE); @@ -64,7 +64,7 @@ contact_jid_when_name_not_exists(void** state) } void -contact_string_when_name_exists(void** state) +p_contact_create_display_string__returns__name_and_resource_when_name_exists(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -78,7 +78,7 @@ contact_string_when_name_exists(void** state) } void -contact_string_when_name_not_exists(void** state) +p_contact_create_display_string__returns__jid_and_resource_when_name_not_exists(void** state) { PContact contact = p_contact_new("bob@server.com", NULL, NULL, "both", "is offline", FALSE); @@ -92,7 +92,7 @@ contact_string_when_name_not_exists(void** state) } void -contact_string_when_default_resource(void** state) +p_contact_create_display_string__returns__name_when_default_resource(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -106,7 +106,7 @@ contact_string_when_default_resource(void** state) } void -contact_presence_offline(void** state) +p_contact_presence__returns__offline_when_no_resources(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -119,7 +119,7 @@ contact_presence_offline(void** state) } void -contact_presence_uses_highest_priority(void** state) +p_contact_presence__returns__highest_priority_presence(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -143,7 +143,7 @@ contact_presence_uses_highest_priority(void** state) } void -contact_presence_chat_when_same_prioroty(void** state) +p_contact_presence__returns__chat_when_same_priority(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -167,7 +167,7 @@ contact_presence_chat_when_same_prioroty(void** state) } void -contact_presence_online_when_same_prioroty(void** state) +p_contact_presence__returns__online_when_same_priority(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -189,7 +189,7 @@ contact_presence_online_when_same_prioroty(void** state) } void -contact_presence_away_when_same_prioroty(void** state) +p_contact_presence__returns__away_when_same_priority(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -209,7 +209,7 @@ contact_presence_away_when_same_prioroty(void** state) } void -contact_presence_xa_when_same_prioroty(void** state) +p_contact_presence__returns__xa_when_same_priority(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -227,7 +227,7 @@ contact_presence_xa_when_same_prioroty(void** state) } void -contact_presence_dnd(void** state) +p_contact_presence__returns__dnd(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -243,7 +243,7 @@ contact_presence_dnd(void** state) } void -contact_subscribed_when_to(void** state) +p_contact_subscribed__is__true_when_to(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "to", "is offline", FALSE); @@ -256,7 +256,7 @@ contact_subscribed_when_to(void** state) } void -contact_subscribed_when_both(void** state) +p_contact_subscribed__is__true_when_both(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", "is offline", FALSE); @@ -269,7 +269,7 @@ contact_subscribed_when_both(void** state) } void -contact_not_subscribed_when_from(void** state) +p_contact_subscribed__is__false_when_from(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "from", "is offline", FALSE); @@ -282,7 +282,7 @@ contact_not_subscribed_when_from(void** state) } void -contact_not_subscribed_when_no_subscription_value(void** state) +p_contact_subscribed__is__false_when_no_subscription_value(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, "is offline", FALSE); @@ -295,7 +295,7 @@ contact_not_subscribed_when_no_subscription_value(void** state) } void -contact_not_available(void** state) +p_contact_is_available__is__false_when_offline(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, "is offline", FALSE); @@ -308,7 +308,7 @@ contact_not_available(void** state) } void -contact_not_available_when_highest_priority_away(void** state) +p_contact_is_available__is__false_when_highest_priority_away(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, "is offline", FALSE); @@ -332,7 +332,7 @@ contact_not_available_when_highest_priority_away(void** state) } void -contact_not_available_when_highest_priority_xa(void** state) +p_contact_is_available__is__false_when_highest_priority_xa(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, "is offline", FALSE); @@ -356,7 +356,7 @@ contact_not_available_when_highest_priority_xa(void** state) } void -contact_not_available_when_highest_priority_dnd(void** state) +p_contact_is_available__is__false_when_highest_priority_dnd(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, "is offline", FALSE); @@ -380,7 +380,7 @@ contact_not_available_when_highest_priority_dnd(void** state) } void -contact_available_when_highest_priority_online(void** state) +p_contact_is_available__is__true_when_highest_priority_online(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, "is offline", FALSE); @@ -404,7 +404,7 @@ contact_available_when_highest_priority_online(void** state) } void -contact_available_when_highest_priority_chat(void** state) +p_contact_is_available__is__true_when_highest_priority_chat(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, "is offline", FALSE); diff --git a/tests/unittests/xmpp/test_contact.h b/tests/unittests/xmpp/test_contact.h new file mode 100644 index 00000000..f68293e4 --- /dev/null +++ b/tests/unittests/xmpp/test_contact.h @@ -0,0 +1,29 @@ +#ifndef TESTS_TEST_CONTACT_H +#define TESTS_TEST_CONTACT_H + +void p_contact_in_group__is__true_when_in_group(void** state); +void p_contact_in_group__is__false_when_not_in_group(void** state); +void p_contact_name_or_jid__returns__name_when_exists(void** state); +void p_contact_name_or_jid__returns__jid_when_name_not_exists(void** state); +void p_contact_create_display_string__returns__name_and_resource_when_name_exists(void** state); +void p_contact_create_display_string__returns__jid_and_resource_when_name_not_exists(void** state); +void p_contact_create_display_string__returns__name_when_default_resource(void** state); +void p_contact_presence__returns__offline_when_no_resources(void** state); +void p_contact_presence__returns__highest_priority_presence(void** state); +void p_contact_presence__returns__chat_when_same_priority(void** state); +void p_contact_presence__returns__online_when_same_priority(void** state); +void p_contact_presence__returns__away_when_same_priority(void** state); +void p_contact_presence__returns__xa_when_same_priority(void** state); +void p_contact_presence__returns__dnd(void** state); +void p_contact_subscribed__is__true_when_to(void** state); +void p_contact_subscribed__is__true_when_both(void** state); +void p_contact_subscribed__is__false_when_from(void** state); +void p_contact_subscribed__is__false_when_no_subscription_value(void** state); +void p_contact_is_available__is__false_when_offline(void** state); +void p_contact_is_available__is__false_when_highest_priority_away(void** state); +void p_contact_is_available__is__false_when_highest_priority_xa(void** state); +void p_contact_is_available__is__false_when_highest_priority_dnd(void** state); +void p_contact_is_available__is__true_when_highest_priority_online(void** state); +void p_contact_is_available__is__true_when_highest_priority_chat(void** state); + +#endif diff --git a/tests/unittests/test_form.c b/tests/unittests/xmpp/test_form.c similarity index 94% rename from tests/unittests/test_form.c rename to tests/unittests/xmpp/test_form.c index 2f6b70eb..103512be 100644 --- a/tests/unittests/test_form.c +++ b/tests/unittests/xmpp/test_form.c @@ -42,7 +42,7 @@ _new_field(void) } void -get_form_type_field_returns_null_no_fields(void** state) +form_get_form_type_field__returns__null_no_fields(void** state) { DataForm* form = _new_form(); @@ -54,7 +54,7 @@ get_form_type_field_returns_null_no_fields(void** state) } void -get_form_type_field_returns_null_when_not_present(void** state) +form_get_form_type_field__returns__null_when_not_present(void** state) { DataForm* form = _new_form(); FormField* field = _new_field(); @@ -70,7 +70,7 @@ get_form_type_field_returns_null_when_not_present(void** state) } void -get_form_type_field_returns_value_when_present(void** state) +form_get_form_type_field__returns__value_when_present(void** state) { DataForm* form = _new_form(); @@ -97,7 +97,7 @@ get_form_type_field_returns_value_when_present(void** state) } void -get_field_type_returns_unknown_when_no_fields(void** state) +form_get_field_type__returns__unknown_when_no_fields(void** state) { DataForm* form = _new_form(); @@ -109,7 +109,7 @@ get_field_type_returns_unknown_when_no_fields(void** state) } void -get_field_type_returns_correct_type(void** state) +form_get_field_type__returns__correct_type(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -135,7 +135,7 @@ get_field_type_returns_correct_type(void** state) } void -set_value_adds_when_none(void** state) +form_set_value__updates__adds_when_none(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -174,7 +174,7 @@ set_value_adds_when_none(void** state) } void -set_value_updates_when_one(void** state) +form_set_value__updates__updates_when_one(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -213,7 +213,7 @@ set_value_updates_when_one(void** state) } void -add_unique_value_adds_when_none(void** state) +form_add_unique_value__updates__adds_when_none(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -253,7 +253,7 @@ add_unique_value_adds_when_none(void** state) } void -add_unique_value_does_nothing_when_exists(void** state) +form_add_unique_value__updates__does_nothing_when_exists(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -294,7 +294,7 @@ add_unique_value_does_nothing_when_exists(void** state) } void -add_unique_value_adds_when_doesnt_exist(void** state) +form_add_unique_value__updates__adds_when_doesnt_exist(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -343,7 +343,7 @@ add_unique_value_adds_when_doesnt_exist(void** state) } void -add_value_adds_when_none(void** state) +form_add_value__updates__adds_when_none(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -375,7 +375,7 @@ add_value_adds_when_none(void** state) } void -add_value_adds_when_some(void** state) +form_add_value__updates__adds_when_some(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -416,7 +416,7 @@ add_value_adds_when_some(void** state) } void -add_value_adds_when_exists(void** state) +form_add_value__updates__adds_when_exists(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -458,7 +458,7 @@ add_value_adds_when_exists(void** state) } void -remove_value_does_nothing_when_none(void** state) +form_remove_value__updates__does_nothing_when_none(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -487,7 +487,7 @@ remove_value_does_nothing_when_none(void** state) } void -remove_value_does_nothing_when_doesnt_exist(void** state) +form_remove_value__updates__does_nothing_when_doesnt_exist(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -529,7 +529,7 @@ remove_value_does_nothing_when_doesnt_exist(void** state) } void -remove_value_removes_when_one(void** state) +form_remove_value__updates__removes_when_one(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -559,7 +559,7 @@ remove_value_removes_when_one(void** state) } void -remove_value_removes_when_many(void** state) +form_remove_value__updates__removes_when_many(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -601,7 +601,7 @@ remove_value_removes_when_many(void** state) } void -remove_text_multi_value_does_nothing_when_none(void** state) +form_remove_text_multi_value__updates__does_nothing_when_none(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -630,7 +630,7 @@ remove_text_multi_value_does_nothing_when_none(void** state) } void -remove_text_multi_value_does_nothing_when_doesnt_exist(void** state) +form_remove_text_multi_value__updates__does_nothing_when_doesnt_exist(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -672,7 +672,7 @@ remove_text_multi_value_does_nothing_when_doesnt_exist(void** state) } void -remove_text_multi_value_removes_when_one(void** state) +form_remove_text_multi_value__updates__removes_when_one(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); @@ -702,7 +702,7 @@ remove_text_multi_value_removes_when_one(void** state) } void -remove_text_multi_value_removes_when_many(void** state) +form_remove_text_multi_value__updates__removes_when_many(void** state) { DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); diff --git a/tests/unittests/xmpp/test_form.h b/tests/unittests/xmpp/test_form.h new file mode 100644 index 00000000..432b9898 --- /dev/null +++ b/tests/unittests/xmpp/test_form.h @@ -0,0 +1,26 @@ +#ifndef TESTS_TEST_FORM_H +#define TESTS_TEST_FORM_H + +void form_get_form_type_field__returns__null_no_fields(void** state); +void form_get_form_type_field__returns__null_when_not_present(void** state); +void form_get_form_type_field__returns__value_when_present(void** state); +void form_get_field_type__returns__unknown_when_no_fields(void** state); +void form_get_field_type__returns__correct_type(void** state); +void form_set_value__updates__adds_when_none(void** state); +void form_set_value__updates__updates_when_one(void** state); +void form_add_unique_value__updates__adds_when_none(void** state); +void form_add_unique_value__updates__does_nothing_when_exists(void** state); +void form_add_unique_value__updates__adds_when_doesnt_exist(void** state); +void form_add_value__updates__adds_when_none(void** state); +void form_add_value__updates__adds_when_some(void** state); +void form_add_value__updates__adds_when_exists(void** state); +void form_remove_value__updates__does_nothing_when_none(void** state); +void form_remove_value__updates__does_nothing_when_doesnt_exist(void** state); +void form_remove_value__updates__removes_when_one(void** state); +void form_remove_value__updates__removes_when_many(void** state); +void form_remove_text_multi_value__updates__does_nothing_when_none(void** state); +void form_remove_text_multi_value__updates__does_nothing_when_doesnt_exist(void** state); +void form_remove_text_multi_value__updates__removes_when_one(void** state); +void form_remove_text_multi_value__updates__removes_when_many(void** state); + +#endif diff --git a/tests/unittests/test_jid.c b/tests/unittests/xmpp/test_jid.c similarity index 76% rename from tests/unittests/test_jid.c rename to tests/unittests/xmpp/test_jid.c index 6c472d0f..51f66f08 100644 --- a/tests/unittests/test_jid.c +++ b/tests/unittests/xmpp/test_jid.c @@ -4,21 +4,21 @@ #include "xmpp/jid.h" void -create_jid_from_null_returns_null(void** state) +jid_create__returns__null_from_null(void** state) { Jid* result = jid_create(NULL); assert_null(result); } void -create_jid_from_empty_string_returns_null(void** state) +jid_create__returns__null_from_empty_string(void** state) { Jid* result = jid_create(""); assert_null(result); } void -create_jid_from_full_returns_full(void** state) +jid_create__returns__full_from_full(void** state) { Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser@mydomain/laptop", result->fulljid); @@ -26,7 +26,7 @@ create_jid_from_full_returns_full(void** state) } void -create_jid_from_full_returns_bare(void** state) +jid_create__returns__bare_from_full(void** state) { Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser@mydomain", result->barejid); @@ -34,7 +34,7 @@ create_jid_from_full_returns_bare(void** state) } void -create_jid_from_full_returns_resourcepart(void** state) +jid_create__returns__resourcepart_from_full(void** state) { Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("laptop", result->resourcepart); @@ -42,7 +42,7 @@ create_jid_from_full_returns_resourcepart(void** state) } void -create_jid_from_full_returns_localpart(void** state) +jid_create__returns__localpart_from_full(void** state) { Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser", result->localpart); @@ -50,7 +50,7 @@ create_jid_from_full_returns_localpart(void** state) } void -create_jid_from_full_returns_domainpart(void** state) +jid_create__returns__domainpart_from_full(void** state) { Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("mydomain", result->domainpart); @@ -58,7 +58,7 @@ create_jid_from_full_returns_domainpart(void** state) } void -create_jid_from_full_nolocal_returns_full(void** state) +jid_create__returns__full_from_full_nolocal(void** state) { Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain/laptop", result->fulljid); @@ -66,7 +66,7 @@ create_jid_from_full_nolocal_returns_full(void** state) } void -create_jid_from_full_nolocal_returns_bare(void** state) +jid_create__returns__bare_from_full_nolocal(void** state) { Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain", result->barejid); @@ -74,7 +74,7 @@ create_jid_from_full_nolocal_returns_bare(void** state) } void -create_jid_from_full_nolocal_returns_resourcepart(void** state) +jid_create__returns__resourcepart_from_full_nolocal(void** state) { Jid* result = jid_create("mydomain/laptop"); assert_string_equal("laptop", result->resourcepart); @@ -82,7 +82,7 @@ create_jid_from_full_nolocal_returns_resourcepart(void** state) } void -create_jid_from_full_nolocal_returns_domainpart(void** state) +jid_create__returns__domainpart_from_full_nolocal(void** state) { Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain", result->domainpart); @@ -90,7 +90,7 @@ create_jid_from_full_nolocal_returns_domainpart(void** state) } void -create_jid_from_full_nolocal_returns_null_localpart(void** state) +jid_create__returns__null_localpart_from_full_nolocal(void** state) { Jid* result = jid_create("mydomain/laptop"); assert_null(result->localpart); @@ -98,7 +98,7 @@ create_jid_from_full_nolocal_returns_null_localpart(void** state) } void -create_jid_from_bare_returns_null_full(void** state) +jid_create__returns__null_full_from_bare(void** state) { Jid* result = jid_create("myuser@mydomain"); assert_null(result->fulljid); @@ -106,7 +106,7 @@ create_jid_from_bare_returns_null_full(void** state) } void -create_jid_from_bare_returns_null_resource(void** state) +jid_create__returns__null_resource_from_bare(void** state) { Jid* result = jid_create("myuser@mydomain"); assert_null(result->resourcepart); @@ -114,7 +114,7 @@ create_jid_from_bare_returns_null_resource(void** state) } void -create_jid_from_bare_returns_bare(void** state) +jid_create__returns__bare_from_bare(void** state) { Jid* result = jid_create("myuser@mydomain"); assert_string_equal("myuser@mydomain", result->barejid); @@ -122,7 +122,7 @@ create_jid_from_bare_returns_bare(void** state) } void -create_jid_from_bare_returns_localpart(void** state) +jid_create__returns__localpart_from_bare(void** state) { Jid* result = jid_create("myuser@mydomain"); assert_string_equal("myuser", result->localpart); @@ -130,7 +130,7 @@ create_jid_from_bare_returns_localpart(void** state) } void -create_jid_from_bare_returns_domainpart(void** state) +jid_create__returns__domainpart_from_bare(void** state) { Jid* result = jid_create("myuser@mydomain"); assert_string_equal("mydomain", result->domainpart); @@ -138,7 +138,7 @@ create_jid_from_bare_returns_domainpart(void** state) } void -create_room_jid_returns_room(void** state) +jid_create_from_bare_and_resource__returns__room(void** state) { Jid* result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); @@ -147,7 +147,7 @@ create_room_jid_returns_room(void** state) } void -create_room_jid_returns_nick(void** state) +jid_create_from_bare_and_resource__returns__nick(void** state) { Jid* result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); @@ -156,7 +156,7 @@ create_room_jid_returns_nick(void** state) } void -create_with_slash_in_resource(void** state) +jid_create__returns__correct_parts_with_slash_in_resource(void** state) { Jid* result = jid_create("room@conference.domain.org/my/nick"); @@ -170,7 +170,7 @@ create_with_slash_in_resource(void** state) } void -create_with_at_in_resource(void** state) +jid_create__returns__correct_parts_with_at_in_resource(void** state) { Jid* result = jid_create("room@conference.domain.org/my@nick"); @@ -184,7 +184,7 @@ create_with_at_in_resource(void** state) } void -create_with_at_and_slash_in_resource(void** state) +jid_create__returns__correct_parts_with_at_and_slash_in_resource(void** state) { Jid* result = jid_create("room@conference.domain.org/my@nick/something"); @@ -198,7 +198,7 @@ create_with_at_and_slash_in_resource(void** state) } void -create_full_with_trailing_slash(void** state) +jid_create__returns__correct_parts_with_trailing_slash(void** state) { Jid* result = jid_create("room@conference.domain.org/nick/"); @@ -212,7 +212,7 @@ create_full_with_trailing_slash(void** state) } void -returns_fulljid_when_exists(void** state) +jid_fulljid_or_barejid__returns__fulljid_when_exists(void** state) { Jid* jid = jid_create("localpart@domainpart/resourcepart"); @@ -224,7 +224,7 @@ returns_fulljid_when_exists(void** state) } void -returns_barejid_when_fulljid_not_exists(void** state) +jid_fulljid_or_barejid__returns__barejid_when_fulljid_not_exists(void** state) { Jid* jid = jid_create("localpart@domainpart"); diff --git a/tests/unittests/xmpp/test_jid.h b/tests/unittests/xmpp/test_jid.h new file mode 100644 index 00000000..4afccf23 --- /dev/null +++ b/tests/unittests/xmpp/test_jid.h @@ -0,0 +1,30 @@ +#ifndef TESTS_TEST_JID_H +#define TESTS_TEST_JID_H + +void jid_create__returns__null_from_null(void** state); +void jid_create__returns__null_from_empty_string(void** state); +void jid_create__returns__full_from_full(void** state); +void jid_create__returns__bare_from_full(void** state); +void jid_create__returns__resourcepart_from_full(void** state); +void jid_create__returns__localpart_from_full(void** state); +void jid_create__returns__domainpart_from_full(void** state); +void jid_create__returns__full_from_full_nolocal(void** state); +void jid_create__returns__bare_from_full_nolocal(void** state); +void jid_create__returns__resourcepart_from_full_nolocal(void** state); +void jid_create__returns__domainpart_from_full_nolocal(void** state); +void jid_create__returns__null_localpart_from_full_nolocal(void** state); +void jid_create__returns__null_full_from_bare(void** state); +void jid_create__returns__null_resource_from_bare(void** state); +void jid_create__returns__bare_from_bare(void** state); +void jid_create__returns__localpart_from_bare(void** state); +void jid_create__returns__domainpart_from_bare(void** state); +void jid_create_from_bare_and_resource__returns__room(void** state); +void jid_create_from_bare_and_resource__returns__nick(void** state); +void jid_create__returns__correct_parts_with_slash_in_resource(void** state); +void jid_create__returns__correct_parts_with_at_in_resource(void** state); +void jid_create__returns__correct_parts_with_at_and_slash_in_resource(void** state); +void jid_create__returns__correct_parts_with_trailing_slash(void** state); +void jid_fulljid_or_barejid__returns__fulljid_when_exists(void** state); +void jid_fulljid_or_barejid__returns__barejid_when_fulljid_not_exists(void** state); + +#endif diff --git a/tests/unittests/test_muc.c b/tests/unittests/xmpp/test_muc.c similarity index 80% rename from tests/unittests/test_muc.c rename to tests/unittests/xmpp/test_muc.c index bf396619..38ad7e1f 100644 --- a/tests/unittests/test_muc.c +++ b/tests/unittests/xmpp/test_muc.c @@ -20,7 +20,7 @@ muc_after_test(void** state) } void -test_muc_invites_add(void** state) +muc_invites_add__updates__invites_list(void** state) { char* room = "room@conf.server"; muc_invites_add(room, NULL); @@ -31,7 +31,7 @@ test_muc_invites_add(void** state) } void -test_muc_remove_invite(void** state) +muc_invites_remove__updates__invites_list(void** state) { char* room = "room@conf.server"; muc_invites_add(room, NULL); @@ -43,7 +43,7 @@ test_muc_remove_invite(void** state) } void -test_muc_invites_count_0(void** state) +muc_invites_count__returns__0_when_no_invites(void** state) { int invite_count = muc_invites_count(); @@ -51,7 +51,7 @@ test_muc_invites_count_0(void** state) } void -test_muc_invites_count_5(void** state) +muc_invites_count__returns__5_when_five_invites_added(void** state) { muc_invites_add("room1@conf.server", NULL); muc_invites_add("room2@conf.server", NULL); @@ -65,7 +65,7 @@ test_muc_invites_count_5(void** state) } void -test_muc_room_is_not_active(void** state) +muc_active__is__false_when_not_joined(void** state) { char* room = "room@server.org"; @@ -75,7 +75,7 @@ test_muc_room_is_not_active(void** state) } void -test_muc_active(void** state) +muc_active__is__true_when_joined(void** state) { char* room = "room@server.org"; char* nick = "bob"; diff --git a/tests/unittests/xmpp/test_muc.h b/tests/unittests/xmpp/test_muc.h new file mode 100644 index 00000000..431c3457 --- /dev/null +++ b/tests/unittests/xmpp/test_muc.h @@ -0,0 +1,14 @@ +#ifndef TESTS_TEST_MUC_H +#define TESTS_TEST_MUC_H + +int muc_before_test(void** state); +int muc_after_test(void** state); + +void muc_invites_add__updates__invites_list(void** state); +void muc_invites_remove__updates__invites_list(void** state); +void muc_invites_count__returns__0_when_no_invites(void** state); +void muc_invites_count__returns__5_when_five_invites_added(void** state); +void muc_active__is__false_when_not_joined(void** state); +void muc_active__is__true_when_joined(void** state); + +#endif diff --git a/tests/unittests/test_roster_list.c b/tests/unittests/xmpp/test_roster_list.c similarity index 90% rename from tests/unittests/test_roster_list.c rename to tests/unittests/xmpp/test_roster_list.c index cc28063b..8eacfe78 100644 --- a/tests/unittests/test_roster_list.c +++ b/tests/unittests/xmpp/test_roster_list.c @@ -7,7 +7,7 @@ #include "xmpp/roster_list.h" void -empty_list_when_none_added(void** state) +roster_get_contacts__returns__empty_list_when_none_added(void** state) { roster_create(); GSList* list = roster_get_contacts(ROSTER_ORD_NAME); @@ -18,7 +18,7 @@ empty_list_when_none_added(void** state) } void -contains_one_element(void** state) +roster_get_contacts__returns__one_element(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -30,7 +30,7 @@ contains_one_element(void** state) } void -first_element_correct(void** state) +roster_get_contacts__returns__correct_first_element(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -44,7 +44,7 @@ first_element_correct(void** state) } void -contains_two_elements(void** state) +roster_get_contacts__returns__two_elements(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -58,7 +58,7 @@ contains_two_elements(void** state) } void -first_and_second_elements_correct(void** state) +roster_get_contacts__returns__correct_first_and_second_elements(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -76,7 +76,7 @@ first_and_second_elements_correct(void** state) } void -contains_three_elements(void** state) +roster_get_contacts__returns__three_elements(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -91,7 +91,7 @@ contains_three_elements(void** state) } void -first_three_elements_correct(void** state) +roster_get_contacts__returns__correct_first_three_elements(void** state) { roster_create(); roster_add("Bob", NULL, NULL, NULL, FALSE); @@ -111,7 +111,7 @@ first_three_elements_correct(void** state) } void -add_twice_at_beginning_adds_once(void** state) +roster_add__updates__adds_once_when_called_twice_at_beginning(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -133,7 +133,7 @@ add_twice_at_beginning_adds_once(void** state) } void -add_twice_in_middle_adds_once(void** state) +roster_add__updates__adds_once_when_called_twice_in_middle(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -155,7 +155,7 @@ add_twice_in_middle_adds_once(void** state) } void -add_twice_at_end_adds_once(void** state) +roster_add__updates__adds_once_when_called_twice_at_end(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -177,7 +177,7 @@ add_twice_at_end_adds_once(void** state) } void -find_first_exists(void** state) +roster_contact_autocomplete__returns__first_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -194,7 +194,7 @@ find_first_exists(void** state) } void -find_second_exists(void** state) +roster_contact_autocomplete__returns__second_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -208,7 +208,7 @@ find_second_exists(void** state) } void -find_third_exists(void** state) +roster_contact_autocomplete__returns__third_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -222,7 +222,7 @@ find_third_exists(void** state) } void -find_returns_null(void** state) +roster_contact_autocomplete__returns__null_when_no_match(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -235,7 +235,7 @@ find_returns_null(void** state) } void -find_on_empty_returns_null(void** state) +roster_contact_autocomplete__returns__null_on_empty_roster(void** state) { roster_create(); char* result = roster_contact_autocomplete("James", FALSE, NULL); @@ -244,7 +244,7 @@ find_on_empty_returns_null(void** state) } void -find_twice_returns_second_when_two_match(void** state) +roster_contact_autocomplete__returns__second_when_two_match(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -260,7 +260,7 @@ find_twice_returns_second_when_two_match(void** state) } void -find_five_times_finds_fifth(void** state) +roster_contact_autocomplete__returns__fifth_when_multiple_match(void** state) { roster_create(); roster_add("Jama", NULL, NULL, NULL, FALSE); @@ -289,7 +289,7 @@ find_five_times_finds_fifth(void** state) } void -find_twice_returns_first_when_two_match_and_reset(void** state) +roster_contact_autocomplete__returns__first_when_two_match_and_reset(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); @@ -306,7 +306,7 @@ find_twice_returns_first_when_two_match_and_reset(void** state) } void -add_contact_with_no_group(void** state) +roster_get_groups__returns__empty_for_no_group(void** state) { roster_create(); roster_add("person@server.org", NULL, NULL, NULL, FALSE); @@ -319,7 +319,7 @@ add_contact_with_no_group(void** state) } void -add_contact_with_group(void** state) +roster_get_groups__returns__one_group(void** state) { roster_create(); @@ -339,7 +339,7 @@ add_contact_with_group(void** state) } void -add_contact_with_two_groups(void** state) +roster_get_groups__returns__two_groups(void** state) { roster_create(); @@ -363,7 +363,7 @@ add_contact_with_two_groups(void** state) } void -add_contact_with_three_groups(void** state) +roster_get_groups__returns__three_groups(void** state) { roster_create(); @@ -391,7 +391,7 @@ add_contact_with_three_groups(void** state) } void -add_contact_with_three_groups_update_adding_two(void** state) +roster_update__updates__adding_two_groups(void** state) { roster_create(); @@ -433,7 +433,7 @@ add_contact_with_three_groups_update_adding_two(void** state) } void -add_contact_with_three_groups_update_removing_one(void** state) +roster_update__updates__removing_one_group(void** state) { roster_create(); @@ -463,7 +463,7 @@ add_contact_with_three_groups_update_removing_one(void** state) } void -add_contact_with_three_groups_update_removing_two(void** state) +roster_update__updates__removing_two_groups(void** state) { roster_create(); @@ -489,7 +489,7 @@ add_contact_with_three_groups_update_removing_two(void** state) } void -add_contact_with_three_groups_update_removing_three(void** state) +roster_update__updates__removing_three_groups(void** state) { roster_create(); @@ -509,7 +509,7 @@ add_contact_with_three_groups_update_removing_three(void** state) } void -add_contact_with_three_groups_update_two_new(void** state) +roster_update__updates__two_new_groups(void** state) { roster_create(); @@ -537,7 +537,7 @@ add_contact_with_three_groups_update_two_new(void** state) } void -add_remove_contact_groups(void** state) +roster_remove__updates__contact_groups(void** state) { roster_create(); @@ -557,7 +557,7 @@ add_remove_contact_groups(void** state) } void -add_contacts_with_different_groups(void** state) +roster_add__updates__different_groups(void** state) { roster_create(); @@ -591,7 +591,7 @@ add_contacts_with_different_groups(void** state) } void -add_contacts_with_same_groups(void** state) +roster_add__updates__same_groups(void** state) { roster_create(); @@ -622,7 +622,7 @@ add_contacts_with_same_groups(void** state) } void -add_contacts_with_overlapping_groups(void** state) +roster_add__updates__overlapping_groups(void** state) { roster_create(); @@ -655,7 +655,7 @@ add_contacts_with_overlapping_groups(void** state) } void -remove_contact_with_remaining_in_group(void** state) +roster_remove__updates__remaining_in_group(void** state) { roster_create(); @@ -688,7 +688,7 @@ remove_contact_with_remaining_in_group(void** state) } void -get_contact_display_name(void** state) +roster_get_display_name__returns__nickname_when_exists(void** state) { roster_create(); roster_add("person@server.org", "nickname", NULL, NULL, FALSE); @@ -699,7 +699,7 @@ get_contact_display_name(void** state) } void -get_contact_display_name_is_barejid_if_name_is_empty(void** state) +roster_get_display_name__returns__barejid_when_nickname_empty(void** state) { roster_create(); roster_add("person@server.org", NULL, NULL, NULL, FALSE); @@ -710,7 +710,7 @@ get_contact_display_name_is_barejid_if_name_is_empty(void** state) } void -get_contact_display_name_is_passed_barejid_if_contact_does_not_exist(void** state) +roster_get_display_name__returns__barejid_when_not_exists(void** state) { roster_create(); diff --git a/tests/unittests/xmpp/test_roster_list.h b/tests/unittests/xmpp/test_roster_list.h new file mode 100644 index 00000000..378ff275 --- /dev/null +++ b/tests/unittests/xmpp/test_roster_list.h @@ -0,0 +1,40 @@ +#ifndef TESTS_TEST_ROSTER_LIST_H +#define TESTS_TEST_ROSTER_LIST_H + +void roster_get_contacts__returns__empty_list_when_none_added(void** state); +void roster_get_contacts__returns__one_element(void** state); +void roster_get_contacts__returns__correct_first_element(void** state); +void roster_get_contacts__returns__two_elements(void** state); +void roster_get_contacts__returns__correct_first_and_second_elements(void** state); +void roster_get_contacts__returns__three_elements(void** state); +void roster_get_contacts__returns__correct_first_three_elements(void** state); +void roster_add__updates__adds_once_when_called_twice_at_beginning(void** state); +void roster_add__updates__adds_once_when_called_twice_in_middle(void** state); +void roster_add__updates__adds_once_when_called_twice_at_end(void** state); +void roster_contact_autocomplete__returns__first_exists(void** state); +void roster_contact_autocomplete__returns__second_exists(void** state); +void roster_contact_autocomplete__returns__third_exists(void** state); +void roster_contact_autocomplete__returns__null_when_no_match(void** state); +void roster_contact_autocomplete__returns__null_on_empty_roster(void** state); +void roster_contact_autocomplete__returns__second_when_two_match(void** state); +void roster_contact_autocomplete__returns__fifth_when_multiple_match(void** state); +void roster_contact_autocomplete__returns__first_when_two_match_and_reset(void** state); +void roster_get_groups__returns__empty_for_no_group(void** state); +void roster_get_groups__returns__one_group(void** state); +void roster_get_groups__returns__two_groups(void** state); +void roster_get_groups__returns__three_groups(void** state); +void roster_update__updates__adding_two_groups(void** state); +void roster_update__updates__removing_one_group(void** state); +void roster_update__updates__removing_two_groups(void** state); +void roster_update__updates__removing_three_groups(void** state); +void roster_update__updates__two_new_groups(void** state); +void roster_remove__updates__contact_groups(void** state); +void roster_add__updates__different_groups(void** state); +void roster_add__updates__same_groups(void** state); +void roster_add__updates__overlapping_groups(void** state); +void roster_remove__updates__remaining_in_group(void** state); +void roster_get_display_name__returns__nickname_when_exists(void** state); +void roster_get_display_name__returns__barejid_when_nickname_empty(void** state); +void roster_get_display_name__returns__barejid_when_not_exists(void** state); + +#endif