Ticket #7024: test_libs_linprogram.patch

File test_libs_linprogram.patch, 2.2 KB (added by Karvjorm, 13 years ago)

Fixing the test program to use the BObjetList object.

  • src/tests/libs/linprog/Jamfile

     
    22
    33SetSubDirSupportedPlatformsBeOSCompatible ;
    44
     5UsePrivateHeaders shared ;
     6
    57UseLibraryHeaders lp_solve linprog ;
    68
    79SimpleTest linprog_test :
    810    Program.cpp
    911    :
    10     be liblpsolve55.so liblinprog.so $(TARGET_LIBSUPC++)
     12    be liblpsolve55.so liblinprog.a $(TARGET_LIBSUPC++)
    1113;
  • src/tests/libs/linprog/Program.cpp

     
    44 * Distributed under the terms of the MIT License.
    55 */
    66
    7 #include <List.h>
     7#include <ObjectList.h>
    88#include <SupportDefs.h>
    99
    1010#include "LinearSpec.h"
    1111
    1212#include <stdio.h>
    1313
     14using namespace LinearProgramming;
    1415
    1516void
    1617PrintVars(LinearSpec* ls)
    1718{
    18     int32 size = ls->Variables()->CountItems();
     19    int32 size = ls->Variables().CountItems();
    1920    Variable* variable;
    20     for (int i = 0; i < size; i++) {
    21         variable = (Variable*)ls->Variables()->ItemAt(i);
     21    for (int32 i = 0; i < size; i++) {
     22        variable = (Variable*)ls->Variables().ItemAt(i);
    2223        printf("%f ", variable->Value());
    2324    }
    2425    printf("%d\n", ls->Result());
     
    3233    Variable* x1 = ls->AddVariable();
    3334    Variable* x2 = ls->AddVariable();
    3435   
    35     Constraint* c1 = ls->AddConstraint(1.0, x1, OperatorType(LE), 108);
    36     Constraint* c2 = ls->AddConstraint(1.0, x2, OperatorType(GE), 113);
     36    Constraint* c1 = ls->AddConstraint(1.0, x1, OperatorType(kLE), 108);   
     37    Constraint* c2 = ls->AddConstraint(1.0, x2, OperatorType(kGE), 113);
    3738   
    38     BList* summands = new BList(2);
     39    SummandList* summands = new SummandList(2);
    3940    summands->AddItem(new Summand(1.0, x1));
    4041    summands->AddItem(new Summand(1.0, x2));
    41     ls->SetObjFunction(summands);
    42    
     42    ls->SetObjectiveFunction(summands);
     43
    4344    ls->Solve();
    4445    PrintVars(ls);
    45    
     46
     47    delete c1;
    4648    delete c2;
    4749    ls->Solve();
    4850    PrintVars(ls);
    4951   
    50     c2 = ls->AddConstraint(1.0, x2, OperatorType(GE), 113);
     52    c2 = ls->AddConstraint(1.0, x2, OperatorType(kGE), 113);
    5153    ls->Solve();
    5254    PrintVars(ls);
    5355}