summaryrefslogtreecommitdiffstats
path: root/kwallet/backend/tests/backendtest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kwallet/backend/tests/backendtest.cpp')
-rw-r--r--kwallet/backend/tests/backendtest.cpp46
1 files changed, 28 insertions, 18 deletions
diff --git a/kwallet/backend/tests/backendtest.cpp b/kwallet/backend/tests/backendtest.cpp
index e7599b3a2..c96fa42ce 100644
--- a/kwallet/backend/tests/backendtest.cpp
+++ b/kwallet/backend/tests/backendtest.cpp
@@ -2,12 +2,28 @@
#include <stdio.h>
#include <kapplication.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
#include <tqstring.h>
#include "kwalletbackend.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) {
- KApplication a(argc, argv, "kwalletbackendtest");
+ KAboutData aboutData( "kwalletbackendtest", "kwallet backend testing routine", "0.1" );
+
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KApplication a(false, false);
KWallet::Backend be("ktestwallet");
printf("KWalletBackend 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;
}