doublecash = priceCalculator.AcceptCash(PriceCal::DiscountType::CASE_90PERCENTOFF,90.0); //then EXPECT_EQ(81, cash); EXPECT_DOUBLE_EQ(81, cash); } TEST(PriceCalculator, should_return_72_when_given_cash_80percentoff_and_price_90)
使用EXPECT_NEAR或DoubleEq匹配器,浮点运算可能导致rounding errors,这会使结果稍有不同。
{ comma::regular_vector<double,int> v(1.2,0.5,10); v(2.1) =5;EXPECT_EQ(5, v[ v.index(2.1) ] ); } 開發者ID:sheenzhaox,項目名稱:comma,代碼行數:6,代碼來源:vector_test.cpp 示例6: elementAtIndexMustBe ▲點讚 1▼ voidelementAtIndexMustBe(intindex, T expected){EXPECT_EQ(expected,...