| 577 | } |
| 578 | |
| 579 | void testNames() { |
| 580 | void* highs = Highs_create(); |
| 581 | |
| 582 | if (!dev_run) Highs_setBoolOptionValue(highs, "output_flag", 0); |
| 583 | |
| 584 | createBlendingLp(highs); |
| 585 | |
| 586 | HighsInt return_status; |
| 587 | |
| 588 | const HighsInt num_col = 2; |
| 589 | const HighsInt num_row = 3; |
| 590 | assert(num_col == Highs_getNumCols(highs)); |
| 591 | assert(num_row == Highs_getNumRows(highs)); |
| 592 | |
| 593 | char* col_prefix = "Col"; |
| 594 | char* row_prefix = "Row"; |
| 595 | // Check index out of bounds |
| 596 | |
| 597 | return_status = Highs_passColName(highs, -1, col_prefix); |
| 598 | assert(return_status == kHighsStatusError); |
| 599 | return_status = Highs_passRowName(highs, -1, row_prefix); |
| 600 | assert(return_status == kHighsStatusError); |
| 601 | return_status = Highs_passColName(highs, num_col, col_prefix); |
| 602 | assert(return_status == kHighsStatusError); |
| 603 | return_status = Highs_passRowName(highs, num_row, row_prefix); |
| 604 | assert(return_status == kHighsStatusError); |
| 605 | |
| 606 | // Define all column names to be the same |
| 607 | for (HighsInt iCol = 0; iCol < num_col; iCol++) { |
| 608 | return_status = Highs_passColName(highs, iCol, col_prefix); |
| 609 | assert(return_status == kHighsStatusOk); |
| 610 | } |
| 611 | return_status = Highs_writeModel(highs, ""); |
| 612 | assert(return_status == kHighsStatusWarning); |
| 613 | |
| 614 | char name[5]; // 3 chars prefix, 1 char iCol, 1 char 0-terminator |
| 615 | |
| 616 | // Define all column names to be different |
| 617 | for (HighsInt iCol = 0; iCol < num_col; iCol++) { |
| 618 | sprintf(name, "%s%" HIGHSINT_FORMAT "", col_prefix, iCol); |
| 619 | return_status = Highs_passColName(highs, iCol, name); |
| 620 | assert(return_status == kHighsStatusOk); |
| 621 | } |
| 622 | return_status = Highs_writeModel(highs, ""); |
| 623 | assert(return_status == kHighsStatusOk); |
| 624 | |
| 625 | // Check that the columns can be found by name |
| 626 | HighsInt ck_iCol; |
| 627 | for (HighsInt iCol = 0; iCol < num_col; iCol++) { |
| 628 | return_status = Highs_getColName(highs, iCol, name); |
| 629 | assert(return_status == kHighsStatusOk); |
| 630 | return_status = Highs_getColByName(highs, name, &ck_iCol); |
| 631 | assert(return_status == kHighsStatusOk); |
| 632 | assert(ck_iCol == iCol); |
| 633 | } |
| 634 | return_status = Highs_getColByName(highs, "FRED", &ck_iCol); |
| 635 | assert(return_status == kHighsStatusError); |
| 636 |
no test coverage detected