equal
deleted
inserted
replaced
20 |
20 |
21 #include "cpixsearch.h" |
21 #include "cpixsearch.h" |
22 |
22 |
23 #include "suggestion.h" |
23 #include "suggestion.h" |
24 #include "config.h" |
24 #include "config.h" |
|
25 #include "testutils.h" |
25 |
26 |
26 |
27 |
27 |
28 |
28 Suggestion::Suggestion(cpix_Document & doc, |
29 Suggestion::Suggestion(cpix_Document * doc, |
29 Itk::TestMgr * testMgr) |
30 Itk::TestMgr * testMgr) |
30 { |
31 { |
31 const wchar_t |
32 const wchar_t |
32 * value = cpix_Document_getFieldValue(&doc, |
33 * value = cpix_Document_getFieldValue(doc, |
33 LTERM_TEXT_FIELD); |
34 LTERM_TEXT_FIELD); |
34 if (cpix_Failed(&doc)) |
35 if (cpix_Failed(doc)) |
35 { |
36 { |
36 ITK_EXPECT(testMgr, |
37 ITK_EXPECT(testMgr, |
37 false, |
38 false, |
38 "Could not get suggestion term"); |
39 "Could not get suggestion term"); |
39 term_ = L"(error)"; |
40 term_ = L"(error)"; |
41 else |
42 else |
42 { |
43 { |
43 term_ = value; |
44 term_ = value; |
44 } |
45 } |
45 |
46 |
46 value = cpix_Document_getFieldValue(&doc, |
47 value = cpix_Document_getFieldValue(doc, |
47 LTERM_DOCFREQ_FIELD); |
48 LTERM_DOCFREQ_FIELD); |
48 if (cpix_Failed(&doc)) |
49 if (cpix_Failed(doc)) |
49 { |
50 { |
50 ITK_EXPECT(testMgr, |
51 ITK_EXPECT(testMgr, |
51 false, |
52 false, |
52 "Could not get suggestion doc frequency"); |
53 "Could not get suggestion doc frequency"); |
53 frequency_ = L"0"; |
54 frequency_ = L"0"; |
126 suggestions.reserve(hitCount); |
127 suggestions.reserve(hitCount); |
127 |
128 |
128 for (int32_t i = 0; i < hitCount; ++i) |
129 for (int32_t i = 0; i < hitCount; ++i) |
129 { |
130 { |
130 cpix_Document |
131 cpix_Document |
131 doc; |
132 **doc; |
|
133 ALLOC_DOC(doc, 1); |
132 cpix_Hits_doc(hits, |
134 cpix_Hits_doc(hits, |
133 i, |
135 i, |
134 &doc); |
136 doc, |
|
137 1); |
|
138 if (doc[0]->ptr_ != NULL) { |
135 if (cpix_Failed(hits)) |
139 if (cpix_Failed(hits)) |
136 { |
140 { |
137 ITK_EXPECT(testMgr, |
141 ITK_EXPECT(testMgr, |
138 false, |
142 false, |
139 "Failed to get doc %d", |
143 "Failed to get doc %d", |
140 i); |
144 i); |
141 cpix_ClearError(hits); |
145 cpix_ClearError(hits); |
142 goOn = false; |
146 goOn = false; |
143 break; |
147 break; |
144 } |
148 } |
145 |
149 |
146 suggestions.push_back(Suggestion(doc, |
150 suggestions.push_back(Suggestion(doc[0], |
147 testMgr)); |
151 testMgr)); |
|
152 } |
|
153 FREE_DOC(doc, 1); |
148 } |
154 } |
149 |
155 |
150 if (goOn) |
156 if (goOn) |
151 { |
157 { |
152 std::sort(suggestions.begin(), |
158 std::sort(suggestions.begin(), |