~ubuntu-branches/ubuntu/quantal/icu/quantal

« back to all changes in this revision

Viewing changes to source/test/intltest/normconf.h

  • Committer: Package Import Robot
  • Author(s): Yves Arrouye
  • Date: 2002-03-03 15:31:13 UTC
  • Revision ID: package-import@ubuntu.com-20020303153113-3ssceqlq45xbmbnc
Tags: upstream-2.0-2.1pre20020303
ImportĀ upstreamĀ versionĀ 2.0-2.1pre20020303

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
************************************************************************
 
3
* Copyright (c) 1997-2001, International Business Machines
 
4
* Corporation and others.  All Rights Reserved.
 
5
************************************************************************
 
6
*/
 
7
 
 
8
#ifndef _NORMCONF
 
9
#define _NORMCONF
 
10
 
 
11
#include "unicode/utypes.h"
 
12
#include "unicode/normlzr.h"
 
13
#include "intltest.h"
 
14
 
 
15
#define TEST_SUITE_DIR  "unidata"
 
16
#define TEST_SUITE_FILE "NormalizationTest.txt"
 
17
 
 
18
class NormalizerConformanceTest : public IntlTest {
 
19
    Normalizer normalizer;
 
20
 
 
21
 public:
 
22
    NormalizerConformanceTest();
 
23
    virtual ~NormalizerConformanceTest();
 
24
 
 
25
    void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
 
26
 
 
27
    /**
 
28
     * Test the conformance of Normalizer to
 
29
     * http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt
 
30
     * This file must be located at the path specified as TEST_SUITE_FILE.
 
31
     */
 
32
    void TestConformance(void);
 
33
 
 
34
    // Specific tests for debugging.  These are generally failures taken from
 
35
    // the conformance file, but culled out to make debugging easier.
 
36
    void TestCase6(void);
 
37
 
 
38
 private:
 
39
    /**
 
40
     * Verify the conformance of the given line of the Unicode
 
41
     * normalization (UTR 15) test suite file.  For each line,
 
42
     * there are five columns, corresponding to field[0]..field[4].
 
43
     *
 
44
     * The following invariants must be true for all conformant implementations
 
45
     *  c2 == NFC(c1) == NFC(c2) == NFC(c3)
 
46
     *  c3 == NFD(c1) == NFD(c2) == NFD(c3)
 
47
     *  c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
 
48
     *  c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
 
49
     *
 
50
     * @param field the 5 columns
 
51
     * @param line the source line from the test suite file
 
52
     * @return true if the test passes
 
53
     */
 
54
    UBool checkConformance(const UnicodeString* field,
 
55
                           const UnicodeString& line);
 
56
 
 
57
    void iterativeNorm(const UnicodeString& str,
 
58
                       UNormalizationMode mode,
 
59
                       UnicodeString& result,
 
60
                       int8_t dir);
 
61
 
 
62
    /**
 
63
     * @param op name of normalization form, e.g., "KC"
 
64
     * @param s string being normalized
 
65
     * @param got value received
 
66
     * @param exp expected value
 
67
     * @param msg description of this test
 
68
     * @param return true if got == exp
 
69
     */
 
70
    UBool assertEqual(const char *op,
 
71
                      const UnicodeString& s,
 
72
                      const UnicodeString& got,
 
73
                      const UnicodeString& exp,
 
74
                      const char *msg,
 
75
                      int32_t field);
 
76
 
 
77
    /**
 
78
     * Split a string into pieces based on the given delimiter
 
79
     * character.  Then, parse the resultant fields from hex into
 
80
     * characters.  That is, "0040 0400;0C00;0899" -> new String[] {
 
81
     * "\u0040\u0400", "\u0C00", "\u0899" }.  The output is assumed to
 
82
     * be of the proper length already, and exactly output.length
 
83
     * fields are parsed.  If there are too few an exception is
 
84
     * thrown.  If there are too many the extras are ignored.
 
85
     *
 
86
     * @param buf scratch buffer
 
87
     * @return FALSE upon failure
 
88
     */
 
89
    UBool hexsplit(const char *s, char delimiter,
 
90
                   UnicodeString output[], int32_t outputLength);
 
91
 
 
92
    void _testOneLine(const char *line);
 
93
};
 
94
 
 
95
#endif