diff options
author | Alexander Golubev <fatzer2@gmail.com> | 2016-12-21 01:13:31 +0300 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2017-01-29 02:48:50 +0100 |
commit | 0e614010bd32bccc8bd5b9a9e49894a9f466b08d (patch) | |
tree | 05309c2dbd304806feceac88e3eff2c5b0d3b819 /tdewallet/backend/tests/backendtest.cpp | |
parent | 86921d65c5c218a2c721d905a93885cf2fe9b7b7 (diff) | |
download | tdelibs-0e614010bd32bccc8bd5b9a9e49894a9f466b08d.tar.gz tdelibs-0e614010bd32bccc8bd5b9a9e49894a9f466b08d.zip |
tdeui & tdewallet: add tests
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit 16a176dab1e978bef8f8d49801fa98a028d1d17b)
Diffstat (limited to 'tdewallet/backend/tests/backendtest.cpp')
-rw-r--r-- | tdewallet/backend/tests/backendtest.cpp | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/tdewallet/backend/tests/backendtest.cpp b/tdewallet/backend/tests/backendtest.cpp index 85e916940..306aa3c4b 100644 --- a/tdewallet/backend/tests/backendtest.cpp +++ b/tdewallet/backend/tests/backendtest.cpp @@ -2,12 +2,28 @@ #include <stdio.h> #include <tdeapplication.h> +#include <tdeaboutdata.h> +#include <tdecmdlineargs.h> #include <tqstring.h> #include "tdewalletbackend.h" +#define CHECK_RETURN(func, test, test_str) { \ + int rc = (func); \ + test_cnt++;\ + if (test) {\ + printf("%-20s returned %d as expected (should be %s)\n", #func, rc, test_str);\ + } else {\ + printf("%-20s returned %d UNEXPECTEDLY (should be %s)\n", #func, rc, test_str);\ + test_failed++;\ + }\ +} + int main(int argc, char **argv) { - TDEApplication a(argc, argv, "tdewalletbackendtest"); + TDEAboutData aboutData( "tdewalletbackendtest", "tdewallet backend testing routine", "0.1" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDEApplication a(false, false); TDEWallet::Backend be("ktestwallet"); printf("TDEWalletBackend constructed\n"); @@ -18,28 +34,22 @@ int main(int argc, char **argv) { bpass.duplicate("bpassword", 9); cpass.duplicate("cpassword", 9); - printf("Passwords initialised.\n"); - int rc = be.close(apass); - - printf("be.close(apass) returned %d (should be -255)\n", rc); - rc = be.open(bpass); + int test_cnt = 0; + int test_failed = 0; - printf("be.open(bpass) returned %d (should be 0 or 1)\n", rc); - - rc = be.close(bpass); - - printf("be.close(bpass) returned %d (should be 0)\n", rc); - - rc = be.open(apass); - - printf("be.open(apass) returned %d (should be negative)\n", rc); + printf("Passwords initialised.\n"); - rc = be.open(bpass); + CHECK_RETURN(be.close(apass), rc==-255, "-255"); + CHECK_RETURN(be.open(bpass), rc==0 || rc==1, "0 or 1"); + CHECK_RETURN(be.close(bpass), rc==0, "0 or 1"); + CHECK_RETURN(be.open(apass), rc<0, "negative"); + CHECK_RETURN(be.open(bpass), rc==0, "0"); - printf("be.open(bpass) returned %d (should be 0)\n", rc); + printf ("===========================================\n"); + printf ("%d test failed out of %d\n", test_failed, test_cnt); - return 0; + return test_failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } |