MCPcopy Create free account
hub / github.com/amule-project/amule / TEST

Function TEST

unittests/tests/StringFunctionsTest.cpp:15–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#define itemsof(x) (sizeof(x)/sizeof(x[0]))
14
15TEST(StringFunctions, FuzzyStrCmp)
16{
17 struct FuzzyTest {
18 const char* a;
19 const char* b;
20 int expected;
21 };
22
23 FuzzyTest checks[] = {
24 { "a (10)", "a (2)", 1},
25 { "a (10)", "b (2)", -1},
26 { "c3 (7)", "c3 (12)", -1},
27 { "c3 (12)", "c3 (7)", 1},
28 { "c3 12d", "c3 12d", 0},
29 { "a (10) ", "a (2) ", 1},
30 { "a (10) ", "b (2) ", -1},
31 { " c3 (7)", " c3 (12)", -1},
32 { " c3 (12)", " c3 (7)", 1},
33 { "c3 12d", "c3 12d", 0},
34 { "", "", 0},
35 { "", "c3 12d", -1},
36 { "c3 12d", "", 1},
37 { " ", "c3 12d", -1},
38 { "c3 12d", " ", 1},
39 { "17.10", "17.2", 1},
40 { " c3 (a)", " c3 (12)", 1},
41 { " c3 (12)", " c3 (a)", -1},
42 };
43
44 for (size_t i = 0; i < itemsof(checks); ++i) {
45 wxString a = checks[i].a;
46 wxString b = checks[i].b;
47
48 ASSERT_EQUALS(checks[i].expected, FuzzyStrCmp(a, b));
49 }
50}
51
52
53///////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 4

FuzzyStrCmpFunction · 0.85
remainingMethod · 0.80
nextMethod · 0.80
tokenCountMethod · 0.80

Tested by

no test coverage detected