summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/tools/gencolusb/verify_uset.cpp
blob: 03a493048945028c774e81cb43a91a930338769d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/**
 * Copyright (c) 1999-2012, International Business Machines Corporation and
 * others. All Rights Reserved.
 *
 * Test for source/i18n/collunsafe.h
 */

#include <stdio.h>
#include "unicode/ucol.h"
#include "unicode/uniset.h"
#include "unicode/coll.h"
#include "collation.h"

#include "collunsafe.h"


int main(int argc, const char *argv[]) {
  puts("verify");
  UErrorCode errorCode = U_ZERO_ERROR;
#if defined (COLLUNSAFE_PATTERN)
  puts("verify pattern");
  const UnicodeString unsafeBackwardPattern(false, collunsafe_pattern, collunsafe_len);
  fprintf(stderr, "\n -- pat '%c%c%c%c%c'\n",
          collunsafe_pattern[0],
          collunsafe_pattern[1],
          collunsafe_pattern[2],
          collunsafe_pattern[3],
          collunsafe_pattern[4]);
  if(U_SUCCESS(errorCode)) {
    UnicodeSet us(unsafeBackwardPattern, errorCode);
    fprintf(stderr, "\n%s:%d: err creating set %s\n", __FILE__, __LINE__, u_errorName(errorCode));
  }
#endif

#if defined (COLLUNSAFE_RANGE)
  {
    puts("verify range");
    UnicodeSet u;
    for(int32_t i=0;i<unsafe_rangeCount*2;i+=2) {
      u.add(unsafe_ranges[i+0],unsafe_ranges[i+1]);
    }
    printf("Finished with %d ranges\n", u.getRangeCount());
  }
#endif

#if defined (COLLUNSAFE_SERIALIZE)
  {
    puts("verify serialize");
    UnicodeSet u(unsafe_serializedData, unsafe_serializedCount, UnicodeSet::kSerialized, errorCode);
    fprintf(stderr, "\n%s:%d: err creating set %s\n", __FILE__, __LINE__, u_errorName(errorCode));
    printf("Finished deserialize with %d ranges\n", u.getRangeCount());
  }
#endif
// if(tailoring.unsafeBackwardSet == nullptr) {
  //   errorCode = U_MEMORY_ALLOCATION_ERROR;
  //   fprintf(stderr, "\n%s:%d: err %s\n", __FILE__, __LINE__, u_errorName(errorCode));
  // }
  puts("verify col UCA");
  if(U_SUCCESS(errorCode)) {
    Collator *col = Collator::createInstance(Locale::getEnglish(), errorCode);
    fprintf(stderr, "\n%s:%d: err %s creating collator\n", __FILE__, __LINE__, u_errorName(errorCode));
  }
  
  if(U_FAILURE(errorCode)) {
    return 1;
  } else {
    return 0;
  }
}