This source file includes following definitions.
- check_fstrcmp
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "fstrcmp.h"
22
23 #include <stdbool.h>
24
25 #include "macros.h"
26
27 static bool
28 check_fstrcmp (const char *string1, const char *string2, double expected)
29 {
30
31
32
33
34
35
36 {
37 volatile double result = fstrcmp (string1, string2);
38 if (!(result == expected))
39 return false;
40 }
41 {
42 volatile double result = fstrcmp_bounded (string1, string2, expected);
43 if (!(result == expected))
44 return false;
45 }
46 {
47 double bound = expected * 0.5;
48 volatile double result = fstrcmp_bounded (string1, string2, bound);
49 if (!(result == expected))
50 return false;
51 }
52 {
53 double bound = (1 + expected) * 0.5;
54 if (expected < bound)
55 {
56 volatile double result = fstrcmp_bounded (string1, string2, bound);
57 if (!(result < bound))
58 return false;
59 }
60 }
61
62 return true;
63 }
64
65 int
66 main (int argc, char *argv[])
67 {
68 ASSERT (check_fstrcmp ("Langstrumpf", "Langstrumpf", 1.0));
69 ASSERT (check_fstrcmp ("Levenshtein", "Levenstein", 20./21.));
70 ASSERT (check_fstrcmp ("Levenstein", "Levenshtein", 20./21.));
71 ASSERT (check_fstrcmp ("xy", "yx", 1./2.));
72 ASSERT (check_fstrcmp ("George Bush", "Abraham Lincoln", 2./13.));
73 ASSERT (check_fstrcmp ("George Bush", "George \"Bugs\" Moran", 2./3.));
74
75 return 0;
76 }