Skip to main content

Questions tagged [assertions]

In computer programming, an assertion is a predicate (a true|false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place. If an assertion evaluates to false at run-time, an assertion failure results, which typically causes execution to abort.

Filter by
Sorted by
Tagged with
3 votes
1 answer
156 views

I have improved my code here and it looks like this: Code assertlib.h: ...
coderodde's user avatar
  • 32.2k
3 votes
1 answer
565 views

I really like ArgumentNullException.ThrowIf(...) and ArgumentException.ThrowIfNullOrEmpty(...) and there are upcoming ones in ....
nop's user avatar
  • 819
0 votes
1 answer
210 views

The question is: In many mathematical problems, the parameters need to be scaled, either to convert between units or to standardise measurements to a certain range of values. Write a void function ...
Strange Alchemist's user avatar
0 votes
1 answer
109 views

I have a type that returns a result based on some logic. The result contains a message. Should a good unit test check that the message is correct? A negligible amount has changed as I'm not allowed ...
Steve Dunn's user avatar
0 votes
1 answer
515 views

Is it a good or bad practice to use closures for asserting the method was called in such a way? The method set a shim and return an Action wich both capture local mutable variable: ...
SerG's user avatar
  • 171
3 votes
1 answer
1k views

I've been writing a basic script to enumerate SMTP users (via a user dictionary) on poorly configured SMTP servers. In scripts like this, I usually see arguments handled as follows: ...
user avatar
5 votes
2 answers
16k views

I have a class Address, a class AddressTest and I am trying to write unit tests for its constructors and getter setters. ...
Sandeep Chatterjee's user avatar
13 votes
1 answer
2k views

Inspired by this open ticket on Boost, this seeks to complete the work there. Given a printf-style format string and associated arguments, a static_assert is ...
Steve Lorimer's user avatar
1 vote
1 answer
90 views

I have written a toolkit (hwrt) which has a plugin system. One type of plugin is a feature (see this) for many of them. There are some restrictions of feature ...
Martin Thoma's user avatar
  • 1,275
5 votes
1 answer
244 views

I have written a function that returns me the duplicates of a list: ...
valenterry's user avatar
6 votes
1 answer
569 views

I always see comments about how a Unit Test should only be testing one piece of functionality. For the most part, I definitely agree with that assessment. However, I'm working on testing a method ...
krillgar's user avatar
  • 343
5 votes
2 answers
413 views

Below is code that will compile when INT_MAX is equal to 232. It will generate a compiler error when INT_MAX is not equal to 232....
KeithSmith's user avatar
8 votes
1 answer
2k views

Everyone knows you can't put a Derived in an std::vector<Base>. I decided to implement a collection which does allow you ...
Komi Golov's user avatar
  • 3,269