Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mayankagnihotri7/string-calculator-tdd-kata
https://github.com/mayankagnihotri7/string-calculator-tdd-kata
ruby tdd tdd-kata
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mayankagnihotri7/string-calculator-tdd-kata
- Owner: mayankagnihotri7
- Created: 2022-02-07T13:14:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-03T05:49:21.000Z (almost 3 years ago)
- Last Synced: 2024-11-05T22:38:35.410Z (3 months ago)
- Topics: ruby, tdd, tdd-kata
- Language: Ruby
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# String Calculator TDD Kata
1. Create a simple String calculator with a method signature:
`int Add(string numbers)`
The method can take up to two numbers, separated by commas, and will return their sum.For example `""` or `"1"` or `"1,2"` as inputs. (for an empty string it will return 0)
#### Hints:
- Start with the simplest test case of an empty string and move to one and two numbers
- Remember to solve things as simply as possible so that you force yourself to write tests you did not think about
- Remember to refactor after each passing test2. Allow the Add method to handle an unknown amount of numbers
3. Allow the Add method to handle new lines between numbers (instead of commas).
- The following input is ok: `"1\n2,3"` (will equal 6)
- The following input is NOT ok: `"1,\n"` (not need to prove it - just clarifying)
- Support different delimiters- To change a delimiter, the beginning of the string will contain a separate line that looks like this: `"//[delimiter]\n[numbers…]"` for example `"//;\n1;2"` should return 3 where the default delimiter is `";"`
The first line is optional. all existing scenarios should still be supported5. Calling Add with a negative number will throw an exception "negatives not allowed" - and the negative that was passed.
- If there are multiple negatives, show all of them in the exception message.