/
fake-qofquery.cpp
68 lines (56 loc) · 1.37 KB
/
fake-qofquery.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <config.h>
#include "fake-qofquery.h"
#include "gmock-qofbook.h"
QofQuery *
qof_query_create_for (QofIdTypeConst obj_type)
{
return (QofQuery*)qof_query_factory.create();
/*
// \todo create typed query objects
QofQuery *ret = NULL;
if (g_strcmp0(obj_type, GNC_ID_SPLIT) == 0)
ret = (QofQuery*)qof_query_factory.createForSplit();
// else
// FAIL();
return ret;
*/
}
void
qof_query_set_book (QofQuery *query, QofBook *book)
{
ASSERT_TRUE(QOF_IS_MOCK_BOOK(book));
((QofFakeQuery*)query)->setBook(book);
}
GList *
qof_query_run (QofQuery *query)
{
GList *matching_objects = NULL;
// \todo use typed mock objects
auto matchingObjects = ((QofFakeQuery*)query)->run();
for (auto object : matchingObjects)
{
matching_objects = g_list_append(matching_objects, static_cast<gpointer>(object));
}
return matching_objects;
}
void
xaccQueryAddDateMatchTT (
QofQuery *query,
gboolean use_start,
time64 stt,
gboolean use_end,
time64 ett,
QofQueryOp op)
{
((QofFakeQuery*)query)->addDateMatchTT(use_start, stt, use_end, ett, op);
}
void
xaccQueryAddSingleAccountMatch(QofQuery *query, Account *acc, QofQueryOp op)
{
((QofFakeQuery*)query)->addSingleAccountMatch(acc, op);
}
void
qof_query_destroy (QofQuery *query)
{
((QofFakeQuery*)query)->destroy();
}