PageRenderTime 27ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/ext/Subversion/subversion/tests/libsvn_subr/error-code-test.c

http://commitmonitor.googlecode.com/
C | 83 lines | 40 code | 13 blank | 30 comment | 7 complexity | 41374705d485c5fc3108ee574eeb39a5 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.0, GPL-2.0, BSD-3-Clause, AGPL-1.0
  1. /*
  2. * error-code-test.c -- tests for error codes
  3. *
  4. * ====================================================================
  5. * Licensed to the Apache Software Foundation (ASF) under one
  6. * or more contributor license agreements. See the NOTICE file
  7. * distributed with this work for additional information
  8. * regarding copyright ownership. The ASF licenses this file
  9. * to you under the Apache License, Version 2.0 (the
  10. * "License"); you may not use this file except in compliance
  11. * with the License. You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing,
  16. * software distributed under the License is distributed on an
  17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18. * KIND, either express or implied. See the License for the
  19. * specific language governing permissions and limitations
  20. * under the License.
  21. * ====================================================================
  22. */
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <apr_general.h>
  26. #include "svn_error.h"
  27. /* Duplicate of the same typedef in libsvn_subr/error.c */
  28. typedef struct err_defn {
  29. svn_errno_t errcode; /* 160004 */
  30. const char *errname; /* SVN_ERR_FS_CORRUPT */
  31. const char *errdesc; /* default message */
  32. } err_defn;
  33. /* To understand what is going on here, read svn_error_codes.h. */
  34. #define SVN_ERROR_BUILD_ARRAY
  35. #include "svn_error_codes.h"
  36. #include "../svn_test.h"
  37. #define NUM_ERRORS (sizeof(error_table)/sizeof(error_table[0]))
  38. static svn_error_t *
  39. check_error_codes_unique(apr_pool_t *pool)
  40. {
  41. int i;
  42. struct err_defn e = error_table[0];
  43. /* Ensure error codes are strictly monotonically increasing. */
  44. for (i = 1; i < NUM_ERRORS; i++)
  45. {
  46. struct err_defn e2 = error_table[i];
  47. /* Don't fail the test if there is an odd number of errors.
  48. * The error array's sentinel has an error code of zero. */
  49. if (i == NUM_ERRORS - 1 && e2.errcode == 0)
  50. break;
  51. /* SVN_ERR_WC_NOT_DIRECTORY is an alias for SVN_ERR_WC_NOT_WORKING_COPY
  52. * and shares the same error code. */
  53. if (e.errcode != SVN_ERR_WC_NOT_DIRECTORY &&
  54. e.errcode >= e2.errcode)
  55. return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
  56. "Error 0x%x (%s) is not < 0x%x (%s)\n",
  57. e.errcode, e.errdesc, e2.errcode, e2.errdesc);
  58. e = e2;
  59. }
  60. return SVN_NO_ERROR;
  61. }
  62. /* The test table. */
  63. struct svn_test_descriptor_t test_funcs[] =
  64. {
  65. SVN_TEST_NULL,
  66. SVN_TEST_PASS2(check_error_codes_unique,
  67. "check that error codes are unique"),
  68. SVN_TEST_NULL
  69. };