Merge pull request #2099 from profanity-im/clean-unittests

Cleanup unittests and improve documentation for new contibutors
This commit is contained in:
Michael Vetter
2026-02-28 15:15:13 +01:00
committed by GitHub
118 changed files with 2675 additions and 2360 deletions

View File

@@ -55,9 +55,9 @@ jobs:
run: | run: |
grep -P 'auto_(char|gchar|gcharv|gerror|guchar|jid|sqlite|gfd|FILE)[\w *]*;$' -r src && exit -1 || true grep -P 'auto_(char|gchar|gcharv|gerror|guchar|jid|sqlite|gfd|FILE)[\w *]*;$' -r src && exit -1 || true
- name: Run clang-format - name: Run clang-format
uses: jidicula/clang-format-action@v4.11.0 uses: jidicula/clang-format-action@v4.15.0
with: with:
clang-format-version: '16' clang-format-version: '21'
check-path: 'src' check-path: 'src'
spell-check: spell-check:

View File

@@ -1,8 +1,42 @@
# Contributing to Profanity # Contributing to Profanity
## Build ## 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. You might also take a look at the `Dockerfile.*` in the root directory.
## Submitting patches ## 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. 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. 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 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 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). * 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 * Squash fixup commits into one
* If applicable, document how to test the functionality * 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. * 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. * 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 ;-) Follow the style already present ;-)
To make this easier for you we created a `.clang-format` file. 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. 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. *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 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:
Test your changes with the following tools to find mistakes. ```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. 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. 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` `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`. 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. Running the clang static code analyzer helps improving the quality too.
``` ```
@@ -127,13 +192,39 @@ scan-view ...
``` ```
### Finding typos ### Finding typos
We include a `.codespellrc` configuration file for `codespell` in the root directory. 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. 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. 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
```

View File

@@ -142,31 +142,31 @@ unittest_sources = \
tests/unittests/tools/stub_aesgcm_download.c \ tests/unittests/tools/stub_aesgcm_download.c \
tests/unittests/tools/stub_plugin_download.c \ tests/unittests/tools/stub_plugin_download.c \
tests/unittests/helpers.c tests/unittests/helpers.h \ 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_common.c tests/unittests/test_common.h \
tests/unittests/test_autocomplete.c tests/unittests/test_autocomplete.h \ tests/unittests/tools/test_autocomplete.c tests/unittests/tools/test_autocomplete.h \
tests/unittests/test_jid.c tests/unittests/test_jid.h \ tests/unittests/xmpp/test_jid.c tests/unittests/xmpp/test_jid.h \
tests/unittests/test_parser.c tests/unittests/test_parser.h \ tests/unittests/tools/test_parser.c tests/unittests/tools/test_parser.h \
tests/unittests/test_roster_list.c tests/unittests/test_roster_list.h \ tests/unittests/xmpp/test_roster_list.c tests/unittests/xmpp/test_roster_list.h \
tests/unittests/test_chat_session.c tests/unittests/test_chat_session.h \ tests/unittests/xmpp/test_chat_session.c tests/unittests/xmpp/test_chat_session.h \
tests/unittests/test_contact.c tests/unittests/test_contact.h \ tests/unittests/xmpp/test_contact.c tests/unittests/xmpp/test_contact.h \
tests/unittests/test_preferences.c tests/unittests/test_preferences.h \ tests/unittests/config/test_preferences.c tests/unittests/config/test_preferences.h \
tests/unittests/test_server_events.c tests/unittests/test_server_events.h \ tests/unittests/event/test_server_events.c tests/unittests/event/test_server_events.h \
tests/unittests/test_muc.c tests/unittests/test_muc.h \ tests/unittests/xmpp/test_muc.c tests/unittests/xmpp/test_muc.h \
tests/unittests/test_cmd_presence.c tests/unittests/test_cmd_presence.h \ tests/unittests/command/test_cmd_presence.c tests/unittests/command/test_cmd_presence.h \
tests/unittests/test_cmd_alias.c tests/unittests/test_cmd_alias.h \ tests/unittests/command/test_cmd_alias.c tests/unittests/command/test_cmd_alias.h \
tests/unittests/test_cmd_connect.c tests/unittests/test_cmd_connect.h \ tests/unittests/command/test_cmd_connect.c tests/unittests/command/test_cmd_connect.h \
tests/unittests/test_cmd_rooms.c tests/unittests/test_cmd_rooms.h \ tests/unittests/command/test_cmd_rooms.c tests/unittests/command/test_cmd_rooms.h \
tests/unittests/test_cmd_account.c tests/unittests/test_cmd_account.h \ tests/unittests/command/test_cmd_account.c tests/unittests/command/test_cmd_account.h \
tests/unittests/test_cmd_sub.c tests/unittests/test_cmd_sub.h \ tests/unittests/command/test_cmd_sub.c tests/unittests/command/test_cmd_sub.h \
tests/unittests/test_cmd_bookmark.c tests/unittests/test_cmd_bookmark.h \ tests/unittests/command/test_cmd_bookmark.c tests/unittests/command/test_cmd_bookmark.h \
tests/unittests/test_cmd_otr.c tests/unittests/test_cmd_otr.h \ tests/unittests/command/test_cmd_otr.c tests/unittests/command/test_cmd_otr.h \
tests/unittests/test_cmd_pgp.c tests/unittests/test_cmd_pgp.h \ tests/unittests/command/test_cmd_pgp.c tests/unittests/command/test_cmd_pgp.h \
tests/unittests/test_cmd_join.c tests/unittests/test_cmd_join.h \ tests/unittests/command/test_cmd_join.c tests/unittests/command/test_cmd_join.h \
tests/unittests/test_cmd_roster.c tests/unittests/test_cmd_roster.h \ tests/unittests/command/test_cmd_roster.c tests/unittests/command/test_cmd_roster.h \
tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \ tests/unittests/command/test_cmd_disconnect.c tests/unittests/command/test_cmd_disconnect.h \
tests/unittests/test_callbacks.c tests/unittests/test_callbacks.h \ tests/unittests/plugins/test_callbacks.c tests/unittests/plugins/test_callbacks.h \
tests/unittests/test_plugins_disco.c tests/unittests/test_plugins_disco.h \ tests/unittests/plugins/test_plugins_disco.c tests/unittests/plugins/test_plugins_disco.h \
tests/unittests/unittests.c tests/unittests/unittests.c
functionaltest_sources = \ functionaltest_sources = \
@@ -285,7 +285,7 @@ endif
TESTS = tests/unittests/unittests TESTS = tests/unittests/unittests
check_PROGRAMS = 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_SOURCES = $(unittest_sources)
tests_unittests_unittests_LDADD = -lcmocka tests_unittests_unittests_LDADD = -lcmocka
@@ -374,4 +374,5 @@ format-sources: $(core_sources) $(main_source)
spell: spell:
codespell codespell
doublecheck: format check spell doublecheck:
@./scripts/quality-check.sh --fix-formatting --autotools

View File

@@ -606,31 +606,31 @@ if get_option('tests')
'tests/unittests/tools/stub_aesgcm_download.c', 'tests/unittests/tools/stub_aesgcm_download.c',
'tests/unittests/tools/stub_plugin_download.c', 'tests/unittests/tools/stub_plugin_download.c',
'tests/unittests/helpers.c', 'tests/unittests/helpers.c',
'tests/unittests/test_form.c', 'tests/unittests/xmpp/test_form.c',
'tests/unittests/test_common.c', 'tests/unittests/test_common.c',
'tests/unittests/test_autocomplete.c', 'tests/unittests/tools/test_autocomplete.c',
'tests/unittests/test_jid.c', 'tests/unittests/xmpp/test_jid.c',
'tests/unittests/test_parser.c', 'tests/unittests/tools/test_parser.c',
'tests/unittests/test_roster_list.c', 'tests/unittests/xmpp/test_roster_list.c',
'tests/unittests/test_chat_session.c', 'tests/unittests/xmpp/test_chat_session.c',
'tests/unittests/test_contact.c', 'tests/unittests/xmpp/test_contact.c',
'tests/unittests/test_preferences.c', 'tests/unittests/config/test_preferences.c',
'tests/unittests/test_server_events.c', 'tests/unittests/event/test_server_events.c',
'tests/unittests/test_muc.c', 'tests/unittests/xmpp/test_muc.c',
'tests/unittests/test_cmd_presence.c', 'tests/unittests/command/test_cmd_presence.c',
'tests/unittests/test_cmd_alias.c', 'tests/unittests/command/test_cmd_alias.c',
'tests/unittests/test_cmd_connect.c', 'tests/unittests/command/test_cmd_connect.c',
'tests/unittests/test_cmd_rooms.c', 'tests/unittests/command/test_cmd_rooms.c',
'tests/unittests/test_cmd_account.c', 'tests/unittests/command/test_cmd_account.c',
'tests/unittests/test_cmd_sub.c', 'tests/unittests/command/test_cmd_sub.c',
'tests/unittests/test_cmd_bookmark.c', 'tests/unittests/command/test_cmd_bookmark.c',
'tests/unittests/test_cmd_otr.c', 'tests/unittests/command/test_cmd_otr.c',
'tests/unittests/test_cmd_pgp.c', 'tests/unittests/command/test_cmd_pgp.c',
'tests/unittests/test_cmd_join.c', 'tests/unittests/command/test_cmd_join.c',
'tests/unittests/test_cmd_roster.c', 'tests/unittests/command/test_cmd_roster.c',
'tests/unittests/test_cmd_disconnect.c', 'tests/unittests/command/test_cmd_disconnect.c',
'tests/unittests/test_callbacks.c', 'tests/unittests/plugins/test_callbacks.c',
'tests/unittests/test_plugins_disco.c', 'tests/unittests/plugins/test_plugins_disco.c',
'tests/unittests/unittests.c', 'tests/unittests/unittests.c',
) )
@@ -667,7 +667,7 @@ if get_option('tests')
'unittests', 'unittests',
unittest_sources, unittest_sources,
dependencies: profanity_deps + [cmocka_dep], 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, build_by_default: false,
) )
@@ -677,6 +677,10 @@ if get_option('tests')
endif endif
endif endif
run_target('doublecheck',
command: ['scripts/quality-check.sh', '--fix-formatting', '--meson']
)
summary({ summary({
'Platform': platform, 'Platform': platform,
'Package status': get_option('buildtype'), 'Package status': get_option('buildtype'),

143
scripts/quality-check.sh Executable file
View File

@@ -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}"

View File

@@ -1789,7 +1789,7 @@ _bytes_from_hex(const char* hex, size_t hex_size,
const unsigned char ht[] = { const unsigned char ht[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567
0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89:;<=>? 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); const size_t ht_size = sizeof(ht);

View File

@@ -22,7 +22,9 @@
#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test) #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[] = { const struct CMUnitTest all_tests[] = {

View File

@@ -230,13 +230,11 @@ prof_connect_with_roster(const char *roster)
{ {
GString* roster_str = g_string_new( GString* roster_str = g_string_new(
"<iq type='result' to='stabber@localhost/profanity'>" "<iq type='result' to='stabber@localhost/profanity'>"
"<query xmlns='jabber:iq:roster' ver='362'>" "<query xmlns='jabber:iq:roster' ver='362'>");
);
g_string_append(roster_str, roster); g_string_append(roster_str, roster);
g_string_append(roster_str, g_string_append(roster_str,
"</query>" "</query>"
"</iq>" "</iq>");
);
stbbr_for_query("jabber:iq:roster", roster_str->str); stbbr_for_query("jabber:iq:roster", roster_str->str);
g_string_free(roster_str, TRUE); g_string_free(roster_str, TRUE);
@@ -245,8 +243,7 @@ prof_connect_with_roster(const char *roster)
"<presence id='prof_presence_1' lang='en' to='stabber@localhost/profanity' from='stabber@localhost/profanity'>" "<presence id='prof_presence_1' lang='en' to='stabber@localhost/profanity' from='stabber@localhost/profanity'>"
"<priority>0</priority>" "<priority>0</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io/' ver='f8mrtdyAmhnj8Ca+630bThSL718='/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io/' ver='f8mrtdyAmhnj8Ca+630bThSL718='/>"
"</presence>" "</presence>");
);
prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow"); prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow");
prof_input("password"); prof_input("password");
@@ -275,6 +272,5 @@ prof_connect(void)
{ {
prof_connect_with_roster( prof_connect_with_roster(
"<item jid='buddy1@localhost' subscription='both' name='Buddy1'/>" "<item jid='buddy1@localhost' subscription='both' name='Buddy1'/>"
"<item jid='buddy2@localhost' subscription='both' name='Buddy2'/>" "<item jid='buddy2@localhost' subscription='both' name='Buddy2'/>");
);
} }

View File

@@ -16,8 +16,7 @@ send_enable_carbons(void **state)
prof_input("/carbons on"); prof_input("/carbons on");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>" "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
));
} }
void void
@@ -28,8 +27,7 @@ connect_with_carbons_enabled(void **state)
prof_connect(); prof_connect();
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>" "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
));
} }
void void
@@ -42,8 +40,7 @@ send_disable_carbons(void **state)
prof_input("/carbons off"); prof_input("/carbons off");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='*' type='set'><disable xmlns='urn:xmpp:carbons:2'/></iq>" "<iq id='*' type='set'><disable xmlns='urn:xmpp:carbons:2'/></iq>"));
));
} }
void void
@@ -53,15 +50,13 @@ receive_carbon(void **state)
prof_connect(); prof_connect();
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>" "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
));
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>On my mobile</status>" "<status>On my mobile</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1"); prof_input("/msg Buddy1");
assert_true(prof_output_exact("unencrypted")); assert_true(prof_output_exact("unencrypted"));
@@ -75,8 +70,7 @@ receive_carbon(void **state)
"</message>" "</message>"
"</forwarded>" "</forwarded>"
"</received>" "</received>"
"</message>" "</message>");
);
assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient")); assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient"));
} }
@@ -88,15 +82,13 @@ receive_self_carbon(void **state)
prof_connect(); prof_connect();
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>" "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
));
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>On my mobile</status>" "<status>On my mobile</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1"); prof_input("/msg Buddy1");
assert_true(prof_output_exact("unencrypted")); assert_true(prof_output_exact("unencrypted"));
@@ -110,8 +102,7 @@ receive_self_carbon(void **state)
"</message>" "</message>"
"</forwarded>" "</forwarded>"
"</sent>" "</sent>"
"</message>" "</message>");
);
assert_true(prof_output_regex("me: .+self sent carbon")); assert_true(prof_output_regex("me: .+self sent carbon"));
} }
@@ -123,15 +114,13 @@ receive_private_carbon(void **state)
prof_connect(); prof_connect();
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>" "<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
));
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>On my mobile</status>" "<status>On my mobile</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1"); prof_input("/msg Buddy1");
assert_true(prof_output_exact("unencrypted")); assert_true(prof_output_exact("unencrypted"));
@@ -140,8 +129,7 @@ receive_private_carbon(void **state)
"<message type='chat' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>" "<message type='chat' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<body>Private carbon</body>" "<body>Private carbon</body>"
"<private xmlns='urn:xmpp:carbons:2'/>" "<private xmlns='urn:xmpp:carbons:2'/>"
"</message>" "</message>");
);
assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon")); assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon"));
} }

View File

@@ -18,8 +18,7 @@ sends_message_to_barejid_when_contact_offline(void **state)
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost' type='chat'>" "<message id='*' to='buddy1@localhost' type='chat'>"
"<body>Hi there</body>" "<body>Hi there</body>"
"</message>" "</message>"));
));
} }
void void
@@ -30,8 +29,7 @@ sends_message_to_barejid_when_contact_online(void **state)
stbbr_send( stbbr_send(
"<presence to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online")); assert_true(prof_output_exact("Buddy1 (mobile) is online"));
prof_input("/msg buddy1@localhost Hi there"); prof_input("/msg buddy1@localhost Hi there");
@@ -39,8 +37,7 @@ sends_message_to_barejid_when_contact_online(void **state)
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost' type='chat'>" "<message id='*' to='buddy1@localhost' type='chat'>"
"<body>Hi there</body>" "<body>Hi there</body>"
"</message>" "</message>"));
));
} }
void void
@@ -51,15 +48,13 @@ sends_message_to_fulljid_when_received_from_fulljid(void **state)
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online")); assert_true(prof_output_exact("Buddy1 (mobile) is online"));
stbbr_send( stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>" "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>First message</body>" "<body>First message</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
prof_input("/msg buddy1@localhost Hi there"); prof_input("/msg buddy1@localhost Hi there");
@@ -67,8 +62,7 @@ sends_message_to_fulljid_when_received_from_fulljid(void **state)
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Hi there</body>" "<body>Hi there</body>"
"</message>" "</message>"));
));
} }
void void
@@ -79,37 +73,32 @@ sends_subsequent_messages_to_fulljid(void **state)
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online")); assert_true(prof_output_exact("Buddy1 (mobile) is online"));
stbbr_send( stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>" "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>First message</body>" "<body>First message</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
prof_input("/msg buddy1@localhost Outgoing 1"); prof_input("/msg buddy1@localhost Outgoing 1");
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 1</body>" "<body>Outgoing 1</body>"
"</message>" "</message>"));
));
prof_input("/msg buddy1@localhost Outgoing 2"); prof_input("/msg buddy1@localhost Outgoing 2");
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 2</body>" "<body>Outgoing 2</body>"
"</message>" "</message>"));
));
prof_input("/msg buddy1@localhost Outgoing 3"); prof_input("/msg buddy1@localhost Outgoing 3");
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 3</body>" "<body>Outgoing 3</body>"
"</message>" "</message>"));
));
} }
void void
@@ -120,38 +109,33 @@ resets_to_barejid_after_presence_received(void **state)
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online")); assert_true(prof_output_exact("Buddy1 (mobile) is online"));
stbbr_send( stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>" "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>First message</body>" "<body>First message</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
prof_input("/msg buddy1@localhost Outgoing 1"); prof_input("/msg buddy1@localhost Outgoing 1");
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 1</body>" "<body>Outgoing 1</body>"
"</message>" "</message>"));
));
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>" "<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<priority>5</priority>" "<priority>5</priority>"
"<show>dnd</show>" "<show>dnd</show>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (laptop) is dnd")); assert_true(prof_output_exact("Buddy1 (laptop) is dnd"));
prof_input("/msg buddy1@localhost Outgoing 2"); prof_input("/msg buddy1@localhost Outgoing 2");
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost' type='chat'>" "<message id='*' to='buddy1@localhost' type='chat'>"
"<body>Outgoing 2</body>" "<body>Outgoing 2</body>"
"</message>" "</message>"));
));
} }
void void
@@ -162,43 +146,37 @@ new_session_when_message_received_from_different_fulljid(void **state)
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online")); assert_true(prof_output_exact("Buddy1 (mobile) is online"));
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>" "<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<priority>8</priority>" "<priority>8</priority>"
"<show>away</show>" "<show>away</show>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (laptop) is away")); assert_true(prof_output_exact("Buddy1 (laptop) is away"));
stbbr_send( stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>" "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>From first resource</body>" "<body>From first resource</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)")); assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
prof_input("/msg buddy1@localhost Outgoing 1"); prof_input("/msg buddy1@localhost Outgoing 1");
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>" "<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 1</body>" "<body>Outgoing 1</body>"
"</message>" "</message>"));
));
stbbr_send( stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/laptop' type='chat'>" "<message id='message1' to='stabber@localhost' from='buddy1@localhost/laptop' type='chat'>"
"<body>From second resource</body>" "<body>From second resource</body>"
"</message>" "</message>");
);
assert_true(prof_output_regex("Buddy1/laptop:.+From second resource")); assert_true(prof_output_regex("Buddy1/laptop:.+From second resource"));
prof_input("/msg buddy1@localhost Outgoing 2"); prof_input("/msg buddy1@localhost Outgoing 2");
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/laptop' type='chat'>" "<message id='*' to='buddy1@localhost/laptop' type='chat'>"
"<body>Outgoing 2</body>" "<body>Outgoing 2</body>"
"</message>" "</message>"));
));
} }

View File

@@ -14,8 +14,7 @@ connect_jid_requests_roster(void **state)
prof_connect(); prof_connect();
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='*' type='get'><query xmlns='jabber:iq:roster'/></iq>" "<iq id='*' type='get'><query xmlns='jabber:iq:roster'/></iq>"));
));
} }
void void
@@ -26,8 +25,7 @@ connect_jid_sends_presence_after_receiving_roster(void **state)
assert_true(stbbr_received( assert_true(stbbr_received(
"<presence id='*'>" "<presence id='*'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
} }
void void
@@ -40,8 +38,7 @@ connect_jid_requests_bookmarks(void **state)
"<query xmlns='jabber:iq:private'>" "<query xmlns='jabber:iq:private'>"
"<storage xmlns='storage:bookmarks'/>" "<storage xmlns='storage:bookmarks'/>"
"</query>" "</query>"
"</iq>" "</iq>"));
));
} }
void void
@@ -62,31 +59,27 @@ connect_shows_presence_updates(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<show>dnd</show>" "<show>dnd</show>"
"<status>busy!</status>" "<status>busy!</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is dnd, \"busy!\"")); assert_true(prof_output_exact("Buddy1 (mobile) is dnd, \"busy!\""));
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>" "<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<show>chat</show>" "<show>chat</show>"
"<status>Talk to me!</status>" "<status>Talk to me!</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (laptop) is chat, \"Talk to me!\"")); assert_true(prof_output_exact("Buddy1 (laptop) is chat, \"Talk to me!\""));
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy2@localhost/work'>" "<presence to='stabber@localhost' from='buddy2@localhost/work'>"
"<show>away</show>" "<show>away</show>"
"<status>Out of office</status>" "<status>Out of office</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy2 (work) is away, \"Out of office\"")); assert_true(prof_output_exact("Buddy2 (work) is away, \"Out of office\""));
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<show>xa</show>" "<show>xa</show>"
"<status>Gone :(</status>" "<status>Gone :(</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is xa, \"Gone :(\"")); assert_true(prof_output_exact("Buddy1 (mobile) is xa, \"Gone :(\""));
} }

View File

@@ -18,8 +18,7 @@ message_send(void **state)
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='somejid@someserver.com' type='chat'>" "<message id='*' to='somejid@someserver.com' type='chat'>"
"<body>Hi there</body>" "<body>Hi there</body>"
"</message>" "</message>"));
));
assert_true(prof_output_regex("me: .+Hi there")); assert_true(prof_output_regex("me: .+Hi there"));
} }
@@ -32,8 +31,7 @@ message_receive_console(void **state)
stbbr_send( stbbr_send(
"<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>" "<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>"
"<body>How are you?</body>" "<body>How are you?</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)")); assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)"));
} }
@@ -49,8 +47,7 @@ message_receive_chatwin(void **state)
stbbr_send( stbbr_send(
"<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>" "<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>"
"<body>How are you?</body>" "<body>How are you?</body>"
"</message>" "</message>");
);
assert_true(prof_output_regex("someuser@chatserv.org/laptop: .+How are you?")); assert_true(prof_output_regex("someuser@chatserv.org/laptop: .+How are you?"));
} }

View File

@@ -19,8 +19,7 @@ sends_room_join(void **state)
"<presence id='*' to='testroom@conference.localhost/stabber'>" "<presence id='*' to='testroom@conference.localhost/stabber'>"
"<x xmlns='http://jabber.org/protocol/muc'/>" "<x xmlns='http://jabber.org/protocol/muc'/>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
} }
void void
@@ -34,8 +33,7 @@ sends_room_join_with_nick(void **state)
"<presence id='*' to='testroom@conference.localhost/testnick'>" "<presence id='*' to='testroom@conference.localhost/testnick'>"
"<x xmlns='http://jabber.org/protocol/muc'/>" "<x xmlns='http://jabber.org/protocol/muc'/>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
} }
void void
@@ -51,8 +49,7 @@ sends_room_join_with_password(void **state)
"<password>testpassword</password>" "<password>testpassword</password>"
"</x>" "</x>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
} }
void void
@@ -68,8 +65,7 @@ sends_room_join_with_nick_and_password(void **state)
"<password>testpassword</password>" "<password>testpassword</password>"
"</x>" "</x>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
} }
void void
@@ -84,8 +80,7 @@ shows_role_and_affiliation_on_join(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
@@ -104,8 +99,7 @@ shows_subject_on_join(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -114,8 +108,7 @@ shows_subject_on_join(void **state)
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost'>"
"<subject>Test room subject</subject>" "<subject>Test room subject</subject>"
"<body>anothernick has set the subject to: Test room subject</body>" "<body>anothernick has set the subject to: Test room subject</body>"
"</message>" "</message>");
);
assert_true(prof_output_regex("Room subject: .+Test room subject")); assert_true(prof_output_regex("Room subject: .+Test room subject"));
} }
@@ -132,8 +125,7 @@ shows_history_message(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -143,8 +135,7 @@ shows_history_message(void **state)
"<body>an old message</body>" "<body>an old message</body>"
"<delay xmlns='urn:xmpp:delay' stamp='2015-12-19T23:55:25Z' from='testroom@conference.localhost'/>" "<delay xmlns='urn:xmpp:delay' stamp='2015-12-19T23:55:25Z' from='testroom@conference.localhost'/>"
"<x xmlns='jabber:x:delay' stamp='20151219T23:55:25'/>" "<x xmlns='jabber:x:delay' stamp='20151219T23:55:25'/>"
"</message>" "</message>");
);
assert_true(prof_output_regex("testoccupant: an old message")); assert_true(prof_output_regex("testoccupant: an old message"));
} }
@@ -161,8 +152,7 @@ shows_occupant_join(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -172,8 +162,7 @@ shows_occupant_join(void **state)
"<x xmlns='http://jabber.org/protocol/muc#user'>" "<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='someuser@someserver.org/work' affiliation='none'/>" "<item role='participant' jid='someuser@someserver.org/work' affiliation='none'/>"
"</x>" "</x>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("-> testoccupant has joined the room, role: participant, affiliation: none")); assert_true(prof_output_exact("-> testoccupant has joined the room, role: participant, affiliation: none"));
} }
@@ -190,8 +179,7 @@ shows_message(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -199,8 +187,7 @@ shows_message(void **state)
stbbr_send( stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>a new message</body>" "<body>a new message</body>"
"</message>" "</message>");
);
assert_true(prof_output_regex("testoccupant: .+a new message")); assert_true(prof_output_regex("testoccupant: .+a new message"));
} }
@@ -217,8 +204,7 @@ shows_me_message_from_occupant(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -226,8 +212,7 @@ shows_me_message_from_occupant(void **state)
stbbr_send( stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>/me did something</body>" "<body>/me did something</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("*testoccupant did something")); assert_true(prof_output_exact("*testoccupant did something"));
} }
@@ -244,8 +229,7 @@ shows_me_message_from_self(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -253,8 +237,7 @@ shows_me_message_from_self(void **state)
stbbr_send( stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<body>/me did something</body>" "<body>/me did something</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("*stabber did something")); assert_true(prof_output_exact("*stabber did something"));
} }
@@ -271,8 +254,7 @@ shows_all_messages_in_console_when_window_not_focussed(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -283,16 +265,14 @@ shows_all_messages_in_console_when_window_not_focussed(void **state)
stbbr_send( stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>a new message</body>" "<body>a new message</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("<< room message: testoccupant in testroom@conference.localhost (win 2)")); assert_true(prof_output_exact("<< room message: testoccupant in testroom@conference.localhost (win 2)"));
stbbr_send( stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
"<body>some other message</body>" "<body>some other message</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("<< room message: anotheroccupant in testroom@conference.localhost (win 2)")); assert_true(prof_output_exact("<< room message: anotheroccupant in testroom@conference.localhost (win 2)"));
} }
@@ -312,8 +292,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -324,8 +303,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
stbbr_send( stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>a new message</body>" "<body>a new message</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("<< room message: testroom@conference.localhost (win 2)")); assert_true(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
prof_input("/clear"); prof_input("/clear");
@@ -335,8 +313,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
stbbr_send( stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
"<body>some other message</body>" "<body>some other message</body>"
"</message>" "</message>");
);
prof_timeout(2); prof_timeout(2);
assert_false(prof_output_exact("<< room message: testroom@conference.localhost (win 2)")); assert_false(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
@@ -358,8 +335,7 @@ shows_no_message_in_console_when_window_not_focussed(void **state)
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>" "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>" "</x>"
"<status code='110'/>" "<status code='110'/>"
"</presence>" "</presence>");
);
prof_input("/join testroom@conference.localhost"); prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -370,8 +346,7 @@ shows_no_message_in_console_when_window_not_focussed(void **state)
stbbr_send( stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>" "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>a new message</body>" "<body>a new message</body>"
"</message>" "</message>");
);
prof_timeout(2); prof_timeout(2);
assert_false(prof_output_exact("testroom@conference.localhost (win 2)")); assert_false(prof_output_exact("testroom@conference.localhost (win 2)"));

View File

@@ -17,15 +17,12 @@ ping_server(void **state)
"<identity category='server' type='im' name='Prosody'/>" "<identity category='server' type='im' name='Prosody'/>"
"<feature var='urn:xmpp:ping'/>" "<feature var='urn:xmpp:ping'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
stbbr_for_id("prof_ping_4", stbbr_for_id("prof_ping_4",
"<iq id='prof_ping_4' type='result' to='stabber@localhost/profanity'/>" "<iq id='prof_ping_4' type='result' to='stabber@localhost/profanity'/>");
);
stbbr_for_id("prof_ping_5", stbbr_for_id("prof_ping_5",
"<iq id='prof_ping_5' type='result' to='stabber@localhost/profanity'/>" "<iq id='prof_ping_5' type='result' to='stabber@localhost/profanity'/>");
);
prof_connect(); prof_connect();
@@ -33,16 +30,14 @@ ping_server(void **state)
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_ping_4' type='get'>" "<iq id='prof_ping_4' type='get'>"
"<ping xmlns='urn:xmpp:ping'/>" "<ping xmlns='urn:xmpp:ping'/>"
"</iq>" "</iq>"));
));
assert_true(prof_output_exact("Ping response from server")); assert_true(prof_output_exact("Ping response from server"));
prof_input("/ping"); prof_input("/ping");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_ping_5' type='get'>" "<iq id='prof_ping_5' type='get'>"
"<ping xmlns='urn:xmpp:ping'/>" "<ping xmlns='urn:xmpp:ping'/>"
"</iq>" "</iq>"));
));
assert_true(prof_output_exact("Ping response from server")); assert_true(prof_output_exact("Ping response from server"));
} }
@@ -54,8 +49,7 @@ ping_server_not_supported(void **state)
"<query xmlns='http://jabber.org/protocol/disco#info'>" "<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='server' type='im' name='Stabber'/>" "<identity category='server' type='im' name='Stabber'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_connect(); prof_connect();
@@ -71,15 +65,14 @@ ping_responds_to_server_request(void **state)
stbbr_send( stbbr_send(
"<iq id='pingtest1' type='get' to='stabber@localhost/profanity' from='localhost'>" "<iq id='pingtest1' type='get' to='stabber@localhost/profanity' from='localhost'>"
"<ping xmlns='urn:xmpp:ping'/>" "<ping xmlns='urn:xmpp:ping'/>"
"</iq>" "</iq>");
);
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'/>" "<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'/>"));
));
} }
void ping_jid(void **state) void
ping_jid(void** state)
{ {
stbbr_for_id("prof_caps_4", stbbr_for_id("prof_caps_4",
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>" "<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
@@ -89,8 +82,7 @@ void ping_jid(void **state)
"<feature var='http://jabber.org/protocol/disco#info'/>" "<feature var='http://jabber.org/protocol/disco#info'/>"
"<feature var='http://jabber.org/protocol/caps'/>" "<feature var='http://jabber.org/protocol/caps'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_connect(); prof_connect();
@@ -104,31 +96,28 @@ void ping_jid(void **state)
"node='http://profanity-im.github.io' " "node='http://profanity-im.github.io' "
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='" "ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
"/>" "/>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_caps_4' to='buddy1@localhost/mobile' type='get'>" "<iq id='prof_caps_4' to='buddy1@localhost/mobile' type='get'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>" "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
"</iq>" "</iq>"));
));
stbbr_for_id("prof_ping_5", stbbr_for_id("prof_ping_5",
"<iq from='buddy1@localhost/mobile' to='stabber@localhost' id='prof_ping_5' type='result'/>" "<iq from='buddy1@localhost/mobile' to='stabber@localhost' id='prof_ping_5' type='result'/>");
);
prof_input("/ping buddy1@localhost/mobile"); prof_input("/ping buddy1@localhost/mobile");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_ping_5' type='get' to='buddy1@localhost/mobile'>" "<iq id='prof_ping_5' type='get' to='buddy1@localhost/mobile'>"
"<ping xmlns='urn:xmpp:ping'/>" "<ping xmlns='urn:xmpp:ping'/>"
"</iq>" "</iq>"));
));
assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile")); 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", stbbr_for_id("prof_caps_4",
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>" "<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
@@ -137,8 +126,7 @@ void ping_jid_not_supported(void **state)
"<feature var='http://jabber.org/protocol/disco#info'/>" "<feature var='http://jabber.org/protocol/disco#info'/>"
"<feature var='http://jabber.org/protocol/caps'/>" "<feature var='http://jabber.org/protocol/caps'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_connect(); prof_connect();
@@ -152,15 +140,13 @@ void ping_jid_not_supported(void **state)
"node='http://profanity-im.github.io' " "node='http://profanity-im.github.io' "
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='" "ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
"/>" "/>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='prof_caps_4' to='buddy1@localhost/mobile' type='get'>" "<iq id='prof_caps_4' to='buddy1@localhost/mobile' type='get'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>" "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
"</iq>" "</iq>"));
));
prof_input("/ping buddy1@localhost/mobile"); prof_input("/ping buddy1@localhost/mobile");
assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests.")); assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests."));

View File

@@ -18,8 +18,7 @@ presence_online(void **state)
assert_true(stbbr_received( assert_true(stbbr_received(
"<presence id='prof_presence_3'>" "<presence id='prof_presence_3'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to online (priority 0)")); assert_true(prof_output_exact("Status set to online (priority 0)"));
} }
@@ -35,8 +34,7 @@ presence_online_with_message(void **state)
"<presence id='prof_presence_4'>" "<presence id='prof_presence_4'>"
"<status>Hi there</status>" "<status>Hi there</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to online (priority 0), \"Hi there\".")); assert_true(prof_output_exact("Status set to online (priority 0), \"Hi there\"."));
} }
@@ -52,8 +50,7 @@ presence_away(void **state)
"<presence id='prof_presence_4'>" "<presence id='prof_presence_4'>"
"<show>away</show>" "<show>away</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to away (priority 0)")); assert_true(prof_output_exact("Status set to away (priority 0)"));
} }
@@ -70,8 +67,7 @@ presence_away_with_message(void **state)
"<show>away</show>" "<show>away</show>"
"<status>I'm not here for a bit</status>" "<status>I'm not here for a bit</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to away (priority 0), \"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\"."));
} }
@@ -87,8 +83,7 @@ presence_xa(void **state)
"<presence id='prof_presence_4'>" "<presence id='prof_presence_4'>"
"<show>xa</show>" "<show>xa</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to xa (priority 0)")); assert_true(prof_output_exact("Status set to xa (priority 0)"));
} }
@@ -105,8 +100,7 @@ presence_xa_with_message(void **state)
"<show>xa</show>" "<show>xa</show>"
"<status>Gone to the shops</status>" "<status>Gone to the shops</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to xa (priority 0), \"Gone to the shops\".")); assert_true(prof_output_exact("Status set to xa (priority 0), \"Gone to the shops\"."));
} }
@@ -122,8 +116,7 @@ presence_dnd(void **state)
"<presence id='prof_presence_4'>" "<presence id='prof_presence_4'>"
"<show>dnd</show>" "<show>dnd</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to dnd (priority 0)")); assert_true(prof_output_exact("Status set to dnd (priority 0)"));
} }
@@ -140,8 +133,7 @@ presence_dnd_with_message(void **state)
"<show>dnd</show>" "<show>dnd</show>"
"<status>Working</status>" "<status>Working</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to dnd (priority 0), \"Working\".")); assert_true(prof_output_exact("Status set to dnd (priority 0), \"Working\"."));
} }
@@ -157,8 +149,7 @@ presence_chat(void **state)
"<presence id='prof_presence_4'>" "<presence id='prof_presence_4'>"
"<show>chat</show>" "<show>chat</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to chat (priority 0)")); assert_true(prof_output_exact("Status set to chat (priority 0)"));
} }
@@ -175,8 +166,7 @@ presence_chat_with_message(void **state)
"<show>chat</show>" "<show>chat</show>"
"<status>Free to talk</status>" "<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\".")); assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\"."));
} }
@@ -192,8 +182,7 @@ presence_set_priority(void **state)
"<presence id='prof_presence_4'>" "<presence id='prof_presence_4'>"
"<priority>25</priority>" "<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Priority set to 25.")); assert_true(prof_output_exact("Priority set to 25."));
} }
@@ -208,8 +197,7 @@ presence_includes_priority(void **state)
"<presence id='prof_presence_4'>" "<presence id='prof_presence_4'>"
"<priority>25</priority>" "<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Priority set to 25.")); assert_true(prof_output_exact("Priority set to 25."));
prof_input("/chat \"Free to talk\""); prof_input("/chat \"Free to talk\"");
@@ -219,8 +207,7 @@ presence_includes_priority(void **state)
"<show>chat</show>" "<show>chat</show>"
"<status>Free to talk</status>" "<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to chat (priority 25), \"Free to talk\".")); assert_true(prof_output_exact("Status set to chat (priority 25), \"Free to talk\"."));
} }
@@ -235,8 +222,7 @@ presence_keeps_status(void **state)
"<show>chat</show>" "<show>chat</show>"
"<status>Free to talk</status>" "<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\".")); assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\"."));
prof_input("/priority 25"); prof_input("/priority 25");
@@ -246,8 +232,7 @@ presence_keeps_status(void **state)
"<status>Free to talk</status>" "<status>Free to talk</status>"
"<priority>25</priority>" "<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>" "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>" "</presence>"));
));
assert_true(prof_output_exact("Priority set to 25.")); assert_true(prof_output_exact("Priority set to 25."));
} }
@@ -260,8 +245,7 @@ presence_received(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>I'm here</status>" "<status>I'm here</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
} }
@@ -276,8 +260,7 @@ presence_missing_resource_defaults(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost'>" "<presence to='stabber@localhost' from='buddy1@localhost'>"
"<priority>15</priority>" "<priority>15</priority>"
"<status>My status</status>" "<status>My status</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 is online, \"My status\"")); assert_true(prof_output_exact("Buddy1 is online, \"My status\""));

View File

@@ -20,8 +20,7 @@ does_not_send_receipt_request_to_barejid(void **state)
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' type='chat' to='somejid@someserver.com'>" "<message id='*' type='chat' to='somejid@someserver.com'>"
"<body>Hi there</body>" "<body>Hi there</body>"
"</message>" "</message>"));
));
} }
void void
@@ -37,16 +36,14 @@ send_receipt_request(void **state)
"<identity category='client' name='Profanity 0.5.0' type='console'/>" "<identity category='client' name='Profanity 0.5.0' type='console'/>"
"<feature var='urn:xmpp:receipts'/>" "<feature var='urn:xmpp:receipts'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
stbbr_send( stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>" "<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<priority>15</priority>" "<priority>15</priority>"
"<status>My status</status>" "<status>My status</status>"
"<c hash='sha-256' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>" "<c hash='sha-256' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
"</presence>" "</presence>");
);
prof_output_exact("Buddy1 is online, \"My status\""); prof_output_exact("Buddy1 is online, \"My status\"");
@@ -58,8 +55,7 @@ send_receipt_request(void **state)
"<message id='*' type='chat' to='buddy1@localhost/laptop'>" "<message id='*' type='chat' to='buddy1@localhost/laptop'>"
"<body>Hi there, where is my receipt?</body>" "<body>Hi there, where is my receipt?</body>"
"<request xmlns='urn:xmpp:receipts'/>" "<request xmlns='urn:xmpp:receipts'/>"
"</message>" "</message>"));
));
} }
void void
@@ -73,12 +69,10 @@ send_receipt_on_request(void **state)
"<message id='msg12213' type='chat' to='stabber@localhost/profanity' from='someuser@server.org/profanity'>" "<message id='msg12213' type='chat' to='stabber@localhost/profanity' from='someuser@server.org/profanity'>"
"<body>Wants a receipt</body>" "<body>Wants a receipt</body>"
"<request xmlns='urn:xmpp:receipts'/>" "<request xmlns='urn:xmpp:receipts'/>"
"</message>" "</message>");
);
assert_true(stbbr_received( assert_true(stbbr_received(
"<message id='*' to='someuser@server.org/profanity'>" "<message id='*' to='someuser@server.org/profanity'>"
"<received id='msg12213' xmlns='urn:xmpp:receipts'/>" "<received id='msg12213' xmlns='urn:xmpp:receipts'/>"
"</message>" "</message>"));
));
} }

View File

@@ -17,8 +17,7 @@ rooms_query(void **state)
"<item jid='chatroom@conference.localhost' name='A chat room'/>" "<item jid='chatroom@conference.localhost' name='A chat room'/>"
"<item jid='hangout@conference.localhost' name='Another chat room'/>" "<item jid='hangout@conference.localhost' name='Another chat room'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_connect(); prof_connect();
@@ -30,6 +29,5 @@ rooms_query(void **state)
assert_true(stbbr_last_received( assert_true(stbbr_last_received(
"<iq id='prof_confreq_4' to='conference.localhost' type='get'>" "<iq id='prof_confreq_4' to='conference.localhost' type='get'>"
"<query xmlns='http://jabber.org/protocol/disco#items'/>" "<query xmlns='http://jabber.org/protocol/disco#items'/>"
"</iq>" "</iq>"));
));
} }

View File

@@ -18,8 +18,7 @@ sends_new_item(void **state)
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' subscription='none' name=''/>" "<item jid='bob@localhost' subscription='none' name=''/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_input("/roster add bob@localhost"); prof_input("/roster add bob@localhost");
@@ -28,8 +27,7 @@ sends_new_item(void **state)
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' name=''/>" "<item jid='bob@localhost' name=''/>"
"</query>" "</query>"
"</iq>" "</iq>"));
));
assert_true(prof_output_exact("Roster item added: bob@localhost")); assert_true(prof_output_exact("Roster item added: bob@localhost"));
} }
@@ -44,8 +42,7 @@ sends_new_item_nick(void **state)
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' subscription='none' name='Bobby'/>" "<item jid='bob@localhost' subscription='none' name='Bobby'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_input("/roster add bob@localhost Bobby"); prof_input("/roster add bob@localhost Bobby");
@@ -54,8 +51,7 @@ sends_new_item_nick(void **state)
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' name='Bobby'/>" "<item jid='bob@localhost' name='Bobby'/>"
"</query>" "</query>"
"</iq>" "</iq>"));
));
assert_true(prof_output_exact("Roster item added: bob@localhost (Bobby)")); assert_true(prof_output_exact("Roster item added: bob@localhost (Bobby)"));
} }
@@ -65,16 +61,14 @@ sends_remove_item(void **state)
{ {
prof_connect_with_roster( prof_connect_with_roster(
"<item jid='buddy1@localhost' subscription='both'/>" "<item jid='buddy1@localhost' subscription='both'/>"
"<item jid='buddy2@localhost' subscription='both'/>" "<item jid='buddy2@localhost' subscription='both'/>");
);
stbbr_for_query("jabber:iq:roster", stbbr_for_query("jabber:iq:roster",
"<iq id='*' type='set'>" "<iq id='*' type='set'>"
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>" "<item jid='buddy1@localhost' subscription='remove'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_input("/roster remove buddy1@localhost"); prof_input("/roster remove buddy1@localhost");
@@ -83,8 +77,7 @@ sends_remove_item(void **state)
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>" "<item jid='buddy1@localhost' subscription='remove'/>"
"</query>" "</query>"
"</iq>" "</iq>"));
));
assert_true(prof_output_exact("Roster item removed: buddy1@localhost")); assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
} }
@@ -94,16 +87,14 @@ sends_remove_item_nick(void **state)
{ {
prof_connect_with_roster( prof_connect_with_roster(
"<item jid='buddy1@localhost' name='Bobby' subscription='both'/>" "<item jid='buddy1@localhost' name='Bobby' subscription='both'/>"
"<item jid='buddy2@localhost' subscription='both'/>" "<item jid='buddy2@localhost' subscription='both'/>");
);
stbbr_for_query("jabber:iq:roster", stbbr_for_query("jabber:iq:roster",
"<iq id='*' type='set'>" "<iq id='*' type='set'>"
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>" "<item jid='buddy1@localhost' subscription='remove'/>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_input("/roster remove Bobby"); prof_input("/roster remove Bobby");
@@ -112,8 +103,7 @@ sends_remove_item_nick(void **state)
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>" "<item jid='buddy1@localhost' subscription='remove'/>"
"</query>" "</query>"
"</iq>" "</iq>"));
));
assert_true(prof_output_exact("Roster item removed: buddy1@localhost")); assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
} }
@@ -122,8 +112,7 @@ void
sends_nick_change(void** state) sends_nick_change(void** state)
{ {
prof_connect_with_roster( prof_connect_with_roster(
"<item jid='buddy1@localhost' subscription='both'/>" "<item jid='buddy1@localhost' subscription='both'/>");
);
prof_input("/roster nick buddy1@localhost Buddy1"); prof_input("/roster nick buddy1@localhost Buddy1");
@@ -134,6 +123,5 @@ sends_nick_change(void **state)
"<query xmlns='jabber:iq:roster'>" "<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' name='Buddy1'/>" "<item jid='buddy1@localhost' name='Buddy1'/>"
"</query>" "</query>"
"</iq>" "</iq>"));
));
} }

View File

@@ -16,16 +16,14 @@ send_software_version_request(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>I'm here</status>" "<status>I'm here</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
prof_input("/software buddy1@localhost/mobile"); prof_input("/software buddy1@localhost/mobile");
assert_true(stbbr_received( assert_true(stbbr_received(
"<iq id='*' to='buddy1@localhost/mobile' type='get'>" "<iq id='*' to='buddy1@localhost/mobile' type='get'>"
"<query xmlns='jabber:iq:version'/>" "<query xmlns='jabber:iq:version'/>"
"</iq>" "</iq>"));
));
} }
void void
@@ -36,8 +34,7 @@ display_software_version_result(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>I'm here</status>" "<status>I'm here</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
stbbr_for_query("jabber:iq:version", stbbr_for_query("jabber:iq:version",
@@ -46,8 +43,7 @@ display_software_version_result(void **state)
"<name>Profanity</name>" "<name>Profanity</name>"
"<version>0.4.7dev.master.2cb2f83</version>" "<version>0.4.7dev.master.2cb2f83</version>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_input("/software buddy1@localhost/mobile"); prof_input("/software buddy1@localhost/mobile");
// assert_true(prof_output_exact("buddy1@localhost/mobile:")); // assert_true(prof_output_exact("buddy1@localhost/mobile:"));
@@ -63,8 +59,7 @@ shows_message_when_software_version_error(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>I'm here</status>" "<status>I'm here</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
stbbr_for_query("jabber:iq:version", stbbr_for_query("jabber:iq:version",
@@ -73,8 +68,7 @@ shows_message_when_software_version_error(void **state)
"<error code='503' type='cancel'>" "<error code='503' type='cancel'>"
"<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" "<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
"</error>" "</error>"
"</iq>" "</iq>");
);
prof_input("/software buddy1@localhost/laptop"); prof_input("/software buddy1@localhost/laptop");
assert_true(prof_output_exact("Could not get software version: service-unavailable")); assert_true(prof_output_exact("Could not get software version: service-unavailable"));
@@ -89,8 +83,7 @@ display_software_version_result_when_from_domainpart(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost'>" "<presence to='stabber@localhost' from='buddy1@localhost'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>I'm here</status>" "<status>I'm here</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 is online, \"I'm here\""));
stbbr_for_query("jabber:iq:version", stbbr_for_query("jabber:iq:version",
@@ -99,8 +92,7 @@ display_software_version_result_when_from_domainpart(void **state)
"<name>Some Gateway</name>" "<name>Some Gateway</name>"
"<version>1.0</version>" "<version>1.0</version>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_input("/software buddy1@localhost/__prof_default"); prof_input("/software buddy1@localhost/__prof_default");
// assert_true(prof_output_exact("buddy1@localhost/__prof_default:")); // assert_true(prof_output_exact("buddy1@localhost/__prof_default:"));
@@ -116,8 +108,7 @@ show_message_in_chat_window_when_no_resource(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>I'm here</status>" "<status>I'm here</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
prof_input("/msg Buddy1"); prof_input("/msg Buddy1");
@@ -134,16 +125,14 @@ display_software_version_result_in_chat(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>" "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>" "<priority>10</priority>"
"<status>I'm here</status>" "<status>I'm here</status>"
"</presence>" "</presence>");
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"")); assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
prof_input("/msg Buddy1"); prof_input("/msg Buddy1");
stbbr_send( stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>" "<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>Here's a message</body>" "<body>Here's a message</body>"
"</message>" "</message>");
);
assert_true(prof_output_exact("Here's a message")); assert_true(prof_output_exact("Here's a message"));
stbbr_for_query("jabber:iq:version", stbbr_for_query("jabber:iq:version",
@@ -152,8 +141,7 @@ display_software_version_result_in_chat(void **state)
"<name>Profanity</name>" "<name>Profanity</name>"
"<version>0.4.7dev.master.2cb2f83</version>" "<version>0.4.7dev.master.2cb2f83</version>"
"</query>" "</query>"
"</iq>" "</iq>");
);
prof_input("/software"); prof_input("/software");

View File

@@ -15,7 +15,7 @@
#define CMD_ACCOUNT "/account" #define CMD_ACCOUNT "/account"
void 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 }; gchar* args[] = { NULL };
@@ -28,7 +28,7 @@ cmd_account_shows_usage_when_not_connected_and_no_args(void** state)
} }
void 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, 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); 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 void
cmd_account_list_shows_accounts(void** state) cmd_account_list__shows__accounts(void** state)
{ {
gchar* args[] = { "list", NULL }; gchar* args[] = { "list", NULL };
@@ -65,7 +65,7 @@ cmd_account_list_shows_accounts(void** state)
} }
void 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 }; gchar* args[] = { "show", NULL };
@@ -76,7 +76,7 @@ cmd_account_show_shows_usage_when_no_arg(void** state)
} }
void 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 }; gchar* args[] = { "show", "account_name", NULL };
@@ -91,7 +91,7 @@ cmd_account_show_shows_message_when_account_does_not_exist(void** state)
} }
void 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 }; gchar* args[] = { "show", "account_name", NULL };
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, 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 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 }; gchar* args[] = { "add", NULL };
@@ -118,7 +118,7 @@ cmd_account_add_shows_usage_when_no_arg(void** state)
} }
void void
cmd_account_add_adds_account(void** state) cmd_account_add__updates__adds_account(void** state)
{ {
gchar* args[] = { "add", "new_account", NULL }; gchar* args[] = { "add", "new_account", NULL };
@@ -133,7 +133,7 @@ cmd_account_add_adds_account(void** state)
} }
void 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 }; gchar* args[] = { "enable", NULL };
@@ -144,7 +144,7 @@ cmd_account_enable_shows_usage_when_no_arg(void** state)
} }
void void
cmd_account_enable_enables_account(void** state) cmd_account_enable__updates__enables_account(void** state)
{ {
gchar* args[] = { "enable", "account_name", NULL }; gchar* args[] = { "enable", "account_name", NULL };
@@ -159,7 +159,7 @@ cmd_account_enable_enables_account(void** state)
} }
void 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 }; gchar* args[] = { "enable", "account_name", NULL };
@@ -174,7 +174,7 @@ cmd_account_enable_shows_message_when_account_doesnt_exist(void** state)
} }
void 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 }; gchar* args[] = { "disable", NULL };
@@ -185,7 +185,7 @@ cmd_account_disable_shows_usage_when_no_arg(void** state)
} }
void void
cmd_account_disable_disables_account(void** state) cmd_account_disable__updates__disables_account(void** state)
{ {
gchar* args[] = { "disable", "account_name", NULL }; gchar* args[] = { "disable", "account_name", NULL };
@@ -200,7 +200,7 @@ cmd_account_disable_disables_account(void** state)
} }
void 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 }; gchar* args[] = { "disable", "account_name", NULL };
@@ -215,7 +215,7 @@ cmd_account_disable_shows_message_when_account_doesnt_exist(void** state)
} }
void 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 }; gchar* args[] = { "rename", NULL };
@@ -226,7 +226,7 @@ cmd_account_rename_shows_usage_when_no_args(void** state)
} }
void 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 }; gchar* args[] = { "rename", "original_name", NULL };
@@ -237,7 +237,7 @@ cmd_account_rename_shows_usage_when_one_arg(void** state)
} }
void void
cmd_account_rename_renames_account(void** state) cmd_account_rename__updates__renames_account(void** state)
{ {
gchar* args[] = { "rename", "original_name", "new_name", NULL }; gchar* args[] = { "rename", "original_name", "new_name", NULL };
@@ -253,7 +253,7 @@ cmd_account_rename_renames_account(void** state)
} }
void 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 }; gchar* args[] = { "rename", "original_name", "new_name", NULL };
@@ -269,7 +269,7 @@ cmd_account_rename_shows_message_when_not_renamed(void** state)
} }
void 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 }; gchar* args[] = { "set", NULL };
@@ -280,7 +280,7 @@ cmd_account_set_shows_usage_when_no_args(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", NULL };
@@ -291,7 +291,7 @@ cmd_account_set_shows_usage_when_one_arg(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "a_property", NULL };
@@ -302,7 +302,7 @@ cmd_account_set_shows_usage_when_two_args(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "set", "a_account", "jid", "@malformed", NULL };
@@ -331,7 +331,7 @@ cmd_account_set_jid_shows_message_for_malformed_jid(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL };
@@ -349,7 +349,7 @@ cmd_account_set_jid_sets_barejid(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "set", "a_account", "server", "a_server", NULL };
@@ -390,7 +390,7 @@ cmd_account_set_server_sets_server(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL };
@@ -410,7 +410,7 @@ cmd_account_set_resource_sets_resource(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "set", "a_account", "password", "a_password", NULL };
ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, 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 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 }; gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL };
ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, 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 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 }; gchar* args[] = { "set", "a_account", "password", "a_password", NULL };
ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, g_strdup("a_password"), 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 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 }; gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL };
ProfAccount* account = account_new(g_strdup("a_account"), NULL, g_strdup("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 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 }; gchar* args[] = { "set", "a_account", "muc", "a_muc", NULL };
@@ -532,7 +532,7 @@ cmd_account_set_muc_sets_muc(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "nick", "a_nick", NULL };
@@ -550,7 +550,7 @@ cmd_account_set_nick_sets_nick(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "otr", NULL };
@@ -561,7 +561,7 @@ cmd_account_show_message_for_missing_otr_policy(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "set", "a_account", "otr", "opportunistic", NULL };
@@ -594,7 +594,7 @@ cmd_account_set_otr_sets_otr(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "set", "a_account", "status", "away", NULL };
@@ -627,7 +627,7 @@ cmd_account_set_status_sets_status_when_valid(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "status", "last", NULL };
@@ -645,7 +645,7 @@ cmd_account_set_status_sets_status_when_last(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "blah", "10", NULL };
@@ -660,7 +660,7 @@ cmd_account_set_invalid_presence_string_priority_shows_message(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "last", "10", NULL };
@@ -675,7 +675,7 @@ cmd_account_set_last_priority_shows_message(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "online", "10", NULL };
@@ -695,7 +695,7 @@ cmd_account_set_online_priority_sets_preference(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "chat", "10", NULL };
@@ -715,7 +715,7 @@ cmd_account_set_chat_priority_sets_preference(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "away", "10", NULL };
@@ -735,7 +735,7 @@ cmd_account_set_away_priority_sets_preference(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "xa", "10", NULL };
@@ -755,7 +755,7 @@ cmd_account_set_xa_priority_sets_preference(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "dnd", "10", NULL };
@@ -775,7 +775,7 @@ cmd_account_set_dnd_priority_sets_preference(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "online", "-150", NULL };
@@ -789,7 +789,7 @@ cmd_account_set_priority_too_low_shows_message(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "online", "150", NULL };
@@ -803,7 +803,7 @@ cmd_account_set_priority_too_high_shows_message(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "online", "abc", NULL };
@@ -817,7 +817,7 @@ cmd_account_set_priority_when_not_number_shows_message(void** state)
} }
void 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 }; gchar* args[] = { "set", "a_account", "online", "", NULL };
@@ -831,7 +831,7 @@ cmd_account_set_priority_when_empty_shows_message(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "clear", NULL };
@@ -879,7 +879,7 @@ cmd_account_clear_shows_usage_when_no_args(void** state)
} }
void 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 }; gchar* args[] = { "clear", "a_account", NULL };
@@ -890,7 +890,7 @@ cmd_account_clear_shows_usage_when_one_arg(void** state)
} }
void 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 }; gchar* args[] = { "clear", "a_account", "a_property", NULL };
@@ -905,7 +905,7 @@ cmd_account_clear_shows_message_when_account_doesnt_exist(void** state)
} }
void 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 }; gchar* args[] = { "clear", "a_account", "badproperty", NULL };

View File

@@ -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

View File

@@ -17,7 +17,7 @@
#define CMD_ALIAS "/alias" #define CMD_ALIAS "/alias"
void 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 }; gchar* args[] = { "add", NULL };
@@ -28,7 +28,7 @@ cmd_alias_add_shows_usage_when_no_args(void** state)
} }
void 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 }; gchar* args[] = { "add", "alias", NULL };
@@ -39,7 +39,7 @@ cmd_alias_add_shows_usage_when_no_value(void** state)
} }
void 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 }; gchar* args[] = { "remove", NULL };
@@ -50,7 +50,7 @@ cmd_alias_remove_shows_usage_when_no_args(void** state)
} }
void void
cmd_alias_show_usage_when_invalid_subcmd(void** state) cmd_alias__shows__usage_when_invalid_subcmd(void** state)
{ {
gchar* args[] = { "blah", NULL }; gchar* args[] = { "blah", NULL };
@@ -61,7 +61,7 @@ cmd_alias_show_usage_when_invalid_subcmd(void** state)
} }
void void
cmd_alias_add_adds_alias(void** state) cmd_alias__updates__adds_alias(void** state)
{ {
gchar* args[] = { "add", "hc", "/help commands", NULL }; gchar* args[] = { "add", "hc", "/help commands", NULL };
@@ -77,7 +77,7 @@ cmd_alias_add_adds_alias(void** state)
} }
void 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 }; gchar* args[] = { "add", "hc", "/help commands", NULL };
@@ -91,7 +91,7 @@ cmd_alias_add_shows_message_when_exists(void** state)
} }
void void
cmd_alias_remove_removes_alias(void** state) cmd_alias__updates__removes_alias(void** state)
{ {
gchar* args[] = { "remove", "hn", NULL }; gchar* args[] = { "remove", "hn", NULL };
@@ -109,7 +109,7 @@ cmd_alias_remove_removes_alias(void** state)
} }
void 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 }; gchar* args[] = { "remove", "hn", NULL };
@@ -120,7 +120,7 @@ cmd_alias_remove_shows_message_when_no_alias(void** state)
} }
void void
cmd_alias_list_shows_all_aliases(void** state) cmd_alias__shows__all_aliases(void** state)
{ {
gchar* args[] = { "list", NULL }; gchar* args[] = { "list", NULL };

View File

@@ -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

View File

@@ -32,25 +32,25 @@ test_with_connection_status(jabber_conn_status_t status)
} }
void void
cmd_bookmark_shows_message_when_disconnected(void** state) cmd_bookmark__shows__message_when_disconnected(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTED); test_with_connection_status(JABBER_DISCONNECTED);
} }
void void
cmd_bookmark_shows_message_when_disconnecting(void** state) cmd_bookmark__shows__message_when_disconnecting(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTING); test_with_connection_status(JABBER_DISCONNECTING);
} }
void void
cmd_bookmark_shows_message_when_connecting(void** state) cmd_bookmark__shows__message_when_connecting(void** state)
{ {
test_with_connection_status(JABBER_CONNECTING); test_with_connection_status(JABBER_CONNECTING);
} }
void void
cmd_bookmark_shows_usage_when_no_args(void** state) cmd_bookmark__shows__usage_when_no_args(void** state)
{ {
gchar* args[] = { NULL }; gchar* args[] = { NULL };
ProfWin window; ProfWin window;
@@ -90,7 +90,7 @@ _cmp_bookmark(Bookmark* bm1, Bookmark* bm2)
} }
void void
cmd_bookmark_list_shows_bookmarks(void** state) cmd_bookmark_list__shows__bookmarks(void** state)
{ {
gchar* args[] = { "list", NULL }; gchar* args[] = { "list", NULL };
GList* bookmarks = NULL; GList* bookmarks = NULL;
@@ -152,7 +152,7 @@ cmd_bookmark_list_shows_bookmarks(void** state)
} }
void void
cmd_bookmark_add_shows_message_when_invalid_jid(void** state) cmd_bookmark_add__shows__message_when_invalid_jid(void** state)
{ {
char* jid = "room"; char* jid = "room";
gchar* args[] = { "add", jid, NULL }; gchar* args[] = { "add", jid, NULL };
@@ -169,7 +169,7 @@ cmd_bookmark_add_shows_message_when_invalid_jid(void** state)
} }
void void
cmd_bookmark_add_adds_bookmark_with_jid(void** state) cmd_bookmark_add__updates__bookmark_with_jid(void** state)
{ {
char* jid = "room@conf.server"; char* jid = "room@conf.server";
gchar* args[] = { "add", jid, NULL }; gchar* args[] = { "add", jid, NULL };
@@ -191,7 +191,7 @@ cmd_bookmark_add_adds_bookmark_with_jid(void** state)
} }
void void
cmd_bookmark_uses_roomjid_in_room(void** state) cmd_bookmark__tests__uses_roomjid_in_room(void** state)
{ {
gchar* args[] = { NULL }; gchar* args[] = { NULL };
ProfMucWin muc_win; ProfMucWin muc_win;
@@ -214,7 +214,7 @@ cmd_bookmark_uses_roomjid_in_room(void** state)
} }
void void
cmd_bookmark_add_uses_roomjid_in_room(void** state) cmd_bookmark_add__tests__uses_roomjid_in_room(void** state)
{ {
gchar* args[] = { "add", NULL }; gchar* args[] = { "add", NULL };
ProfMucWin muc_win; ProfMucWin muc_win;
@@ -237,7 +237,7 @@ cmd_bookmark_add_uses_roomjid_in_room(void** state)
} }
void 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"; char* jid = "room1@conf.server";
gchar* args[] = { "add", jid, NULL }; gchar* args[] = { "add", jid, NULL };
@@ -261,7 +261,7 @@ cmd_bookmark_add_uses_supplied_jid_in_room(void** state)
} }
void 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* jid = "room@conf.server";
char* nick = "bob"; char* nick = "bob";
@@ -284,7 +284,7 @@ cmd_bookmark_add_adds_bookmark_with_jid_nick(void** state)
} }
void 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"; char* jid = "room@conf.server";
gchar* args[] = { "add", jid, "autojoin", "on", NULL }; gchar* args[] = { "add", jid, "autojoin", "on", NULL };
@@ -306,7 +306,7 @@ cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void** state)
} }
void 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* jid = "room@conf.server";
char* nick = "bob"; char* nick = "bob";
@@ -329,7 +329,7 @@ cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void** state)
} }
void void
cmd_bookmark_remove_removes_bookmark(void** state) cmd_bookmark_remove__updates__removes_bookmark(void** state)
{ {
char* jid = "room@conf.server"; char* jid = "room@conf.server";
gchar* args[] = { "remove", jid, NULL }; gchar* args[] = { "remove", jid, NULL };
@@ -348,7 +348,7 @@ cmd_bookmark_remove_removes_bookmark(void** state)
} }
void 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"; char* jid = "room@conf.server";
gchar* args[] = { "remove", jid, NULL }; gchar* args[] = { "remove", jid, NULL };
@@ -367,7 +367,7 @@ cmd_bookmark_remove_shows_message_when_no_bookmark(void** state)
} }
void void
cmd_bookmark_remove_uses_roomjid_in_room(void** state) cmd_bookmark_remove__tests__uses_roomjid_in_room(void** state)
{ {
gchar* args[] = { "remove", NULL }; gchar* args[] = { "remove", NULL };
ProfMucWin muc_win; ProfMucWin muc_win;
@@ -387,7 +387,7 @@ cmd_bookmark_remove_uses_roomjid_in_room(void** state)
} }
void 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"; char* jid = "room1@conf.server";
gchar* args[] = { "remove", jid, NULL }; gchar* args[] = { "remove", jid, NULL };

View File

@@ -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

View File

@@ -25,25 +25,25 @@ test_with_connection_status(jabber_conn_status_t status)
} }
void void
cmd_connect_shows_message_when_disconnecting(void** state) cmd_connect__shows__message_when_disconnecting(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTING); test_with_connection_status(JABBER_DISCONNECTING);
} }
void void
cmd_connect_shows_message_when_connecting(void** state) cmd_connect__shows__message_when_connecting(void** state)
{ {
test_with_connection_status(JABBER_CONNECTING); test_with_connection_status(JABBER_CONNECTING);
} }
void void
cmd_connect_shows_message_when_connected(void** state) cmd_connect__shows__message_when_connected(void** state)
{ {
test_with_connection_status(JABBER_CONNECTED); test_with_connection_status(JABBER_CONNECTED);
} }
void void
cmd_connect_when_no_account(void** state) cmd_connect__tests__no_account(void** state)
{ {
gchar* args[] = { "user@server.org", NULL }; gchar* args[] = { "user@server.org", NULL };
@@ -67,7 +67,7 @@ cmd_connect_when_no_account(void** state)
} }
void void
cmd_connect_fail_message(void** state) cmd_connect__shows__fail_message(void** state)
{ {
gchar* args[] = { "user@server.org", NULL }; gchar* args[] = { "user@server.org", NULL };
@@ -93,7 +93,7 @@ cmd_connect_fail_message(void** state)
} }
void 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 }; gchar* args[] = { "USER@server.ORG", NULL };
@@ -117,7 +117,7 @@ cmd_connect_lowercases_argument_with_no_account(void** state)
} }
void void
cmd_connect_lowercases_argument_with_account(void** state) cmd_connect__tests__lowercases_argument_with_account(void** state)
{ {
gchar* args[] = { "Jabber_org", NULL }; gchar* args[] = { "Jabber_org", NULL };
ProfAccount* account = account_new(g_strdup("Jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), 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 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 }; gchar* args[] = { "jabber_org", NULL };
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, 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 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 }; gchar* args[] = { "user@server.org", "server", NULL };
@@ -175,7 +175,7 @@ cmd_connect_shows_usage_when_no_server_value(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "user@server.org", "port", NULL };
@@ -203,7 +203,7 @@ cmd_connect_shows_usage_when_no_port_value(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "user@server.org", "port", "0", NULL };
@@ -231,7 +231,7 @@ cmd_connect_shows_message_when_port_0(void** state)
} }
void 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 }; gchar* args[] = { "user@server.org", "port", "-1", NULL };
@@ -245,7 +245,7 @@ cmd_connect_shows_message_when_port_minus1(void** state)
} }
void 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 }; gchar* args[] = { "user@server.org", "port", "65536", NULL };
@@ -259,7 +259,7 @@ cmd_connect_shows_message_when_port_65536(void** state)
} }
void 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 }; gchar* args[] = { "user@server.org", "port", "52f66", NULL };
@@ -273,7 +273,7 @@ cmd_connect_shows_message_when_port_contains_chars(void** state)
} }
void 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 }; 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 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 }; 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 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 }; gchar* args[] = { "user@server.org", "wrong", "server", NULL };
@@ -315,7 +315,7 @@ cmd_connect_shows_usage_when_invalid_first_property(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "user@server.org", "server", "aserver", NULL };
@@ -353,7 +353,7 @@ cmd_connect_with_server_when_provided(void** state)
} }
void 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 }; gchar* args[] = { "user@server.org", "port", "5432", NULL };
@@ -377,7 +377,7 @@ cmd_connect_with_port_when_provided(void** state)
} }
void 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 }; 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 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 }; gchar* args[] = { "jabber_org", NULL };
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("user@jabber.org"), g_strdup("password"), 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 void
cmd_connect_connects_with_account(void** state) cmd_connect__tests__connects_with_account(void** state)
{ {
gchar* args[] = { "jabber_org", NULL }; gchar* args[] = { "jabber_org", NULL };
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), NULL, ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), NULL,

View File

@@ -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

View File

@@ -12,7 +12,7 @@
#define CMD_DISCONNECT "/disconnect" #define CMD_DISCONNECT "/disconnect"
void void
clears_chat_sessions(void** state) cmd_disconnect__updates__clears_chat_sessions(void** state)
{ {
chat_sessions_init(); chat_sessions_init();
roster_create(); roster_create();

View File

@@ -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

View File

@@ -27,25 +27,25 @@ test_with_connection_status(jabber_conn_status_t status)
} }
void void
cmd_join_shows_message_when_disconnecting(void** state) cmd_join__shows__message_when_disconnecting(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTING); test_with_connection_status(JABBER_DISCONNECTING);
} }
void void
cmd_join_shows_message_when_connecting(void** state) cmd_join__shows__message_when_connecting(void** state)
{ {
test_with_connection_status(JABBER_CONNECTING); test_with_connection_status(JABBER_CONNECTING);
} }
void void
cmd_join_shows_message_when_disconnected(void** state) cmd_join__shows__message_when_disconnected(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTED); test_with_connection_status(JABBER_DISCONNECTED);
} }
void 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 }; gchar* args[] = { "//@@/", NULL };
@@ -59,7 +59,7 @@ cmd_join_shows_error_message_when_invalid_room_jid(void** state)
} }
void 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"); gchar* account_name = g_strdup("an_account");
char* room = "room"; char* room = "room";
@@ -85,7 +85,7 @@ cmd_join_uses_account_mucservice_when_no_service_specified(void** state)
} }
void void
cmd_join_uses_supplied_nick(void** state) cmd_join__tests__uses_supplied_nick(void** state)
{ {
gchar* account_name = g_strdup("an_account"); gchar* account_name = g_strdup("an_account");
char* room = "room@conf.server.org"; char* room = "room@conf.server.org";
@@ -109,7 +109,7 @@ cmd_join_uses_supplied_nick(void** state)
} }
void 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"); gchar* account_name = g_strdup("an_account");
char* room = "room2@conf.server.org"; char* room = "room2@conf.server.org";
@@ -133,7 +133,7 @@ cmd_join_uses_account_nick_when_not_supplied(void** state)
} }
void 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"); gchar* account_name = g_strdup("an_account");
char* room = "room"; char* room = "room";

View File

@@ -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

View File

@@ -24,7 +24,7 @@
#ifdef HAVE_LIBOTR #ifdef HAVE_LIBOTR
void 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 }; gchar* args[] = { "log", NULL };
@@ -35,7 +35,7 @@ cmd_otr_log_shows_usage_when_no_args(void** state)
} }
void 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 }; gchar* args[] = { "log", "wrong", NULL };
@@ -46,7 +46,7 @@ cmd_otr_log_shows_usage_when_invalid_subcommand(void** state)
} }
void void
cmd_otr_log_on_enables_logging(void** state) cmd_otr_log__updates__enables_logging(void** state)
{ {
gchar* args[] = { "log", "on", NULL }; gchar* args[] = { "log", "on", NULL };
prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_string(PREF_OTR_LOG, "off");
@@ -62,7 +62,7 @@ cmd_otr_log_on_enables_logging(void** state)
} }
void 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 }; gchar* args[] = { "log", "on", NULL };
prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_string(PREF_OTR_LOG, "off");
@@ -76,7 +76,7 @@ cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state)
} }
void void
cmd_otr_log_off_disables_logging(void** state) cmd_otr_log__updates__disables_logging(void** state)
{ {
gchar* args[] = { "log", "off", NULL }; gchar* args[] = { "log", "off", NULL };
prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_string(PREF_OTR_LOG, "on");
@@ -92,7 +92,7 @@ cmd_otr_log_off_disables_logging(void** state)
} }
void void
cmd_otr_redact_redacts_logging(void** state) cmd_otr_log__updates__redacts_logging(void** state)
{ {
gchar* args[] = { "log", "redact", NULL }; gchar* args[] = { "log", "redact", NULL };
prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_string(PREF_OTR_LOG, "on");
@@ -108,7 +108,7 @@ cmd_otr_redact_redacts_logging(void** state)
} }
void 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 }; gchar* args[] = { "log", "redact", NULL };
prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_string(PREF_OTR_LOG, "off");
@@ -122,7 +122,7 @@ cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state)
} }
void void
cmd_otr_libver_shows_libotr_version(void** state) cmd_otr_libver__shows__libotr_version(void** state)
{ {
gchar* args[] = { "libver", NULL }; gchar* args[] = { "libver", NULL };
char* version = "9.9.9"; char* version = "9.9.9";
@@ -140,7 +140,7 @@ cmd_otr_libver_shows_libotr_version(void** state)
} }
void 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 }; gchar* args[] = { "gen", NULL };
@@ -167,25 +167,25 @@ test_with_command_and_connection_status(char* command, void* cmd_func, jabber_co
} }
void 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); test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTED);
} }
void 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); test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_CONNECTING);
} }
void 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); test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTING);
} }
void 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* args[] = { "gen", NULL };
gchar* account_name = g_strdup("myaccount"); gchar* account_name = g_strdup("myaccount");
@@ -206,25 +206,25 @@ cmd_otr_gen_generates_key_for_connected_account(void** state)
} }
void 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); test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTED);
} }
void 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); test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_CONNECTING);
} }
void 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); test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTING);
} }
void 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 }; gchar* args[] = { "myfp", NULL };
@@ -238,7 +238,7 @@ cmd_otr_myfp_shows_message_when_no_key(void** state)
} }
void void
cmd_otr_myfp_shows_my_fingerprint(void** state) cmd_otr_myfp__shows__my_fingerprint(void** state)
{ {
char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
gchar* args[] = { "myfp", NULL }; gchar* args[] = { "myfp", NULL };
@@ -277,25 +277,25 @@ test_cmd_otr_theirfp_from_wintype(win_type_t wintype)
} }
void 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); test_cmd_otr_theirfp_from_wintype(WIN_CONSOLE);
} }
void 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); test_cmd_otr_theirfp_from_wintype(WIN_MUC);
} }
void 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); test_cmd_otr_theirfp_from_wintype(WIN_PRIVATE);
} }
void 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 }; gchar* args[] = { "theirfp", NULL };
@@ -320,7 +320,7 @@ cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state)
} }
void void
cmd_otr_theirfp_shows_fingerprint(void** state) cmd_otr_theirfp__shows__fingerprint(void** state)
{ {
char* recipient = "someone@chat.com"; char* recipient = "someone@chat.com";
char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
@@ -373,25 +373,25 @@ test_cmd_otr_start_from_wintype(win_type_t wintype)
} }
void 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); test_cmd_otr_start_from_wintype(WIN_CONSOLE);
} }
void 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); test_cmd_otr_start_from_wintype(WIN_MUC);
} }
void 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); test_cmd_otr_start_from_wintype(WIN_PRIVATE);
} }
void 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"; char* recipient = "someone@server.org";
gchar* args[] = { "start", NULL }; gchar* args[] = { "start", NULL };
@@ -417,7 +417,7 @@ cmd_otr_start_shows_message_when_already_started(void** state)
} }
void 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"; char* recipient = "someone@server.org";
gchar* args[] = { "start", NULL }; gchar* args[] = { "start", NULL };
@@ -444,7 +444,7 @@ cmd_otr_start_shows_message_when_no_key(void** state)
} }
void 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* recipient = "buddy@chat.com";
char* query_message = "?OTR?"; char* query_message = "?OTR?";
@@ -475,7 +475,7 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state)
#else #else
void void
cmd_otr_shows_message_when_otr_unsupported(void** state) cmd_otr__shows__message_when_otr_unsupported(void** state)
{ {
gchar* args[] = { "gen", NULL }; gchar* args[] = { "gen", NULL };

View File

@@ -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

View File

@@ -14,7 +14,7 @@
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
void void
cmd_pgp_shows_usage_when_no_args(void** state) cmd_pgp__shows__usage_when_no_args(void** state)
{ {
gchar* args[] = { NULL }; gchar* args[] = { NULL };
@@ -25,7 +25,7 @@ cmd_pgp_shows_usage_when_no_args(void** state)
} }
void 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 }; gchar* args[] = { "start", NULL };
ProfWin window; ProfWin window;
@@ -40,25 +40,25 @@ cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
} }
void 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 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 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 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 }; gchar* args[] = { "start", NULL };
ProfWin window; ProfWin window;
@@ -73,38 +73,38 @@ cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
} }
void 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 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 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 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 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 #else
void void
cmd_pgp_shows_message_when_pgp_unsupported(void** state) cmd_pgp__shows__message_when_pgp_unsupported(void** state)
{ {
gchar* args[] = { "gen", NULL }; gchar* args[] = { "gen", NULL };

View File

@@ -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

View File

@@ -13,7 +13,7 @@
#define CMD_PRESENCE "/presence" #define CMD_PRESENCE "/presence"
void void
cmd_presence_shows_usage_when_bad_subcmd(void** state) cmd_presence__shows__usage_when_bad_subcmd(void** state)
{ {
gchar* args[] = { "badcmd", NULL }; gchar* args[] = { "badcmd", NULL };
@@ -24,7 +24,7 @@ cmd_presence_shows_usage_when_bad_subcmd(void** state)
} }
void 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 }; gchar* args[] = { "console", "badsetting", NULL };
@@ -35,7 +35,7 @@ cmd_presence_shows_usage_when_bad_console_setting(void** state)
} }
void 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 }; gchar* args[] = { "chat", "badsetting", NULL };
@@ -46,7 +46,7 @@ cmd_presence_shows_usage_when_bad_chat_setting(void** state)
} }
void 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 }; gchar* args[] = { "muc", "badsetting", NULL };
@@ -57,7 +57,7 @@ cmd_presence_shows_usage_when_bad_muc_setting(void** state)
} }
void void
cmd_presence_console_sets_all(void** state) cmd_presence__updates__console_all(void** state)
{ {
gchar* args[] = { "console", "all", NULL }; gchar* args[] = { "console", "all", NULL };
@@ -72,7 +72,7 @@ cmd_presence_console_sets_all(void** state)
} }
void void
cmd_presence_console_sets_online(void** state) cmd_presence__updates__console_online(void** state)
{ {
gchar* args[] = { "console", "online", NULL }; gchar* args[] = { "console", "online", NULL };
@@ -87,7 +87,7 @@ cmd_presence_console_sets_online(void** state)
} }
void void
cmd_presence_console_sets_none(void** state) cmd_presence__updates__console_none(void** state)
{ {
gchar* args[] = { "console", "none", NULL }; gchar* args[] = { "console", "none", NULL };
@@ -102,7 +102,7 @@ cmd_presence_console_sets_none(void** state)
} }
void void
cmd_presence_chat_sets_all(void** state) cmd_presence__updates__chat_all(void** state)
{ {
gchar* args[] = { "chat", "all", NULL }; gchar* args[] = { "chat", "all", NULL };
@@ -117,7 +117,7 @@ cmd_presence_chat_sets_all(void** state)
} }
void void
cmd_presence_chat_sets_online(void** state) cmd_presence__updates__chat_online(void** state)
{ {
gchar* args[] = { "chat", "online", NULL }; gchar* args[] = { "chat", "online", NULL };
@@ -132,7 +132,7 @@ cmd_presence_chat_sets_online(void** state)
} }
void void
cmd_presence_chat_sets_none(void** state) cmd_presence__updates__chat_none(void** state)
{ {
gchar* args[] = { "chat", "none", NULL }; gchar* args[] = { "chat", "none", NULL };
@@ -147,7 +147,7 @@ cmd_presence_chat_sets_none(void** state)
} }
void void
cmd_presence_room_sets_all(void** state) cmd_presence__updates__room_all(void** state)
{ {
gchar* args[] = { "room", "all", NULL }; gchar* args[] = { "room", "all", NULL };
@@ -162,7 +162,7 @@ cmd_presence_room_sets_all(void** state)
} }
void void
cmd_presence_room_sets_online(void** state) cmd_presence__updates__room_online(void** state)
{ {
gchar* args[] = { "room", "online", NULL }; gchar* args[] = { "room", "online", NULL };
@@ -177,7 +177,7 @@ cmd_presence_room_sets_online(void** state)
} }
void void
cmd_presence_room_sets_none(void** state) cmd_presence__updates__room_none(void** state)
{ {
gchar* args[] = { "room", "none", NULL }; gchar* args[] = { "room", "none", NULL };

View File

@@ -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

View File

@@ -25,25 +25,25 @@ test_with_connection_status(jabber_conn_status_t status)
} }
void void
cmd_rooms_shows_message_when_disconnected(void** state) cmd_rooms__shows__message_when_disconnected(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTED); test_with_connection_status(JABBER_DISCONNECTED);
} }
void void
cmd_rooms_shows_message_when_disconnecting(void** state) cmd_rooms__shows__message_when_disconnecting(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTING); test_with_connection_status(JABBER_DISCONNECTING);
} }
void void
cmd_rooms_shows_message_when_connecting(void** state) cmd_rooms__shows__message_when_connecting(void** state)
{ {
test_with_connection_status(JABBER_CONNECTING); test_with_connection_status(JABBER_CONNECTING);
} }
void void
cmd_rooms_uses_account_default_when_no_arg(void** state) cmd_rooms__tests__account_default_when_no_arg(void** state)
{ {
gchar* args[] = { NULL }; gchar* args[] = { NULL };
@@ -66,7 +66,7 @@ cmd_rooms_uses_account_default_when_no_arg(void** state)
} }
void 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 }; gchar* args[] = { "service", "conf_server_arg", NULL };
@@ -83,7 +83,7 @@ cmd_rooms_service_arg_used_when_passed(void** state)
} }
void 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 }; gchar* args[] = { "filter", "text", NULL };

View File

@@ -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

View File

@@ -26,25 +26,25 @@ test_with_connection_status(jabber_conn_status_t status)
} }
void void
cmd_roster_shows_message_when_disconnecting(void** state) cmd_roster__shows__message_when_disconnecting(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTING); test_with_connection_status(JABBER_DISCONNECTING);
} }
void void
cmd_roster_shows_message_when_connecting(void** state) cmd_roster__shows__message_when_connecting(void** state)
{ {
test_with_connection_status(JABBER_CONNECTING); test_with_connection_status(JABBER_CONNECTING);
} }
void void
cmd_roster_shows_message_when_disconnected(void** state) cmd_roster__shows__message_when_disconnected(void** state)
{ {
test_with_connection_status(JABBER_DISCONNECTED); test_with_connection_status(JABBER_DISCONNECTED);
} }
void void
cmd_roster_shows_roster_when_no_args(void** state) cmd_roster__shows__roster_when_no_args(void** state)
{ {
gchar* args[] = { NULL }; gchar* args[] = { NULL };
@@ -64,7 +64,7 @@ cmd_roster_shows_roster_when_no_args(void** state)
} }
void 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 }; gchar* args[] = { "add", NULL };
@@ -77,7 +77,7 @@ cmd_roster_add_shows_message_when_no_jid(void** state)
} }
void 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* jid = "bob@server.org";
char* nick = "bob"; char* nick = "bob";
@@ -93,7 +93,7 @@ cmd_roster_add_sends_roster_add_request(void** state)
} }
void 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 }; gchar* args[] = { "remove", NULL };
@@ -106,7 +106,7 @@ cmd_roster_remove_shows_message_when_no_jid(void** state)
} }
void 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"; char* jid = "bob@server.org";
gchar* args[] = { "remove", jid, NULL }; gchar* args[] = { "remove", jid, NULL };
@@ -124,13 +124,14 @@ cmd_roster_remove_sends_roster_remove_request(void** state)
} }
void 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"; char* jid = "bob@server.org";
gchar* args[] = { "remove", "bob", NULL }; char* nick = "bob";
gchar* args[] = { "remove", nick, NULL };
roster_create(); 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); will_return(connection_get_status, JABBER_CONNECTED);
@@ -142,7 +143,7 @@ cmd_roster_remove_nickname_sends_roster_remove_request(void** state)
} }
void 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 }; gchar* args[] = { "nick", NULL };
@@ -155,7 +156,7 @@ cmd_roster_nick_shows_message_when_no_jid(void** state)
} }
void 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 }; gchar* args[] = { "nick", "bob@server.org", NULL };
@@ -168,7 +169,7 @@ cmd_roster_nick_shows_message_when_no_nick(void** state)
} }
void 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 }; gchar* args[] = { "nick", "bob@server.org", "bobster", NULL };
@@ -185,7 +186,7 @@ cmd_roster_nick_shows_message_when_no_contact_exists(void** state)
} }
void 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* jid = "bob@server.org";
char* nick = "bobster"; char* nick = "bobster";
@@ -214,7 +215,7 @@ cmd_roster_nick_sends_name_change_request(void** state)
} }
void 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 }; gchar* args[] = { "clearnick", NULL };
@@ -227,7 +228,7 @@ cmd_roster_clearnick_shows_message_when_no_jid(void** state)
} }
void 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 }; gchar* args[] = { "clearnick", "bob@server.org", NULL };
@@ -244,7 +245,7 @@ cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state)
} }
void 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"; char* jid = "bob@server.org";
gchar* args[] = { "clearnick", jid, NULL }; gchar* args[] = { "clearnick", jid, NULL };

View File

@@ -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

View File

@@ -13,7 +13,7 @@
#define CMD_SUB "/sub" #define CMD_SUB "/sub"
void void
cmd_sub_shows_message_when_not_connected(void** state) cmd_sub__shows__message_when_not_connected(void** state)
{ {
gchar* args[] = { NULL }; gchar* args[] = { NULL };
@@ -26,7 +26,7 @@ cmd_sub_shows_message_when_not_connected(void** state)
} }
void void
cmd_sub_shows_usage_when_no_arg(void** state) cmd_sub__shows__usage_when_no_arg(void** state)
{ {
gchar* args[] = { NULL }; gchar* args[] = { NULL };

View File

@@ -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

View File

@@ -6,7 +6,7 @@
#include "config/preferences.h" #include "config/preferences.h"
void 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); gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE);
@@ -16,7 +16,7 @@ statuses_console_defaults_to_all(void** state)
} }
void 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); gchar* setting = prefs_get_string(PREF_STATUSES_CHAT);
@@ -26,7 +26,7 @@ statuses_chat_defaults_to_all(void** state)
} }
void 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); gchar* setting = prefs_get_string(PREF_STATUSES_MUC);

View File

@@ -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

View File

@@ -15,7 +15,7 @@
#include "ui/window_list.h" #include "ui/window_list.h"
void 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"); prefs_set_string(PREF_STATUSES_CONSOLE, "online");
plugins_init(); plugins_init();
@@ -35,7 +35,7 @@ console_shows_online_presence_when_set_online(void** state)
} }
void 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"); prefs_set_string(PREF_STATUSES_CONSOLE, "all");
plugins_init(); plugins_init();
@@ -55,7 +55,7 @@ console_shows_online_presence_when_set_all(void** state)
} }
void 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"); prefs_set_string(PREF_STATUSES_CONSOLE, "all");
plugins_init(); plugins_init();
@@ -75,7 +75,7 @@ console_shows_dnd_presence_when_set_all(void** state)
} }
void void
handle_offline_removes_chat_session(void** state) sv_ev_contact_offline__updates__removes_chat_session(void** state)
{ {
plugins_init(); plugins_init();
roster_create(); roster_create();
@@ -100,7 +100,7 @@ handle_offline_removes_chat_session(void** state)
} }
void void
lost_connection_clears_chat_sessions(void** state) sv_ev_lost_connection__updates__clears_chat_sessions(void** state)
{ {
roster_create(); roster_create();
roster_process_pending_presence(); roster_process_pending_presence();

View File

@@ -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

View File

@@ -7,7 +7,7 @@
#include "plugins/plugins.h" #include "plugins/plugins.h"
void void
returns_no_commands(void** state) plugins_get_command_names__returns__no_commands(void** state)
{ {
plugins_init(); plugins_init();
GList* commands = plugins_get_command_names(); GList* commands = plugins_get_command_names();
@@ -16,7 +16,7 @@ returns_no_commands(void** state)
} }
void void
returns_commands(void** state) plugins_get_command_names__returns__commands_when_added(void** state)
{ {
plugins_init(); plugins_init();
PluginCommand* command1 = g_new0(PluginCommand, 1); PluginCommand* command1 = g_new0(PluginCommand, 1);

View File

@@ -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

View File

@@ -4,7 +4,7 @@
#include "plugins/disco.h" #include "plugins/disco.h"
void void
returns_empty_list_when_none(void** state) disco_get_features__returns__empty_list_when_none(void** state)
{ {
disco_close(); disco_close();
GList* features = disco_get_features(); GList* features = disco_get_features();
@@ -16,7 +16,7 @@ returns_empty_list_when_none(void** state)
} }
void void
returns_added_feature(void** state) disco_add_feature__updates__added_feature(void** state)
{ {
disco_close(); disco_close();
disco_add_feature("my_plugin", "some:feature:example"); disco_add_feature("my_plugin", "some:feature:example");
@@ -31,7 +31,7 @@ returns_added_feature(void** state)
} }
void void
resets_features_on_close(void** state) disco_close__updates__resets_features(void** state)
{ {
disco_close(); disco_close();
disco_add_feature("my_plugin", "some:feature:example"); disco_add_feature("my_plugin", "some:feature:example");
@@ -49,7 +49,7 @@ resets_features_on_close(void** state)
} }
void void
returns_all_added_features(void** state) disco_get_features__returns__all_added_features(void** state)
{ {
disco_close(); disco_close();
disco_add_feature("first_plugin", "first:feature"); disco_add_feature("first_plugin", "first:feature");
@@ -72,7 +72,7 @@ returns_all_added_features(void** state)
} }
void void
does_not_add_duplicate_feature(void** state) disco_add_feature__updates__not_duplicate_feature(void** state)
{ {
disco_close(); disco_close();
disco_add_feature("my_plugin", "my:feature"); disco_add_feature("my_plugin", "my:feature");
@@ -86,7 +86,7 @@ does_not_add_duplicate_feature(void** state)
} }
void void
removes_plugin_features(void** state) disco_remove_features__updates__removes_plugin_features(void** state)
{ {
disco_close(); disco_close();
disco_add_feature("plugin1", "plugin1:feature1"); disco_add_feature("plugin1", "plugin1:feature1");
@@ -107,7 +107,7 @@ removes_plugin_features(void** state)
} }
void 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_close();
disco_add_feature("plugin1", "feature1"); disco_add_feature("plugin1", "feature1");

View File

@@ -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

View File

@@ -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);

View File

@@ -1,2 +0,0 @@
void returns_no_commands(void** state);
void returns_commands(void** state);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -1 +0,0 @@
void clears_chat_sessions(void** state);

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -1,2 +0,0 @@
void cmd_sub_shows_message_when_not_connected(void** state);
void cmd_sub_shows_usage_when_no_arg(void** state);

View File

@@ -5,7 +5,7 @@
#include "tests/unittests/ui/stub_ui.h" // Include for mocking cons_show #include "tests/unittests/ui/stub_ui.h" // Include for mocking cons_show
void void
replace_one_substr(void** state) str_replace__returns__one_substr(void** state)
{ {
char* string = "it is a string"; char* string = "it is a string";
char* sub = "is"; char* sub = "is";
@@ -19,7 +19,7 @@ replace_one_substr(void** state)
} }
void void
replace_one_substr_beginning(void** state) str_replace__returns__one_substr_beginning(void** state)
{ {
char* string = "it is a string"; char* string = "it is a string";
char* sub = "it"; char* sub = "it";
@@ -33,7 +33,7 @@ replace_one_substr_beginning(void** state)
} }
void void
replace_one_substr_end(void** state) str_replace__returns__one_substr_end(void** state)
{ {
char* string = "it is a string"; char* string = "it is a string";
char* sub = "string"; char* sub = "string";
@@ -47,7 +47,7 @@ replace_one_substr_end(void** state)
} }
void void
replace_two_substr(void** state) str_replace__returns__two_substr(void** state)
{ {
char* string = "it is a is string"; char* string = "it is a is string";
char* sub = "is"; char* sub = "is";
@@ -61,7 +61,7 @@ replace_two_substr(void** state)
} }
void void
replace_char(void** state) str_replace__returns__char(void** state)
{ {
char* string = "some & a thing & something else"; char* string = "some & a thing & something else";
char* sub = "&"; char* sub = "&";
@@ -75,7 +75,7 @@ replace_char(void** state)
} }
void void
replace_when_none(void** state) str_replace__returns__original_when_none(void** state)
{ {
char* string = "its another string"; char* string = "its another string";
char* sub = "haha"; char* sub = "haha";
@@ -89,7 +89,7 @@ replace_when_none(void** state)
} }
void void
replace_when_match(void** state) str_replace__returns__replaced_when_match(void** state)
{ {
char* string = "hello"; char* string = "hello";
char* sub = "hello"; char* sub = "hello";
@@ -103,7 +103,7 @@ replace_when_match(void** state)
} }
void void
replace_when_string_empty(void** state) str_replace__returns__empty_when_string_empty(void** state)
{ {
char* string = ""; char* string = "";
char* sub = "hello"; char* sub = "hello";
@@ -117,7 +117,7 @@ replace_when_string_empty(void** state)
} }
void void
replace_when_string_null(void** state) str_replace__returns__null_when_string_null(void** state)
{ {
char* string = NULL; char* string = NULL;
char* sub = "hello"; char* sub = "hello";
@@ -129,7 +129,7 @@ replace_when_string_null(void** state)
} }
void void
replace_when_sub_empty(void** state) str_replace__returns__original_when_sub_empty(void** state)
{ {
char* string = "hello"; char* string = "hello";
char* sub = ""; char* sub = "";
@@ -143,7 +143,7 @@ replace_when_sub_empty(void** state)
} }
void void
replace_when_sub_null(void** state) str_replace__returns__original_when_sub_null(void** state)
{ {
char* string = "hello"; char* string = "hello";
char* sub = NULL; char* sub = NULL;
@@ -157,7 +157,7 @@ replace_when_sub_null(void** state)
} }
void void
replace_when_new_empty(void** state) str_replace__returns__empty_when_new_empty(void** state)
{ {
char* string = "hello"; char* string = "hello";
char* sub = "hello"; char* sub = "hello";
@@ -171,7 +171,7 @@ replace_when_new_empty(void** state)
} }
void void
replace_when_new_null(void** state) str_replace__returns__original_when_new_null(void** state)
{ {
char* string = "hello"; char* string = "hello";
char* sub = "hello"; char* sub = "hello";
@@ -185,55 +185,55 @@ replace_when_new_null(void** state)
} }
void 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")); assert_true(valid_resource_presence_string("online"));
} }
void 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")); assert_true(valid_resource_presence_string("chat"));
} }
void 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")); assert_true(valid_resource_presence_string("away"));
} }
void 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")); assert_true(valid_resource_presence_string("xa"));
} }
void 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")); assert_true(valid_resource_presence_string("dnd"));
} }
void 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")); assert_false(valid_resource_presence_string("available"));
} }
void 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")); assert_false(valid_resource_presence_string("unavailable"));
} }
void 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")); assert_false(valid_resource_presence_string("blah"));
} }
void void
utf8_display_len_null_str(void** state) utf8_display_len__returns__0_for_null(void** state)
{ {
int result = utf8_display_len(NULL); int result = utf8_display_len(NULL);
@@ -241,7 +241,7 @@ utf8_display_len_null_str(void** state)
} }
void 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"); int result = utf8_display_len("1");
@@ -249,7 +249,7 @@ utf8_display_len_1_non_wide(void** state)
} }
void void
utf8_display_len_1_wide(void** state) utf8_display_len__returns__2_for_wide(void** state)
{ {
int result = utf8_display_len(""); int result = utf8_display_len("");
@@ -257,7 +257,7 @@ utf8_display_len_1_wide(void** state)
} }
void void
utf8_display_len_non_wide(void** state) utf8_display_len__returns__correct_for_non_wide(void** state)
{ {
int result = utf8_display_len("123456789abcdef"); int result = utf8_display_len("123456789abcdef");
@@ -265,7 +265,7 @@ utf8_display_len_non_wide(void** state)
} }
void void
utf8_display_len_wide(void** state) utf8_display_len__returns__correct_for_wide(void** state)
{ {
int result = utf8_display_len("12三四56"); int result = utf8_display_len("12三四56");
@@ -273,7 +273,7 @@ utf8_display_len_wide(void** state)
} }
void void
utf8_display_len_all_wide(void** state) utf8_display_len__returns__correct_for_all_wide(void** state)
{ {
int result = utf8_display_len("ひらがな"); int result = utf8_display_len("ひらがな");
@@ -281,7 +281,7 @@ utf8_display_len_all_wide(void** state)
} }
void 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"; char* input = "/cmd test string";
@@ -293,7 +293,7 @@ strip_quotes_does_nothing_when_no_quoted(void** state)
} }
void void
strip_quotes_strips_first(void** state) strip_arg_quotes__returns__stripped_first(void** state)
{ {
char* input = "/cmd \"test string"; char* input = "/cmd \"test string";
@@ -305,7 +305,7 @@ strip_quotes_strips_first(void** state)
} }
void void
strip_quotes_strips_last(void** state) strip_arg_quotes__returns__stripped_last(void** state)
{ {
char* input = "/cmd test string\""; char* input = "/cmd test string\"";
@@ -317,7 +317,7 @@ strip_quotes_strips_last(void** state)
} }
void void
strip_quotes_strips_both(void** state) strip_arg_quotes__returns__stripped_both(void** state)
{ {
char* input = "/cmd \"test string\""; char* input = "/cmd \"test string\"";
@@ -328,7 +328,9 @@ strip_quotes_strips_both(void** state)
free(result); free(result);
} }
void test_valid_tls_policy_option(void** state) { void
valid_tls_policy_option__is__correct_for_various_inputs(void** state)
{
// Valid inputs // Valid inputs
assert_true(valid_tls_policy_option("force")); assert_true(valid_tls_policy_option("force"));
assert_true(valid_tls_policy_option("allow")); assert_true(valid_tls_policy_option("allow"));
@@ -352,7 +354,9 @@ void test_valid_tls_policy_option(void** state) {
assert_true(valid_tls_policy_option(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; gchar* expanded_path;
// `file://` prefix // `file://` prefix
@@ -378,7 +382,9 @@ void test_get_expanded_path(void** state) {
g_free(expanded_path); g_free(expanded_path);
} }
void test_strtoi_range_valid_input(void** state) { void
strtoi_range__returns__true_for_valid_input(void** state)
{
int value; int value;
gchar* err_msg = NULL; gchar* err_msg = NULL;
gboolean result; gboolean result;
@@ -404,7 +410,9 @@ void test_strtoi_range_valid_input(void** state) {
assert_null(err_msg); 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; int value;
gchar* err_msg = NULL; gchar* err_msg = NULL;
gboolean result; gboolean result;
@@ -431,7 +439,9 @@ void test_strtoi_range_out_of_range(void** state) {
err_msg = NULL; err_msg = NULL;
} }
void test_strtoi_range_invalid_input(void** state) { void
strtoi_range__returns__false_for_invalid_input(void** state)
{
int value; int value;
gchar* err_msg = NULL; gchar* err_msg = NULL;
gboolean result; gboolean result;
@@ -451,7 +461,9 @@ void test_strtoi_range_invalid_input(void** state) {
err_msg = NULL; 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; int value;
gchar* err_msg = NULL; gchar* err_msg = NULL;
gboolean result; gboolean result;
@@ -471,7 +483,9 @@ void test_strtoi_range_null_empty_input(void** state) {
err_msg = NULL; 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; int value;
gboolean result; gboolean result;
@@ -485,7 +499,9 @@ void test_strtoi_range_null_err_msg(void** state) {
assert_false(result); assert_false(result);
} }
void test_string_to_verbosity(void** state) { void
string_to_verbosity__returns__correct_values(void** state)
{
int verbosity; int verbosity;
gchar* err_msg = NULL; gchar* err_msg = NULL;
gboolean result; gboolean result;
@@ -495,21 +511,24 @@ void test_string_to_verbosity(void** state) {
assert_true(result); assert_true(result);
assert_int_equal(0, verbosity); assert_int_equal(0, verbosity);
assert_null(err_msg); 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) // Valid input string (1)
result = string_to_verbosity("1", &verbosity, &err_msg); result = string_to_verbosity("1", &verbosity, &err_msg);
assert_true(result); assert_true(result);
assert_int_equal(1, verbosity); assert_int_equal(1, verbosity);
assert_null(err_msg); assert_null(err_msg);
g_free(err_msg); err_msg = NULL; g_free(err_msg);
err_msg = NULL;
// Valid input string (3) // Valid input string (3)
result = string_to_verbosity("3", &verbosity, &err_msg); result = string_to_verbosity("3", &verbosity, &err_msg);
assert_true(result); assert_true(result);
assert_int_equal(3, verbosity); assert_int_equal(3, verbosity);
assert_null(err_msg); assert_null(err_msg);
g_free(err_msg); err_msg = NULL; g_free(err_msg);
err_msg = NULL;
// Invalid input string (not a number) // Invalid input string (not a number)
result = string_to_verbosity("profanity", &verbosity, &err_msg); result = string_to_verbosity("profanity", &verbosity, &err_msg);
@@ -522,25 +541,29 @@ void test_string_to_verbosity(void** state) {
result = string_to_verbosity("-1", &verbosity, &err_msg); result = string_to_verbosity("-1", &verbosity, &err_msg);
assert_false(result); assert_false(result);
assert_string_equal("Value -1 out of range. Must be in 0..3.", err_msg); 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) // Valid input string, out of range (too high)
result = string_to_verbosity("4", &verbosity, &err_msg); result = string_to_verbosity("4", &verbosity, &err_msg);
assert_false(result); assert_false(result);
assert_string_equal("Value 4 out of range. Must be in 0..3.", err_msg); 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 // NULL input string
result = string_to_verbosity(NULL, &verbosity, &err_msg); result = string_to_verbosity(NULL, &verbosity, &err_msg);
assert_false(result); assert_false(result);
assert_string_equal("'str' input pointer can not be NULL", err_msg); 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 // Empty input string
result = string_to_verbosity("", &verbosity, &err_msg); result = string_to_verbosity("", &verbosity, &err_msg);
assert_false(result); assert_false(result);
assert_string_equal("Could not convert \"\" to a number.", err_msg); 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 // err_msg is NULL
result = string_to_verbosity("abc", &verbosity, NULL); result = string_to_verbosity("abc", &verbosity, NULL);
@@ -556,7 +579,7 @@ typedef struct
} format_call_external_argv_t; } format_call_external_argv_t;
void void
format_call_external_argv_td(void** state) format_call_external_argv__tests__table_driven(void** state)
{ {
enum table { num_tests = 4 }; enum table { num_tests = 4 };
@@ -613,7 +636,7 @@ typedef struct
} unique_filename_from_url_t; } unique_filename_from_url_t;
void void
unique_filename_from_url_td(void** state) unique_filename_from_url__tests__table_driven(void** state)
{ {
enum table { num_tests = 15 }; enum table { num_tests = 15 };
@@ -751,7 +774,7 @@ _lists_equal(GSList* a, GSList* b)
} }
void void
prof_occurrences_of_large_message_tests(void** state) prof_occurrences__tests__large_message(void** state)
{ {
GSList* actual = NULL; GSList* actual = NULL;
GSList* expected = NULL; GSList* expected = NULL;
@@ -773,7 +796,7 @@ prof_occurrences_of_large_message_tests(void** state)
} }
void void
prof_partial_occurrences_tests(void** state) prof_occurrences__tests__partial(void** state)
{ {
GSList* actual = NULL; GSList* actual = NULL;
GSList* expected = NULL; GSList* expected = NULL;
@@ -865,7 +888,7 @@ prof_partial_occurrences_tests(void** state)
} }
void void
get_mentions_tests(void** state) get_mentions__tests__various(void** state)
{ {
GSList* actual = NULL; GSList* actual = NULL;
GSList* expected = NULL; GSList* expected = NULL;
@@ -874,70 +897,87 @@ get_mentions_tests(void** state)
expected = g_slist_append(expected, GINT_TO_POINTER(6)); expected = g_slist_append(expected, GINT_TO_POINTER(6));
actual = get_mentions(FALSE, TRUE, "hello boothj5", "boothj5"); actual = get_mentions(FALSE, TRUE, "hello boothj5", "boothj5");
assert_true(_lists_equal(actual, expected)); assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL; g_slist_free(actual);
g_slist_free(expected); expected = NULL; actual = NULL;
g_slist_free(expected);
expected = NULL;
// Case insensitive match // Case insensitive match
expected = g_slist_append(expected, GINT_TO_POINTER(6)); expected = g_slist_append(expected, GINT_TO_POINTER(6));
actual = get_mentions(FALSE, FALSE, "hello BOOTHJ5", "boothj5"); actual = get_mentions(FALSE, FALSE, "hello BOOTHJ5", "boothj5");
assert_true(_lists_equal(actual, expected)); assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL; g_slist_free(actual);
g_slist_free(expected); expected = NULL; actual = NULL;
g_slist_free(expected);
expected = NULL;
// Whole word match // Whole word match
expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(0));
actual = get_mentions(TRUE, TRUE, "boothj5 hello", "boothj5"); actual = get_mentions(TRUE, TRUE, "boothj5 hello", "boothj5");
assert_true(_lists_equal(actual, expected)); assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL; g_slist_free(actual);
g_slist_free(expected); expected = NULL; actual = NULL;
g_slist_free(expected);
expected = NULL;
// Whole word no match (partial) // Whole word no match (partial)
actual = get_mentions(TRUE, TRUE, "boothj5hello", "boothj5"); actual = get_mentions(TRUE, TRUE, "boothj5hello", "boothj5");
assert_true(_lists_equal(actual, expected)); // expected is NULL assert_true(_lists_equal(actual, expected)); // expected is NULL
g_slist_free(actual); actual = NULL; g_slist_free(actual);
actual = NULL;
// Multiple matches // Multiple matches
expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(0));
expected = g_slist_append(expected, GINT_TO_POINTER(14)); expected = g_slist_append(expected, GINT_TO_POINTER(14));
actual = get_mentions(FALSE, TRUE, "boothj5 hello boothj5", "boothj5"); actual = get_mentions(FALSE, TRUE, "boothj5 hello boothj5", "boothj5");
assert_true(_lists_equal(actual, expected)); assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL; g_slist_free(actual);
g_slist_free(expected); expected = NULL; actual = NULL;
g_slist_free(expected);
expected = NULL;
// Nick with punctuation (whole word) // Nick with punctuation (whole word)
expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(0));
actual = get_mentions(TRUE, TRUE, "boothj5: hi", "boothj5"); actual = get_mentions(TRUE, TRUE, "boothj5: hi", "boothj5");
assert_true(_lists_equal(actual, expected)); assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL; g_slist_free(actual);
g_slist_free(expected); expected = NULL; actual = NULL;
g_slist_free(expected);
expected = NULL;
// Nick surrounded by punctuation // Nick surrounded by punctuation
expected = g_slist_append(expected, GINT_TO_POINTER(1)); expected = g_slist_append(expected, GINT_TO_POINTER(1));
actual = get_mentions(TRUE, TRUE, "(boothj5)", "boothj5"); actual = get_mentions(TRUE, TRUE, "(boothj5)", "boothj5");
assert_true(_lists_equal(actual, expected)); assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL; g_slist_free(actual);
g_slist_free(expected); expected = NULL; actual = NULL;
g_slist_free(expected);
expected = NULL;
// Empty message // Empty message
actual = get_mentions(FALSE, TRUE, "", "boothj5"); actual = get_mentions(FALSE, TRUE, "", "boothj5");
assert_true(_lists_equal(actual, expected)); // expected is NULL assert_true(_lists_equal(actual, expected)); // expected is NULL
g_slist_free(actual); actual = NULL; g_slist_free(actual);
actual = NULL;
// Empty nick // Empty nick
actual = get_mentions(FALSE, TRUE, "hello", ""); actual = get_mentions(FALSE, TRUE, "hello", "");
assert_true(_lists_equal(actual, expected)); // expected is NULL assert_true(_lists_equal(actual, expected)); // expected is NULL
g_slist_free(actual); actual = NULL; g_slist_free(actual);
actual = NULL;
// UTF-8 characters // UTF-8 characters
expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(0));
actual = get_mentions(TRUE, TRUE, "我能 hello", "我能"); actual = get_mentions(TRUE, TRUE, "我能 hello", "我能");
assert_true(_lists_equal(actual, expected)); assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL; g_slist_free(actual);
g_slist_free(expected); expected = NULL; actual = NULL;
g_slist_free(expected);
expected = NULL;
} }
void void
release_is_new_tests(void** state) release_is_new__tests__various(void** state)
{ {
// Higher major version // Higher major version
assert_true(release_is_new("0.16.0", "1.0.0")); assert_true(release_is_new("0.16.0", "1.0.0"));
@@ -973,7 +1013,7 @@ release_is_new_tests(void** state)
} }
void void
prof_whole_occurrences_tests(void** state) prof_occurrences__tests__whole(void** state)
{ {
GSList* actual = NULL; GSList* actual = NULL;
GSList* expected = NULL; GSList* expected = NULL;
@@ -1175,7 +1215,9 @@ prof_whole_occurrences_tests(void** state)
expected = NULL; 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 // is is NULL, is_can_be_null is TRUE -> should return TRUE
assert_true(string_matches_one_of(NULL, NULL, TRUE, "option1", "option2", NULL)); assert_true(string_matches_one_of(NULL, NULL, TRUE, "option1", "option2", NULL));

View File

@@ -1,47 +1,56 @@
void replace_one_substr(void** state); #ifndef TESTS_TEST_COMMON_H
void replace_one_substr_beginning(void** state); #define TESTS_TEST_COMMON_H
void replace_one_substr_end(void** state);
void replace_two_substr(void** state); void str_replace__returns__one_substr(void** state);
void replace_char(void** state); void str_replace__returns__one_substr_beginning(void** state);
void replace_when_none(void** state); void str_replace__returns__one_substr_end(void** state);
void replace_when_match(void** state); void str_replace__returns__two_substr(void** state);
void replace_when_string_empty(void** state); void str_replace__returns__char(void** state);
void replace_when_string_null(void** state); void str_replace__returns__original_when_none(void** state);
void replace_when_sub_empty(void** state); void str_replace__returns__replaced_when_match(void** state);
void replace_when_sub_null(void** state); void str_replace__returns__empty_when_string_empty(void** state);
void replace_when_new_empty(void** state); void str_replace__returns__null_when_string_null(void** state);
void replace_when_new_null(void** state); void str_replace__returns__original_when_sub_empty(void** state);
void test_online_is_valid_resource_presence_string(void** state); void str_replace__returns__original_when_sub_null(void** state);
void test_chat_is_valid_resource_presence_string(void** state); void str_replace__returns__empty_when_new_empty(void** state);
void test_away_is_valid_resource_presence_string(void** state); void str_replace__returns__original_when_new_null(void** state);
void test_xa_is_valid_resource_presence_string(void** state);
void test_dnd_is_valid_resource_presence_string(void** state); void valid_resource_presence_string__is__true_for_online(void** state);
void test_available_is_not_valid_resource_presence_string(void** state); void valid_resource_presence_string__is__true_for_chat(void** state);
void test_unavailable_is_not_valid_resource_presence_string(void** state); void valid_resource_presence_string__is__true_for_away(void** state);
void test_blah_is_not_valid_resource_presence_string(void** state); void valid_resource_presence_string__is__true_for_xa(void** state);
void utf8_display_len_null_str(void** state); void valid_resource_presence_string__is__true_for_dnd(void** state);
void utf8_display_len_1_non_wide(void** state); void valid_resource_presence_string__is__false_for_available(void** state);
void utf8_display_len_1_wide(void** state); void valid_resource_presence_string__is__false_for_unavailable(void** state);
void utf8_display_len_non_wide(void** state); void valid_resource_presence_string__is__false_for_blah(void** state);
void utf8_display_len_wide(void** state);
void utf8_display_len_all_wide(void** state); void utf8_display_len__returns__0_for_null(void** state);
void strip_quotes_does_nothing_when_no_quoted(void** state); void utf8_display_len__returns__1_for_non_wide(void** state);
void strip_quotes_strips_first(void** state); void utf8_display_len__returns__2_for_wide(void** state);
void strip_quotes_strips_last(void** state); void utf8_display_len__returns__correct_for_non_wide(void** state);
void strip_quotes_strips_both(void** state); void utf8_display_len__returns__correct_for_wide(void** state);
void prof_partial_occurrences_tests(void** state); void utf8_display_len__returns__correct_for_all_wide(void** state);
void prof_whole_occurrences_tests(void** state);
void prof_occurrences_of_large_message_tests(void** state); void strip_arg_quotes__returns__original_when_no_quotes(void** state);
void unique_filename_from_url_td(void** state); void strip_arg_quotes__returns__stripped_first(void** state);
void format_call_external_argv_td(void** state); void strip_arg_quotes__returns__stripped_last(void** state);
void test_get_expanded_path(void** state); void strip_arg_quotes__returns__stripped_both(void** state);
void test_string_to_verbosity(void** state);
void test_strtoi_range_valid_input(void** state); void prof_occurrences__tests__partial(void** state);
void test_strtoi_range_out_of_range(void** state); void prof_occurrences__tests__whole(void** state);
void test_strtoi_range_invalid_input(void** state); void prof_occurrences__tests__large_message(void** state);
void test_strtoi_range_null_empty_input(void** state); void unique_filename_from_url__tests__table_driven(void** state);
void test_strtoi_range_null_err_msg(void** state); void format_call_external_argv__tests__table_driven(void** state);
void test_string_matches_one_of_edge_cases(void** state); void get_expanded_path__returns__expanded(void** state);
void test_valid_tls_policy_option(void** state); void string_to_verbosity__returns__correct_values(void** state);
void get_mentions_tests(void** state); void strtoi_range__returns__true_for_valid_input(void** state);
void release_is_new_tests(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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -6,7 +6,7 @@
#include "tools/autocomplete.h" #include "tools/autocomplete.h"
void void
clear_empty(void** state) autocomplete_complete__returns__null_when_empty(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
char* result = autocomplete_complete(ac, "test", TRUE, FALSE); char* result = autocomplete_complete(ac, "test", TRUE, FALSE);
@@ -16,7 +16,7 @@ clear_empty(void** state)
} }
void void
reset_after_create(void** state) autocomplete_reset__updates__after_create(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_reset(ac); autocomplete_reset(ac);
@@ -24,7 +24,7 @@ reset_after_create(void** state)
} }
void void
find_after_create(void** state) autocomplete_complete__returns__null_after_create(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
char* result = autocomplete_complete(ac, "hello", TRUE, FALSE); char* result = autocomplete_complete(ac, "hello", TRUE, FALSE);
@@ -34,7 +34,7 @@ find_after_create(void** state)
} }
void void
get_after_create_returns_null(void** state) autocomplete_create_list__returns__null_after_create(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
GList* result = autocomplete_create_list(ac); GList* result = autocomplete_create_list(ac);
@@ -46,7 +46,7 @@ get_after_create_returns_null(void** state)
} }
void void
add_one_and_complete(void** state) autocomplete_add__updates__one_and_complete(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello");
@@ -59,7 +59,7 @@ add_one_and_complete(void** state)
} }
void void
add_two_and_complete_returns_first(void** state) autocomplete_complete__returns__first_of_two(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello");
@@ -73,7 +73,7 @@ add_two_and_complete_returns_first(void** state)
} }
void void
add_two_and_complete_returns_second(void** state) autocomplete_complete__returns__second_of_two(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello");
@@ -89,7 +89,7 @@ add_two_and_complete_returns_second(void** state)
} }
void void
add_two_adds_two(void** state) autocomplete_add__updates__two_elements(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello");
@@ -103,7 +103,7 @@ add_two_adds_two(void** state)
} }
void void
add_two_same_adds_one(void** state) autocomplete_add__updates__only_once_for_same_value(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello");
@@ -117,7 +117,7 @@ add_two_same_adds_one(void** state)
} }
void void
add_two_same_updates(void** state) autocomplete_add__updates__existing_value(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello");
@@ -135,7 +135,7 @@ add_two_same_updates(void** state)
} }
void void
complete_accented_with_accented(void** state) autocomplete_complete__returns__accented_with_accented(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "èâîô"); autocomplete_add(ac, "èâîô");
@@ -149,7 +149,7 @@ complete_accented_with_accented(void** state)
} }
void void
complete_accented_with_base(void** state) autocomplete_complete__returns__accented_with_base(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "èâîô"); autocomplete_add(ac, "èâîô");
@@ -163,7 +163,7 @@ complete_accented_with_base(void** state)
} }
void void
complete_both_with_accented(void** state) autocomplete_complete__returns__both_with_accented(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "eaooooo"); autocomplete_add(ac, "eaooooo");
@@ -180,7 +180,7 @@ complete_both_with_accented(void** state)
} }
void void
complete_both_with_base(void** state) autocomplete_complete__returns__both_with_base(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "eaooooo"); autocomplete_add(ac, "eaooooo");
@@ -198,7 +198,7 @@ complete_both_with_base(void** state)
} }
void void
complete_ignores_case(void** state) autocomplete_complete__is__case_insensitive(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "MyBuddy"); autocomplete_add(ac, "MyBuddy");
@@ -212,7 +212,7 @@ complete_ignores_case(void** state)
} }
void void
complete_previous(void** state) autocomplete_complete__returns__previous(void** state)
{ {
Autocomplete ac = autocomplete_new(); Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "MyBuddy1"); autocomplete_add(ac, "MyBuddy1");

View File

@@ -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

View File

@@ -4,7 +4,7 @@
#include "tools/parser.h" #include "tools/parser.h"
void void
parse_null_returns_null(void** state) parse_args__returns__null_from_null(void** state)
{ {
char* inp = NULL; char* inp = NULL;
gboolean result = TRUE; gboolean result = TRUE;
@@ -16,7 +16,7 @@ parse_null_returns_null(void** state)
} }
void void
parse_empty_returns_null(void** state) parse_args__returns__null_from_empty(void** state)
{ {
char* inp = ""; char* inp = "";
gboolean result = TRUE; gboolean result = TRUE;
@@ -28,7 +28,7 @@ parse_empty_returns_null(void** state)
} }
void void
parse_space_returns_null(void** state) parse_args__returns__null_from_space(void** state)
{ {
char* inp = " "; char* inp = " ";
gboolean result = TRUE; gboolean result = TRUE;
@@ -40,7 +40,7 @@ parse_space_returns_null(void** state)
} }
void void
parse_cmd_no_args_returns_null(void** state) parse_args__returns__null_when_no_args(void** state)
{ {
char* inp = "/cmd"; char* inp = "/cmd";
gboolean result = TRUE; gboolean result = TRUE;
@@ -52,7 +52,7 @@ parse_cmd_no_args_returns_null(void** state)
} }
void void
parse_cmd_with_space_returns_null(void** state) parse_args__returns__null_from_cmd_with_space(void** state)
{ {
char* inp = "/cmd "; char* inp = "/cmd ";
gboolean result = TRUE; gboolean result = TRUE;
@@ -64,7 +64,7 @@ parse_cmd_with_space_returns_null(void** state)
} }
void void
parse_cmd_with_too_few_returns_null(void** state) parse_args__returns__null_when_too_few(void** state)
{ {
char* inp = "/cmd arg1"; char* inp = "/cmd arg1";
gboolean result = TRUE; gboolean result = TRUE;
@@ -76,7 +76,7 @@ parse_cmd_with_too_few_returns_null(void** state)
} }
void 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"; char* inp = "/cmd arg1 arg2 arg3 arg4";
gboolean result = TRUE; gboolean result = TRUE;
@@ -88,7 +88,7 @@ parse_cmd_with_too_many_returns_null(void** state)
} }
void void
parse_cmd_one_arg(void** state) parse_args__returns__one_arg(void** state)
{ {
char* inp = "/cmd arg1"; char* inp = "/cmd arg1";
gboolean result = FALSE; gboolean result = FALSE;
@@ -101,7 +101,7 @@ parse_cmd_one_arg(void** state)
} }
void void
parse_cmd_two_args(void** state) parse_args__returns__two_args(void** state)
{ {
char* inp = "/cmd arg1 arg2"; char* inp = "/cmd arg1 arg2";
gboolean result = FALSE; gboolean result = FALSE;
@@ -115,7 +115,7 @@ parse_cmd_two_args(void** state)
} }
void void
parse_cmd_three_args(void** state) parse_args__returns__three_args(void** state)
{ {
char* inp = "/cmd arg1 arg2 arg3"; char* inp = "/cmd arg1 arg2 arg3";
gboolean result = FALSE; gboolean result = FALSE;
@@ -130,7 +130,7 @@ parse_cmd_three_args(void** state)
} }
void void
parse_cmd_three_args_with_spaces(void** state) parse_args__returns__three_args_with_spaces(void** state)
{ {
char* inp = " /cmd arg1 arg2 arg3 "; char* inp = " /cmd arg1 arg2 arg3 ";
gboolean result = FALSE; gboolean result = FALSE;
@@ -145,7 +145,7 @@ parse_cmd_three_args_with_spaces(void** state)
} }
void void
parse_cmd_with_freetext(void** state) parse_args_with_freetext__returns__freetext(void** state)
{ {
char* inp = "/cmd this is some free text"; char* inp = "/cmd this is some free text";
gboolean result = FALSE; gboolean result = FALSE;
@@ -158,7 +158,7 @@ parse_cmd_with_freetext(void** state)
} }
void 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"; char* inp = "/cmd arg1 this is some free text";
gboolean result = FALSE; gboolean result = FALSE;
@@ -172,7 +172,7 @@ parse_cmd_one_arg_with_freetext(void** state)
} }
void 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"; char* inp = "/cmd arg1 arg2 this is some free text";
gboolean result = FALSE; gboolean result = FALSE;
@@ -187,7 +187,7 @@ parse_cmd_two_args_with_freetext(void** state)
} }
void void
parse_cmd_min_zero(void** state) parse_args__returns__zero_args_when_min_zero(void** state)
{ {
char* inp = "/cmd"; char* inp = "/cmd";
gboolean result = FALSE; gboolean result = FALSE;
@@ -200,7 +200,7 @@ parse_cmd_min_zero(void** state)
} }
void void
parse_cmd_min_zero_with_freetext(void** state) parse_args_with_freetext__returns__zero_args_when_min_zero(void** state)
{ {
char* inp = "/cmd"; char* inp = "/cmd";
gboolean result = FALSE; gboolean result = FALSE;
@@ -213,7 +213,7 @@ parse_cmd_min_zero_with_freetext(void** state)
} }
void void
parse_cmd_with_quoted(void** state) parse_args__returns__quoted_args(void** state)
{ {
char* inp = "/cmd \"arg1\" arg2"; char* inp = "/cmd \"arg1\" arg2";
gboolean result = FALSE; gboolean result = FALSE;
@@ -227,7 +227,7 @@ parse_cmd_with_quoted(void** state)
} }
void void
parse_cmd_with_quoted_and_space(void** state) parse_args__returns__quoted_args_with_space(void** state)
{ {
char* inp = "/cmd \"the arg1\" arg2"; char* inp = "/cmd \"the arg1\" arg2";
gboolean result = FALSE; gboolean result = FALSE;
@@ -241,7 +241,7 @@ parse_cmd_with_quoted_and_space(void** state)
} }
void 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"; char* inp = "/cmd \"the arg1 is here\" arg2";
gboolean result = FALSE; gboolean result = FALSE;
@@ -255,7 +255,7 @@ parse_cmd_with_quoted_and_many_spaces(void** state)
} }
void 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\""; char* inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\"";
gboolean result = FALSE; gboolean result = FALSE;
@@ -269,7 +269,7 @@ parse_cmd_with_many_quoted_and_many_spaces(void** state)
} }
void 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"; char* inp = "/cmd \"arg1\" arg2 hello there what's up";
gboolean result = FALSE; gboolean result = FALSE;
@@ -284,7 +284,7 @@ parse_cmd_freetext_with_quoted(void** state)
} }
void 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"; char* inp = "/cmd \"the arg1\" arg2 another bit of freetext";
gboolean result = FALSE; gboolean result = FALSE;
@@ -299,7 +299,7 @@ parse_cmd_freetext_with_quoted_and_space(void** state)
} }
void 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"; char* inp = "/cmd \"the arg1 is here\" arg2 some more freetext";
gboolean result = FALSE; gboolean result = FALSE;
@@ -314,7 +314,7 @@ parse_cmd_freetext_with_quoted_and_many_spaces(void** state)
} }
void 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"; char* inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\" and heres the free text";
gboolean result = FALSE; gboolean result = FALSE;
@@ -329,7 +329,7 @@ parse_cmd_freetext_with_many_quoted_and_many_spaces(void** state)
} }
void 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"; char* inp = "/cmd arg1 here is \"some\" quoted freetext";
gboolean result = FALSE; gboolean result = FALSE;
@@ -343,7 +343,7 @@ parse_cmd_with_quoted_freetext(void** state)
} }
void 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\""; char* inp = "/group add friends \"The User\"";
gboolean result = FALSE; gboolean result = FALSE;
@@ -359,7 +359,7 @@ parse_cmd_with_third_arg_quoted_0_min_3_max(void** state)
} }
void 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"; char* inp = "/group add \"The Group\" friend";
gboolean result = FALSE; gboolean result = FALSE;
@@ -375,7 +375,7 @@ parse_cmd_with_second_arg_quoted_0_min_3_max(void** state)
} }
void 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\""; char* inp = "/group add \"The Group\" \"The User\"";
gboolean result = FALSE; gboolean result = FALSE;
@@ -391,7 +391,7 @@ parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void** state)
} }
void void
count_one_token(void** state) count_tokens__returns__one_token(void** state)
{ {
char* inp = "one"; char* inp = "one";
int result = count_tokens(inp); int result = count_tokens(inp);
@@ -400,7 +400,7 @@ count_one_token(void** state)
} }
void void
count_one_token_quoted_no_whitespace(void** state) count_tokens__returns__one_token_quoted_no_whitespace(void** state)
{ {
char* inp = "\"one\""; char* inp = "\"one\"";
int result = count_tokens(inp); int result = count_tokens(inp);
@@ -409,7 +409,7 @@ count_one_token_quoted_no_whitespace(void** state)
} }
void void
count_one_token_quoted_with_whitespace(void** state) count_tokens__returns__one_token_quoted_with_whitespace(void** state)
{ {
char* inp = "\"one two\""; char* inp = "\"one two\"";
int result = count_tokens(inp); int result = count_tokens(inp);
@@ -418,7 +418,7 @@ count_one_token_quoted_with_whitespace(void** state)
} }
void void
count_two_tokens(void** state) count_tokens__returns__two_tokens(void** state)
{ {
char* inp = "one two"; char* inp = "one two";
int result = count_tokens(inp); int result = count_tokens(inp);
@@ -427,7 +427,7 @@ count_two_tokens(void** state)
} }
void void
count_two_tokens_first_quoted(void** state) count_tokens__returns__two_tokens_first_quoted(void** state)
{ {
char* inp = "\"one and\" two"; char* inp = "\"one and\" two";
int result = count_tokens(inp); int result = count_tokens(inp);
@@ -436,7 +436,7 @@ count_two_tokens_first_quoted(void** state)
} }
void void
count_two_tokens_second_quoted(void** state) count_tokens__returns__two_tokens_second_quoted(void** state)
{ {
char* inp = "one \"two and\""; char* inp = "one \"two and\"";
int result = count_tokens(inp); int result = count_tokens(inp);
@@ -445,7 +445,7 @@ count_two_tokens_second_quoted(void** state)
} }
void void
count_two_tokens_both_quoted(void** state) count_tokens__returns__two_tokens_both_quoted(void** state)
{ {
char* inp = "\"one and then\" \"two and\""; char* inp = "\"one and then\" \"two and\"";
int result = count_tokens(inp); int result = count_tokens(inp);
@@ -454,7 +454,7 @@ count_two_tokens_both_quoted(void** state)
} }
void void
get_first_of_one(void** state) get_start__returns__first_of_one(void** state)
{ {
char* inp = "one"; char* inp = "one";
char* result = get_start(inp, 2); char* result = get_start(inp, 2);
@@ -464,7 +464,7 @@ get_first_of_one(void** state)
} }
void void
get_first_of_two(void** state) get_start__returns__first_of_two(void** state)
{ {
char* inp = "one two"; char* inp = "one two";
char* result = get_start(inp, 2); char* result = get_start(inp, 2);
@@ -474,7 +474,7 @@ get_first_of_two(void** state)
} }
void void
get_first_two_of_three(void** state) get_start__returns__first_two_of_three(void** state)
{ {
char* inp = "one two three"; char* inp = "one two three";
char* result = get_start(inp, 3); char* result = get_start(inp, 3);
@@ -484,7 +484,7 @@ get_first_two_of_three(void** state)
} }
void 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* inp = "\"one\" two three";
char* result = get_start(inp, 3); char* result = get_start(inp, 3);
@@ -494,7 +494,7 @@ get_first_two_of_three_first_quoted(void** state)
} }
void 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* inp = "one \"two\" three";
char* result = get_start(inp, 3); char* result = get_start(inp, 3);
@@ -504,7 +504,7 @@ get_first_two_of_three_second_quoted(void** state)
} }
void 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* inp = "\"one\" \"two\" three";
char* result = get_start(inp, 3); char* result = get_start(inp, 3);
@@ -514,7 +514,7 @@ get_first_two_of_three_first_and_second_quoted(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", NULL };
gchar* keys[] = { "opt1", NULL }; gchar* keys[] = { "opt1", NULL };
@@ -531,7 +531,7 @@ parse_options_when_none_returns_empty_hasmap(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", "opt1", NULL };
gchar* keys[] = { "opt1", NULL }; gchar* keys[] = { "opt1", NULL };
@@ -547,7 +547,7 @@ parse_options_when_opt1_no_val_sets_error(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", "opt1", "val1", NULL };
gchar* keys[] = { "opt1", NULL }; gchar* keys[] = { "opt1", NULL };
@@ -565,7 +565,7 @@ parse_options_when_one_returns_map(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", NULL };
gchar* keys[] = { "opt1", "opt2", NULL }; gchar* keys[] = { "opt1", "opt2", NULL };
@@ -581,7 +581,7 @@ parse_options_when_opt2_no_val_sets_error(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", NULL };
gchar* keys[] = { "opt1", "opt2", NULL }; gchar* keys[] = { "opt1", "opt2", NULL };
@@ -601,7 +601,7 @@ parse_options_when_two_returns_map(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", NULL };
gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gchar* keys[] = { "opt1", "opt2", "opt3", NULL };
@@ -617,7 +617,7 @@ parse_options_when_opt3_no_val_sets_error(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", "val3", NULL };
gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gchar* keys[] = { "opt1", "opt2", "opt3", NULL };
@@ -639,7 +639,7 @@ parse_options_when_three_returns_map(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", "opt1", "val1", "oops", "val2", "opt3", "val3", NULL };
gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gchar* keys[] = { "opt1", "opt2", "opt3", NULL };
@@ -655,7 +655,7 @@ parse_options_when_unknown_opt_sets_error(void** state)
} }
void 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* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt1", "val3", NULL };
gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gchar* keys[] = { "opt1", "opt2", "opt3", NULL };

View File

@@ -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

View File

@@ -12,7 +12,8 @@ static char line[INP_WIN_MAX];
// append // append
void append_to_empty(void **state) void
key_printable__updates__append_to_empty(void** state)
{ {
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
line[0] = '\0'; line[0] = '\0';
@@ -28,7 +29,8 @@ void append_to_empty(void **state)
assert_int_equal(pad_start, 0); 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, ""); setlocale(LC_ALL, "");
line[0] = '\0'; line[0] = '\0';
@@ -44,7 +46,8 @@ void append_wide_to_empty(void **state)
assert_int_equal(pad_start, 0); assert_int_equal(pad_start, 0);
} }
void append_to_single(void **state) void
key_printable__updates__append_to_single(void** state)
{ {
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "a", 1); g_utf8_strncpy(line, "a", 1);
@@ -61,8 +64,8 @@ void append_to_single(void **state)
assert_int_equal(pad_start, 0); assert_int_equal(pad_start, 0);
} }
void
void append_wide_to_single_non_wide(void **state) key_printable__updates__append_wide_to_single_non_wide(void** state)
{ {
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "a", 1); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "", 1); g_utf8_strncpy(line, "", 1);
@@ -96,7 +100,8 @@ void append_non_wide_to_single_wide(void **state)
assert_int_equal(pad_start, 0); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "", 1); g_utf8_strncpy(line, "", 1);
@@ -113,7 +118,8 @@ void append_wide_to_single_wide(void **state)
assert_int_equal(pad_start, 0); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "0123456789四1234567", 18); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd", 4); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "AAAAAAAAAAAAAAA", 15); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "AAAAAAAAAAAAAAA", 15); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcdefghijklmno", 15); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcdefghijklmno", 15); 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); 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, ""); setlocale(LC_ALL, "");
line[0] = '\0'; line[0] = '\0';
@@ -235,7 +247,8 @@ void ctrl_left_when_no_input(void **state)
assert_int_equal(pad_start, 0); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "abcd efghij klmn opqr", 21); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, " ", 7); g_utf8_strncpy(line, " ", 7);
@@ -443,7 +468,8 @@ void ctrl_left_when_in_only_whitespace(void **state)
assert_int_equal(pad_start, 0); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, " hello", 9); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, " hello", 9); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "hey hello", 12); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "hey hello", 12); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "hey hello", 12); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword anotherword", 20); 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); 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, ""); setlocale(LC_ALL, "");
line[0] = '\0'; line[0] = '\0';
@@ -554,7 +586,8 @@ void ctrl_right_when_no_input(void **state)
assert_int_equal(pad_start, 0); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword anotherword", 20); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword", 8); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword", 8); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword", 8); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword anotherword", 20); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword anotherword", 20); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword anotherword", 20); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword anotherword", 20); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, " someword", 15); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, " someword adfasdf", 30); 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); 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, ""); setlocale(LC_ALL, "");
g_utf8_strncpy(line, "someword ", 16); g_utf8_strncpy(line, "someword ", 16);

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -5,14 +5,14 @@
#include "xmpp/chat_session.h" #include "xmpp/chat_session.h"
void 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"); ChatSession* session = chat_session_get("somejid@server.org");
assert_null(session); assert_null(session);
} }
void void
creates_chat_session_on_recipient_activity(void** state) chat_session_recipient_active__updates__new_session(void** state)
{ {
char* barejid = "myjid@server.org"; char* barejid = "myjid@server.org";
char* resource = "tablet"; char* resource = "tablet";
@@ -25,7 +25,7 @@ creates_chat_session_on_recipient_activity(void** state)
} }
void 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* barejid = "myjid@server.org";
char* resource1 = "tablet"; char* resource1 = "tablet";
@@ -39,7 +39,7 @@ replaces_chat_session_on_recipient_activity_with_different_resource(void** state
} }
void void
removes_chat_session(void** state) chat_session_remove__updates__session_removed(void** state)
{ {
char* barejid = "myjid@server.org"; char* barejid = "myjid@server.org";
char* resource1 = "laptop"; char* resource1 = "laptop";

View File

@@ -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

View File

@@ -6,7 +6,7 @@
#include "xmpp/contact.h" #include "xmpp/contact.h"
void void
contact_in_group(void** state) p_contact_in_group__is__true_when_in_group(void** state)
{ {
GSList* groups = NULL; GSList* groups = NULL;
groups = g_slist_append(groups, g_strdup("somegroup")); groups = g_slist_append(groups, g_strdup("somegroup"));
@@ -22,7 +22,7 @@ contact_in_group(void** state)
} }
void void
contact_not_in_group(void** state) p_contact_in_group__is__false_when_not_in_group(void** state)
{ {
GSList* groups = NULL; GSList* groups = NULL;
groups = g_slist_append(groups, g_strdup("somegroup")); groups = g_slist_append(groups, g_strdup("somegroup"));
@@ -38,7 +38,7 @@ contact_not_in_group(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -51,7 +51,7 @@ contact_name_when_name_exists(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", NULL, NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -64,7 +64,7 @@ contact_jid_when_name_not_exists(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -78,7 +78,7 @@ contact_string_when_name_exists(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", NULL, NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -92,7 +92,7 @@ contact_string_when_name_not_exists(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -106,7 +106,7 @@ contact_string_when_default_resource(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -119,7 +119,7 @@ contact_presence_offline(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -143,7 +143,7 @@ contact_presence_uses_highest_priority(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -167,7 +167,7 @@ contact_presence_chat_when_same_prioroty(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -189,7 +189,7 @@ contact_presence_online_when_same_prioroty(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -209,7 +209,7 @@ contact_presence_away_when_same_prioroty(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -227,7 +227,7 @@ contact_presence_xa_when_same_prioroty(void** state)
} }
void void
contact_presence_dnd(void** state) p_contact_presence__returns__dnd(void** state)
{ {
PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -243,7 +243,7 @@ contact_presence_dnd(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "to",
"is offline", FALSE); "is offline", FALSE);
@@ -256,7 +256,7 @@ contact_subscribed_when_to(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both",
"is offline", FALSE); "is offline", FALSE);
@@ -269,7 +269,7 @@ contact_subscribed_when_both(void** state)
} }
void 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", PContact contact = p_contact_new("bob@server.com", "bob", NULL, "from",
"is offline", FALSE); "is offline", FALSE);
@@ -282,7 +282,7 @@ contact_not_subscribed_when_from(void** state)
} }
void 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, PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL,
"is offline", FALSE); "is offline", FALSE);
@@ -295,7 +295,7 @@ contact_not_subscribed_when_no_subscription_value(void** state)
} }
void 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, PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL,
"is offline", FALSE); "is offline", FALSE);
@@ -308,7 +308,7 @@ contact_not_available(void** state)
} }
void 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, PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL,
"is offline", FALSE); "is offline", FALSE);
@@ -332,7 +332,7 @@ contact_not_available_when_highest_priority_away(void** state)
} }
void 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, PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL,
"is offline", FALSE); "is offline", FALSE);
@@ -356,7 +356,7 @@ contact_not_available_when_highest_priority_xa(void** state)
} }
void 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, PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL,
"is offline", FALSE); "is offline", FALSE);
@@ -380,7 +380,7 @@ contact_not_available_when_highest_priority_dnd(void** state)
} }
void 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, PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL,
"is offline", FALSE); "is offline", FALSE);
@@ -404,7 +404,7 @@ contact_available_when_highest_priority_online(void** state)
} }
void 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, PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL,
"is offline", FALSE); "is offline", FALSE);

