We need a function that takes an Arabic number and returns its Roman numeral equivalent (as a string).
Let’s Go!
What are we building?
One, Two, Three, ...
Getting the first test to pass will take us a few minutes, since there’s a good amount of setup work to do (getting the build script in place, adding header includes, and so on). There are also decisions to be made: What are we going to name our test method? What should the interface to our function look like?
We choose to make our conversion a free function. Here’s the first, failing test:
roman/1/RomanConverterTest.cpp | |
| TEST(RomanConverter, CanConvertPositiveDigits) { |
| EXPECT_THAT(convert(1), Eq("I")); |
| } |
One of the goals for a kata is to minimize our movements. ...
Get Modern C++ Programming with Test-Driven Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.