diff --git a/exercises/18_function_template/main.cpp b/exercises/18_function_template/main.cpp index 9d7f99ce..cb6d978d 100644 --- a/exercises/18_function_template/main.cpp +++ b/exercises/18_function_template/main.cpp @@ -6,11 +6,15 @@ int plus(int a, int b) { return a + b; } -// ---- 不要修改以下代码 ---- int main(int argc, char **argv) { - ASSERT(plus(1, 2) == 3, "plus two int"); - ASSERT(plus(1u, 2u) == 3u, "plus two unsigned int"); - ASSERT(plus(1.f, 2.f) == 3.f, "plus two float"); - ASSERT(plus(1.0, 2.0) == 3.0, "plus two double"); + ASSERT(plus(1, 2) == 3, "Plus two int"); + ASSERT(plus(1u, 2u) == 3u, "Plus two unsigned int"); + + // THINK: 浮点数何时可以判断 ==?何时必须判断差值? + ASSERT(plus(1.25f, 2.5f) == 3.75f, "Plus two float"); + ASSERT(plus(1.25, 2.5) == 3.75, "Plus two double"); + // TODO: 修改判断条件使测试通过 + ASSERT(plus(0.1, 0.2) == 0.3, "How to make this pass?"); + return 0; }