You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- 2It could be the case that when I later change or refactor this method I decide to do something that causes negative to react wrongly, which would have been picked up if I had that test there. Should I just not worry about adding such tests until I go to make changes that could effect that?Joshua Harris– Joshua Harris2012-11-11 08:10:40 +00:00Commented Nov 11, 2012 at 8:10
- 3@JoshuaHarris: Exactly. Like I say, you could make a change that causes it not to work when passed exactly 40.23. Are you going to test for that too? If you're doing tests like that then you're moving to unit testing, rather than TDD, and then your red-green-refactor cycle isn't quite as important.pdr– pdr2012-11-11 08:40:47 +00:00Commented Nov 11, 2012 at 8:40
- 2@JoshuaHarris: exactly. If you see no possible error in the code that could cause a test to fail, the test is worthless. Frex a function that adds 1 to an unsigned int -- you could write a test for every possible value an unsigned int might hold, but really, how many of them would be useful?jmoreno– jmoreno2012-11-11 08:43:10 +00:00Commented Nov 11, 2012 at 8:43
- 2I agree with the answer and comments here regarding testing vast permutations of numbers, but I think it would be fine to add a test for negative numbers in this case. It seems like it would give you more confidence in the code you've written and your ability to refactor it in the future. Gaining that confidence is one of the reasons we write tests. The test passed on the first run? That's a warning sign, not a sin. Investigate why it passed to make sure something unexpected isn't happening. You wrote the code correctly the first time? Clever you. Pat yourself on the back and move forward.nocash– nocash2014-09-20 15:23:15 +00:00Commented Sep 20, 2014 at 15:23
Add a comment |
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you