Commit 0c67410c authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fixed tester

parent 9dfe8c4c
......@@ -8,6 +8,11 @@ noinst_PROGRAMS=belcard-tester
belcard_tester_SOURCES=belcard-tester.cpp belcard-tester.hpp common/bc_tester_utils.c common/bc_tester_utils.h belcard-identification-tester.cpp
belcard_tester_LDADD=$(top_builddir)/src/libbelcard.la -lbelr $(CUNIT_LIBS)
belcard_tester_AM_CPPFLAGS= -DBC_CONFIG_FILE=\"config.h\" \
-I$(top_srcdir)/include \
-I$(top_srcdir)/tester \
-I$(top_srcdir)/tester/common
endif # BUILD_TESTS
belcard_folder_SOURCES=belcard-folder.cpp
......@@ -16,6 +21,4 @@ belcard_folder_LDADD=$(top_builddir)/src/libbelcard.la -lbelr
belcard_unfolder_SOURCES=belcard-unfolder.cpp
belcard_unfolder_LDADD=$(top_builddir)/src/libbelcard.la -lbelr
AM_CPPFLAGS=-I$(top_srcdir)/include \
-I$(top_srcdir)/tester \
-I$(top_srcdir)/tester/common
AM_CPPFLAGS=-I$(top_srcdir)/include
......@@ -17,63 +17,72 @@ static int tester_after_all(void) {
static void fn_property(void) {
string input = "FN:Sylvain Berfini\r\n";
shared_ptr<BelCardFN> fn = BelCardFN::parse(input);
BC_ASSERT_TRUE_FATAL(fn != NULL);
stringstream sstream;
sstream << *fn;
BC_ASSERT_TRUE(input.compare(sstream.str()) == 0);
BC_ASSERT_EQUAL(input.compare(sstream.str()), 0, int, "%d");
}
static void n_property(void) {
string input = "N:Berfini;Sylvain;Pascal;;\r\n";
shared_ptr<BelCardN> n = BelCardN::parse(input);
BC_ASSERT_TRUE_FATAL(n != NULL);
stringstream sstream;
sstream << *n;
BC_ASSERT_TRUE(input.compare(sstream.str()) == 0);
BC_ASSERT_EQUAL(input.compare(sstream.str()), 0, int, "%d");
}
static void nickname_property(void) {
string input = "NICKNAME;TYPE=home:Viish\r\n";
shared_ptr<BelCardNickname> nickname = BelCardNickname::parse(input);
BC_ASSERT_TRUE_FATAL(nickname != NULL);
stringstream sstream;
sstream << *nickname;
BC_ASSERT_TRUE(input.compare(sstream.str()) == 0);
BC_ASSERT_EQUAL(input.compare(sstream.str()), 0, int, "%d");
}
static void bday_property(void) {
string input = "BDAY:19891001\r\n";
shared_ptr<BelCardBirthday> bday = BelCardBirthday::parse(input);
BC_ASSERT_TRUE_FATAL(bday != NULL);
stringstream sstream;
sstream << *bday;
BC_ASSERT_TRUE(input.compare(sstream.str()) == 0);
BC_ASSERT_EQUAL(input.compare(sstream.str()), 0, int, "%d");
}
static void anniversary_property(void) {
string input = "ANNIVERSARY:20140621\r\n";
shared_ptr<BelCardAnniversary> anniversary = BelCardAnniversary::parse(input);
BC_ASSERT_TRUE_FATAL(anniversary != NULL);
stringstream sstream;
sstream << *anniversary;
BC_ASSERT_TRUE(input.compare(sstream.str()) == 0);
BC_ASSERT_EQUAL(input.compare(sstream.str()), 0, int, "%d");
}
static void gender_property(void) {
string input = "GENDER:M\r\n";
shared_ptr<BelCardGender> gender = BelCardGender::parse(input);
BC_ASSERT_TRUE_FATAL(gender != NULL);
stringstream sstream;
sstream << *gender;
BC_ASSERT_TRUE(input.compare(sstream.str()) == 0);
BC_ASSERT_EQUAL(input.compare(sstream.str()), 0, int, "%d");
}
static void photo_property(void) {
string input = "PHOTO;VALUE=URL;MEDIATYPE=image/png:http://www.belledonne-communications.com/uploads/images/belledonne-communications.png\r\n";
shared_ptr<BelCardPhoto> photo = BelCardPhoto::parse(input);
BC_ASSERT_TRUE_FATAL(photo != NULL);
stringstream sstream;
sstream << *photo;
BC_ASSERT_TRUE(input.compare(sstream.str()) == 0);
BC_ASSERT_EQUAL(input.compare(sstream.str()), 0, int, "%d");
input = "PHOTO:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAYAAAAehFoBAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH3wkYDSo4+LD+vgAAB/pJREFUWMPtmH1sXXUZxz/P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QZN7TtpcwTtl29eEy3TGiLe7d/Ux4eLYISflGj9p5Brnq2g0Mi2MhB5Gow0jeyCx+3wmua4caVHdecPOOO/UMFUlaJFM7/w5slvyvVFDFvDOzdbXt56NXu0XBkZAQWoNwIWc9grYLqdXxz+TFhP/SO4+i2/Isv7t762z29Sys9Q71nGAwtP1/ZxLK6KuJGiFTZn85yy+ZOako1x6AR7mtpYmZFHBEhF1o2bE9x55sHwTNg3TOsaV710WxCH3zZY0p8M55ZFjdCvSdUilBxtAITQVC8ktKqEKkSKhRQhq3Sbx0HrBbfjnXPIHyW1c360W7z17ffhpG7xBPKjaHWCBUCcRE8kRE/U4rAxTgLh50j4xQ96garm9d9jF9+2hoR8zsMZ1NSNyFCIKPpMwJyChktKaqqONpw7grWLu8dz23NuIGRfaw+ZxlWawjdY2Hk3GBktTe0HIwcByNHb2gZiqy60IVY9xMincLqc1oQ6R33XY/bZ8XvPi/UV87EUA1SKsM0h6PvWOl20iZt0ibt/9j+CXhStzl5GgtiAAAAAElFTkSuQmCC\r\n";
photo = BelCardPhoto::parse(input);
stringstream sstream2;
sstream2 << *photo;
BC_ASSERT_TRUE(input.compare(sstream2.str()) == 0);
BC_ASSERT_TRUE_FATAL(photo != NULL);
sstream.str(std::string());
sstream.clear();
sstream << *photo;
BC_ASSERT_EQUAL(input.compare(sstream.str()), 0, int, "%d");
}
static test_t tests[] = {
......
# Copyright (C) 2012 Belledonne Comunications, Grenoble, France
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Created by Gautier Pelloux-Prayer on 2014/10/24.
# This script adds auto-completion for liblinphone_tester binary for Bash and
# Zsh. To use it, just type: `source liblinphone_completion`, then for each
# supported exectuable (see end of file), you will get auto-completions.
# To use it permanently, source this file in your .rc file (.bashrc or .zshrc).
_liblinphone_complete() {
local completions command_requiring_argument prev_arg latest_arg available_tasks has_not_set_suite suite_name
if [ -n "$BASH_VERSION" ]; then
set -- "${COMP_WORDS[@]}" #convert them to arguments (eg $1,$#,$@,etc.)
elif [ -n "$ZSH_VERSION" ]; then
local args
read -cA args #read list of arguments user entered
set -- "${args[@]}" #convert them to arguments (eg $1,$#,$@,etc.)
fi
#skip program name
program=$1
shift
# if user required help, do not complete anything
if ! grep -q -- "--help" <<< "$@"; then
# retrieve the last argument
latest_arg=""
prev_arg=""
latest_is_empty=0
for arg in "$@"; do
if [ ! -z "$arg" ]; then
prev_arg="$latest_arg"
latest_arg="$arg"
else
latest_is_empty=1
fi
done
# get the tasks available, from --help
available_tasks="$($program 2>&1 --help | sed -nE "s/.*--([^ ]*).*/--\\1/p")"
# these commands expect an argument
command_requiring_argument="$($program 2>&1 --help | sed -nE "s/.*--(.*) <.*/--\\1/p")"
# remove all already provided tasks (it's useless to provide them twice)
if [[ ! -z "$@" ]]; then
current_tasks=$(echo $@ | grep -Eo -- "--([^ ])*" | tr '\n' '|' | sed 's/|/$|/g')--$
if [ ! -z "$current_tasks" ]; then
available_tasks=$(echo "$available_tasks" | grep -vE -- "(${current_tasks})")
fi
fi
# remove --test option if --suite is not provided yet!
has_not_set_suite=$(grep -q -- "--suite" <<< "$@"; echo $?)
if [ $has_not_set_suite = 1 ]; then
available_tasks=$(echo "$available_tasks" | grep -v -- --test)
fi
# if latest arg does not start with '--', it is a custom value
if [ $latest_is_empty = 0 ] && ! grep -q -- '^--' <<< "$latest_arg"; then
if [ "$prev_arg" = "--test" ] && [ $has_not_set_suite = 0 ]; then
suite_name=$(echo $@ | sed -nE 's/.*--suite ([^(--)]*) (--.*)$/\1/p' |sed "s@\\\\@@g")
completions="$($program --list-tests $suite_name)"
elif [ "$prev_arg" = "--suite" ] || [ "$prev_arg" = "--list-tests" ]; then
completions="$($program --list-suites)"
fi
elif [ "$latest_arg" = "--test" ]; then
# list available tests if --suite was provided
if [ $has_not_set_suite = 0 ]; then
suite_name=$(echo $@ | sed -nE 's/.*--suite ([^(--)]*) (--.*)/\1/p' |sed "s@\\\\@@g")
completions="$($program --list-tests $suite_name)"
fi
elif [ "$latest_arg" = "--suite" ] || [ "$latest_arg" = "--list-tests" ]; then
completions="$($program --list-suites)"
# we are waiting for a custom value, so do not hint anything
elif [[ ! -z "$latest_arg" ]] && grep -q -- "^$latest_arg$" <<< "$command_requiring_argument"; then
completions=""
else
completions="$available_tasks"
fi
fi
if [ ! -z "$completions" ]; then
if [ -n "$BASH_VERSION" ]; then
IFS=$'\n' #if that even necessary?
COMPREPLY=($(compgen -W "${completions}" -- ${COMP_WORDS[COMP_CWORD]}))
elif [ -n "$ZSH_VERSION" ]; then
reply=( "${(ps:\n:)completions}" )
fi
fi
}
for tester in belcard-tester; do
if [ -n "$BASH_VERSION" ]; then
complete -F _liblinphone_complete $tester
elif [ -n "$ZSH_VERSION" ]; then
compctl -K _liblinphone_complete $tester
else
echo "Your shell might be not supported! Only bash and zsh tested."
fi
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment