Ignore:
Timestamp:
Mar 17, 2014 4:21:18 PM (5 years ago)
Author:
mlubin
Message:

Improved documentation. Tests for callbacks and row/column names. More restructuring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/test/CInterfaceTest.c

    r2020 r2021  
    1010#include <stdio.h>
    1111#include <string.h>
     12
     13
     14static int callback_called = 0;
     15
     16void (COINLINKAGE_CB test_callback)(Cbc_Model * model,int  msgno, int ndouble,
     17                            const double * dvec, int nint, const int * ivec,
     18                            int nchar, char ** cvec) {
     19
     20    callback_called = 1;
     21    printf("In callback: message %d\n", msgno);
     22
     23}
    1224
    1325
     
    3547    int i;
    3648
     49    printf("Interface reports Cbc version %s\n", Cbc_getVersion());
     50
    3751    Cbc_loadProblem(model, 5, 1, start, rowindex, value, collb, colub, obj, rowlb, rowub);
     52
     53    Cbc_setColName(model, 2, "var2");
     54    Cbc_setRowName(model, 0, "constr0");
     55
    3856
    3957    assert(Cbc_getNumCols(model) == 5);
     
    5068    Cbc_setProblemName(model, setname);
    5169
     70    Cbc_registerCallBack(model, test_callback);
     71
    5272    Cbc_solve(model);
    5373
     
    6080    assert(!Cbc_isSolutionLimitReached(model));
    6181    assert(fabs( Cbc_getObjValue(model)- (16.0) < 1e-6));
     82    assert(fabs( Cbc_getBestPossibleObjValue(model)- (16.0) < 1e-6));
     83
     84    assert(callback_called == 1);
    6285   
    6386    sol = Cbc_getColSolution(model);
     
    7295    i = strcmp(getname,setname);
    7396    assert( (i == 0) );
     97
     98    Cbc_getColName(model, 2, getname, 20);
     99    i = strcmp(getname, "var2");
     100    assert( (i == 0) );
     101    Cbc_getRowName(model, 0, getname, 20);
     102    i = strcmp(getname, "constr0");
     103    assert( (i == 0) );
     104    assert( Cbc_maxNameLength(model) >= 7 );
    74105   
    75106    Cbc_deleteModel(model);
Note: See TracChangeset for help on using the changeset viewer.