test_main.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /****************************************************************************
  2. *
  3. * MODULE: test.rtree.lib
  4. *
  5. * AUTHOR(S): Original author
  6. * Soeren Gebbert soerengebbert <at> gmx <dot> de
  7. * 05 Sep 2007 Berlin
  8. *
  9. * PURPOSE: Unit test for the vector rtree implementation
  10. *
  11. * COPYRIGHT: (C) 2007 by the GRASS Development Team
  12. *
  13. * This program is free software under the GNU General Public
  14. * License (>=v2). Read the file COPYING that comes with GRASS
  15. * for details.
  16. *
  17. *****************************************************************************/
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <grass/gis.h>
  21. #include <grass/glocale.h>
  22. #include "test_rtree_lib.h"
  23. /*- Parameters and global variables -----------------------------------------*/
  24. typedef struct {
  25. struct Option *unit;
  26. } paramType;
  27. paramType param; /*Parameters */
  28. /*- prototypes --------------------------------------------------------------*/
  29. static void set_params(void); /*Fill the paramType structure */
  30. /* ************************************************************************* */
  31. /* Set up the arguments we are expecting ********************************** */
  32. /* ************************************************************************* */
  33. void set_params(void) {
  34. param.unit = G_define_option();
  35. param.unit->key = "unit";
  36. param.unit->type = TYPE_STRING;
  37. param.unit->required = YES;
  38. param.unit->options = "basic";
  39. param.unit->description = _("Choose the unit tests to run");
  40. }
  41. /* ************************************************************************* */
  42. /* ************************************************************************* */
  43. /* ************************************************************************* */
  44. int main(int argc, char *argv[]) {
  45. struct GModule *module;
  46. int returnstat = 0, i;
  47. /* Initialize GRASS */
  48. G_gisinit(argv[0]);
  49. module = G_define_module();
  50. module->description
  51. = _("Unit tests for the vector rtree library");
  52. /* Get parameters from user */
  53. set_params();
  54. if (G_parser(argc, argv))
  55. exit(EXIT_FAILURE);
  56. /*unit tests */
  57. i = 0;
  58. if (param.unit->answers) {
  59. while (param.unit->answers[i]) {
  60. if (strcmp(param.unit->answers[i], "basic") == 0)
  61. returnstat += unit_test_basics();
  62. i++;
  63. }
  64. }
  65. if (returnstat != 0)
  66. G_warning("Errors detected while testing the vector rtree lib");
  67. else
  68. G_message("\n-- vector rtree lib tests finished successfully --");
  69. return (returnstat);
  70. }