Exemplo n.º 1
0
TEST(ExpressionTest, ReduceMoney) {
    Money* one =Money::dollar(1);
    
    Bank* bank = new Bank();
    Money* result = bank->reduce(one,"USD");
    
    EXPECT_EQ(*one,*result);
    
    delete one;
    delete bank;
    delete result;
                                 
}
Exemplo n.º 2
0
TEST(MoneyTest, SimpleAddition) {
    Money* five = Money::dollar(5);
    Money* ten = Money::dollar(10);
    
    Expression* sum = five->plus(five);
    
    
    Bank* bank = new Bank();
    Money* reduced = bank->reduce(sum,"USD");
    EXPECT_EQ(*ten,*reduced);
    
    delete five;
    delete ten;
    delete sum;
    delete reduced;
}
Exemplo n.º 3
0
TEST(ExpressionTest, ReduceMoneyDifferentCurrency) {
    Money* two = Money::franc(2);
    Money* one = Money::dollar(1);
    
    Bank* bank = new Bank();
    bank->addRate("CHF","USD",2);
    Money* result = bank->reduce(two,"USD");
    
    EXPECT_EQ(*one,*result);
    
    delete one;
    delete two;
    delete bank;
    delete result;
                                
}
Exemplo n.º 4
0
TEST(ExpressionTest,MixedAddition)
{
    Money* ten = Money::dollar(10);
    
    Expression* fiveBucks = Money::dollar(5);
    Expression* tenFrancs = Money::franc(10);
    
    Bank bank;
    bank.addRate("CHF","USD",2);
    
    Expression* sum = fiveBucks->plus(tenFrancs);
    Money* result = bank.reduce(sum,"USD");
    
    EXPECT_EQ(*ten,*result);
    
    delete sum;
    delete ten;
    delete result;
    delete fiveBucks;
    delete tenFrancs;

}
Exemplo n.º 5
0
TEST(ExpressionTest,SumTimes)
{
    Money* d20 = Money::dollar(20);
    
    Expression* fiveBucks = Money::dollar(5);
    Expression* tenFrancs = Money::franc(10);
    Bank bank;
    bank.addRate("CHF","USD",2);
    
    Expression* sum = new Sum(fiveBucks,tenFrancs);
    Expression* sum2nd = sum->times(2);
    
    Money* result = bank.reduce(sum2nd,"USD");
    
    EXPECT_EQ(*d20,*result);
    
    delete d20;
    delete sum;
    delete sum2nd;
    delete result;
    delete fiveBucks;
    delete tenFrancs;
}
Exemplo n.º 6
0
TEST(ExpressionTest,SumPlusMoney)
{
    Money* fifteen = Money::dollar(15);
    
    Expression* fiveBucks = Money::dollar(5);
    Expression* tenFrancs = Money::franc(10);
    Bank bank;
    bank.addRate("CHF","USD",2);
    
    Expression* sum = new Sum(fiveBucks,tenFrancs);
    Expression* sum2nd = sum->plus(fiveBucks);
    
    Money* result = bank.reduce(sum2nd,"USD");
    
    EXPECT_EQ(*fifteen,*result);
    
    delete fifteen;
    delete sum;
    delete sum2nd;
    delete result;
    delete fiveBucks;
    delete tenFrancs;
}