~svn/ubuntu/oneiric/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/tests/libsvn_subr/utf-test.c

  • Committer: Max Bowsher
  • Date: 2012-06-27 12:25:12 UTC
  • mfrom: (44.1.46 precise)
  • Revision ID: _@maxb.eu-20120627122512-kmo8fj0lr7mlkppj
Make tree identical to precise branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * utf-test.c -- test the utf functions
3
3
 *
4
4
 * ====================================================================
5
 
 * Copyright (c) 2004, 2009 CollabNet.  All rights reserved.
6
 
 *
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.
12
 
 *
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/.
 
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.
16
21
 * ====================================================================
17
22
 */
18
23
 
54
59
 
55
60
/* Explicit tests of various valid/invalid sequences */
56
61
static svn_error_t *
57
 
utf_validate(const char **msg,
58
 
             svn_boolean_t msg_only,
59
 
             svn_test_opts_t *opts,
60
 
             apr_pool_t *pool)
 
62
utf_validate(apr_pool_t *pool)
61
63
{
62
64
  struct data {
63
65
    svn_boolean_t valid;
149
151
  };
150
152
  int i = 0;
151
153
 
152
 
  *msg = "test is_valid/last_valid";
153
 
 
154
 
  if (msg_only)
155
 
    return SVN_NO_ERROR;
156
 
 
157
 
 
158
154
  while (tests[i].valid != -1)
159
155
    {
160
156
      const char *last = svn_utf__last_valid(tests[i].string,
181
177
 
182
178
/* Compare the two different implementations using random data. */
183
179
static svn_error_t *
184
 
utf_validate2(const char **msg,
185
 
              svn_boolean_t msg_only,
186
 
              svn_test_opts_t *opts,
187
 
              apr_pool_t *pool)
 
180
utf_validate2(apr_pool_t *pool)
188
181
{
189
182
  int i;
190
183
 
191
 
  *msg = apr_psprintf(pool,
192
 
                      "test last_valid/last_valid2 (seed:%u)", seed_val());
193
 
 
194
 
  if (msg_only)
195
 
    return SVN_NO_ERROR;
 
184
  seed_val();
196
185
 
197
186
  /* We want enough iterations so that most runs get both valid and invalid
198
187
     strings.  We also want enough iterations such that a deliberate error
227
216
 
228
217
/* Test conversion from different codepages to utf8. */
229
218
static svn_error_t *
230
 
test_utf_cstring_to_utf8_ex2(const char **msg,
231
 
                             svn_boolean_t msg_only,
232
 
                             svn_test_opts_t *opts,
233
 
                             apr_pool_t *pool)
 
219
test_utf_cstring_to_utf8_ex2(apr_pool_t *pool)
234
220
{
235
221
  apr_size_t i;
236
222
  apr_pool_t *subpool = svn_pool_create(pool);
244
230
      {"Edelwei\xdf", "Edelwei\xc3\x9f", "ISO-8859-1"}
245
231
  };
246
232
 
247
 
  *msg = "test svn_utf_cstring_to_utf8_ex2";
248
 
 
249
 
  if (msg_only)
250
 
    return SVN_NO_ERROR;
251
 
 
252
233
  for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
253
234
    {
254
235
      const char *dest;
275
256
 
276
257
/* Test conversion to different codepages from utf8. */
277
258
static svn_error_t *
278
 
test_utf_cstring_from_utf8_ex2(const char **msg,
279
 
                               svn_boolean_t msg_only,
280
 
                               svn_test_opts_t *opts,
281
 
                               apr_pool_t *pool)
 
259
test_utf_cstring_from_utf8_ex2(apr_pool_t *pool)
282
260
{
283
261
  apr_size_t i;
284
262
  apr_pool_t *subpool = svn_pool_create(pool);
292
270
      {"Edelwei\xc3\x9f", "Edelwei\xdf", "ISO-8859-1"}
293
271
  };
294
272
 
295
 
  *msg = "test svn_utf_cstring_from_utf8_ex2";
296
 
 
297
 
  if (msg_only)
298
 
    return SVN_NO_ERROR;
299
 
 
300
273
  for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
301
274
    {
302
275
      const char *dest;
327
300
struct svn_test_descriptor_t test_funcs[] =
328
301
  {
329
302
    SVN_TEST_NULL,
330
 
    SVN_TEST_PASS(utf_validate),
331
 
    SVN_TEST_PASS(utf_validate2),
332
 
    SVN_TEST_PASS(test_utf_cstring_to_utf8_ex2),
333
 
    SVN_TEST_PASS(test_utf_cstring_from_utf8_ex2),
 
303
    SVN_TEST_PASS2(utf_validate,
 
304
                   "test is_valid/last_valid"),
 
305
    SVN_TEST_PASS2(utf_validate2,
 
306
                   "test last_valid/last_valid2"),
 
307
    SVN_TEST_PASS2(test_utf_cstring_to_utf8_ex2,
 
308
                   "test svn_utf_cstring_to_utf8_ex2"),
 
309
    SVN_TEST_PASS2(test_utf_cstring_from_utf8_ex2,
 
310
                   "test svn_utf_cstring_from_utf8_ex2"),
334
311
    SVN_TEST_NULL
335
312
  };