Ejemplo n.º 1
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;
                                
}
Ejemplo n.º 2
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;

}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
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;
}