~ubuntu-branches/ubuntu/gutsy/icu/gutsy-updates

« back to all changes in this revision

Viewing changes to source/test/cintltst/cfintst.c

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2005-11-19 11:29:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20051119112931-vcizkrp10tli4enw
Tags: 3.4-3
Explicitly build with g++ 3.4.  The current ICU fails its test suite
with 4.0 but not with 3.4.  Future versions should work properly with
4.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/********************************************************************
2
 
 * COPYRIGHT: 
3
 
 * Copyright (c) 1997-2001, International Business Machines Corporation and
4
 
 * others. All Rights Reserved.
5
 
 ********************************************************************/
6
 
/********************************************************************************
7
 
*
8
 
* File CFINTST.C
9
 
*
10
 
* Modification History:
11
 
*        Name                     Description            
12
 
*     Madhu Katragadda            Ported for C API
13
 
*********************************************************************************/
14
 
/**
15
 
 * CollationFinnishTest is a third level test class.  This tests the locale
16
 
 * specific primary, secondary and tertiary rules.  For example, the ignorable
17
 
 * character '-' in string "black-bird".  The en_US locale uses the default
18
 
 * collation rules as its sorting sequence.
19
 
 */
20
 
 
21
 
#include <stdlib.h>
22
 
#include "unicode/utypes.h"
23
 
#include "unicode/ucol.h"
24
 
#include "unicode/uloc.h"
25
 
#include "cintltst.h"
26
 
#include "ccolltst.h"
27
 
#include "callcoll.h"
28
 
#include "cfintst.h"
29
 
#include "unicode/ustring.h"
30
 
#include "string.h"
31
 
 
32
 
static UCollator *myCollation;
33
 
const static UChar testSourceCases[][MAX_TOKEN_LEN] = {
34
 
    {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
35
 
    {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
36
 
    {0x0061/*'a'*/, 0x00FC, 0x0062/*'b'*/, 0x0065/*'e'*/, 0x0063/*'c'*/, 0x006b/*'k'*/, 0x0000},
37
 
    {0x004c/*'L'*/, 0x00E5, 0x0076/*'v'*/, 0x0069/*'i'*/, 0x0000},
38
 
    {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}
39
 
};
40
 
 
41
 
const static UChar testTargetCases[][MAX_TOKEN_LEN] = {
42
 
    {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
43
 
    {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0079/*'y'*/, 0x0000},
44
 
    {0x0061/*'a'*/, 0x0078/*'x'*/, 0x0062/*'b'*/, 0x0065/*'e'*/, 0x0063/*'c'*/, 0x006b/*'k'*/, 0x0000},
45
 
    {0x004c/*'L'*/, 0x00E4, 0x0077/*'w'*/, 0x0065/*'e'*/, 0x0000},
46
 
    {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}
47
 
};
48
 
 
49
 
const static UCollationResult results[] = {
50
 
    UCOL_GREATER,
51
 
    UCOL_LESS,
52
 
    UCOL_GREATER,
53
 
    UCOL_LESS,
54
 
    /* test primary > 4*/
55
 
    UCOL_EQUAL
56
 
};
57
 
 
58
 
 
59
 
 
60
 
void addFinnishCollTest(TestNode** root)
61
 
{
62
 
    
63
 
    
64
 
    addTest(root, &TestPrimary, "tscoll/cficoll/TestPrimary");
65
 
    addTest(root, &TestTertiary, "tscoll/cficoll/TestTertiary");
66
 
    
67
 
 
68
 
 
69
 
}
70
 
 
71
 
 
72
 
static void TestTertiary( )
73
 
{
74
 
    
75
 
    int32_t i;
76
 
    UErrorCode status = U_ZERO_ERROR;
77
 
    myCollation = ucol_open("fi_FI", &status);
78
 
    if(U_FAILURE(status)){
79
 
        log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
80
 
    }
81
 
    log_verbose("Testing Finnish Collation with Tertiary strength\n");
82
 
    ucol_setStrength(myCollation, UCOL_TERTIARY);
83
 
    for (i = 0; i < 4 ; i++)
84
 
    {
85
 
        doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
86
 
    }
87
 
    ucol_close(myCollation);
88
 
}
89
 
 
90
 
static void TestPrimary()
91
 
{
92
 
    
93
 
    int32_t i;
94
 
    UErrorCode status = U_ZERO_ERROR;
95
 
    myCollation = ucol_open("fi_FI", &status);
96
 
    if(U_FAILURE(status)){
97
 
        log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
98
 
    }
99
 
    log_verbose("Testing Finnish Collation with Tertiary strength\n");
100
 
    ucol_setStrength(myCollation, UCOL_PRIMARY);
101
 
    for (i = 4; i < 4; i++)
102
 
    {
103
 
        doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
104
 
    }
105
 
    ucol_close(myCollation);
106
 
}
107