From e8ec7aa8e38a93f5b034ac74cebce5de23710317 Mon Sep 17 00:00:00 2001 From: hongbotian Date: Mon, 30 Nov 2015 01:45:08 -0500 Subject: upload http JIRA: BOTTLENECK-10 Change-Id: I7598427ff904df438ce77c2819ee48ac75ffa8da Signed-off-by: hongbotian --- rubbos/app/httpd-2.0.64/srclib/apr/test/testpath.c | 138 +++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 rubbos/app/httpd-2.0.64/srclib/apr/test/testpath.c (limited to 'rubbos/app/httpd-2.0.64/srclib/apr/test/testpath.c') diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/test/testpath.c b/rubbos/app/httpd-2.0.64/srclib/apr/test/testpath.c new file mode 100644 index 00000000..e41e26ac --- /dev/null +++ b/rubbos/app/httpd-2.0.64/srclib/apr/test/testpath.c @@ -0,0 +1,138 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "test_apr.h" +#include "apr_file_info.h" +#include "apr_errno.h" +#include "apr_pools.h" +#include "apr_tables.h" + +#if defined(WIN32) || defined(NETWARE) || defined(OS2) +#define PSEP ";" +#define DSEP "\\" +#else +#define PSEP ":" +#define DSEP "/" +#endif + +#define PX "" +#define P1 "first path" +#define P2 "second" DSEP "path" +#define P3 "th ird" DSEP "path" +#define P4 "fourth" DSEP "pa th" +#define P5 "fifthpath" + +static const char *parts_in[] = { P1, P2, P3, PX, P4, P5 }; +static const char *path_in = P1 PSEP P2 PSEP P3 PSEP PX PSEP P4 PSEP P5; +static const int parts_in_count = sizeof(parts_in)/sizeof(*parts_in); + +static const char *parts_out[] = { P1, P2, P3, P4, P5 }; +static const char *path_out = P1 PSEP P2 PSEP P3 PSEP P4 PSEP P5; +static const int parts_out_count = sizeof(parts_out)/sizeof(*parts_out); + +static void list_split_multi(CuTest *tc) +{ + int i; + apr_status_t rv; + apr_array_header_t *pathelts; + + pathelts = NULL; + rv = apr_filepath_list_split(&pathelts, path_in, p); + CuAssertPtrNotNull(tc, pathelts); + CuAssertIntEquals(tc, APR_SUCCESS, rv); + CuAssertIntEquals(tc, parts_out_count, pathelts->nelts); + for (i = 0; i < pathelts->nelts; ++i) + CuAssertStrEquals(tc, parts_out[i], ((char**)pathelts->elts)[i]); +} + +static void list_split_single(CuTest *tc) +{ + int i; + apr_status_t rv; + apr_array_header_t *pathelts; + + for (i = 0; i < parts_in_count; ++i) + { + pathelts = NULL; + rv = apr_filepath_list_split(&pathelts, parts_in[i], p); + CuAssertPtrNotNull(tc, pathelts); + CuAssertIntEquals(tc, APR_SUCCESS, rv); + if (parts_in[i][0] == '\0') + CuAssertIntEquals(tc, 0, pathelts->nelts); + else + { + CuAssertIntEquals(tc, 1, pathelts->nelts); + CuAssertStrEquals(tc, parts_in[i], *(char**)pathelts->elts); + } + } +} + +static void list_merge_multi(CuTest *tc) +{ + int i; + char *liststr; + apr_status_t rv; + apr_array_header_t *pathelts; + + pathelts = apr_array_make(p, parts_in_count, sizeof(const char*)); + for (i = 0; i < parts_in_count; ++i) + *(const char**)apr_array_push(pathelts) = parts_in[i]; + + liststr = NULL; + rv = apr_filepath_list_merge(&liststr, pathelts, p); + CuAssertPtrNotNull(tc, liststr); + CuAssertIntEquals(tc, APR_SUCCESS, rv); + CuAssertStrEquals(tc, liststr, path_out); +} + +static void list_merge_single(CuTest *tc) +{ + int i; + char *liststr; + apr_status_t rv; + apr_array_header_t *pathelts; + + pathelts = apr_array_make(p, 1, sizeof(const char*)); + apr_array_push(pathelts); + for (i = 0; i < parts_in_count; ++i) + { + *(const char**)pathelts->elts = parts_in[i]; + liststr = NULL; + rv = apr_filepath_list_merge(&liststr, pathelts, p); + if (parts_in[i][0] == '\0') + CuAssertPtrEquals(tc, NULL, liststr); + else + { + CuAssertPtrNotNull(tc, liststr); + CuAssertIntEquals(tc, APR_SUCCESS, rv); + CuAssertStrEquals(tc, liststr, parts_in[i]); + } + } +} + + +CuSuite *testpath(void) +{ + CuSuite *suite = CuSuiteNew("Path lists"); + + SUITE_ADD_TEST(suite, list_split_multi); + SUITE_ADD_TEST(suite, list_split_single); + SUITE_ADD_TEST(suite, list_merge_multi); + SUITE_ADD_TEST(suite, list_merge_single); + + return suite; +} + -- cgit 1.2.3-korg