/* Siconos is a program dedicated to modeling, simulation and control
 * of non smooth dynamical systems.
 *
 * Copyright 2021 INRIA.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <stdio.h>             // for printf
#include <string.h>            // for strcmp
#include "relay_cst.h"         // for SICONOS_RELAY_AVI_CAOFERRIS, SICONOS_R...
#include "relay_test_utils.h"  // for relay_test_function
#include "test_utils.h"        // for build_test_collection_generic, data_co...
#include "SiconosConfig.h"     // for HAVE_PATHFERRIS // IWYU pragma: keep


#define @PROBLEM_COLLECTION@ 1

int main(void)
{
  // Remind that data_collection depends on current PROBLEM_COLLECTION value.
  const char ** _data_collection = data_collection();
  int n_data = 0;
  while (strcmp(_data_collection[n_data], "---") !=0)
    n_data++;

  // set the list of solvers to be tested on the current data collections.
#ifdef TEST_RELAY_COLLECTION_1
  int solvers[] = {
                   SICONOS_RELAY_LEMKE, SICONOS_RELAY_PGS, SICONOS_RELAY_AVI_CAOFERRIS,
#ifdef HAVE_PATHFERRIS
                   SICONOS_RELAY_PATH,
#endif
                   SICONOS_RELAY_ENUM
  };
#endif

  // Rq : solver options parameters (tol and maxiter + default) are set explicitely in relay_test_function.
  // All the same for all test cases.

  int n_solvers = (int)(sizeof(solvers) / sizeof(solvers[0]));

  TestCase * collection = build_test_collection_generic(n_data, _data_collection, n_solvers, solvers);

  printf("Test %i data files with %i solvers.\n", n_data, n_solvers);
  int number_of_tests = n_data * n_solvers;

  number_of_tests -= 1;   // Remove the last test : no enum on data/relay1.dat, too long ...
  int out = run_test_collection(collection, number_of_tests, relay_test_function);

  free_test_collection(collection, number_of_tests);

  
  return out;
}