View File

@@ -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

View File

@@ -42,7 +42,7 @@ _new_field(void)
} }
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(); DataForm* form = _new_form();
@@ -54,7 +54,7 @@ get_form_type_field_returns_null_no_fields(void** state)
} }
void 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(); DataForm* form = _new_form();
FormField* field = _new_field(); FormField* field = _new_field();
@@ -70,7 +70,7 @@ get_form_type_field_returns_null_when_not_present(void** state)
} }
void 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(); DataForm* form = _new_form();
@@ -97,7 +97,7 @@ get_form_type_field_returns_value_when_present(void** state)
} }
void 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(); DataForm* form = _new_form();
@@ -109,7 +109,7 @@ get_field_type_returns_unknown_when_no_fields(void** state)
} }
void void
get_field_type_returns_correct_type(void** state) form_get_field_type__returns__correct_type(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
set_value_adds_when_none(void** state) form_set_value__updates__adds_when_none(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
set_value_updates_when_one(void** state) form_set_value__updates__updates_when_one(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
add_unique_value_adds_when_none(void** state) form_add_unique_value__updates__adds_when_none(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 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(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 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(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
add_value_adds_when_none(void** state) form_add_value__updates__adds_when_none(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
add_value_adds_when_some(void** state) form_add_value__updates__adds_when_some(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
add_value_adds_when_exists(void** state) form_add_value__updates__adds_when_exists(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
remove_value_does_nothing_when_none(void** state) form_remove_value__updates__does_nothing_when_none(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 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(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
remove_value_removes_when_one(void** state) form_remove_value__updates__removes_when_one(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 void
remove_value_removes_when_many(void** state) form_remove_value__updates__removes_when_many(void** state)
{ {
DataForm* form = _new_form(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 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(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 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(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 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(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); 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 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(); DataForm* form = _new_form();
g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1")); g_hash_table_insert(form->tag_to_var, g_strdup("tag1"), g_strdup("var1"));

View File

@@ -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

View File

@@ -4,21 +4,21 @@
#include "xmpp/jid.h" #include "xmpp/jid.h"
void void
create_jid_from_null_returns_null(void** state) jid_create__returns__null_from_null(void** state)
{ {
Jid* result = jid_create(NULL); Jid* result = jid_create(NULL);
assert_null(result); assert_null(result);
} }
void void
create_jid_from_empty_string_returns_null(void** state) jid_create__returns__null_from_empty_string(void** state)
{ {
Jid* result = jid_create(""); Jid* result = jid_create("");
assert_null(result); assert_null(result);
} }
void void
create_jid_from_full_returns_full(void** state) jid_create__returns__full_from_full(void** state)
{ {
Jid* result = jid_create("myuser@mydomain/laptop"); Jid* result = jid_create("myuser@mydomain/laptop");
assert_string_equal("myuser@mydomain/laptop", result->fulljid); assert_string_equal("myuser@mydomain/laptop", result->fulljid);
@@ -26,7 +26,7 @@ create_jid_from_full_returns_full(void** state)
} }
void void
create_jid_from_full_returns_bare(void** state) jid_create__returns__bare_from_full(void** state)
{ {
Jid* result = jid_create("myuser@mydomain/laptop"); Jid* result = jid_create("myuser@mydomain/laptop");
assert_string_equal("myuser@mydomain", result->barejid); assert_string_equal("myuser@mydomain", result->barejid);
@@ -34,7 +34,7 @@ create_jid_from_full_returns_bare(void** state)
} }
void void
create_jid_from_full_returns_resourcepart(void** state) jid_create__returns__resourcepart_from_full(void** state)
{ {
Jid* result = jid_create("myuser@mydomain/laptop"); Jid* result = jid_create("myuser@mydomain/laptop");
assert_string_equal("laptop", result->resourcepart); assert_string_equal("laptop", result->resourcepart);
@@ -42,7 +42,7 @@ create_jid_from_full_returns_resourcepart(void** state)
} }
void void
create_jid_from_full_returns_localpart(void** state) jid_create__returns__localpart_from_full(void** state)
{ {
Jid* result = jid_create("myuser@mydomain/laptop"); Jid* result = jid_create("myuser@mydomain/laptop");
assert_string_equal("myuser", result->localpart); assert_string_equal("myuser", result->localpart);
@@ -50,7 +50,7 @@ create_jid_from_full_returns_localpart(void** state)
} }
void void
create_jid_from_full_returns_domainpart(void** state) jid_create__returns__domainpart_from_full(void** state)
{ {
Jid* result = jid_create("myuser@mydomain/laptop"); Jid* result = jid_create("myuser@mydomain/laptop");
assert_string_equal("mydomain", result->domainpart); assert_string_equal("mydomain", result->domainpart);
@@ -58,7 +58,7 @@ create_jid_from_full_returns_domainpart(void** state)
} }
void 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"); Jid* result = jid_create("mydomain/laptop");
assert_string_equal("mydomain/laptop", result->fulljid); assert_string_equal("mydomain/laptop", result->fulljid);
@@ -66,7 +66,7 @@ create_jid_from_full_nolocal_returns_full(void** state)
} }
void 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"); Jid* result = jid_create("mydomain/laptop");
assert_string_equal("mydomain", result->barejid); assert_string_equal("mydomain", result->barejid);
@@ -74,7 +74,7 @@ create_jid_from_full_nolocal_returns_bare(void** state)
} }
void 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"); Jid* result = jid_create("mydomain/laptop");
assert_string_equal("laptop", result->resourcepart); assert_string_equal("laptop", result->resourcepart);
@@ -82,7 +82,7 @@ create_jid_from_full_nolocal_returns_resourcepart(void** state)
} }
void 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"); Jid* result = jid_create("mydomain/laptop");
assert_string_equal("mydomain", result->domainpart); assert_string_equal("mydomain", result->domainpart);
@@ -90,7 +90,7 @@ create_jid_from_full_nolocal_returns_domainpart(void** state)
} }
void 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"); Jid* result = jid_create("mydomain/laptop");
assert_null(result->localpart); assert_null(result->localpart);
@@ -98,7 +98,7 @@ create_jid_from_full_nolocal_returns_null_localpart(void** state)
} }
void 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"); Jid* result = jid_create("myuser@mydomain");
assert_null(result->fulljid); assert_null(result->fulljid);
@@ -106,7 +106,7 @@ create_jid_from_bare_returns_null_full(void** state)
} }
void 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"); Jid* result = jid_create("myuser@mydomain");
assert_null(result->resourcepart); assert_null(result->resourcepart);
@@ -114,7 +114,7 @@ create_jid_from_bare_returns_null_resource(void** state)
} }
void void
create_jid_from_bare_returns_bare(void** state) jid_create__returns__bare_from_bare(void** state)
{ {
Jid* result = jid_create("myuser@mydomain"); Jid* result = jid_create("myuser@mydomain");
assert_string_equal("myuser@mydomain", result->barejid); assert_string_equal("myuser@mydomain", result->barejid);
@@ -122,7 +122,7 @@ create_jid_from_bare_returns_bare(void** state)
} }
void void
create_jid_from_bare_returns_localpart(void** state) jid_create__returns__localpart_from_bare(void** state)
{ {
Jid* result = jid_create("myuser@mydomain"); Jid* result = jid_create("myuser@mydomain");
assert_string_equal("myuser", result->localpart); assert_string_equal("myuser", result->localpart);
@@ -130,7 +130,7 @@ create_jid_from_bare_returns_localpart(void** state)
} }
void void
create_jid_from_bare_returns_domainpart(void** state) jid_create__returns__domainpart_from_bare(void** state)
{ {
Jid* result = jid_create("myuser@mydomain"); Jid* result = jid_create("myuser@mydomain");
assert_string_equal("mydomain", result->domainpart); assert_string_equal("mydomain", result->domainpart);
@@ -138,7 +138,7 @@ create_jid_from_bare_returns_domainpart(void** state)
} }
void 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"); 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 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"); 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 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"); Jid* result = jid_create("room@conference.domain.org/my/nick");
@@ -170,7 +170,7 @@ create_with_slash_in_resource(void** state)
} }
void 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"); Jid* result = jid_create("room@conference.domain.org/my@nick");
@@ -184,7 +184,7 @@ create_with_at_in_resource(void** state)
} }
void 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"); 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 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/"); Jid* result = jid_create("room@conference.domain.org/nick/");
@@ -212,7 +212,7 @@ create_full_with_trailing_slash(void** state)
} }
void void
returns_fulljid_when_exists(void** state) jid_fulljid_or_barejid__returns__fulljid_when_exists(void** state)
{ {
Jid* jid = jid_create("localpart@domainpart/resourcepart"); Jid* jid = jid_create("localpart@domainpart/resourcepart");
@@ -224,7 +224,7 @@ returns_fulljid_when_exists(void** state)
} }
void 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"); Jid* jid = jid_create("localpart@domainpart");

