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

View File

@@ -1,8 +1,42 @@
# Contributing to Profanity
## Build
Profanity can be built using either **Autotools** or **Meson**.
Please follow the [build section](https://profanity-im.github.io/guide/latest/build.html) in our user guide.
### Build Options
Both build systems support several features that can be enabled or disabled.
**Important Difference:**
- **Autotools**: Features are **auto-enabled** if the required dependencies are found on your system during the `./configure` step.
- **Meson**: Features must be **explicitly enabled**. Nothing is auto-enabled; if you want a feature, you must pass the corresponding `-Doption=enabled` flag.
| Feature | Description | Autotools flag | Meson option |
| :--- | :--- | :--- | :--- |
| **Notifications** | Desktop notifications support | `--enable-notifications` | `-Dnotifications=enabled` |
| **Python Plugins** | Support for Python plugins | `--enable-python-plugins` | `-Dpython-plugins=enabled` |
| **C Plugins** | Support for C plugins | `--enable-c-plugins` | `-Dc-plugins=enabled` |
| **OTR** | Off-the-Record encryption | `--enable-otr` | `-Dotr=enabled` |
| **PGP** | PGP encryption support | `--enable-pgp` | `-Dpgp=enabled` |
| **OMEMO** | OMEMO encryption support | `--enable-omemo` | `-Domemo=enabled` |
| **QR Code** | OMEMO QR code display | `--enable-omemo-qrcode` | `-Domemo-qrcode=enabled` |
| **Icons/Clipboard** | GTK tray icons & clipboard | `--enable-icons-and-clipboard` | `-Dicons-and-clipboard=enabled` |
| **GDK Pixbuf** | Avatar scaling support | `--enable-gdk-pixbuf` | `-Dgdk-pixbuf=enabled` |
| **XScreenSaver** | Idle time detection | `--with-xscreensaver` | `-Dxscreensaver=enabled` |
| **Tests** | Build unit tests | *Built by default* | `-Dtests=true` |
| **Sanitizers** | Run-time error detection | *Via CFLAGS* | `-Db_sanitize=address,undefined` |
### Using Autotools
1. Generate configuration files: `./bootstrap.sh`
2. Configure: `./configure --enable-otr --enable-omemo`
3. Build: `make`
4. Run: `./profanity`
### Using Meson
1. Setup build directory: `meson setup build_run -Domemo=enabled -Dotr=enabled`
2. Build: `meson compile -C build_run`
3. Run: `./build_run/profanity`
We also have a [build section](https://profanity-im.github.io/guide/latest/build.html) in our user guide.
You might also take a look at the `Dockerfile.*` in the root directory.
## Submitting patches
@@ -41,8 +75,9 @@ Then our team can easily request reviews. And we have the history of the review
If using GitHub is out of the question but you are okay using another service (i.e.: GitLab, codeberg) then please message us in the MUC or send us an email.
We will then pull from your repository and merge manually.
### Rules
## Rules & Guidelines
### Contribution Rules
* When fixing a bug, describe it and how your patch fixes it.
* When fixing a reported issue add an `Fixes https://github.com/profanity-im/profanity/issues/23` in the commit body.
* When adding a new feature add a description of the feature and how it should be used (workflow).
@@ -54,16 +89,16 @@ We will then pull from your repository and merge manually.
* Squash fixup commits into one
* If applicable, document how to test the functionality
## Hints and Pitfalls
### Hints and Pitfalls
* When adding a new hotkey/shortcut make sure it's not registered in Profanity already. And also that it's not a default shortcut of readline.
* We ship a `.git-blame-ignore-revs` file containing banal commits which you will most likely want to ignore when using `git blame`. In case you are using vim and [fugitive](https://github.com/tpope/vim-fugitive) `command Gblame Git blame --ignore-revs-file=.git-blame-ignore-revs` might be helpful in your vimrc. You can also set the `blame.ignoreRevsFile` option in your git config to have `git blame` generally ignore the listed commits.
## Coding style
## Coding Style
Follow the style already present ;-)
To make this easier for you we created a `.clang-format` file.
You'll need to have `clang-format` installed.
You'll need to have `clang-format` installed. We currently use **version 21**, which is also the version enforced by our CI in `.github/workflows/main.yml`.
Then just run `make format` before you do any commit.
@@ -98,14 +133,45 @@ and the `pre-push` hook will be skipped.
*Note:* We provide a config file that describes our coding style for clang. But due to a mistake on their side it might happen that you can get a different result that what we expect. See [here](https://github.com/profanity-im/profanity/pull/1774) and [here](https://github.com/profanity-im/profanity/pull/1828) for details. We will try to always run latest clang-format.
## Finding mistakes
Test your changes with the following tools to find mistakes.
In cases where you want to disable automatic formatting for a specific block of code (e.g. a complex lookup table), you can use the following comments:
```c
/* clang-format off */
// your code
/* clang-format on */
```
### unit tests
## Verification & Testing
### Running unit tests
Run `make check` to run the unit tests with your current configuration or `./ci-build.sh` to check with different switches passed to configure.
### valgrind
### Writing unit tests
We use the [cmocka](https://cmocka.org/) testing framework for unit tests.
Test files are located in `tests/unittests` and should mirror the directory structure of the `src/` directory. For example, if you are testing `src/xmpp/jid.c`, the corresponding test file should be `tests/unittests/xmpp/test_jid.c`.
#### Naming Convention
Test functions must follow a behavior-driven naming convention using double underscores (`__`) as semantic separators:
`[unit]__[verb]__[scenario]`
- **unit**: The name of the function or module being tested.
- **verb**: A descriptive verb of the outcome (`returns`, `is`, `updates`, `shows`, `triggers`, `fails`).
- **scenario**: The specific condition or input being tested.
Examples:
- `jid_create__returns__null_from_null`
- `p_contact_is_available__is__false_when_offline`
- `cmd_connect__shows__usage_when_no_server_value`
- `str_replace__returns__one_substr`
#### Adding a new test
When adding a new test file:
1. Create the `.c` and `.h` files in the appropriate subdirectory of `tests/unittests`.
2. Register the test functions in `tests/unittests/unittests.c` within the `all_tests` array.
3. Add the new source file to `unittest_sources` in both `meson.build` and `Makefile.am`.
### Valgrind
We provide a suppressions file `prof.supp`. It is a combination of the suppressions for shipped with glib2, python and custom rules.
`G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --track-origins=yes --leak-check=full --leak-resolution=high --num-callers=30 --show-leak-kinds=definite --log-file=profval --suppressions=prof.supp ./profanity`
@@ -116,8 +182,7 @@ There's also the option to create a "personalized" suppression file with the up-
After executing this, you can replace the `--suppressions=prof.supp` argument in the above call, by `--suppressions=my-prof.supp`.
### clang
### Clang Static Analyzer
Running the clang static code analyzer helps improving the quality too.
```
@@ -127,13 +192,39 @@ scan-view ...
```
### Finding typos
We include a `.codespellrc` configuration file for `codespell` in the root directory.
Before committing it might make sense to run `codespell` to see if you made any typos.
You can run the `make spell` command for this.
### Check everything
### Full check
Run the central quality check script before submitting a patch. This runs the spell checker, code formatter, and unit tests.
`make doublecheck` will run the code formatter, spell checker and unit tests.
If using Autotools:
```
make doublecheck
```
If using Meson:
```
meson compile doublecheck
```
*Note: The script expects the build directory to be named `build_run` as specified in the Meson build instructions above.*
Alternatively, you can run the script directly:
```
./scripts/quality-check.sh --fix-formatting --meson # or --autotools
```
### Pre-commit hook
It is highly recommended to install the quality check script as a git pre-commit hook. This will automatically check your staged changes for spelling and formatting issues every time you commit.
To install the hook:
```
./scripts/quality-check.sh --install
```
If you need to bypass the formatting check (e.g. due to a `clang-format` version mismatch), you can set the `SKIP_FORMAT` environment variable:
```
SKIP_FORMAT=1 git commit
```

View File

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

View File

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

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[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567
0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89:;<=>?
0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, // @ABCDEFG
0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00 // @ABCDEFG
};
const size_t ht_size = sizeof(ht);

View File

@@ -22,7 +22,9 @@
#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test)
int main(int argc, char* argv[]) {
int
main(int argc, char* argv[])
{
const struct CMUnitTest all_tests[] = {

View File

@@ -14,13 +14,13 @@
#include "proftest.h"
char *config_orig;
char *data_orig;
char* config_orig;
char* data_orig;
int fd = 0;
gboolean
_create_dir(const char *name)
_create_dir(const char* name)
{
struct stat sb;
@@ -38,14 +38,14 @@ _create_dir(const char *name)
}
gboolean
_mkdir_recursive(const char *dir)
_mkdir_recursive(const char* dir)
{
int i;
gboolean result = TRUE;
for (i = 1; i <= strlen(dir); i++) {
if (dir[i] == '/' || dir[i] == '\0') {
gchar *next_dir = g_strndup(dir, i);
gchar* next_dir = g_strndup(dir, i);
result = _create_dir(next_dir);
g_free(next_dir);
if (!result) {
@@ -60,7 +60,7 @@ _mkdir_recursive(const char *dir)
void
_create_config_dir(void)
{
GString *profanity_dir = g_string_new(XDG_CONFIG_HOME);
GString* profanity_dir = g_string_new(XDG_CONFIG_HOME);
g_string_append(profanity_dir, "/profanity");
if (!_mkdir_recursive(profanity_dir->str)) {
@@ -73,7 +73,7 @@ _create_config_dir(void)
void
_create_data_dir(void)
{
GString *profanity_dir = g_string_new(XDG_DATA_HOME);
GString* profanity_dir = g_string_new(XDG_DATA_HOME);
g_string_append(profanity_dir, "/profanity");
if (!_mkdir_recursive(profanity_dir->str)) {
@@ -86,7 +86,7 @@ _create_data_dir(void)
void
_create_chatlogs_dir(void)
{
GString *chatlogs_dir = g_string_new(XDG_DATA_HOME);
GString* chatlogs_dir = g_string_new(XDG_DATA_HOME);
g_string_append(chatlogs_dir, "/profanity/chatlogs");
if (!_mkdir_recursive(chatlogs_dir->str)) {
@@ -99,7 +99,7 @@ _create_chatlogs_dir(void)
void
_create_logs_dir(void)
{
GString *logs_dir = g_string_new(XDG_DATA_HOME);
GString* logs_dir = g_string_new(XDG_DATA_HOME);
g_string_append(logs_dir, "/profanity/logs");
if (!_mkdir_recursive(logs_dir->str)) {
@@ -124,21 +124,21 @@ prof_start(void)
// helper script sets terminal columns, avoids assertions failing
// based on the test runner terminal size
fd = exp_spawnl("sh",
"sh",
"-c",
"./tests/functionaltests/start_profanity.sh",
NULL);
FILE *fp = fdopen(fd, "r+");
"sh",
"-c",
"./tests/functionaltests/start_profanity.sh",
NULL);
FILE* fp = fdopen(fd, "r+");
assert_true(fp != NULL);
setbuf(fp, (char *)0);
setbuf(fp, (char*)0);
}
int
init_prof_test(void **state)
init_prof_test(void** state)
{
if (stbbr_start(STBBR_LOGDEBUG ,5230, 0) != 0) {
if (stbbr_start(STBBR_LOGDEBUG, 5230, 0) != 0) {
assert_true(FALSE);
return -1;
}
@@ -191,7 +191,7 @@ init_prof_test(void **state)
}
int
close_prof_test(void **state)
close_prof_test(void** state)
{
prof_input("/quit");
waitpid(exp_pid, NULL, 0);
@@ -205,48 +205,45 @@ close_prof_test(void **state)
}
void
prof_input(const char *input)
prof_input(const char* input)
{
GString *inp_str = g_string_new(input);
GString* inp_str = g_string_new(input);
g_string_append(inp_str, "\r");
write(fd, inp_str->str, inp_str->len);
g_string_free(inp_str, TRUE);
}
int
prof_output_exact(const char *text)
prof_output_exact(const char* text)
{
return (1 == exp_expectl(fd, exp_exact, text, 1, exp_end));
}
int
prof_output_regex(const char *text)
prof_output_regex(const char* text)
{
return (1 == exp_expectl(fd, exp_regexp, text, 1, exp_end));
}
void
prof_connect_with_roster(const char *roster)
prof_connect_with_roster(const char* roster)
{
GString *roster_str = g_string_new(
GString* roster_str = g_string_new(
"<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,
"</query>"
"</iq>"
);
"</query>"
"</iq>");
stbbr_for_query("jabber:iq:roster", roster_str->str);
g_string_free(roster_str, TRUE);
stbbr_for_id("prof_presence_1",
"<presence id='prof_presence_1' lang='en' to='stabber@localhost/profanity' from='stabber@localhost/profanity'>"
"<priority>0</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io/' ver='f8mrtdyAmhnj8Ca+630bThSL718='/>"
"</presence>"
);
"<presence id='prof_presence_1' lang='en' to='stabber@localhost/profanity' from='stabber@localhost/profanity'>"
"<priority>0</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io/' ver='f8mrtdyAmhnj8Ca+630bThSL718='/>"
"</presence>");
prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow");
prof_input("password");
@@ -275,6 +272,5 @@ prof_connect(void)
{
prof_connect_with_roster(
"<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

@@ -4,16 +4,16 @@
#define XDG_CONFIG_HOME "./tests/functionaltests/files/xdg_config_home"
#define XDG_DATA_HOME "./tests/functionaltests/files/xdg_data_home"
int init_prof_test(void **state);
int close_prof_test(void **state);
int init_prof_test(void** state);
int close_prof_test(void** state);
void prof_start(void);
void prof_connect(void);
void prof_connect_with_roster(const char *roster);
void prof_input(const char *input);
void prof_connect_with_roster(const char* roster);
void prof_input(const char* input);
int prof_output_exact(const char *text);
int prof_output_regex(const char *text);
int prof_output_exact(const char* text);
int prof_output_regex(const char* text);
void prof_timeout(int timeout);
void prof_timeout_reset(void);

View File

@@ -9,31 +9,29 @@
#include "proftest.h"
void
send_enable_carbons(void **state)
send_enable_carbons(void** state)
{
prof_connect();
prof_input("/carbons on");
assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
));
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
}
void
connect_with_carbons_enabled(void **state)
connect_with_carbons_enabled(void** state)
{
prof_input("/carbons on");
prof_connect();
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
send_disable_carbons(void **state)
send_disable_carbons(void** state)
{
prof_input("/carbons on");
@@ -42,106 +40,96 @@ send_disable_carbons(void **state)
prof_input("/carbons off");
assert_true(stbbr_received(
"<iq id='*' type='set'><disable xmlns='urn:xmpp:carbons:2'/></iq>"
));
"<iq id='*' type='set'><disable xmlns='urn:xmpp:carbons:2'/></iq>"));
}
void
receive_carbon(void **state)
receive_carbon(void** state)
{
prof_input("/carbons on");
prof_connect();
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(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1");
assert_true(prof_output_exact("unencrypted"));
stbbr_send(
"<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>"
"<received xmlns='urn:xmpp:carbons:2'>"
"<forwarded xmlns='urn:xmpp:forward:0'>"
"<message id='prof_msg_7' xmlns='jabber:client' type='chat' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<body>test carbon from recipient</body>"
"</message>"
"</forwarded>"
"</received>"
"<received xmlns='urn:xmpp:carbons:2'>"
"<forwarded xmlns='urn:xmpp:forward:0'>"
"<message id='prof_msg_7' xmlns='jabber:client' type='chat' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<body>test carbon from recipient</body>"
"</message>"
);
"</forwarded>"
"</received>"
"</message>");
assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient"));
}
void
receive_self_carbon(void **state)
receive_self_carbon(void** state)
{
prof_input("/carbons on");
prof_connect();
assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
));
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1");
assert_true(prof_output_exact("unencrypted"));
stbbr_send(
"<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>"
"<sent xmlns='urn:xmpp:carbons:2'>"
"<forwarded xmlns='urn:xmpp:forward:0'>"
"<message id='59' xmlns='jabber:client' type='chat' to='buddy1@localhost/mobile' lang='en' from='stabber@localhost/profanity'>"
"<body>self sent carbon</body>"
"</message>"
"</forwarded>"
"</sent>"
"<sent xmlns='urn:xmpp:carbons:2'>"
"<forwarded xmlns='urn:xmpp:forward:0'>"
"<message id='59' xmlns='jabber:client' type='chat' to='buddy1@localhost/mobile' lang='en' from='stabber@localhost/profanity'>"
"<body>self sent carbon</body>"
"</message>"
);
"</forwarded>"
"</sent>"
"</message>");
assert_true(prof_output_regex("me: .+self sent carbon"));
}
void
receive_private_carbon(void **state)
receive_private_carbon(void** state)
{
prof_input("/carbons on");
prof_connect();
assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
));
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1");
assert_true(prof_output_exact("unencrypted"));
stbbr_send(
"<message type='chat' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<body>Private carbon</body>"
"<private xmlns='urn:xmpp:carbons:2'/>"
"</message>"
);
"<body>Private carbon</body>"
"<private xmlns='urn:xmpp:carbons:2'/>"
"</message>");
assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon"));
}

View File

@@ -1,6 +1,6 @@
void send_enable_carbons(void **state);
void connect_with_carbons_enabled(void **state);
void send_disable_carbons(void **state);
void receive_carbon(void **state);
void receive_self_carbon(void **state);
void receive_private_carbon(void **state);
void send_enable_carbons(void** state);
void connect_with_carbons_enabled(void** state);
void send_disable_carbons(void** state);
void receive_carbon(void** state);
void receive_self_carbon(void** state);
void receive_private_carbon(void** state);

View File

@@ -9,7 +9,7 @@
#include "proftest.h"
void
sends_message_to_barejid_when_contact_offline(void **state)
sends_message_to_barejid_when_contact_offline(void** state)
{
prof_connect();
@@ -17,188 +17,166 @@ sends_message_to_barejid_when_contact_offline(void **state)
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost' type='chat'>"
"<body>Hi there</body>"
"</message>"
));
"<body>Hi there</body>"
"</message>"));
}
void
sends_message_to_barejid_when_contact_online(void **state)
sends_message_to_barejid_when_contact_online(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"</presence>"
);
"<priority>10</priority>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
prof_input("/msg buddy1@localhost Hi there");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost' type='chat'>"
"<body>Hi there</body>"
"</message>"
));
"<body>Hi there</body>"
"</message>"));
}
void
sends_message_to_fulljid_when_received_from_fulljid(void **state)
sends_message_to_fulljid_when_received_from_fulljid(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"</presence>"
);
"<priority>10</priority>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>First message</body>"
"</message>"
);
"<body>First message</body>"
"</message>");
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
prof_input("/msg buddy1@localhost Hi there");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Hi there</body>"
"</message>"
));
"<body>Hi there</body>"
"</message>"));
}
void
sends_subsequent_messages_to_fulljid(void **state)
sends_subsequent_messages_to_fulljid(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"</presence>"
);
"<priority>10</priority>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>First message</body>"
"</message>"
);
"<body>First message</body>"
"</message>");
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
prof_input("/msg buddy1@localhost Outgoing 1");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 1</body>"
"</message>"
));
"<body>Outgoing 1</body>"
"</message>"));
prof_input("/msg buddy1@localhost Outgoing 2");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 2</body>"
"</message>"
));
"<body>Outgoing 2</body>"
"</message>"));
prof_input("/msg buddy1@localhost Outgoing 3");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 3</body>"
"</message>"
));
"<body>Outgoing 3</body>"
"</message>"));
}
void
resets_to_barejid_after_presence_received(void **state)
resets_to_barejid_after_presence_received(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"</presence>"
);
"<priority>10</priority>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>First message</body>"
"</message>"
);
"<body>First message</body>"
"</message>");
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
prof_input("/msg buddy1@localhost Outgoing 1");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 1</body>"
"</message>"
));
"<body>Outgoing 1</body>"
"</message>"));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<priority>5</priority>"
"<show>dnd</show>"
"</presence>"
);
"<priority>5</priority>"
"<show>dnd</show>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (laptop) is dnd"));
prof_input("/msg buddy1@localhost Outgoing 2");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost' type='chat'>"
"<body>Outgoing 2</body>"
"</message>"
));
"<body>Outgoing 2</body>"
"</message>"));
}
void
new_session_when_message_received_from_different_fulljid(void **state)
new_session_when_message_received_from_different_fulljid(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"</presence>"
);
"<priority>10</priority>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<priority>8</priority>"
"<show>away</show>"
"</presence>"
);
"<priority>8</priority>"
"<show>away</show>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (laptop) is away"));
stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>From first resource</body>"
"</message>"
);
"<body>From first resource</body>"
"</message>");
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
prof_input("/msg buddy1@localhost Outgoing 1");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
"<body>Outgoing 1</body>"
"</message>"
));
"<body>Outgoing 1</body>"
"</message>"));
stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/laptop' type='chat'>"
"<body>From second resource</body>"
"</message>"
);
"<body>From second resource</body>"
"</message>");
assert_true(prof_output_regex("Buddy1/laptop:.+From second resource"));
prof_input("/msg buddy1@localhost Outgoing 2");
assert_true(stbbr_received(
"<message id='*' to='buddy1@localhost/laptop' type='chat'>"
"<body>Outgoing 2</body>"
"</message>"
));
"<body>Outgoing 2</body>"
"</message>"));
}

