当前位置: 首页>>代码示例>>C++>>正文


C++ Bank::addRate方法代码示例

本文整理汇总了C++中Bank::addRate方法的典型用法代码示例。如果您正苦于以下问题:C++ Bank::addRate方法的具体用法?C++ Bank::addRate怎么用?C++ Bank::addRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bank的用法示例。


在下文中一共展示了Bank::addRate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Bank

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;
                                
}
开发者ID:ishii0514,项目名称:TDD-,代码行数:16,代码来源:DollarTest.cpp

示例2:

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;

}
开发者ID:ishii0514,项目名称:TDD-,代码行数:22,代码来源:DollarTest.cpp

示例3: Sum

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;
}
开发者ID:ishii0514,项目名称:TDD-,代码行数:23,代码来源:DollarTest.cpp


注:本文中的Bank::addRate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。