View File

@@ -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

View File

@@ -20,7 +20,7 @@ muc_after_test(void** state)
} }
void void
test_muc_invites_add(void** state) muc_invites_add__updates__invites_list(void** state)
{ {
char* room = "room@conf.server"; char* room = "room@conf.server";
muc_invites_add(room, NULL); muc_invites_add(room, NULL);
@@ -31,7 +31,7 @@ test_muc_invites_add(void** state)
} }
void void
test_muc_remove_invite(void** state) muc_invites_remove__updates__invites_list(void** state)
{ {
char* room = "room@conf.server"; char* room = "room@conf.server";
muc_invites_add(room, NULL); muc_invites_add(room, NULL);
@@ -43,7 +43,7 @@ test_muc_remove_invite(void** state)
} }
void void
test_muc_invites_count_0(void** state) muc_invites_count__returns__0_when_no_invites(void** state)
{ {
int invite_count = muc_invites_count(); int invite_count = muc_invites_count();
@@ -51,7 +51,7 @@ test_muc_invites_count_0(void** state)
} }
void 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("room1@conf.server", NULL);
muc_invites_add("room2@conf.server", NULL); muc_invites_add("room2@conf.server", NULL);
@@ -65,7 +65,7 @@ test_muc_invites_count_5(void** state)
} }
void void
test_muc_room_is_not_active(void** state) muc_active__is__false_when_not_joined(void** state)
{ {
char* room = "room@server.org"; char* room = "room@server.org";
@@ -75,7 +75,7 @@ test_muc_room_is_not_active(void** state)
} }
void void
test_muc_active(void** state) muc_active__is__true_when_joined(void** state)
{ {
char* room = "room@server.org"; char* room = "room@server.org";
char* nick = "bob"; char* nick = "bob";

View File

@@ -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

View File

@@ -7,7 +7,7 @@
#include "xmpp/roster_list.h" #include "xmpp/roster_list.h"
void void
empty_list_when_none_added(void** state) roster_get_contacts__returns__empty_list_when_none_added(void** state)
{ {
roster_create(); roster_create();
GSList* list = roster_get_contacts(ROSTER_ORD_NAME); GSList* list = roster_get_contacts(ROSTER_ORD_NAME);
@@ -18,7 +18,7 @@ empty_list_when_none_added(void** state)
} }
void void
contains_one_element(void** state) roster_get_contacts__returns__one_element(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -30,7 +30,7 @@ contains_one_element(void** state)
} }
void void
first_element_correct(void** state) roster_get_contacts__returns__correct_first_element(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -44,7 +44,7 @@ first_element_correct(void** state)
} }
void void
contains_two_elements(void** state) roster_get_contacts__returns__two_elements(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -58,7 +58,7 @@ contains_two_elements(void** state)
} }
void void
first_and_second_elements_correct(void** state) roster_get_contacts__returns__correct_first_and_second_elements(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -76,7 +76,7 @@ first_and_second_elements_correct(void** state)
} }
void void
contains_three_elements(void** state) roster_get_contacts__returns__three_elements(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -91,7 +91,7 @@ contains_three_elements(void** state)
} }
void void
first_three_elements_correct(void** state) roster_get_contacts__returns__correct_first_three_elements(void** state)
{ {
roster_create(); roster_create();
roster_add("Bob", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE);
@@ -111,7 +111,7 @@ first_three_elements_correct(void** state)
} }
void void
add_twice_at_beginning_adds_once(void** state) roster_add__updates__adds_once_when_called_twice_at_beginning(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -133,7 +133,7 @@ add_twice_at_beginning_adds_once(void** state)
} }
void void
add_twice_in_middle_adds_once(void** state) roster_add__updates__adds_once_when_called_twice_in_middle(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -155,7 +155,7 @@ add_twice_in_middle_adds_once(void** state)
} }
void void
add_twice_at_end_adds_once(void** state) roster_add__updates__adds_once_when_called_twice_at_end(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -177,7 +177,7 @@ add_twice_at_end_adds_once(void** state)
} }
void void
find_first_exists(void** state) roster_contact_autocomplete__returns__first_exists(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -194,7 +194,7 @@ find_first_exists(void** state)
} }
void void
find_second_exists(void** state) roster_contact_autocomplete__returns__second_exists(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -208,7 +208,7 @@ find_second_exists(void** state)
} }
void void
find_third_exists(void** state) roster_contact_autocomplete__returns__third_exists(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -222,7 +222,7 @@ find_third_exists(void** state)
} }
void void
find_returns_null(void** state) roster_contact_autocomplete__returns__null_when_no_match(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -235,7 +235,7 @@ find_returns_null(void** state)
} }
void void
find_on_empty_returns_null(void** state) roster_contact_autocomplete__returns__null_on_empty_roster(void** state)
{ {
roster_create(); roster_create();
char* result = roster_contact_autocomplete("James", FALSE, NULL); char* result = roster_contact_autocomplete("James", FALSE, NULL);
@@ -244,7 +244,7 @@ find_on_empty_returns_null(void** state)
} }
void void
find_twice_returns_second_when_two_match(void** state) roster_contact_autocomplete__returns__second_when_two_match(void** state)
{ {
roster_create(); roster_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -260,7 +260,7 @@ find_twice_returns_second_when_two_match(void** state)
} }
void void
find_five_times_finds_fifth(void** state) roster_contact_autocomplete__returns__fifth_when_multiple_match(void** state)
{ {
roster_create(); roster_create();
roster_add("Jama", NULL, NULL, NULL, FALSE); roster_add("Jama", NULL, NULL, NULL, FALSE);
@@ -289,7 +289,7 @@ find_five_times_finds_fifth(void** state)
} }
void 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_create();
roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE);
@@ -306,7 +306,7 @@ find_twice_returns_first_when_two_match_and_reset(void** state)
} }
void void
add_contact_with_no_group(void** state) roster_get_groups__returns__empty_for_no_group(void** state)
{ {
roster_create(); roster_create();
roster_add("person@server.org", NULL, NULL, NULL, FALSE); roster_add("person@server.org", NULL, NULL, NULL, FALSE);
@@ -319,7 +319,7 @@ add_contact_with_no_group(void** state)
} }
void void
add_contact_with_group(void** state) roster_get_groups__returns__one_group(void** state)
{ {
roster_create(); roster_create();
@@ -339,7 +339,7 @@ add_contact_with_group(void** state)
} }
void void
add_contact_with_two_groups(void** state) roster_get_groups__returns__two_groups(void** state)
{ {
roster_create(); roster_create();
@@ -363,7 +363,7 @@ add_contact_with_two_groups(void** state)
} }
void void
add_contact_with_three_groups(void** state) roster_get_groups__returns__three_groups(void** state)
{ {
roster_create(); roster_create();
@@ -391,7 +391,7 @@ add_contact_with_three_groups(void** state)
} }
void void
add_contact_with_three_groups_update_adding_two(void** state) roster_update__updates__adding_two_groups(void** state)
{ {
roster_create(); roster_create();
@@ -433,7 +433,7 @@ add_contact_with_three_groups_update_adding_two(void** state)
} }
void void
add_contact_with_three_groups_update_removing_one(void** state) roster_update__updates__removing_one_group(void** state)
{ {
roster_create(); roster_create();
@@ -463,7 +463,7 @@ add_contact_with_three_groups_update_removing_one(void** state)
} }
void void
add_contact_with_three_groups_update_removing_two(void** state) roster_update__updates__removing_two_groups(void** state)
{ {
roster_create(); roster_create();
@@ -489,7 +489,7 @@ add_contact_with_three_groups_update_removing_two(void** state)
} }
void void
add_contact_with_three_groups_update_removing_three(void** state) roster_update__updates__removing_three_groups(void** state)
{ {
roster_create(); roster_create();
@@ -509,7 +509,7 @@ add_contact_with_three_groups_update_removing_three(void** state)
} }
void void
add_contact_with_three_groups_update_two_new(void** state) roster_update__updates__two_new_groups(void** state)
{ {
roster_create(); roster_create();
@@ -537,7 +537,7 @@ add_contact_with_three_groups_update_two_new(void** state)
} }
void void
add_remove_contact_groups(void** state) roster_remove__updates__contact_groups(void** state)
{ {
roster_create(); roster_create();
@@ -557,7 +557,7 @@ add_remove_contact_groups(void** state)
} }
void void
add_contacts_with_different_groups(void** state) roster_add__updates__different_groups(void** state)
{ {
roster_create(); roster_create();
@@ -591,7 +591,7 @@ add_contacts_with_different_groups(void** state)
} }
void void
add_contacts_with_same_groups(void** state) roster_add__updates__same_groups(void** state)
{ {
roster_create(); roster_create();
@@ -622,7 +622,7 @@ add_contacts_with_same_groups(void** state)
} }
void void
add_contacts_with_overlapping_groups(void** state) roster_add__updates__overlapping_groups(void** state)
{ {
roster_create(); roster_create();
@@ -655,7 +655,7 @@ add_contacts_with_overlapping_groups(void** state)
} }
void void
remove_contact_with_remaining_in_group(void** state) roster_remove__updates__remaining_in_group(void** state)
{ {
roster_create(); roster_create();
@@ -688,7 +688,7 @@ remove_contact_with_remaining_in_group(void** state)
} }
void void
get_contact_display_name(void** state) roster_get_display_name__returns__nickname_when_exists(void** state)
{ {
roster_create(); roster_create();
roster_add("person@server.org", "nickname", NULL, NULL, FALSE); roster_add("person@server.org", "nickname", NULL, NULL, FALSE);
@@ -699,7 +699,7 @@ get_contact_display_name(void** state)
} }
void 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_create();
roster_add("person@server.org", NULL, NULL, NULL, FALSE); 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 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(); roster_create();

View File

@@ -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