View File

@@ -1,6 +1,6 @@
void sends_message_to_barejid_when_contact_offline(void **state);
void sends_message_to_barejid_when_contact_online(void **state);
void sends_message_to_fulljid_when_received_from_fulljid(void **state);
void sends_subsequent_messages_to_fulljid(void **state);
void resets_to_barejid_after_presence_received(void **state);
void new_session_when_message_received_from_different_fulljid(void **state);
void sends_message_to_barejid_when_contact_offline(void** state);
void sends_message_to_barejid_when_contact_online(void** state);
void sends_message_to_fulljid_when_received_from_fulljid(void** state);
void sends_subsequent_messages_to_fulljid(void** state);
void resets_to_barejid_after_presence_received(void** state);
void new_session_when_message_received_from_different_fulljid(void** state);

View File

@@ -9,43 +9,40 @@
#include "proftest.h"
void
connect_jid_requests_roster(void **state)
connect_jid_requests_roster(void** state)
{
prof_connect();
assert_true(stbbr_received(
"<iq id='*' type='get'><query xmlns='jabber:iq:roster'/></iq>"
));
"<iq id='*' type='get'><query xmlns='jabber:iq:roster'/></iq>"));
}
void
connect_jid_sends_presence_after_receiving_roster(void **state)
connect_jid_sends_presence_after_receiving_roster(void** state)
{
prof_connect();
assert_true(stbbr_received(
"<presence id='*'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
}
void
connect_jid_requests_bookmarks(void **state)
connect_jid_requests_bookmarks(void** state)
{
prof_connect();
assert_true(stbbr_received(
"<iq id='*' type='get'>"
"<query xmlns='jabber:iq:private'>"
"<storage xmlns='storage:bookmarks'/>"
"</query>"
"</iq>"
));
"<query xmlns='jabber:iq:private'>"
"<storage xmlns='storage:bookmarks'/>"
"</query>"
"</iq>"));
}
void
connect_bad_password(void **state)
connect_bad_password(void** state)
{
prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow");
prof_input("badpassword");
@@ -54,39 +51,35 @@ connect_bad_password(void **state)
}
void
connect_shows_presence_updates(void **state)
connect_shows_presence_updates(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<show>dnd</show>"
"<status>busy!</status>"
"</presence>"
);
"<show>dnd</show>"
"<status>busy!</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is dnd, \"busy!\""));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<show>chat</show>"
"<status>Talk to me!</status>"
"</presence>"
);
"<show>chat</show>"
"<status>Talk to me!</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (laptop) is chat, \"Talk to me!\""));
stbbr_send(
"<presence to='stabber@localhost' from='buddy2@localhost/work'>"
"<show>away</show>"
"<status>Out of office</status>"
"</presence>"
);
"<show>away</show>"
"<status>Out of office</status>"
"</presence>");
assert_true(prof_output_exact("Buddy2 (work) is away, \"Out of office\""));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<show>xa</show>"
"<status>Gone :(</status>"
"</presence>"
);
"<show>xa</show>"
"<status>Gone :(</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is xa, \"Gone :(\""));
}

View File

@@ -1,5 +1,5 @@
void connect_jid_requests_roster(void **state);
void connect_jid_sends_presence_after_receiving_roster(void **state);
void connect_jid_requests_bookmarks(void **state);
void connect_bad_password(void **state);
void connect_shows_presence_updates(void **state);
void connect_jid_requests_roster(void** state);
void connect_jid_sends_presence_after_receiving_roster(void** state);
void connect_jid_requests_bookmarks(void** state);
void connect_bad_password(void** state);
void connect_shows_presence_updates(void** state);

View File

@@ -9,7 +9,7 @@
#include "proftest.h"
void
disconnect_ends_session(void **state)
disconnect_ends_session(void** state)
{
prof_connect();

View File

@@ -1 +1 @@
void disconnect_ends_session(void **state);
void disconnect_ends_session(void** state);

View File

@@ -9,7 +9,7 @@
#include "proftest.h"
void
message_send(void **state)
message_send(void** state)
{
prof_connect();
@@ -17,29 +17,27 @@ message_send(void **state)
assert_true(stbbr_received(
"<message id='*' to='somejid@someserver.com' type='chat'>"
"<body>Hi there</body>"
"</message>"
));
"<body>Hi there</body>"
"</message>"));
assert_true(prof_output_regex("me: .+Hi there"));
}
void
message_receive_console(void **state)
message_receive_console(void** state)
{
prof_connect();
stbbr_send(
"<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>"
"<body>How are you?</body>"
"</message>"
);
"<body>How are you?</body>"
"</message>");
assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)"));
}
void
message_receive_chatwin(void **state)
message_receive_chatwin(void** state)
{
prof_connect();
@@ -48,9 +46,8 @@ message_receive_chatwin(void **state)
stbbr_send(
"<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>"
"<body>How are you?</body>"
"</message>"
);
"<body>How are you?</body>"
"</message>");
assert_true(prof_output_regex("someuser@chatserv.org/laptop: .+How are you?"));
}

View File

@@ -1,3 +1,3 @@
void message_send(void **state);
void message_receive_console(void **state);
void message_receive_chatwin(void **state);
void message_send(void** state);
void message_receive_console(void** state);
void message_receive_chatwin(void** state);

View File

