Changeset 41:a3f71b4eaca1 in xplra for test


Ignore:
Timestamp:
02/14/13 18:32:21 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added test cases for the 'unknown dataref' error with position information

Location:
test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • test/multigetctest.c

    r30 r41  
    5151
    5252    int connectionID = -1;
     53    int wrongGetterID = -1;
    5354    int getterID = -1;
    5455
     
    147148        goto cleanup;
    148149    }
     150
     151    wrongGetterID = xplra_multi_create_getter(connectionID);
     152    if (wrongGetterID<0) goto error;
     153    xplra_multi_add_int(wrongGetterID, "sim/time/local_date_days");
     154    xplra_multi_add_int(wrongGetterID, "sim/time/paused");
     155    xplra_multi_add_int(wrongGetterID, "sim/time/hello_te_lo");
     156    xplra_multi_add_float(wrongGetterID, "sim/time/zulu_time_sec");
     157    xplra_multi_add_int(wrongGetterID, "sim/operation/prefs/replay_mode");
     158
     159    printf("Executing a multi-dataref getter with an invalid dataref...\n");
     160    if (xplra_multi_execute(wrongGetterID)<0) {
     161        printf("Error occured: %s\n\n",
     162               xplra_get_last_error_string(connectionID));
     163        xplra_clear_last_error(connectionID);
     164    } else {
     165        printf(">>>>>>>>>>>>>>>>>>>>> Succeeded, but it should not have!!!!\n\n");
     166    }
     167
     168    printf("Executing a registered multi-dataref getter with an invalid dataref...\n");
     169    if (xplra_multi_register(wrongGetterID)<0) goto error;
     170    if (xplra_multi_execute(wrongGetterID)<0) {
     171        printf("Error occured: %s\n\n",
     172               xplra_get_last_error_string(connectionID));
     173        xplra_clear_last_error(connectionID);
     174    } else {
     175        printf(">>>>>>>>>>>>>>>>>>>>> Succeeded, but it should not have!!!!\n\n");
     176    }
     177
    149178
    150179    getterID = xplra_multi_create_getter(connectionID);
  • test/multigettest.cc

    r29 r41  
    4242using hu::varadiistvan::xplra::MultiGetter;
    4343using hu::varadiistvan::xplra::Exception;
     44using hu::varadiistvan::xplra::ProtocolException;
    4445
    4546using hu::varadiistvan::scpl::Thread;
     
    6263        xplane.connect();
    6364        printf("Connected to X-Plane.\n\n");
     65
     66        MultiGetter& wrongGetter = xplane.createMultiGetter();
     67        wrongGetter.addInt("sim/time/local_date_days");
     68        wrongGetter.addInt("sim/time/paused");
     69        wrongGetter.addInt("sim/time/hello_te_lo");
     70        wrongGetter.addFloat("sim/time/zulu_time_sec");
     71        wrongGetter.addInt("sim/operation/prefs/replay_mode");
     72
     73        printf("Executing a multi-dataref getter with an invalid dataref...\n");
     74        try {
     75            wrongGetter.execute();
     76            printf(">>>>>>>>>>>>>>>>>>>>> Succeeded, but it should not have!!!!\n\n");
     77        } catch(const ProtocolException& e) {
     78            printf("Caught protocol exception: %s\n\n", e.what());
     79        }
     80
     81        printf("Executing a registered multi-dataref getter with an invalid dataref...\n");
     82        wrongGetter.registerInXPlane();
     83        try {
     84            wrongGetter.execute();
     85            printf(">>>>>>>>>>>>>>>>>>>>> Succeeded, but it should not have!!!!\n\n");
     86        } catch(const ProtocolException& e) {
     87            printf("Caught protocol exception: %s\n\n", e.what());
     88        }
    6489
    6590        MultiGetter& getter = xplane.createMultiGetter();
  • test/multigettest.py

    r35 r41  
    1616        xplane.connect()
    1717        print "Connected to X-Plane."
     18        print
     19
     20        wrongGetter = xplane.createMultiGetter();
     21        wrongGetter.addInt("sim/time/local_date_days");
     22        wrongGetter.addInt("sim/time/paused");
     23        wrongGetter.addInt("sim/time/hello_te_lo");
     24        wrongGetter.addFloat("sim/time/zulu_time_sec");
     25        wrongGetter.addInt("sim/operation/prefs/replay_mode");
     26
     27        print "Executing a multi-dataref getter with an invalid dataref..."
     28        try:
     29            wrongGetter.execute();
     30            print ">>>>>>>>>>>>>>>>>>>>> Succeeded, but it should not have!!!!"
     31        except ProtocolException, e:
     32            print "Caught protocol exception: " + str(e)
     33        print
     34
     35        print "Executing a registered multi-dataref getter with an invalid dataref..."
     36        wrongGetter.register()
     37        try:
     38            wrongGetter.execute();
     39            print ">>>>>>>>>>>>>>>>>>>>> Succeeded, but it should not have!!!!"
     40        except ProtocolException, e:
     41            print "Caught protocol exception: " + str(e)
    1842        print
    1943
Note: See TracChangeset for help on using the changeset viewer.