bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr / test / testfmt.c
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "test_apr.h"
18 #include "apr.h"
19 #include "apr_portable.h"
20 #include "apr_strings.h"
21
22 static void ssize_t_fmt(CuTest *tc)
23 {
24     char buf[100];
25     apr_ssize_t var = 0;
26
27     sprintf(buf, "%" APR_SSIZE_T_FMT, var);
28     CuAssertStrEquals(tc, "0", buf);
29     apr_snprintf(buf, sizeof(buf), "%" APR_SSIZE_T_FMT, var);
30     CuAssertStrEquals(tc, "0", buf);
31 }
32
33 static void size_t_fmt(CuTest *tc)
34 {
35     char buf[100];
36     apr_size_t var = 0;
37
38     sprintf(buf, "%" APR_SIZE_T_FMT, var);
39     CuAssertStrEquals(tc, "0", buf);
40     apr_snprintf(buf, sizeof(buf), "%" APR_SIZE_T_FMT, var);
41     CuAssertStrEquals(tc, "0", buf);
42 }
43
44 static void off_t_fmt(CuTest *tc)
45 {
46     char buf[100];
47     apr_off_t var = 0;
48
49     sprintf(buf, "%" APR_OFF_T_FMT, var);
50     CuAssertStrEquals(tc, "0", buf);
51     apr_snprintf(buf, sizeof(buf), "%" APR_OFF_T_FMT, var);
52     CuAssertStrEquals(tc, "0", buf);
53 }
54
55 static void pid_t_fmt(CuTest *tc)
56 {
57     char buf[100];
58     pid_t var = 0;
59
60     sprintf(buf, "%" APR_PID_T_FMT, var);
61     CuAssertStrEquals(tc, "0", buf);
62     apr_snprintf(buf, sizeof(buf), "%" APR_PID_T_FMT, var);
63     CuAssertStrEquals(tc, "0", buf);
64 }
65
66 static void int64_t_fmt(CuTest *tc)
67 {
68     char buf[100];
69     apr_int64_t var = 0;
70
71     sprintf(buf, "%" APR_INT64_T_FMT, var);
72     CuAssertStrEquals(tc, "0", buf);
73     apr_snprintf(buf, sizeof(buf), "%" APR_INT64_T_FMT, var);
74     CuAssertStrEquals(tc, "0", buf);
75 }
76
77 static void uint64_t_fmt(CuTest *tc)
78 {
79     char buf[100];
80     apr_uint64_t var = 14000000;
81
82     sprintf(buf, "%" APR_UINT64_T_FMT, var);
83     CuAssertStrEquals(tc, "14000000", buf);
84     apr_snprintf(buf, sizeof(buf), "%" APR_UINT64_T_FMT, var);
85     CuAssertStrEquals(tc, "14000000", buf);
86 }
87
88 static void uint64_t_hex_fmt(CuTest *tc)
89 {
90     char buf[100];
91     apr_uint64_t var = 14000000;
92
93     sprintf(buf, "%" APR_UINT64_T_HEX_FMT, var);
94     CuAssertStrEquals(tc, "d59f80", buf);
95     apr_snprintf(buf, sizeof(buf), "%" APR_UINT64_T_HEX_FMT, var);
96     CuAssertStrEquals(tc, "d59f80", buf);
97 }
98
99 CuSuite *testfmt(void)
100 {
101     CuSuite *suite = CuSuiteNew("Formats");
102
103     SUITE_ADD_TEST(suite, ssize_t_fmt);
104     SUITE_ADD_TEST(suite, size_t_fmt);
105     SUITE_ADD_TEST(suite, off_t_fmt);
106     SUITE_ADD_TEST(suite, pid_t_fmt);
107     SUITE_ADD_TEST(suite, int64_t_fmt);
108     SUITE_ADD_TEST(suite, uint64_t_fmt);
109     SUITE_ADD_TEST(suite, uint64_t_hex_fmt);
110
111     return suite;
112 }
113