@@ -9,7 +9,7 @@
#include "proftest.h"
void
sends_room_join(void **state)
sends_room_join(void** state)
{
prof_connect();
@@ -17,14 +17,13 @@ sends_room_join(void **state)
assert_true(stbbr_last_received(
"<presence id='*' to='testroom@conference.localhost/stabber'>"
"<x xmlns='http://jabber.org/protocol/muc'/>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<x xmlns='http://jabber.org/protocol/muc'/>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
}
void
sends_room_join_with_nick(void **state)
sends_room_join_with_nick(void** state)
{
prof_connect();
@@ -32,14 +31,13 @@ sends_room_join_with_nick(void **state)
assert_true(stbbr_last_received(
"<presence id='*' to='testroom@conference.localhost/testnick'>"
"<x xmlns='http://jabber.org/protocol/muc'/>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<x xmlns='http://jabber.org/protocol/muc'/>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
}
void
sends_room_join_with_password(void **state)
sends_room_join_with_password(void** state)
{
prof_connect();
@@ -47,16 +45,15 @@ sends_room_join_with_password(void **state)
assert_true(stbbr_last_received(
"<presence id='*' to='testroom@conference.localhost/stabber'>"
"<x xmlns='http://jabber.org/protocol/muc'>"
"<password>testpassword</password>"
"</x>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<x xmlns='http://jabber.org/protocol/muc'>"
"<password>testpassword</password>"
"</x>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
}
void
sends_room_join_with_nick_and_password(void **state)
sends_room_join_with_nick_and_password(void** state)
{
prof_connect();
@@ -64,28 +61,26 @@ sends_room_join_with_nick_and_password(void **state)
assert_true(stbbr_last_received(
"<presence id='*' to='testroom@conference.localhost/testnick'>"
"<x xmlns='http://jabber.org/protocol/muc'>"
"<password>testpassword</password>"
"</x>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<x xmlns='http://jabber.org/protocol/muc'>"
"<password>testpassword</password>"
"</x>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
}
void
shows_role_and_affiliation_on_join(void **state)
shows_role_and_affiliation_on_join(void** state)
{
prof_connect();
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
@@ -93,186 +88,173 @@ shows_role_and_affiliation_on_join(void **state)
}
void
shows_subject_on_join(void **state)
shows_subject_on_join(void** state)
{
prof_connect();
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost'>"
"<subject>Test room subject</subject>"
"<body>anothernick has set the subject to: Test room subject</body>"
"</message>"
);
"<subject>Test room subject</subject>"
"<body>anothernick has set the subject to: Test room subject</body>"
"</message>");
assert_true(prof_output_regex("Room subject: .+Test room subject"));
}
void
shows_history_message(void **state)
shows_history_message(void** state)
{
prof_connect();
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>an old message</body>"
"<delay xmlns='urn:xmpp:delay' stamp='2015-12-19T23:55:25Z' from='testroom@conference.localhost'/>"
"<x xmlns='jabber:x:delay' stamp='20151219T23:55:25'/>"
"</message>"
);
"<body>an old message</body>"
"<delay xmlns='urn:xmpp:delay' stamp='2015-12-19T23:55:25Z' from='testroom@conference.localhost'/>"
"<x xmlns='jabber:x:delay' stamp='20151219T23:55:25'/>"
"</message>");
assert_true(prof_output_regex("testoccupant: an old message"));
}
void
shows_occupant_join(void **state)
shows_occupant_join(void** state)
{
prof_connect();
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
stbbr_send(
"<presence to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='someuser@someserver.org/work' affiliation='none'/>"
"</x>"
"</presence>"
);
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='someuser@someserver.org/work' affiliation='none'/>"
"</x>"
"</presence>");
assert_true(prof_output_exact("-> testoccupant has joined the room, role: participant, affiliation: none"));
}
void
shows_message(void **state)
shows_message(void** state)
{
prof_connect();
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>a new message</body>"
"</message>"
);
"<body>a new message</body>"
"</message>");
assert_true(prof_output_regex("testoccupant: .+a new message"));
}
void
shows_me_message_from_occupant(void **state)
shows_me_message_from_occupant(void** state)
{
prof_connect();
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>/me did something</body>"
"</message>"
);
"<body>/me did something</body>"
"</message>");
assert_true(prof_output_exact("*testoccupant did something"));
}
void
shows_me_message_from_self(void **state)
shows_me_message_from_self(void** state)
{
prof_connect();
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<body>/me did something</body>"
"</message>"
);
"<body>/me did something</body>"
"</message>");
assert_true(prof_output_exact("*stabber did something"));
}
void
shows_all_messages_in_console_when_window_not_focussed(void **state)
shows_all_messages_in_console_when_window_not_focussed(void** state)
{
prof_connect();
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -282,23 +264,21 @@ shows_all_messages_in_console_when_window_not_focussed(void **state)
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>a new message</body>"
"</message>"
);
"<body>a new message</body>"
"</message>");
assert_true(prof_output_exact("<< room message: testoccupant in testroom@conference.localhost (win 2)"));
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
"<body>some other message</body>"
"</message>"
);
"<body>some other message</body>"
"</message>");
assert_true(prof_output_exact("<< room message: anotheroccupant in testroom@conference.localhost (win 2)"));
}
void
shows_first_message_in_console_when_window_not_focussed(void **state)
shows_first_message_in_console_when_window_not_focussed(void** state)
{
prof_connect();
@@ -306,14 +286,13 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
assert_true(prof_output_exact("Console MUC messages set: first"));
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -323,9 +302,8 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>a new message</body>"
"</message>"
);
"<body>a new message</body>"
"</message>");
assert_true(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
prof_input("/clear");
@@ -334,9 +312,8 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
"<body>some other message</body>"
"</message>"
);
"<body>some other message</body>"
"</message>");
prof_timeout(2);
assert_false(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
@@ -344,7 +321,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
}
void
shows_no_message_in_console_when_window_not_focussed(void **state)
shows_no_message_in_console_when_window_not_focussed(void** state)
{
prof_connect();
@@ -352,14 +329,13 @@ shows_no_message_in_console_when_window_not_focussed(void **state)
assert_true(prof_output_exact("Console MUC messages set: none"));
stbbr_for_id("prof_join_4",
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>"
);
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
"<x xmlns='http://jabber.org/protocol/muc#user'>"
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
"</x>"
"<status code='110'/>"
"</presence>");
prof_input("/join testroom@conference.localhost");
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
@@ -369,9 +345,8 @@ shows_no_message_in_console_when_window_not_focussed(void **state)
stbbr_send(
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
"<body>a new message</body>"
"</message>"
);
"<body>a new message</body>"
"</message>");
prof_timeout(2);
assert_false(prof_output_exact("testroom@conference.localhost (win 2)"));

View File

@@ -1,14 +1,14 @@
void sends_room_join(void **state);
void sends_room_join_with_nick(void **state);
void sends_room_join_with_password(void **state);
void sends_room_join_with_nick_and_password(void **state);
void shows_role_and_affiliation_on_join(void **state);
void shows_subject_on_join(void **state);
void shows_history_message(void **state);
void shows_occupant_join(void **state);
void shows_message(void **state);
void shows_me_message_from_occupant(void **state);
void shows_me_message_from_self(void **state);
void shows_all_messages_in_console_when_window_not_focussed(void **state);
void shows_first_message_in_console_when_window_not_focussed(void **state);
void shows_no_message_in_console_when_window_not_focussed(void **state);
void sends_room_join(void** state);
void sends_room_join_with_nick(void** state);
void sends_room_join_with_password(void** state);
void sends_room_join_with_nick_and_password(void** state);
void shows_role_and_affiliation_on_join(void** state);
void shows_subject_on_join(void** state);
void shows_history_message(void** state);
void shows_occupant_join(void** state);
void shows_message(void** state);
void shows_me_message_from_occupant(void** state);
void shows_me_message_from_self(void** state);
void shows_all_messages_in_console_when_window_not_focussed(void** state);
void shows_first_message_in_console_when_window_not_focussed(void** state);
void shows_no_message_in_console_when_window_not_focussed(void** state);

View File

@@ -9,53 +9,47 @@
#include "proftest.h"
void
ping_server(void **state)
ping_server(void** state)
{
stbbr_for_id("prof_disco_info_onconnect_2",
"<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='server' type='im' name='Prosody'/>"
"<feature var='urn:xmpp:ping'/>"
"</query>"
"</iq>"
);
"<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='server' type='im' name='Prosody'/>"
"<feature var='urn:xmpp:ping'/>"
"</query>"
"</iq>");
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",
"<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_input("/ping");
assert_true(stbbr_received(
"<iq id='prof_ping_4' type='get'>"
"<ping xmlns='urn:xmpp:ping'/>"
"</iq>"
));
"<ping xmlns='urn:xmpp:ping'/>"
"</iq>"));
assert_true(prof_output_exact("Ping response from server"));
prof_input("/ping");
assert_true(stbbr_received(
"<iq id='prof_ping_5' type='get'>"
"<ping xmlns='urn:xmpp:ping'/>"
"</iq>"
));
"<ping xmlns='urn:xmpp:ping'/>"
"</iq>"));
assert_true(prof_output_exact("Ping response from server"));
}
void
ping_server_not_supported(void **state)
ping_server_not_supported(void** state)
{
stbbr_for_id("prof_disco_info_onconnect_2",
"<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='server' type='im' name='Stabber'/>"
"</query>"
"</iq>"
);
"<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='server' type='im' name='Stabber'/>"
"</query>"
"</iq>");
prof_connect();
@@ -64,103 +58,95 @@ ping_server_not_supported(void **state)
}
void
ping_responds_to_server_request(void **state)
ping_responds_to_server_request(void** state)
{
prof_connect();
stbbr_send(
"<iq id='pingtest1' type='get' to='stabber@localhost/profanity' from='localhost'>"
"<ping xmlns='urn:xmpp:ping'/>"
"</iq>"
);
"<ping xmlns='urn:xmpp:ping'/>"
"</iq>");
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",
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
"<identity category='client' type='console' name='Profanity0.6.0'/>"
"<feature var='urn:xmpp:ping'/>"
"<feature var='http://jabber.org/protocol/disco#info'/>"
"<feature var='http://jabber.org/protocol/caps'/>"
"</query>"
"</iq>"
);
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
"<identity category='client' type='console' name='Profanity0.6.0'/>"
"<feature var='urn:xmpp:ping'/>"
"<feature var='http://jabber.org/protocol/disco#info'/>"
"<feature var='http://jabber.org/protocol/caps'/>"
"</query>"
"</iq>");
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"<c "
"hash='sha-1' "
"xmlns='http://jabber.org/protocol/caps' "
"node='http://profanity-im.github.io' "
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
"/>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"<c "
"hash='sha-1' "
"xmlns='http://jabber.org/protocol/caps' "
"node='http://profanity-im.github.io' "
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
"/>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
assert_true(stbbr_received(
"<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='/>"
"</iq>"
));
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
"</iq>"));
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");
assert_true(stbbr_received(
"<iq id='prof_ping_5' type='get' to='buddy1@localhost/mobile'>"
"<ping xmlns='urn:xmpp:ping'/>"
"</iq>"
));
"<ping xmlns='urn:xmpp:ping'/>"
"</iq>"));
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",
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
"<identity category='client' type='console' name='Profanity0.6.0'/>"
"<feature var='http://jabber.org/protocol/disco#info'/>"
"<feature var='http://jabber.org/protocol/caps'/>"
"</query>"
"</iq>"
);
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
"<identity category='client' type='console' name='Profanity0.6.0'/>"
"<feature var='http://jabber.org/protocol/disco#info'/>"
"<feature var='http://jabber.org/protocol/caps'/>"
"</query>"
"</iq>");
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"<c "
"hash='sha-1' "
"xmlns='http://jabber.org/protocol/caps' "
"node='http://profanity-im.github.io' "
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
"/>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"<c "
"hash='sha-1' "
"xmlns='http://jabber.org/protocol/caps' "
"node='http://profanity-im.github.io' "
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
"/>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
assert_true(stbbr_received(
"<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='/>"
"</iq>"
));
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
"</iq>"));
prof_input("/ping buddy1@localhost/mobile");
assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests."));

View File

@@ -1,5 +1,5 @@
void ping_server(void **state);
void ping_server_not_supported(void **state);
void ping_responds_to_server_request(void **state);
void ping_jid(void **state);
void ping_jid_not_supported(void **state);
void ping_server(void** state);
void ping_server_not_supported(void** state);
void ping_responds_to_server_request(void** state);
void ping_jid(void** state);
void ping_jid_not_supported(void** state);

View File

@@ -9,7 +9,7 @@
#include "proftest.h"
void
presence_online(void **state)
presence_online(void** state)
{
prof_connect();
@@ -17,15 +17,14 @@ presence_online(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_3'>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to online (priority 0)"));
}
void
presence_online_with_message(void **state)
presence_online_with_message(void** state)
{
prof_connect();
@@ -33,16 +32,15 @@ presence_online_with_message(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<status>Hi there</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<status>Hi there</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to online (priority 0), \"Hi there\"."));
}
void
presence_away(void **state)
presence_away(void** state)
{
prof_connect();
@@ -50,16 +48,15 @@ presence_away(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>away</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>away</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to away (priority 0)"));
}
void
presence_away_with_message(void **state)
presence_away_with_message(void** state)
{
prof_connect();
@@ -67,17 +64,16 @@ presence_away_with_message(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>away</show>"
"<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'/>"
"</presence>"
));
"<show>away</show>"
"<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'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to away (priority 0), \"I'm not here for a bit\"."));
}
void
presence_xa(void **state)
presence_xa(void** state)
{
prof_connect();
@@ -85,16 +81,15 @@ presence_xa(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>xa</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>xa</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to xa (priority 0)"));
}
void
presence_xa_with_message(void **state)
presence_xa_with_message(void** state)
{
prof_connect();
@@ -102,17 +97,16 @@ presence_xa_with_message(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>xa</show>"
"<status>Gone to the shops</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>xa</show>"
"<status>Gone to the shops</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to xa (priority 0), \"Gone to the shops\"."));
}
void
presence_dnd(void **state)
presence_dnd(void** state)
{
prof_connect();
@@ -120,16 +114,15 @@ presence_dnd(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>dnd</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>dnd</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to dnd (priority 0)"));
}
void
presence_dnd_with_message(void **state)
presence_dnd_with_message(void** state)
{
prof_connect();
@@ -137,17 +130,16 @@ presence_dnd_with_message(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>dnd</show>"
"<status>Working</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>dnd</show>"
"<status>Working</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to dnd (priority 0), \"Working\"."));
}
void
presence_chat(void **state)
presence_chat(void** state)
{
prof_connect();
@@ -155,16 +147,15 @@ presence_chat(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>chat</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>chat</show>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to chat (priority 0)"));
}
void
presence_chat_with_message(void **state)
presence_chat_with_message(void** state)
{
prof_connect();
@@ -172,17 +163,16 @@ presence_chat_with_message(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>chat</show>"
"<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>chat</show>"
"<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\"."));
}
void
presence_set_priority(void **state)
presence_set_priority(void** state)
{
prof_connect();
@@ -190,94 +180,87 @@ presence_set_priority(void **state)
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Priority set to 25."));
}
void
presence_includes_priority(void **state)
presence_includes_priority(void** state)
{
prof_connect();
prof_input("/priority 25");
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Priority set to 25."));
prof_input("/chat \"Free to talk\"");
assert_true(stbbr_received(
"<presence id='prof_presence_5'>"
"<priority>25</priority>"
"<show>chat</show>"
"<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<priority>25</priority>"
"<show>chat</show>"
"<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to chat (priority 25), \"Free to talk\"."));
}
void
presence_keeps_status(void **state)
presence_keeps_status(void** state)
{
prof_connect();
prof_input("/chat \"Free to talk\"");
assert_true(stbbr_received(
"<presence id='prof_presence_4'>"
"<show>chat</show>"
"<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>chat</show>"
"<status>Free to talk</status>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\"."));
prof_input("/priority 25");
assert_true(stbbr_received(
"<presence id='prof_presence_5'>"
"<show>chat</show>"
"<status>Free to talk</status>"
"<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"
));
"<show>chat</show>"
"<status>Free to talk</status>"
"<priority>25</priority>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
"</presence>"));
assert_true(prof_output_exact("Priority set to 25."));
}
void
presence_received(void **state)
presence_received(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
}
// Typical use case for gateways that don't support resources
void
presence_missing_resource_defaults(void **state)
presence_missing_resource_defaults(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost'>"
"<priority>15</priority>"
"<status>My status</status>"
"</presence>"
);
"<priority>15</priority>"
"<status>My status</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 is online, \"My status\""));

