2 * error-test.c -- test the error functions
4 * ====================================================================
5 * Copyright (c) 2006 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
21 #include <apr_general.h>
23 #include "svn_error_codes.h"
24 #include "svn_error.h"
26 #include "../svn_test.h"
29 test_error_root_cause(const char **msg
,
30 svn_boolean_t msg_only
,
31 svn_test_opts_t
*opts
,
34 apr_status_t secondary_err_codes
[] = { SVN_ERR_STREAM_UNRECOGNIZED_DATA
,
35 SVN_ERR_STREAM_MALFORMED_DATA
};
36 apr_status_t root_cause_err_code
= SVN_ERR_STREAM_UNEXPECTED_EOF
;
38 svn_error_t
*err
, *root_err
;
40 *msg
= "test svn_error_root_cause";
45 /* Nest several errors. */
46 err
= svn_error_create(root_cause_err_code
, NULL
, "root cause");
47 for (i
= 0; i
< 2; i
++)
48 err
= svn_error_create(secondary_err_codes
[i
], err
, NULL
);
50 /* Verify that the error is detected at the proper location in the
52 root_err
= svn_error_root_cause(err
);
56 return svn_error_createf(SVN_ERR_TEST_FAILED
, NULL
,
57 "svn_error_root_cause failed to locate any "
58 "root error in the chain");
61 for (i
= 0; i
< 2; i
++)
63 if (root_err
->apr_err
== secondary_err_codes
[i
])
66 return svn_error_createf(SVN_ERR_TEST_FAILED
, NULL
,
67 "svn_error_root_cause returned the "
68 "wrong error from the chain");
72 if (root_err
->apr_err
!= root_cause_err_code
)
75 return svn_error_createf(SVN_ERR_TEST_FAILED
, NULL
,
76 "svn_error_root_cause failed to locate the "
77 "correct error from teh chain");
87 struct svn_test_descriptor_t test_funcs
[] =
90 SVN_TEST_PASS(test_error_root_cause
),