cfad47cfa3/t3compiler/tads3/test/data/strcomp.t

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
#include <tads.h>
2
#include <strcomp.h>
3
4
main(args)
5
{
6
    local comp = new StringComparator(6, nil,
7
        [
8
         ['\u00DF', 'ss', 0x0100, 0x0200],
9
         ['\u00E0', 'a',  0x1000, 0x2000],
10
         ['\u00E1', 'a',  0x4000, 0x8000]
11
        ]);
12
13
    "Type QUIT to quit.\n";
14
    for (;;)
15
    {
16
        local s1, s2;
17
        local m, h1, h2;
18
        
19
        "\bDictionary string: ";
20
        s1 = inputLine();
21
        if (s1.toLower() == 'quit')
22
            break;
23
        
24
        "Input string: ";
25
        s2 = inputLine();
26
27
        m = comp.matchValues(s2, s1);
28
        h1 = comp.calcHash(s1);
29
        h2 = comp.calcHash(s2);
30
        "Match = <<toString(m, 16)>>,
31
        hash(<<s1>>) = <<h1>>, hash(<<s2>>) = <<h2>>";
32
33
        if (m != 0 && h1 != h2)
34
            "\n*** HASH MISMATCH!!! ***\n";
35
    }
36
}
37