View File

@@ -1,15 +1,15 @@
void presence_away(void **state);
void presence_away_with_message(void **state);
void presence_online(void **state);
void presence_online_with_message(void **state);
void presence_xa(void **state);
void presence_xa_with_message(void **state);
void presence_dnd(void **state);
void presence_dnd_with_message(void **state);
void presence_chat(void **state);
void presence_chat_with_message(void **state);
void presence_set_priority(void **state);
void presence_includes_priority(void **state);
void presence_keeps_status(void **state);
void presence_received(void **state);
void presence_missing_resource_defaults(void **state);
void presence_away(void** state);
void presence_away_with_message(void** state);
void presence_online(void** state);
void presence_online_with_message(void** state);
void presence_xa(void** state);
void presence_xa_with_message(void** state);
void presence_dnd(void** state);
void presence_dnd_with_message(void** state);
void presence_chat(void** state);
void presence_chat_with_message(void** state);
void presence_set_priority(void** state);
void presence_includes_priority(void** state);
void presence_keeps_status(void** state);
void presence_received(void** state);
void presence_missing_resource_defaults(void** state);

View File

@@ -9,7 +9,7 @@
#include "proftest.h"
void
does_not_send_receipt_request_to_barejid(void **state)
does_not_send_receipt_request_to_barejid(void** state)
{
prof_input("/receipts request on");
@@ -19,34 +19,31 @@ does_not_send_receipt_request_to_barejid(void **state)
assert_true(stbbr_received(
"<message id='*' type='chat' to='somejid@someserver.com'>"
"<body>Hi there</body>"
"</message>"
));
"<body>Hi there</body>"
"</message>"));
}
void
send_receipt_request(void **state)
send_receipt_request(void** state)
{
prof_input("/receipts request on");
prof_connect();
stbbr_for_id("prof_caps_4",
"<iq from='buddy1@localhost/laptop' to='stabber@localhost' id='prof_caps_4' type='result'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#hAkb1xZdJV9BQpgGNw8zG5Xsals='>"
"<identity category='client' name='Profanity 0.5.0' type='console'/>"
"<feature var='urn:xmpp:receipts'/>"
"</query>"
"</iq>"
);
"<iq from='buddy1@localhost/laptop' to='stabber@localhost' id='prof_caps_4' type='result'>"
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#hAkb1xZdJV9BQpgGNw8zG5Xsals='>"
"<identity category='client' name='Profanity 0.5.0' type='console'/>"
"<feature var='urn:xmpp:receipts'/>"
"</query>"
"</iq>");
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<priority>15</priority>"
"<status>My status</status>"
"<c hash='sha-256' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
"</presence>"
);
"<priority>15</priority>"
"<status>My status</status>"
"<c hash='sha-256' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
"</presence>");
prof_output_exact("Buddy1 is online, \"My status\"");
@@ -56,14 +53,13 @@ send_receipt_request(void **state)
assert_true(stbbr_received(
"<message id='*' type='chat' to='buddy1@localhost/laptop'>"
"<body>Hi there, where is my receipt?</body>"
"<request xmlns='urn:xmpp:receipts'/>"
"</message>"
));
"<body>Hi there, where is my receipt?</body>"
"<request xmlns='urn:xmpp:receipts'/>"
"</message>"));
}
void
send_receipt_on_request(void **state)
send_receipt_on_request(void** state)
{
prof_input("/receipts send on");
@@ -71,14 +67,12 @@ send_receipt_on_request(void **state)
stbbr_send(
"<message id='msg12213' type='chat' to='stabber@localhost/profanity' from='someuser@server.org/profanity'>"
"<body>Wants a receipt</body>"
"<request xmlns='urn:xmpp:receipts'/>"
"</message>"
);
"<body>Wants a receipt</body>"
"<request xmlns='urn:xmpp:receipts'/>"
"</message>");
assert_true(stbbr_received(
"<message id='*' to='someuser@server.org/profanity'>"
"<received id='msg12213' xmlns='urn:xmpp:receipts'/>"
"</message>"
));
"<received id='msg12213' xmlns='urn:xmpp:receipts'/>"
"</message>"));
}

View File

@@ -1,3 +1,3 @@
void does_not_send_receipt_request_to_barejid(void **state);
void send_receipt_request(void **state);
void send_receipt_on_request(void **state);
void does_not_send_receipt_request_to_barejid(void** state);
void send_receipt_request(void** state);
void send_receipt_on_request(void** state);

View File

@@ -9,16 +9,15 @@
#include "proftest.h"
void
rooms_query(void **state)
rooms_query(void** state)
{
stbbr_for_id("prof_confreq_4",
"<iq id='prof_confreq_4' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#items'>"
"<item jid='chatroom@conference.localhost' name='A chat room'/>"
"<item jid='hangout@conference.localhost' name='Another chat room'/>"
"</query>"
"</iq>"
);
"<iq id='prof_confreq_4' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#items'>"
"<item jid='chatroom@conference.localhost' name='A chat room'/>"
"<item jid='hangout@conference.localhost' name='Another chat room'/>"
"</query>"
"</iq>");
prof_connect();
@@ -29,7 +28,6 @@ rooms_query(void **state)
assert_true(stbbr_last_received(
"<iq id='prof_confreq_4' to='conference.localhost' type='get'>"
"<query xmlns='http://jabber.org/protocol/disco#items'/>"
"</iq>"
));
"<query xmlns='http://jabber.org/protocol/disco#items'/>"
"</iq>"));
}

View File

@@ -1 +1 @@
void rooms_query(void **state);
void rooms_query(void** state);

View File

@@ -9,121 +9,110 @@
#include "proftest.h"
void
sends_new_item(void **state)
sends_new_item(void** state)
{
prof_connect();
stbbr_for_query("jabber:iq:roster",
"<iq type='set' from='stabber@localhost'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' subscription='none' name=''/>"
"</query>"
"</iq>"
);
"<iq type='set' from='stabber@localhost'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' subscription='none' name=''/>"
"</query>"
"</iq>");
prof_input("/roster add bob@localhost");
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' name=''/>"
"</query>"
"</iq>"
));
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' name=''/>"
"</query>"
"</iq>"));
assert_true(prof_output_exact("Roster item added: bob@localhost"));
}
void
sends_new_item_nick(void **state)
sends_new_item_nick(void** state)
{
prof_connect();
stbbr_for_query("jabber:iq:roster",
"<iq type='set' from='stabber@localhost'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' subscription='none' name='Bobby'/>"
"</query>"
"</iq>"
);
"<iq type='set' from='stabber@localhost'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' subscription='none' name='Bobby'/>"
"</query>"
"</iq>");
prof_input("/roster add bob@localhost Bobby");
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' name='Bobby'/>"
"</query>"
"</iq>"
));
"<query xmlns='jabber:iq:roster'>"
"<item jid='bob@localhost' name='Bobby'/>"
"</query>"
"</iq>"));
assert_true(prof_output_exact("Roster item added: bob@localhost (Bobby)"));
}
void
sends_remove_item(void **state)
sends_remove_item(void** state)
{
prof_connect_with_roster(
"<item jid='buddy1@localhost' subscription='both'/>"
"<item jid='buddy2@localhost' subscription='both'/>"
);
"<item jid='buddy2@localhost' subscription='both'/>");
stbbr_for_query("jabber:iq:roster",
"<iq id='*' type='set'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"
);
"<iq id='*' type='set'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>");
prof_input("/roster remove buddy1@localhost");
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"
));
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"));
assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
}
void
sends_remove_item_nick(void **state)
sends_remove_item_nick(void** state)
{
prof_connect_with_roster(
"<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",
"<iq id='*' type='set'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"
);
"<iq id='*' type='set'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>");
prof_input("/roster remove Bobby");
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"
));
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' subscription='remove'/>"
"</query>"
"</iq>"));
assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
}
void
sends_nick_change(void **state)
sends_nick_change(void** state)
{
prof_connect_with_roster(
"<item jid='buddy1@localhost' subscription='both'/>"
);
"<item jid='buddy1@localhost' subscription='both'/>");
prof_input("/roster nick buddy1@localhost Buddy1");
@@ -131,9 +120,8 @@ sends_nick_change(void **state)
assert_true(stbbr_received(
"<iq type='set' id='*'>"
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' name='Buddy1'/>"
"</query>"
"</iq>"
));
"<query xmlns='jabber:iq:roster'>"
"<item jid='buddy1@localhost' name='Buddy1'/>"
"</query>"
"</iq>"));
}

View File

@@ -1,5 +1,5 @@
void sends_new_item(void **state);
void sends_new_item_nick(void **state);
void sends_remove_item(void **state);
void sends_remove_item_nick(void **state);
void sends_nick_change(void **state);
void sends_new_item(void** state);
void sends_new_item_nick(void** state);
void sends_remove_item(void** state);
void sends_remove_item_nick(void** state);
void sends_nick_change(void** state);

View File

@@ -9,72 +9,66 @@
#include "proftest.h"
void
send_software_version_request(void **state)
send_software_version_request(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
prof_input("/software buddy1@localhost/mobile");
assert_true(stbbr_received(
"<iq id='*' to='buddy1@localhost/mobile' type='get'>"
"<query xmlns='jabber:iq:version'/>"
"</iq>"
));
"<query xmlns='jabber:iq:version'/>"
"</iq>"));
}
void
display_software_version_result(void **state)
display_software_version_result(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
stbbr_for_query("jabber:iq:version",
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<query xmlns='jabber:iq:version'>"
"<name>Profanity</name>"
"<version>0.4.7dev.master.2cb2f83</version>"
"</query>"
"</iq>"
);
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<query xmlns='jabber:iq:version'>"
"<name>Profanity</name>"
"<version>0.4.7dev.master.2cb2f83</version>"
"</query>"
"</iq>");
prof_input("/software buddy1@localhost/mobile");
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
// assert_true(prof_output_exact("Name : Profanity"));
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
// assert_true(prof_output_exact("Name : Profanity"));
assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83"));
}
void
shows_message_when_software_version_error(void **state)
shows_message_when_software_version_error(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
stbbr_for_query("jabber:iq:version",
"<iq id='*' lang='en' type='error' to='stabber@localhost/profanity' from='buddy1@localhost/laptop'>"
"<query xmlns='jabber:iq:version'/>"
"<error code='503' type='cancel'>"
"<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
"</error>"
"</iq>"
);
"<iq id='*' lang='en' type='error' to='stabber@localhost/profanity' from='buddy1@localhost/laptop'>"
"<query xmlns='jabber:iq:version'/>"
"<error code='503' type='cancel'>"
"<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
"</error>"
"</iq>");
prof_input("/software buddy1@localhost/laptop");
assert_true(prof_output_exact("Could not get software version: service-unavailable"));
@@ -82,42 +76,39 @@ shows_message_when_software_version_error(void **state)
// Typical use case for gateways that don't support resources
void
display_software_version_result_when_from_domainpart(void **state)
display_software_version_result_when_from_domainpart(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 is online, \"I'm here\""));
stbbr_for_query("jabber:iq:version",
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='localhost'>"
"<query xmlns='jabber:iq:version'>"
"<name>Some Gateway</name>"
"<version>1.0</version>"
"</query>"
"</iq>"
);
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='localhost'>"
"<query xmlns='jabber:iq:version'>"
"<name>Some Gateway</name>"
"<version>1.0</version>"
"</query>"
"</iq>");
prof_input("/software buddy1@localhost/__prof_default");
// assert_true(prof_output_exact("buddy1@localhost/__prof_default:"));
// assert_true(prof_output_exact("Name : Some Gateway"));
// assert_true(prof_output_exact("buddy1@localhost/__prof_default:"));
// assert_true(prof_output_exact("Name : Some Gateway"));
assert_true(prof_output_exact("Version : 1.0"));
}
void
show_message_in_chat_window_when_no_resource(void **state)
show_message_in_chat_window_when_no_resource(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
prof_input("/msg Buddy1");
@@ -127,37 +118,34 @@ show_message_in_chat_window_when_no_resource(void **state)
}
void
display_software_version_result_in_chat(void **state)
display_software_version_result_in_chat(void** state)
{
prof_connect();
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>"
);
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>");
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
prof_input("/msg Buddy1");
stbbr_send(
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
"<body>Here's a message</body>"
"</message>"
);
"<body>Here's a message</body>"
"</message>");
assert_true(prof_output_exact("Here's a message"));
stbbr_for_query("jabber:iq:version",
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<query xmlns='jabber:iq:version'>"
"<name>Profanity</name>"
"<version>0.4.7dev.master.2cb2f83</version>"
"</query>"
"</iq>"
);
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<query xmlns='jabber:iq:version'>"
"<name>Profanity</name>"
"<version>0.4.7dev.master.2cb2f83</version>"
"</query>"
"</iq>");
prof_input("/software");
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
// assert_true(prof_output_exact("Name : Profanity"));
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
// assert_true(prof_output_exact("Name : Profanity"));
assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83"));
}

