本文整理汇总了C++中Account::AddTransaction方法的典型用法代码示例。如果您正苦于以下问题:C++ Account::AddTransaction方法的具体用法?C++ Account::AddTransaction怎么用?C++ Account::AddTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account::AddTransaction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MixedTimeBalance
void AccountBalanceTest::MixedTimeBalance()
{
Account account;
account.AddTransaction(t_Transaction_ptr(new Transaction(100, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(1, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(1000, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(2, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(2000, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(3, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(500, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(4, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(1, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(5, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(3000, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(6, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(6, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(7, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(4500, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(8, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(1, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(9, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(3001, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(10, account.StrikeBalance(), 0.01);
}
示例2: LinearBalance
void AccountBalanceTest::LinearBalance()
{
Account account;
account.AddTransaction(t_Transaction_ptr(new Transaction(0, 1)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(1, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(0, 3)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(4, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(50, -45.1f)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(-41.10, account.StrikeBalance(), 0.01);
account.AddTransaction(t_Transaction_ptr(new Transaction(52, 457.5)));
CPPUNIT_ASSERT_DOUBLES_EQUAL(416.40, account.StrikeBalance(), 0.01);
}
示例3: DuplicatedTransaction
void AccountBalanceTest::DuplicatedTransaction()
{
Account account;
t_Transaction_ptr pTransaction(new Transaction(1, 2));
account.AddTransaction(pTransaction);
account.AddTransaction(pTransaction);
CPPUNIT_ASSERT(pTransaction->GetParent() != pTransaction);
CPPUNIT_ASSERT_DOUBLES_EQUAL(2, account.StrikeBalance(), 0.01);
}