test/blacklist_test.cc
author fdik
Thu, 03 Mar 2016 19:27:46 +0100
changeset 494 ddf4130d00a0
child 526 b8b302ec9330
permissions -rw-r--r--
Added blacklist
fdik@494
     1
#include <iostream>
fdik@494
     2
#include <string>
fdik@494
     3
#include <assert.h>
fdik@494
     4
#include "blacklist.h"
fdik@494
     5
fdik@494
     6
using namespace std;
fdik@494
     7
fdik@494
     8
int main() {
fdik@494
     9
    cout << "\n*** blacklist_test ***\n\n";
fdik@494
    10
fdik@494
    11
    PEP_SESSION session;
fdik@494
    12
    
fdik@494
    13
    cout << "calling init()\n";
fdik@494
    14
    PEP_STATUS status1 = init(&session);   
fdik@494
    15
    assert(status1 == PEP_STATUS_OK);
fdik@494
    16
    assert(session);
fdik@494
    17
    cout << "init() completed.\n";
fdik@494
    18
fdik@494
    19
    // blacklist test code
fdik@494
    20
fdik@494
    21
    cout << "adding 23 to blacklist\n";
fdik@494
    22
    PEP_STATUS status2 = blacklist_add(session, "23");
fdik@494
    23
    assert(status2 == PEP_STATUS_OK);
fdik@494
    24
    cout << "added.\n";
fdik@494
    25
fdik@494
    26
    bool listed;
fdik@494
    27
    PEP_STATUS status3 = blacklist_is_listed(session, "23", &listed);
fdik@494
    28
    assert(status3 == PEP_STATUS_OK);
fdik@494
    29
    assert(listed);
fdik@494
    30
    cout << "23 is listed.\n";
fdik@494
    31
fdik@494
    32
    stringlist_t *blacklist;
fdik@494
    33
    PEP_STATUS status6 = blacklist_retrieve(session, &blacklist);
fdik@494
    34
    assert(status6 == PEP_STATUS_OK);
fdik@494
    35
    assert(blacklist);
fdik@494
    36
fdik@494
    37
    bool in23 = false;
fdik@494
    38
    cout << "the blacklist contains now: ";
fdik@494
    39
    for (stringlist_t *bl = blacklist; bl && bl->value; bl = bl->next) {
fdik@494
    40
        cout << bl->value << ", ";
fdik@494
    41
        if (strcmp(bl->value, "23") == 0)
fdik@494
    42
            in23 = true;
fdik@494
    43
    }
fdik@494
    44
    cout << "END\n";
fdik@494
    45
    assert(in23);
fdik@494
    46
    free_stringlist(blacklist);
fdik@494
    47
fdik@494
    48
    cout << "deleting 23 from blacklist\n";
fdik@494
    49
    PEP_STATUS status4 = blacklist_delete(session, "23");
fdik@494
    50
    assert(status4 == PEP_STATUS_OK);
fdik@494
    51
    cout << "deleted.\n";
fdik@494
    52
    
fdik@494
    53
    PEP_STATUS status5 = blacklist_is_listed(session, "23", &listed);
fdik@494
    54
    assert(status5 == PEP_STATUS_OK);
fdik@494
    55
    assert(!listed);
fdik@494
    56
    cout << "23 is not listed any more.\n";
fdik@494
    57
fdik@494
    58
    cout << "calling release()\n";
fdik@494
    59
    release(session);
fdik@494
    60
    return 0;
fdik@494
    61
}
fdik@494
    62