mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-26 02:40:43 -06:00
Relax runtime type checks
Runtime type checks should only check for the mock up type, if neccessary. If objects of another class than the mocked object itself are processed, runtime type check should only check for the base-class type. It should be possible to use mockup objects and non-mockup objects within the same application. The included headers are adapted accordingly.
This commit is contained in:
parent
99256c385b
commit
0e634c5446
@ -4,10 +4,11 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <qofbook.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "fake-qofquery.h"
|
||||
#include "gmock-qofbook.h"
|
||||
|
||||
|
||||
|
||||
@ -119,7 +120,7 @@ void
|
||||
qof_query_set_book (QofQuery *query, QofBook *book)
|
||||
{
|
||||
ASSERT_TRUE(queryPool.query_used(query));
|
||||
ASSERT_TRUE(QOF_IS_MOCKBOOK(book));
|
||||
ASSERT_TRUE(QOF_IS_BOOK(book));
|
||||
((QofFakeQuery*)query)->set_book(book);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <Transaction.h>
|
||||
#include <Account.h>
|
||||
|
||||
#include "gmock-Split.h"
|
||||
#include "gmock-qofbook.h"
|
||||
#include "gmock-Account.h"
|
||||
#include "gmock-Transaction.h"
|
||||
|
||||
|
||||
struct _MockSplitClass
|
||||
@ -60,7 +61,7 @@ void
|
||||
xaccSplitSetAccount (Split *split, Account *acc)
|
||||
{
|
||||
ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
|
||||
ASSERT_TRUE(GNC_IS_MOCKACCOUNT(acc));
|
||||
ASSERT_TRUE(GNC_IS_ACCOUNT(acc));
|
||||
gnc_mocksplit(split)->set_account(acc);
|
||||
}
|
||||
|
||||
@ -152,6 +153,6 @@ void
|
||||
xaccSplitSetParent(Split *split, Transaction *trans)
|
||||
{
|
||||
ASSERT_TRUE(GNC_IS_MOCKSPLIT(split));
|
||||
ASSERT_TRUE(GNC_IS_MOCKTRANSACTION(trans));
|
||||
ASSERT_TRUE(GNC_IS_TRANSACTION(trans));
|
||||
gnc_mocksplit(split)->set_parent(trans);
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <Account.h>
|
||||
|
||||
#include "gmock-Transaction.h"
|
||||
#include "gmock-Account.h"
|
||||
|
||||
|
||||
struct _MockTransactionClass
|
||||
@ -57,7 +58,7 @@ xaccTransFindSplitByAccount(const Transaction *trans, const Account *acc)
|
||||
{
|
||||
SCOPED_TRACE("");
|
||||
const MockTransaction* mocktrans = gnc_mocktransaction(trans);
|
||||
EXPECT_TRUE(GNC_IS_MOCKACCOUNT(acc));
|
||||
EXPECT_TRUE(GNC_IS_ACCOUNT(acc));
|
||||
return mocktrans ? mocktrans->find_split_by_account(acc) : nullptr;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
#include <qofbook.h>
|
||||
#include <qofbook-p.h>
|
||||
#include <Split.h>
|
||||
|
||||
#include "gmock-gobject.h"
|
||||
#include "gmock-Split.h"
|
||||
|
||||
|
||||
GType qof_mockbook_get_type(void);
|
||||
|
Loading…
Reference in New Issue
Block a user