One way to avoid this kind of mistakes is to use Yoda conditions [0]:
ASSERTS(1 == apples);
If you forget one `=`, it doesn't compile. ASSERTS(1 == apples);
If you forget one `=`, it doesn't compile.+EDIT: In those occasions when you actually compare to a integer, the expression is so simple that you immediately understand the whole line. In case of an actual typo the compiler will warn you, and the inversion is not needed. Nowadays, there is simply no excuse for a ignored or missed( bad compiler ) warning.
Assignment in an If statement must produce a warning!
If you're doing
if (var1 == var2)
then yoda expressions won't save you, however. if (42 == some_long_expression_here)
{
...
}
It is immediately clear that the rest of the line after the two equals signs must be an expression because the curly brace in the beginning of the next line. So folks don't have to bother that much about counting parens.