View File

@@ -1,6 +1,6 @@
void send_software_version_request(void **state);
void display_software_version_result(void **state);
void shows_message_when_software_version_error(void **state);
void display_software_version_result_when_from_domainpart(void **state);
void show_message_in_chat_window_when_no_resource(void **state);
void display_software_version_result_in_chat(void **state);
void send_software_version_request(void** state);
void display_software_version_result(void** state);
void shows_message_when_software_version_error(void** state);
void display_software_version_result_when_from_domainpart(void** state);
void show_message_in_chat_window_when_no_resource(void** state);
void display_software_version_result_in_chat(void** state);

View File

@@ -15,7 +15,7 @@
#define CMD_ACCOUNT "/account"
void
cmd_account_shows_usage_when_not_connected_and_no_args(void** state)
cmd_account__shows__usage_when_not_connected_and_no_args(void** state)
{
gchar* args[] = { NULL };
@@ -28,7 +28,7 @@ cmd_account_shows_usage_when_not_connected_and_no_args(void** state)
}
void
cmd_account_shows_account_when_connected_and_no_args(void** state)
cmd_account__shows__account_when_connected_and_no_args(void** state)
{
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0);
@@ -46,7 +46,7 @@ cmd_account_shows_account_when_connected_and_no_args(void** state)
}
void
cmd_account_list_shows_accounts(void** state)
cmd_account_list__shows__accounts(void** state)
{
gchar* args[] = { "list", NULL };
@@ -65,7 +65,7 @@ cmd_account_list_shows_accounts(void** state)
}
void
cmd_account_show_shows_usage_when_no_arg(void** state)
cmd_account_show__shows__usage_when_no_arg(void** state)
{
gchar* args[] = { "show", NULL };
@@ -76,7 +76,7 @@ cmd_account_show_shows_usage_when_no_arg(void** state)
}
void
cmd_account_show_shows_message_when_account_does_not_exist(void** state)
cmd_account_show__shows__message_when_account_does_not_exist(void** state)
{
gchar* args[] = { "show", "account_name", NULL };
@@ -91,7 +91,7 @@ cmd_account_show_shows_message_when_account_does_not_exist(void** state)
}
void
cmd_account_show_shows_account_when_exists(void** state)
cmd_account_show__shows__account_when_exists(void** state)
{
gchar* args[] = { "show", "account_name", NULL };
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL,
@@ -107,7 +107,7 @@ cmd_account_show_shows_account_when_exists(void** state)
}
void
cmd_account_add_shows_usage_when_no_arg(void** state)
cmd_account_add__shows__usage_when_no_arg(void** state)
{
gchar* args[] = { "add", NULL };
@@ -118,7 +118,7 @@ cmd_account_add_shows_usage_when_no_arg(void** state)
}
void
cmd_account_add_adds_account(void** state)
cmd_account_add__updates__adds_account(void** state)
{
gchar* args[] = { "add", "new_account", NULL };
@@ -133,7 +133,7 @@ cmd_account_add_adds_account(void** state)
}
void
cmd_account_enable_shows_usage_when_no_arg(void** state)
cmd_account_enable__shows__usage_when_no_arg(void** state)
{
gchar* args[] = { "enable", NULL };
@@ -144,7 +144,7 @@ cmd_account_enable_shows_usage_when_no_arg(void** state)
}
void
cmd_account_enable_enables_account(void** state)
cmd_account_enable__updates__enables_account(void** state)
{
gchar* args[] = { "enable", "account_name", NULL };
@@ -159,7 +159,7 @@ cmd_account_enable_enables_account(void** state)
}
void
cmd_account_enable_shows_message_when_account_doesnt_exist(void** state)
cmd_account_enable__shows__message_when_account_doesnt_exist(void** state)
{
gchar* args[] = { "enable", "account_name", NULL };
@@ -174,7 +174,7 @@ cmd_account_enable_shows_message_when_account_doesnt_exist(void** state)
}
void
cmd_account_disable_shows_usage_when_no_arg(void** state)
cmd_account_disable__shows__usage_when_no_arg(void** state)
{
gchar* args[] = { "disable", NULL };
@@ -185,7 +185,7 @@ cmd_account_disable_shows_usage_when_no_arg(void** state)
}
void
cmd_account_disable_disables_account(void** state)
cmd_account_disable__updates__disables_account(void** state)
{
gchar* args[] = { "disable", "account_name", NULL };
@@ -200,7 +200,7 @@ cmd_account_disable_disables_account(void** state)
}
void
cmd_account_disable_shows_message_when_account_doesnt_exist(void** state)
cmd_account_disable__shows__message_when_account_doesnt_exist(void** state)
{
gchar* args[] = { "disable", "account_name", NULL };
@@ -215,7 +215,7 @@ cmd_account_disable_shows_message_when_account_doesnt_exist(void** state)
}
void
cmd_account_rename_shows_usage_when_no_args(void** state)
cmd_account_rename__shows__usage_when_no_args(void** state)
{
gchar* args[] = { "rename", NULL };
@@ -226,7 +226,7 @@ cmd_account_rename_shows_usage_when_no_args(void** state)
}
void
cmd_account_rename_shows_usage_when_one_arg(void** state)
cmd_account_rename__shows__usage_when_one_arg(void** state)
{
gchar* args[] = { "rename", "original_name", NULL };
@@ -237,7 +237,7 @@ cmd_account_rename_shows_usage_when_one_arg(void** state)
}
void
cmd_account_rename_renames_account(void** state)
cmd_account_rename__updates__renames_account(void** state)
{
gchar* args[] = { "rename", "original_name", "new_name", NULL };
@@ -253,7 +253,7 @@ cmd_account_rename_renames_account(void** state)
}
void
cmd_account_rename_shows_message_when_not_renamed(void** state)
cmd_account_rename__shows__message_when_not_renamed(void** state)
{
gchar* args[] = { "rename", "original_name", "new_name", NULL };
@@ -269,7 +269,7 @@ cmd_account_rename_shows_message_when_not_renamed(void** state)
}
void
cmd_account_set_shows_usage_when_no_args(void** state)
cmd_account_set__shows__usage_when_no_args(void** state)
{
gchar* args[] = { "set", NULL };
@@ -280,7 +280,7 @@ cmd_account_set_shows_usage_when_no_args(void** state)
}
void
cmd_account_set_shows_usage_when_one_arg(void** state)
cmd_account_set__shows__usage_when_one_arg(void** state)
{
gchar* args[] = { "set", "a_account", NULL };
@@ -291,7 +291,7 @@ cmd_account_set_shows_usage_when_one_arg(void** state)
}
void
cmd_account_set_shows_usage_when_two_args(void** state)
cmd_account_set__shows__usage_when_two_args(void** state)
{
gchar* args[] = { "set", "a_account", "a_property", NULL };
@@ -302,7 +302,7 @@ cmd_account_set_shows_usage_when_two_args(void** state)
}
void
cmd_account_set_shows_message_when_account_doesnt_exist(void** state)
cmd_account_set__shows__message_when_account_doesnt_exist(void** state)
{
gchar* args[] = { "set", "a_account", "a_property", "a_value", NULL };
@@ -317,7 +317,7 @@ cmd_account_set_shows_message_when_account_doesnt_exist(void** state)
}
void
cmd_account_set_jid_shows_message_for_malformed_jid(void** state)
cmd_account_set__shows__message_for_malformed_jid(void** state)
{
gchar* args[] = { "set", "a_account", "jid", "@malformed", NULL };
@@ -331,7 +331,7 @@ cmd_account_set_jid_shows_message_for_malformed_jid(void** state)
}
void
cmd_account_set_jid_sets_barejid(void** state)
cmd_account_set__updates__jid_sets_barejid(void** state)
{
gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL };
@@ -349,7 +349,7 @@ cmd_account_set_jid_sets_barejid(void** state)
}
void
cmd_account_set_jid_sets_resource(void** state)
cmd_account_set__updates__jid_sets_resource(void** state)
{
gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL };
@@ -372,7 +372,7 @@ cmd_account_set_jid_sets_resource(void** state)
}
void
cmd_account_set_server_sets_server(void** state)
cmd_account_set__updates__server_sets_server(void** state)
{
gchar* args[] = { "set", "a_account", "server", "a_server", NULL };
@@ -390,7 +390,7 @@ cmd_account_set_server_sets_server(void** state)
}
void
cmd_account_set_resource_sets_resource(void** state)
cmd_account_set__updates__resource_sets_resource(void** state)
{
gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL };
@@ -410,7 +410,7 @@ cmd_account_set_resource_sets_resource(void** state)
}
void
cmd_account_set_resource_sets_resource_with_online_message(void** state)
cmd_account_set__shows__resource_sets_resource_with_online_message(void** state)
{
gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL };
@@ -430,7 +430,7 @@ cmd_account_set_resource_sets_resource_with_online_message(void** state)
}
void
cmd_account_set_password_sets_password(void** state)
cmd_account_set__updates__password_sets_password(void** state)
{
gchar* args[] = { "set", "a_account", "password", "a_password", NULL };
ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, NULL,
@@ -453,7 +453,7 @@ cmd_account_set_password_sets_password(void** state)
}
void
cmd_account_set_eval_password_sets_eval_password(void** state)
cmd_account_set__updates__eval_password_sets_eval_password(void** state)
{
gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL };
ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, NULL,
@@ -476,7 +476,7 @@ cmd_account_set_eval_password_sets_eval_password(void** state)
}
void
cmd_account_set_password_when_eval_password_set(void** state)
cmd_account_set__shows__password_when_eval_password_set(void** state)
{
gchar* args[] = { "set", "a_account", "password", "a_password", NULL };
ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, g_strdup("a_password"),
@@ -495,7 +495,7 @@ cmd_account_set_password_when_eval_password_set(void** state)
}
void
cmd_account_set_eval_password_when_password_set(void** state)
cmd_account_set__shows__eval_password_when_password_set(void** state)
{
gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL };
ProfAccount* account = account_new(g_strdup("a_account"), NULL, g_strdup("a_password"), NULL,
@@ -514,7 +514,7 @@ cmd_account_set_eval_password_when_password_set(void** state)
}
void
cmd_account_set_muc_sets_muc(void** state)
cmd_account_set__updates__muc_sets_muc(void** state)
{
gchar* args[] = { "set", "a_account", "muc", "a_muc", NULL };
@@ -532,7 +532,7 @@ cmd_account_set_muc_sets_muc(void** state)
}
void
cmd_account_set_nick_sets_nick(void** state)
cmd_account_set__updates__nick_sets_nick(void** state)
{
gchar* args[] = { "set", "a_account", "nick", "a_nick", NULL };
@@ -550,7 +550,7 @@ cmd_account_set_nick_sets_nick(void** state)
}
void
cmd_account_show_message_for_missing_otr_policy(void** state)
cmd_account_set__shows__message_for_missing_otr_policy(void** state)
{
gchar* args[] = { "set", "a_account", "otr", NULL };
@@ -561,7 +561,7 @@ cmd_account_show_message_for_missing_otr_policy(void** state)
}
void
cmd_account_show_message_for_invalid_otr_policy(void** state)
cmd_account_set__shows__message_for_invalid_otr_policy(void** state)
{
gchar* args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL };
@@ -576,7 +576,7 @@ cmd_account_show_message_for_invalid_otr_policy(void** state)
}
void
cmd_account_set_otr_sets_otr(void** state)
cmd_account_set__updates__otr_sets_otr(void** state)
{
gchar* args[] = { "set", "a_account", "otr", "opportunistic", NULL };
@@ -594,7 +594,7 @@ cmd_account_set_otr_sets_otr(void** state)
}
void
cmd_account_set_status_shows_message_when_invalid_status(void** state)
cmd_account_set__shows__message_when_invalid_status(void** state)
{
gchar* args[] = { "set", "a_account", "status", "bad_status", NULL };
@@ -609,7 +609,7 @@ cmd_account_set_status_shows_message_when_invalid_status(void** state)
}
void
cmd_account_set_status_sets_status_when_valid(void** state)
cmd_account_set__updates__status_sets_status_when_valid(void** state)
{
gchar* args[] = { "set", "a_account", "status", "away", NULL };
@@ -627,7 +627,7 @@ cmd_account_set_status_sets_status_when_valid(void** state)
}
void
cmd_account_set_status_sets_status_when_last(void** state)
cmd_account_set__updates__status_sets_status_when_last(void** state)
{
gchar* args[] = { "set", "a_account", "status", "last", NULL };
@@ -645,7 +645,7 @@ cmd_account_set_status_sets_status_when_last(void** state)
}
void
cmd_account_set_invalid_presence_string_priority_shows_message(void** state)
cmd_account_set__shows__invalid_presence_string_priority_message(void** state)
{
gchar* args[] = { "set", "a_account", "blah", "10", NULL };
@@ -660,7 +660,7 @@ cmd_account_set_invalid_presence_string_priority_shows_message(void** state)
}
void
cmd_account_set_last_priority_shows_message(void** state)
cmd_account_set__shows__last_priority_message(void** state)
{
gchar* args[] = { "set", "a_account", "last", "10", NULL };
@@ -675,7 +675,7 @@ cmd_account_set_last_priority_shows_message(void** state)
}
void
cmd_account_set_online_priority_sets_preference(void** state)
cmd_account_set__updates__online_priority_sets_preference(void** state)
{
gchar* args[] = { "set", "a_account", "online", "10", NULL };
@@ -695,7 +695,7 @@ cmd_account_set_online_priority_sets_preference(void** state)
}
void
cmd_account_set_chat_priority_sets_preference(void** state)
cmd_account_set__updates__chat_priority_sets_preference(void** state)
{
gchar* args[] = { "set", "a_account", "chat", "10", NULL };
@@ -715,7 +715,7 @@ cmd_account_set_chat_priority_sets_preference(void** state)
}
void
cmd_account_set_away_priority_sets_preference(void** state)
cmd_account_set__updates__away_priority_sets_preference(void** state)
{
gchar* args[] = { "set", "a_account", "away", "10", NULL };
@@ -735,7 +735,7 @@ cmd_account_set_away_priority_sets_preference(void** state)
}
void
cmd_account_set_xa_priority_sets_preference(void** state)
cmd_account_set__updates__xa_priority_sets_preference(void** state)
{
gchar* args[] = { "set", "a_account", "xa", "10", NULL };
@@ -755,7 +755,7 @@ cmd_account_set_xa_priority_sets_preference(void** state)
}
void
cmd_account_set_dnd_priority_sets_preference(void** state)
cmd_account_set__updates__dnd_priority_sets_preference(void** state)
{
gchar* args[] = { "set", "a_account", "dnd", "10", NULL };
@@ -775,7 +775,7 @@ cmd_account_set_dnd_priority_sets_preference(void** state)
}
void
cmd_account_set_priority_too_low_shows_message(void** state)
cmd_account_set__shows__priority_too_low_message(void** state)
{
gchar* args[] = { "set", "a_account", "online", "-150", NULL };
@@ -789,7 +789,7 @@ cmd_account_set_priority_too_low_shows_message(void** state)
}
void
cmd_account_set_priority_too_high_shows_message(void** state)
cmd_account_set__shows__priority_too_high_message(void** state)
{
gchar* args[] = { "set", "a_account", "online", "150", NULL };
@@ -803,7 +803,7 @@ cmd_account_set_priority_too_high_shows_message(void** state)
}
void
cmd_account_set_priority_when_not_number_shows_message(void** state)
cmd_account_set__shows__priority_when_not_number_message(void** state)
{
gchar* args[] = { "set", "a_account", "online", "abc", NULL };
@@ -817,7 +817,7 @@ cmd_account_set_priority_when_not_number_shows_message(void** state)
}
void
cmd_account_set_priority_when_empty_shows_message(void** state)
cmd_account_set__shows__priority_when_empty_message(void** state)
{
gchar* args[] = { "set", "a_account", "online", "", NULL };
@@ -831,7 +831,7 @@ cmd_account_set_priority_when_empty_shows_message(void** state)
}
void
cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void** state)
cmd_account_set__updates__priority_updates_presence_when_connected(void** state)
{
gchar* args[] = { "set", "a_account", "online", "10", NULL };
@@ -868,7 +868,7 @@ cmd_account_set_priority_updates_presence_when_account_connected_with_presence(v
}
void
cmd_account_clear_shows_usage_when_no_args(void** state)
cmd_account_clear__shows__usage_when_no_args(void** state)
{
gchar* args[] = { "clear", NULL };
@@ -879,7 +879,7 @@ cmd_account_clear_shows_usage_when_no_args(void** state)
}
void
cmd_account_clear_shows_usage_when_one_arg(void** state)
cmd_account_clear__shows__usage_when_one_arg(void** state)
{
gchar* args[] = { "clear", "a_account", NULL };
@@ -890,7 +890,7 @@ cmd_account_clear_shows_usage_when_one_arg(void** state)
}
void
cmd_account_clear_shows_message_when_account_doesnt_exist(void** state)
cmd_account_clear__shows__message_when_account_doesnt_exist(void** state)
{
gchar* args[] = { "clear", "a_account", "a_property", NULL };
@@ -905,7 +905,7 @@ cmd_account_clear_shows_message_when_account_doesnt_exist(void** state)
}
void
cmd_account_clear_shows_message_when_invalid_property(void** state)
cmd_account_clear__shows__message_when_invalid_property(void** state)
{
gchar* args[] = { "clear", "a_account", "badproperty", NULL };

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

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

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
cmd_connect_shows_message_when_disconnecting(void** state)
cmd_connect__shows__message_when_disconnecting(void** state)
{
test_with_connection_status(JABBER_DISCONNECTING);
}
void
cmd_connect_shows_message_when_connecting(void** state)
cmd_connect__shows__message_when_connecting(void** state)
{
test_with_connection_status(JABBER_CONNECTING);
}
void
cmd_connect_shows_message_when_connected(void** state)
cmd_connect__shows__message_when_connected(void** state)
{
test_with_connection_status(JABBER_CONNECTED);
}
void
cmd_connect_when_no_account(void** state)
cmd_connect__tests__no_account(void** state)
{
gchar* args[] = { "user@server.org", NULL };
@@ -67,7 +67,7 @@ cmd_connect_when_no_account(void** state)
}
void
cmd_connect_fail_message(void** state)
cmd_connect__shows__fail_message(void** state)
{
gchar* args[] = { "user@server.org", NULL };
@@ -93,7 +93,7 @@ cmd_connect_fail_message(void** state)
}
void
cmd_connect_lowercases_argument_with_no_account(void** state)
cmd_connect__tests__lowercases_argument_with_no_account(void** state)
{
gchar* args[] = { "USER@server.ORG", NULL };
@@ -117,7 +117,7 @@ cmd_connect_lowercases_argument_with_no_account(void** state)
}
void
cmd_connect_lowercases_argument_with_account(void** state)
cmd_connect__tests__lowercases_argument_with_account(void** state)
{
gchar* args[] = { "Jabber_org", NULL };
ProfAccount* account = account_new(g_strdup("Jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), NULL,
@@ -138,7 +138,7 @@ cmd_connect_lowercases_argument_with_account(void** state)
}
void
cmd_connect_asks_password_when_not_in_account(void** state)
cmd_connect__tests__asks_password_when_not_in_account(void** state)
{
gchar* args[] = { "jabber_org", NULL };
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL,
@@ -161,7 +161,7 @@ cmd_connect_asks_password_when_not_in_account(void** state)
}
void
cmd_connect_shows_usage_when_no_server_value(void** state)
cmd_connect__shows__usage_when_no_server_value(void** state)
{
gchar* args[] = { "user@server.org", "server", NULL };
@@ -175,7 +175,7 @@ cmd_connect_shows_usage_when_no_server_value(void** state)
}
void
cmd_connect_shows_usage_when_server_no_port_value(void** state)
cmd_connect__shows__usage_when_server_no_port_value(void** state)
{
gchar* args[] = { "user@server.org", "server", "aserver", "port", NULL };
@@ -189,7 +189,7 @@ cmd_connect_shows_usage_when_server_no_port_value(void** state)
}
void
cmd_connect_shows_usage_when_no_port_value(void** state)
cmd_connect__shows__usage_when_no_port_value(void** state)
{
gchar* args[] = { "user@server.org", "port", NULL };
@@ -203,7 +203,7 @@ cmd_connect_shows_usage_when_no_port_value(void** state)
}
void
cmd_connect_shows_usage_when_port_no_server_value(void** state)
cmd_connect__shows__usage_when_port_no_server_value(void** state)
{
gchar* args[] = { "user@server.org", "port", "5678", "server", NULL };
@@ -217,7 +217,7 @@ cmd_connect_shows_usage_when_port_no_server_value(void** state)
}
void
cmd_connect_shows_message_when_port_0(void** state)
cmd_connect__shows__message_when_port_0(void** state)
{
gchar* args[] = { "user@server.org", "port", "0", NULL };
@@ -231,7 +231,7 @@ cmd_connect_shows_message_when_port_0(void** state)
}
void
cmd_connect_shows_message_when_port_minus1(void** state)
cmd_connect__shows__message_when_port_minus1(void** state)
{
gchar* args[] = { "user@server.org", "port", "-1", NULL };
@@ -245,7 +245,7 @@ cmd_connect_shows_message_when_port_minus1(void** state)
}
void
cmd_connect_shows_message_when_port_65536(void** state)
cmd_connect__shows__message_when_port_65536(void** state)
{
gchar* args[] = { "user@server.org", "port", "65536", NULL };
@@ -259,7 +259,7 @@ cmd_connect_shows_message_when_port_65536(void** state)
}
void
cmd_connect_shows_message_when_port_contains_chars(void** state)
cmd_connect__shows__message_when_port_contains_chars(void** state)
{
gchar* args[] = { "user@server.org", "port", "52f66", NULL };
@@ -273,7 +273,7 @@ cmd_connect_shows_message_when_port_contains_chars(void** state)
}
void
cmd_connect_shows_usage_when_server_provided_twice(void** state)
cmd_connect__shows__usage_when_server_provided_twice(void** state)
{
gchar* args[] = { "user@server.org", "server", "server1", "server", "server2", NULL };
@@ -287,7 +287,7 @@ cmd_connect_shows_usage_when_server_provided_twice(void** state)
}
void
cmd_connect_shows_usage_when_port_provided_twice(void** state)
cmd_connect__shows__usage_when_port_provided_twice(void** state)
{
gchar* args[] = { "user@server.org", "port", "1111", "port", "1111", NULL };
@@ -301,7 +301,7 @@ cmd_connect_shows_usage_when_port_provided_twice(void** state)
}
void
cmd_connect_shows_usage_when_invalid_first_property(void** state)
cmd_connect__shows__usage_when_invalid_first_property(void** state)
{
gchar* args[] = { "user@server.org", "wrong", "server", NULL };
@@ -315,7 +315,7 @@ cmd_connect_shows_usage_when_invalid_first_property(void** state)
}
void
cmd_connect_shows_usage_when_invalid_second_property(void** state)
cmd_connect__shows__usage_when_invalid_second_property(void** state)
{
gchar* args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL };
@@ -329,7 +329,7 @@ cmd_connect_shows_usage_when_invalid_second_property(void** state)
}
void
cmd_connect_with_server_when_provided(void** state)
cmd_connect__tests__with_server_when_provided(void** state)
{
gchar* args[] = { "user@server.org", "server", "aserver", NULL };
@@ -353,7 +353,7 @@ cmd_connect_with_server_when_provided(void** state)
}
void
cmd_connect_with_port_when_provided(void** state)
cmd_connect__tests__with_port_when_provided(void** state)
{
gchar* args[] = { "user@server.org", "port", "5432", NULL };
@@ -377,7 +377,7 @@ cmd_connect_with_port_when_provided(void** state)
}
void
cmd_connect_with_server_and_port_when_provided(void** state)
cmd_connect__tests__with_server_and_port_when_provided(void** state)
{
gchar* args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL };
@@ -401,7 +401,7 @@ cmd_connect_with_server_and_port_when_provided(void** state)
}
void
cmd_connect_shows_message_when_connecting_with_account(void** state)
cmd_connect__shows__message_when_connecting_with_account(void** state)
{
gchar* args[] = { "jabber_org", NULL };
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("user@jabber.org"), g_strdup("password"), NULL,
@@ -422,7 +422,7 @@ cmd_connect_shows_message_when_connecting_with_account(void** state)
}
void
cmd_connect_connects_with_account(void** state)
cmd_connect__tests__connects_with_account(void** state)
{
gchar* args[] = { "jabber_org", NULL };
ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), NULL,

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

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
void
cmd_otr_log_shows_usage_when_no_args(void** state)
cmd_otr_log__shows__usage_when_no_args(void** state)
{
gchar* args[] = { "log", NULL };
@@ -35,7 +35,7 @@ cmd_otr_log_shows_usage_when_no_args(void** state)
}
void
cmd_otr_log_shows_usage_when_invalid_subcommand(void** state)
cmd_otr_log__shows__usage_when_invalid_subcommand(void** state)
{
gchar* args[] = { "log", "wrong", NULL };
@@ -46,7 +46,7 @@ cmd_otr_log_shows_usage_when_invalid_subcommand(void** state)
}
void
cmd_otr_log_on_enables_logging(void** state)
cmd_otr_log__updates__enables_logging(void** state)
{
gchar* args[] = { "log", "on", NULL };
prefs_set_string(PREF_OTR_LOG, "off");
@@ -62,7 +62,7 @@ cmd_otr_log_on_enables_logging(void** state)
}
void
cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state)
cmd_otr_log__shows__warning_when_chlog_disabled(void** state)
{
gchar* args[] = { "log", "on", NULL };
prefs_set_string(PREF_OTR_LOG, "off");
@@ -76,7 +76,7 @@ cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state)
}
void
cmd_otr_log_off_disables_logging(void** state)
cmd_otr_log__updates__disables_logging(void** state)
{
gchar* args[] = { "log", "off", NULL };
prefs_set_string(PREF_OTR_LOG, "on");
@@ -92,7 +92,7 @@ cmd_otr_log_off_disables_logging(void** state)
}
void
cmd_otr_redact_redacts_logging(void** state)
cmd_otr_log__updates__redacts_logging(void** state)
{
gchar* args[] = { "log", "redact", NULL };
prefs_set_string(PREF_OTR_LOG, "on");
@@ -108,7 +108,7 @@ cmd_otr_redact_redacts_logging(void** state)
}
void
cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state)
cmd_otr_log__shows__redact_warning_when_chlog_disabled(void** state)
{
gchar* args[] = { "log", "redact", NULL };
prefs_set_string(PREF_OTR_LOG, "off");
@@ -122,7 +122,7 @@ cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state)
}
void
cmd_otr_libver_shows_libotr_version(void** state)
cmd_otr_libver__shows__libotr_version(void** state)
{
gchar* args[] = { "libver", NULL };
char* version = "9.9.9";
@@ -140,7 +140,7 @@ cmd_otr_libver_shows_libotr_version(void** state)
}
void
cmd_otr_gen_shows_message_when_not_connected(void** state)
cmd_otr_gen__shows__message_when_not_connected(void** state)
{
gchar* args[] = { "gen", NULL };
@@ -167,25 +167,25 @@ test_with_command_and_connection_status(char* command, void* cmd_func, jabber_co
}
void
cmd_otr_gen_shows_message_when_disconnected(void** state)
cmd_otr_gen__shows__message_when_disconnected(void** state)
{
test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTED);
}
void
cmd_otr_gen_shows_message_when_connecting(void** state)
cmd_otr_gen__shows__message_when_connecting(void** state)
{
test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_CONNECTING);
}
void
cmd_otr_gen_shows_message_when_disconnecting(void** state)
cmd_otr_gen__shows__message_when_disconnecting(void** state)
{
test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTING);
}
void
cmd_otr_gen_generates_key_for_connected_account(void** state)
cmd_otr_gen__tests__generates_key_for_connected_account(void** state)
{
gchar* args[] = { "gen", NULL };
gchar* account_name = g_strdup("myaccount");
@@ -206,25 +206,25 @@ cmd_otr_gen_generates_key_for_connected_account(void** state)
}
void
cmd_otr_myfp_shows_message_when_disconnected(void** state)
cmd_otr_myfp__shows__message_when_disconnected(void** state)
{
test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTED);
}
void
cmd_otr_myfp_shows_message_when_connecting(void** state)
cmd_otr_myfp__shows__message_when_connecting(void** state)
{
test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_CONNECTING);
}
void
cmd_otr_myfp_shows_message_when_disconnecting(void** state)
cmd_otr_myfp__shows__message_when_disconnecting(void** state)
{
test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTING);
}
void
cmd_otr_myfp_shows_message_when_no_key(void** state)
cmd_otr_myfp__shows__message_when_no_key(void** state)
{
gchar* args[] = { "myfp", NULL };
@@ -238,7 +238,7 @@ cmd_otr_myfp_shows_message_when_no_key(void** state)
}
void
cmd_otr_myfp_shows_my_fingerprint(void** state)
cmd_otr_myfp__shows__my_fingerprint(void** state)
{
char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
gchar* args[] = { "myfp", NULL };
@@ -277,25 +277,25 @@ test_cmd_otr_theirfp_from_wintype(win_type_t wintype)
}
void
cmd_otr_theirfp_shows_message_when_in_console(void** state)
cmd_otr_theirfp__shows__message_when_in_console(void** state)
{
test_cmd_otr_theirfp_from_wintype(WIN_CONSOLE);
}
void
cmd_otr_theirfp_shows_message_when_in_muc(void** state)
cmd_otr_theirfp__shows__message_when_in_muc(void** state)
{
test_cmd_otr_theirfp_from_wintype(WIN_MUC);
}
void
cmd_otr_theirfp_shows_message_when_in_private(void** state)
cmd_otr_theirfp__shows__message_when_in_private(void** state)
{
test_cmd_otr_theirfp_from_wintype(WIN_PRIVATE);
}
void
cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state)
cmd_otr_theirfp__shows__message_when_non_otr_chat_window(void** state)
{
gchar* args[] = { "theirfp", NULL };
@@ -320,7 +320,7 @@ cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state)
}
void
cmd_otr_theirfp_shows_fingerprint(void** state)
cmd_otr_theirfp__shows__fingerprint(void** state)
{
char* recipient = "someone@chat.com";
char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
@@ -373,25 +373,25 @@ test_cmd_otr_start_from_wintype(win_type_t wintype)
}
void
cmd_otr_start_shows_message_when_in_console(void** state)
cmd_otr_start__shows__message_when_in_console(void** state)
{
test_cmd_otr_start_from_wintype(WIN_CONSOLE);
}
void
cmd_otr_start_shows_message_when_in_muc(void** state)
cmd_otr_start__shows__message_when_in_muc(void** state)
{
test_cmd_otr_start_from_wintype(WIN_MUC);
}
void
cmd_otr_start_shows_message_when_in_private(void** state)
cmd_otr_start__shows__message_when_in_private(void** state)
{
test_cmd_otr_start_from_wintype(WIN_PRIVATE);
}
void
cmd_otr_start_shows_message_when_already_started(void** state)
cmd_otr_start__shows__message_when_already_started(void** state)
{
char* recipient = "someone@server.org";
gchar* args[] = { "start", NULL };
@@ -417,7 +417,7 @@ cmd_otr_start_shows_message_when_already_started(void** state)
}
void
cmd_otr_start_shows_message_when_no_key(void** state)
cmd_otr_start__shows__message_when_no_key(void** state)
{
char* recipient = "someone@server.org";
gchar* args[] = { "start", NULL };
@@ -444,7 +444,7 @@ cmd_otr_start_shows_message_when_no_key(void** state)
}
void
cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state)
cmd_otr_start__tests__sends_otr_query_message_to_current_recipeint(void** state)
{
char* recipient = "buddy@chat.com";
char* query_message = "?OTR?";
@@ -475,7 +475,7 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state)
#else
void
cmd_otr_shows_message_when_otr_unsupported(void** state)
cmd_otr__shows__message_when_otr_unsupported(void** state)
{
gchar* args[] = { "gen", NULL };

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
void
cmd_pgp_shows_usage_when_no_args(void** state)
cmd_pgp__shows__usage_when_no_args(void** state)
{
gchar* args[] = { NULL };
@@ -25,7 +25,7 @@ cmd_pgp_shows_usage_when_no_args(void** state)
}
void
cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
cmd_pgp_start__shows__message_when_connection(jabber_conn_status_t conn_status)
{
gchar* args[] = { "start", NULL };
ProfWin window;
@@ -40,25 +40,25 @@ cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
}
void
cmd_pgp_start_shows_message_when_disconnected(void** state)
cmd_pgp_start__shows__message_when_disconnected(void** state)
{
cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTED);
cmd_pgp_start__shows__message_when_connection(JABBER_DISCONNECTED);
}
void
cmd_pgp_start_shows_message_when_disconnecting(void** state)
cmd_pgp_start__shows__message_when_disconnecting(void** state)
{
cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTING);
cmd_pgp_start__shows__message_when_connection(JABBER_DISCONNECTING);
}
void
cmd_pgp_start_shows_message_when_connecting(void** state)
cmd_pgp_start__shows__message_when_connecting(void** state)
{
cmd_pgp_start_shows_message_when_connection(JABBER_CONNECTING);
cmd_pgp_start__shows__message_when_connection(JABBER_CONNECTING);
}
void
cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
cmd_pgp_start__shows__message_when_no_arg_in_wintype(win_type_t wintype)
{
gchar* args[] = { "start", NULL };
ProfWin window;
@@ -73,38 +73,38 @@ cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
}
void
cmd_pgp_start_shows_message_when_no_arg_in_console(void** state)
cmd_pgp_start__shows__message_when_no_arg_in_console(void** state)
{
cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONSOLE);
cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_CONSOLE);
}
void
cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state)
cmd_pgp_start__shows__message_when_no_arg_in_muc(void** state)
{
cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC);
cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_MUC);
}
void
cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state)
cmd_pgp_start__shows__message_when_no_arg_in_conf(void** state)
{
cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONFIG);
cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_CONFIG);
}
void
cmd_pgp_start_shows_message_when_no_arg_in_private(void** state)
cmd_pgp_start__shows__message_when_no_arg_in_private(void** state)
{
cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_PRIVATE);
cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_PRIVATE);
}
void
cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state)
cmd_pgp_start__shows__message_when_no_arg_in_xmlconsole(void** state)
{
cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_XML);
cmd_pgp_start__shows__message_when_no_arg_in_wintype(WIN_XML);
}
#else
void
cmd_pgp_shows_message_when_pgp_unsupported(void** state)
cmd_pgp__shows__message_when_pgp_unsupported(void** state)
{
gchar* args[] = { "gen", NULL };

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

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

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

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"
void
cmd_sub_shows_message_when_not_connected(void** state)
cmd_sub__shows__message_when_not_connected(void** state)
{
gchar* args[] = { NULL };
@@ -26,7 +26,7 @@ cmd_sub_shows_message_when_not_connected(void** state)
}
void
cmd_sub_shows_usage_when_no_arg(void** state)
cmd_sub__shows__usage_when_no_arg(void** state)
{
gchar* args[] = { NULL };

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"
void
statuses_console_defaults_to_all(void** state)
prefs_get_string__returns__all_for_console_default(void** state)
{
gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE);
@@ -16,7 +16,7 @@ statuses_console_defaults_to_all(void** state)
}
void
statuses_chat_defaults_to_all(void** state)
prefs_get_string__returns__none_for_chat_default(void** state)
{
gchar* setting = prefs_get_string(PREF_STATUSES_CHAT);
@@ -26,7 +26,7 @@ statuses_chat_defaults_to_all(void** state)
}
void
statuses_muc_defaults_to_all(void** state)
prefs_get_string__returns__none_for_muc_default(void** state)
{
gchar* setting = prefs_get_string(PREF_STATUSES_MUC);

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"
void
console_shows_online_presence_when_set_online(void** state)
sv_ev_contact_online__shows__presence_in_console_when_set_online(void** state)
{
prefs_set_string(PREF_STATUSES_CONSOLE, "online");
plugins_init();
@@ -35,7 +35,7 @@ console_shows_online_presence_when_set_online(void** state)
}
void
console_shows_online_presence_when_set_all(void** state)
sv_ev_contact_online__shows__presence_in_console_when_set_all(void** state)
{
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
plugins_init();
@@ -55,7 +55,7 @@ console_shows_online_presence_when_set_all(void** state)
}
void
console_shows_dnd_presence_when_set_all(void** state)
sv_ev_contact_online__shows__dnd_presence_in_console_when_set_all(void** state)
{
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
plugins_init();
@@ -75,7 +75,7 @@ console_shows_dnd_presence_when_set_all(void** state)
}
void
handle_offline_removes_chat_session(void** state)
sv_ev_contact_offline__updates__removes_chat_session(void** state)
{
plugins_init();
roster_create();
@@ -100,7 +100,7 @@ handle_offline_removes_chat_session(void** state)
}
void
lost_connection_clears_chat_sessions(void** state)
sv_ev_lost_connection__updates__clears_chat_sessions(void** state)
{
roster_create();
roster_process_pending_presence();

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

@@ -109,7 +109,7 @@ omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res)
{
return NULL;
};
void omemo_free(void* a){};
void omemo_free(void* a) {};
uint32_t
omemo_device_id()

View File

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

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

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
void
replace_one_substr(void** state)
str_replace__returns__one_substr(void** state)
{
char* string = "it is a string";
char* sub = "is";
@@ -19,7 +19,7 @@ replace_one_substr(void** state)
}
void
replace_one_substr_beginning(void** state)
str_replace__returns__one_substr_beginning(void** state)
{
char* string = "it is a string";
char* sub = "it";
@@ -33,7 +33,7 @@ replace_one_substr_beginning(void** state)
}
void
replace_one_substr_end(void** state)
str_replace__returns__one_substr_end(void** state)
{
char* string = "it is a string";
char* sub = "string";
@@ -47,7 +47,7 @@ replace_one_substr_end(void** state)
}
void
replace_two_substr(void** state)
str_replace__returns__two_substr(void** state)
{
char* string = "it is a is string";
char* sub = "is";
@@ -61,7 +61,7 @@ replace_two_substr(void** state)
}
void
replace_char(void** state)
str_replace__returns__char(void** state)
{
char* string = "some & a thing & something else";
char* sub = "&";
@@ -75,7 +75,7 @@ replace_char(void** state)
}
void
replace_when_none(void** state)
str_replace__returns__original_when_none(void** state)
{
char* string = "its another string";
char* sub = "haha";
@@ -89,7 +89,7 @@ replace_when_none(void** state)
}
void
replace_when_match(void** state)
str_replace__returns__replaced_when_match(void** state)
{
char* string = "hello";
char* sub = "hello";
@@ -103,7 +103,7 @@ replace_when_match(void** state)
}
void
replace_when_string_empty(void** state)
str_replace__returns__empty_when_string_empty(void** state)
{
char* string = "";
char* sub = "hello";
@@ -117,7 +117,7 @@ replace_when_string_empty(void** state)
}
void
replace_when_string_null(void** state)
str_replace__returns__null_when_string_null(void** state)
{
char* string = NULL;
char* sub = "hello";
@@ -129,7 +129,7 @@ replace_when_string_null(void** state)
}
void
replace_when_sub_empty(void** state)
str_replace__returns__original_when_sub_empty(void** state)
{
char* string = "hello";
char* sub = "";
@@ -143,7 +143,7 @@ replace_when_sub_empty(void** state)
}
void
replace_when_sub_null(void** state)
str_replace__returns__original_when_sub_null(void** state)
{
char* string = "hello";
char* sub = NULL;
@@ -157,7 +157,7 @@ replace_when_sub_null(void** state)
}
void
replace_when_new_empty(void** state)
str_replace__returns__empty_when_new_empty(void** state)
{
char* string = "hello";
char* sub = "hello";
@@ -171,7 +171,7 @@ replace_when_new_empty(void** state)
}
void
replace_when_new_null(void** state)
str_replace__returns__original_when_new_null(void** state)
{
char* string = "hello";
char* sub = "hello";
@@ -185,55 +185,55 @@ replace_when_new_null(void** state)
}
void
test_online_is_valid_resource_presence_string(void** state)
valid_resource_presence_string__is__true_for_online(void** state)
{
assert_true(valid_resource_presence_string("online"));
}
void
test_chat_is_valid_resource_presence_string(void** state)
valid_resource_presence_string__is__true_for_chat(void** state)
{
assert_true(valid_resource_presence_string("chat"));
}
void
test_away_is_valid_resource_presence_string(void** state)
valid_resource_presence_string__is__true_for_away(void** state)
{
assert_true(valid_resource_presence_string("away"));
}
void
test_xa_is_valid_resource_presence_string(void** state)
valid_resource_presence_string__is__true_for_xa(void** state)
{
assert_true(valid_resource_presence_string("xa"));
}
void
test_dnd_is_valid_resource_presence_string(void** state)
valid_resource_presence_string__is__true_for_dnd(void** state)
{
assert_true(valid_resource_presence_string("dnd"));
}
void
test_available_is_not_valid_resource_presence_string(void** state)
valid_resource_presence_string__is__false_for_available(void** state)
{
assert_false(valid_resource_presence_string("available"));
}
void
test_unavailable_is_not_valid_resource_presence_string(void** state)
valid_resource_presence_string__is__false_for_unavailable(void** state)
{
assert_false(valid_resource_presence_string("unavailable"));
}
void
test_blah_is_not_valid_resource_presence_string(void** state)
valid_resource_presence_string__is__false_for_blah(void** state)
{
assert_false(valid_resource_presence_string("blah"));
}
void
utf8_display_len_null_str(void** state)
utf8_display_len__returns__0_for_null(void** state)
{
int result = utf8_display_len(NULL);
@@ -241,7 +241,7 @@ utf8_display_len_null_str(void** state)
}
void
utf8_display_len_1_non_wide(void** state)
utf8_display_len__returns__1_for_non_wide(void** state)
{
int result = utf8_display_len("1");
@@ -249,7 +249,7 @@ utf8_display_len_1_non_wide(void** state)
}
void
utf8_display_len_1_wide(void** state)
utf8_display_len__returns__2_for_wide(void** state)
{
int result = utf8_display_len("");
@@ -257,7 +257,7 @@ utf8_display_len_1_wide(void** state)
}
void
utf8_display_len_non_wide(void** state)
utf8_display_len__returns__correct_for_non_wide(void** state)
{
int result = utf8_display_len("123456789abcdef");
@@ -265,7 +265,7 @@ utf8_display_len_non_wide(void** state)
}
void
utf8_display_len_wide(void** state)
utf8_display_len__returns__correct_for_wide(void** state)
{
int result = utf8_display_len("12三四56");
@@ -273,7 +273,7 @@ utf8_display_len_wide(void** state)
}
void
utf8_display_len_all_wide(void** state)
utf8_display_len__returns__correct_for_all_wide(void** state)
{
int result = utf8_display_len("ひらがな");
@@ -281,7 +281,7 @@ utf8_display_len_all_wide(void** state)
}
void
strip_quotes_does_nothing_when_no_quoted(void** state)
strip_arg_quotes__returns__original_when_no_quotes(void** state)
{
char* input = "/cmd test string";
@@ -293,7 +293,7 @@ strip_quotes_does_nothing_when_no_quoted(void** state)
}
void
strip_quotes_strips_first(void** state)
strip_arg_quotes__returns__stripped_first(void** state)
{
char* input = "/cmd \"test string";
@@ -305,7 +305,7 @@ strip_quotes_strips_first(void** state)
}
void
strip_quotes_strips_last(void** state)
strip_arg_quotes__returns__stripped_last(void** state)
{
char* input = "/cmd test string\"";
@@ -317,7 +317,7 @@ strip_quotes_strips_last(void** state)
}
void
strip_quotes_strips_both(void** state)
strip_arg_quotes__returns__stripped_both(void** state)
{
char* input = "/cmd \"test string\"";
@@ -328,7 +328,9 @@ strip_quotes_strips_both(void** state)
free(result);
}
void test_valid_tls_policy_option(void** state) {
void
valid_tls_policy_option__is__correct_for_various_inputs(void** state)
{
// Valid inputs
assert_true(valid_tls_policy_option("force"));
assert_true(valid_tls_policy_option("allow"));
@@ -348,11 +350,13 @@ void test_valid_tls_policy_option(void** state) {
expect_any_cons_show(); // For "TLS policy must be one of: 'force', 'allow', 'trust', 'disable', 'legacy', or 'direct'."
assert_false(valid_tls_policy_option(""));
// NULL
// NULL
assert_true(valid_tls_policy_option(NULL));
}
void test_get_expanded_path(void** state) {
void
get_expanded_path__returns__expanded(void** state)
{
gchar* expanded_path;
// `file://` prefix
@@ -378,7 +382,9 @@ void test_get_expanded_path(void** state) {
g_free(expanded_path);
}
void test_strtoi_range_valid_input(void** state) {
void
strtoi_range__returns__true_for_valid_input(void** state)
{
int value;
gchar* err_msg = NULL;
gboolean result;
@@ -404,7 +410,9 @@ void test_strtoi_range_valid_input(void** state) {
assert_null(err_msg);
}
void test_strtoi_range_out_of_range(void** state) {
void
strtoi_range__returns__false_for_out_of_range(void** state)
{
int value;
gchar* err_msg = NULL;
gboolean result;
@@ -431,7 +439,9 @@ void test_strtoi_range_out_of_range(void** state) {
err_msg = NULL;
}
void test_strtoi_range_invalid_input(void** state) {
void
strtoi_range__returns__false_for_invalid_input(void** state)
{
int value;
gchar* err_msg = NULL;
gboolean result;
@@ -451,7 +461,9 @@ void test_strtoi_range_invalid_input(void** state) {
err_msg = NULL;
}
void test_strtoi_range_null_empty_input(void** state) {
void
strtoi_range__returns__false_for_null_empty_input(void** state)
{
int value;
gchar* err_msg = NULL;
gboolean result;
@@ -471,7 +483,9 @@ void test_strtoi_range_null_empty_input(void** state) {
err_msg = NULL;
}
void test_strtoi_range_null_err_msg(void** state) {
void
strtoi_range__returns__correct_values_when_err_msg_null(void** state)
{
int value;
gboolean result;
@@ -485,7 +499,9 @@ void test_strtoi_range_null_err_msg(void** state) {
assert_false(result);
}
void test_string_to_verbosity(void** state) {
void
string_to_verbosity__returns__correct_values(void** state)
{
int verbosity;
gchar* err_msg = NULL;
gboolean result;
@@ -495,52 +511,59 @@ void test_string_to_verbosity(void** state) {
assert_true(result);
assert_int_equal(0, verbosity);
assert_null(err_msg);
g_free(err_msg); err_msg = NULL; // Clear for next test
g_free(err_msg);
err_msg = NULL; // Clear for next test
// Valid input string (1)
result = string_to_verbosity("1", &verbosity, &err_msg);
assert_true(result);
assert_int_equal(1, verbosity);
assert_null(err_msg);
g_free(err_msg); err_msg = NULL;
g_free(err_msg);
err_msg = NULL;
// Valid input string (3)
result = string_to_verbosity("3", &verbosity, &err_msg);
assert_true(result);
assert_int_equal(3, verbosity);
assert_null(err_msg);
g_free(err_msg); err_msg = NULL;
g_free(err_msg);
err_msg = NULL;
// Invalid input string (not a number)
result = string_to_verbosity("profanity", &verbosity, &err_msg);
assert_false(result);
assert_string_equal("Could not convert \"profanity\" to a number.", err_msg);
g_free(err_msg);
err_msg = NULL;
err_msg = NULL;
// Valid input string, out of range (too low)
result = string_to_verbosity("-1", &verbosity, &err_msg);
assert_false(result);
assert_string_equal("Value -1 out of range. Must be in 0..3.", err_msg);
g_free(err_msg); err_msg = NULL;
g_free(err_msg);
err_msg = NULL;
// Valid input string, out of range (too high)
result = string_to_verbosity("4", &verbosity, &err_msg);
assert_false(result);
assert_string_equal("Value 4 out of range. Must be in 0..3.", err_msg);
g_free(err_msg); err_msg = NULL;
g_free(err_msg);
err_msg = NULL;
// NULL input string
result = string_to_verbosity(NULL, &verbosity, &err_msg);
assert_false(result);
assert_string_equal("'str' input pointer can not be NULL", err_msg);
g_free(err_msg); err_msg = NULL;
g_free(err_msg);
err_msg = NULL;
// Empty input string
result = string_to_verbosity("", &verbosity, &err_msg);
assert_false(result);
assert_string_equal("Could not convert \"\" to a number.", err_msg);
g_free(err_msg); err_msg = NULL;
g_free(err_msg);
err_msg = NULL;
// err_msg is NULL
result = string_to_verbosity("abc", &verbosity, NULL);
@@ -556,7 +579,7 @@ typedef struct
} format_call_external_argv_t;
void
format_call_external_argv_td(void** state)
format_call_external_argv__tests__table_driven(void** state)
{
enum table { num_tests = 4 };
@@ -613,7 +636,7 @@ typedef struct
} unique_filename_from_url_t;
void
unique_filename_from_url_td(void** state)
unique_filename_from_url__tests__table_driven(void** state)
{
enum table { num_tests = 15 };
@@ -751,7 +774,7 @@ _lists_equal(GSList* a, GSList* b)
}
void
prof_occurrences_of_large_message_tests(void** state)
prof_occurrences__tests__large_message(void** state)
{
GSList* actual = NULL;
GSList* expected = NULL;
@@ -773,7 +796,7 @@ prof_occurrences_of_large_message_tests(void** state)
}
void
prof_partial_occurrences_tests(void** state)
prof_occurrences__tests__partial(void** state)
{
GSList* actual = NULL;
GSList* expected = NULL;
@@ -865,7 +888,7 @@ prof_partial_occurrences_tests(void** state)
}
void
get_mentions_tests(void** state)
get_mentions__tests__various(void** state)
{
GSList* actual = NULL;
GSList* expected = NULL;
@@ -874,70 +897,87 @@ get_mentions_tests(void** state)
expected = g_slist_append(expected, GINT_TO_POINTER(6));
actual = get_mentions(FALSE, TRUE, "hello boothj5", "boothj5");
assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL;
g_slist_free(expected); expected = NULL;
g_slist_free(actual);
actual = NULL;
g_slist_free(expected);
expected = NULL;
// Case insensitive match
expected = g_slist_append(expected, GINT_TO_POINTER(6));
actual = get_mentions(FALSE, FALSE, "hello BOOTHJ5", "boothj5");
assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL;
g_slist_free(expected); expected = NULL;
g_slist_free(actual);
actual = NULL;
g_slist_free(expected);
expected = NULL;
// Whole word match
expected = g_slist_append(expected, GINT_TO_POINTER(0));
actual = get_mentions(TRUE, TRUE, "boothj5 hello", "boothj5");
assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL;
g_slist_free(expected); expected = NULL;
g_slist_free(actual);
actual = NULL;
g_slist_free(expected);
expected = NULL;
// Whole word no match (partial)
actual = get_mentions(TRUE, TRUE, "boothj5hello", "boothj5");
assert_true(_lists_equal(actual, expected)); // expected is NULL
g_slist_free(actual); actual = NULL;
g_slist_free(actual);
actual = NULL;
// Multiple matches
expected = g_slist_append(expected, GINT_TO_POINTER(0));
expected = g_slist_append(expected, GINT_TO_POINTER(14));
actual = get_mentions(FALSE, TRUE, "boothj5 hello boothj5", "boothj5");
assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL;
g_slist_free(expected); expected = NULL;
g_slist_free(actual);
actual = NULL;
g_slist_free(expected);
expected = NULL;
// Nick with punctuation (whole word)
expected = g_slist_append(expected, GINT_TO_POINTER(0));
actual = get_mentions(TRUE, TRUE, "boothj5: hi", "boothj5");
assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL;
g_slist_free(expected); expected = NULL;
g_slist_free(actual);
actual = NULL;
g_slist_free(expected);
expected = NULL;
// Nick surrounded by punctuation
expected = g_slist_append(expected, GINT_TO_POINTER(1));
actual = get_mentions(TRUE, TRUE, "(boothj5)", "boothj5");
assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL;
g_slist_free(expected); expected = NULL;
g_slist_free(actual);
actual = NULL;
g_slist_free(expected);
expected = NULL;
// Empty message
actual = get_mentions(FALSE, TRUE, "", "boothj5");
assert_true(_lists_equal(actual, expected)); // expected is NULL
g_slist_free(actual); actual = NULL;
g_slist_free(actual);
actual = NULL;
// Empty nick
actual = get_mentions(FALSE, TRUE, "hello", "");
assert_true(_lists_equal(actual, expected)); // expected is NULL
g_slist_free(actual); actual = NULL;
g_slist_free(actual);
actual = NULL;
// UTF-8 characters
expected = g_slist_append(expected, GINT_TO_POINTER(0));
actual = get_mentions(TRUE, TRUE, "我能 hello", "我能");
assert_true(_lists_equal(actual, expected));
g_slist_free(actual); actual = NULL;
g_slist_free(expected); expected = NULL;
g_slist_free(actual);
actual = NULL;
g_slist_free(expected);
expected = NULL;
}
void
release_is_new_tests(void** state)
release_is_new__tests__various(void** state)
{
// Higher major version
assert_true(release_is_new("0.16.0", "1.0.0"));
@@ -962,9 +1002,9 @@ release_is_new_tests(void** state)
assert_true(release_is_new("1.2.3", "2.0.0"));
// Malformed version strings
assert_false(release_is_new("0.16.0", "0.16")); // Missing patch in found
assert_false(release_is_new("0.16", "0.16.0")); // Missing patch in curr
assert_false(release_is_new("0.16.0", "0.16.0.1")); // Extra part
assert_false(release_is_new("0.16.0", "0.16")); // Missing patch in found
assert_false(release_is_new("0.16", "0.16.0")); // Missing patch in curr
assert_false(release_is_new("0.16.0", "0.16.0.1")); // Extra part
assert_false(release_is_new("0.16.0", "abc.def.ghi"));
assert_false(release_is_new("0.16.0", ""));
@@ -973,7 +1013,7 @@ release_is_new_tests(void** state)
}
void
prof_whole_occurrences_tests(void** state)
prof_occurrences__tests__whole(void** state)
{
GSList* actual = NULL;
GSList* expected = NULL;
@@ -1175,7 +1215,9 @@ prof_whole_occurrences_tests(void** state)
expected = NULL;
}
void test_string_matches_one_of_edge_cases(void** state) {
void
string_matches_one_of__tests__edge_cases(void** state)
{
// is is NULL, is_can_be_null is TRUE -> should return TRUE
assert_true(string_matches_one_of(NULL, NULL, TRUE, "option1", "option2", NULL));

View File

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

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

@@ -22,7 +22,7 @@ aesgcm_file_get(void* userdata)
return NULL;
};
void aesgcm_download_cancel_processes(ProfWin* window){};
void aesgcm_download_add_download(AESGCMDownload* download){};
void aesgcm_download_cancel_processes(ProfWin* window) {};
void aesgcm_download_add_download(AESGCMDownload* download) {};
#endif

View File

@@ -27,7 +27,7 @@ http_file_get(void* userdata)
return NULL;
}
void http_download_cancel_processes(){};
void http_download_add_download(){};
void http_download_cancel_processes() {};
void http_download_add_download() {};
#endif

View File

@@ -38,7 +38,7 @@ file_size(int filedes)
return 0;
}
void http_upload_cancel_processes(){};
void http_upload_add_upload(){};
void http_upload_cancel_processes() {};
void http_upload_add_upload() {};
#endif

View File

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

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

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

Some files were not shown because too many files have changed in this diff Show More