isocpp / isocpp/CppCoreGuidelines

Pre conditions

Open
#150 4 comments 0 reactions 1 assignee View on GitHub

@gdr-at-ms is already working on this.

Since Oct 12, 2015.

waiting
Dominant language
CSS
Stars
45.3k
Forks
5.6k
PR merge metrics
No merged PRs in 30d

Description

The example used is sqrt() which needs a non-negative input. If passed nan or infinity we should presumably return NaN/infinity. So that's the first question - should that be stated in expects? if we agree that NaN is a defined result, a naive Expects( x >= 0 ) will fail. That's one issue.

Another is that not all preconditions can be so easily stated. Geometrical routines may be undefined for degenerate inputs. So if we are asked whether two "lines" which consist of two co-incident points intersect, is that meant to fail an "Expects"? That's a simple example, you can make the invalid input arbitrarily complex. At what point should the routine treat the input as normal processing and return an error flag / something (you can just decide arbitrarily whether two co-incident points intersect or not), throw an exception?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.