Continue Developing the CalculateDiscount Function in C++

Welcome to your second lesson, which continues to delve into Test Driven Development (TDD) practices using C++ and Google Test. In this unit, we will extend the functionality of our CalculateDiscount function by implementing five new requirements.

Building on the previous unit, this course emphasizes practical experience by sequentially providing requirements through tests. Your mission is to implement code that satisfies each test, mirroring a real-world TDD scenario. Consider this guide your pair programmer, offering test-driven prompts to enhance your expertise incrementally.

Understanding the Red-Green-Refactor Cycle

As a reminder, the Red-Green-Refactor cycle is crucial in TDD, steering your development process:

  • Red: Begin by writing a failing test to define what to do next.
  • Green: Develop just enough code to pass the test, concentrating on meeting the functionality.
  • Refactor: Enhance the code for clarity and efficiency without changing its behavior.
More Requirements for CalculateDiscount Function
6. Negative Discount Percentage
  • Description: The function should not accept negative discount percentages and must throw an error in such cases.
  • Test Case:
Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal