You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
#include <stdlib.h>
|
|
#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) {
|
|
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");
|
|
|
|
TQByteArray apass, bpass, cpass;
|
|
|
|
apass.duplicate("apassword", 9);
|
|
bpass.duplicate("bpassword", 9);
|
|
cpass.duplicate("cpassword", 9);
|
|
|
|
|
|
int test_cnt = 0;
|
|
int test_failed = 0;
|
|
|
|
printf("Passwords initialised.\n");
|
|
|
|
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 ("===========================================\n");
|
|
printf ("%d test failed out of %d\n", test_failed, test_cnt);
|
|
|
|
return test_failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
}
|
|
|
|
|