Completing the Shopping Cart Module with C++ and Google Test

Welcome to the fifth and final unit of this course, focused on practicing the principles of Test Driven Development (TDD) using C++ and Google Test. We're going to continue building our ShoppingCart system by integrating even more sophisticated features into our class.

In this course, emphasis is placed on hands-on practice, where you'll receive requirements through tests, one at a time. Your task is to write tests AND implement code that makes each test pass, simulating a real-world TDD environment. In previous lessons, tests were provided to guide you, but now it's your turn to define them!

Remember to apply the core concepts of the Red-Green-Refactor cycle while completing these coding exercises. Ask questions if you need any clarification!

Final Requirements for `ShoppingCart` Class
11. Quantity Limit for Single Item
  • Description: The cart should enforce a maximum quantity limit of 10 for a single type of item, preventing more than this allowed amount from being added.
  • Details
    • Utilize the AddItem(item, quantity) method to add items to the cart.
    • Ensure an exception is raised when adding a quantity that exceeds the limit of 10 for a single item.
    • The exception should be of type std::invalid_argument with the message "Maximum quantity exceeded."
  • Examples: Attempting to add 11 units of an item should throw a exception indicating "Maximum quantity exceeded."
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