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 ...

learn more… | top users | synonyms

2
votes
2answers
59 views

Simple JavaScript precondition checking implementation

I am writing a JavaScript application and would like to validate function arguments in many places. Most of these checks will be for correct argument types, or numeric values within specific ranges. ...
5
votes
2answers
2k 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. ...
8
votes
0answers
116 views

Suggesting “safe enum” class for ISO C

There are quite some questions and answers about how to make enum really type-safe and I didn't find a solution that ensures both type safety and valid values. So I ...
11
votes
1answer
671 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 ...
5
votes
1answer
481 views

Compile-time printf format checking

Compile time checking of printf-like format strings Inspired by this open ticket on boost, this seeks to complete the work there Given a printf-style format string and associated arguments, a ...
3
votes
1answer
57 views

How can I ensure some structure for classes for a plug-in system written in Python?

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 ...
4
votes
2answers
248 views

NSAssert or NSLog in defaults switch case

I am wondering if I should use NSLog(@"Switch out of range") or NSAssert(FALSE,@"Switch out of range"); in the following example:...
5
votes
1answer
108 views

Better way to assert correct return values in Groovy

I have written a function that returns me the duplicates of a list: ...
10
votes
1answer
309 views

Automatically run doctest every time program is run

I would like this to happen every time I run a program from the command line. Is my approach Pythonic? I'm interested to know whether there is any problem with readability or correctness. Any general ...
6
votes
1answer
339 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 ...
10
votes
5answers
1k views

Testing code with Debug.Assert

I have a small little function in a VB6 codebase: ...
5
votes
2answers
118 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....
5
votes
2answers
256 views

Defensive programming type-checking

I have issues with dynamically typed languages, and I tend to worry about type a lot. Numpy has different behaviour depending on if something is a matrix or a plain ndarray, or a list. I didn't ...
7
votes
1answer
1k 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 ...