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.
25 questions
3
votes
1
answer
156
views
A simple unit test library for C - version II
I have improved my code here and it looks like this:
Code
assertlib.h:
...
3
votes
1
answer
565
views
My own ThrowHelper extension methods
I really like ArgumentNullException.ThrowIf(...) and ArgumentException.ThrowIfNullOrEmpty(...) and there are upcoming ones in ....
0
votes
1
answer
210
views
Parameter Scaling C++ Driver program
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 ...
0
votes
1
answer
109
views
Type that returns a result based on some logic [closed]
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 ...
0
votes
1
answer
515
views
MS Fakes Shims. Assert "was called" (by closures)
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:
...
3
votes
1
answer
1k
views
Verifying user accounts on SMTP servers
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:
...
5
votes
2
answers
16k
views
Unit testing private constructors and getter setters
I have a class Address, a class AddressTest and I am trying to write unit tests for its constructors and getter setters.
...
13
votes
1
answer
2k
views
Compile-time printf-style format checking
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 ...
1
vote
1
answer
90
views
How can I ensure some structure for classes for a plug-in system written in Python? [closed]
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 ...
5
votes
1
answer
244
views
Better way to assert correct return values in Groovy
I have written a function that returns me the duplicates of a list:
...
6
votes
1
answer
569
views
How should I structure my Unit tests for minimal Asserts?
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 ...
5
votes
2
answers
413
views
What might be another way to test if int is 32 bits wide at compile time?
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....
8
votes
1
answer
2k
views
Vector of derived classes
Everyone knows you can't put a Derived in an std::vector<Base>. I decided to implement a collection which does allow you ...