tfhq / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

New EXPECT and ASSERT #383

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There is EXPECT_LT but there is no EXPECT_NOT_LT, so on for other operators and 
ASSERT_.

The difference is simple:

EXPECT_LT(a, b) => check "a < b"
EXPECT_NOT_LT(a, b) => check "!(a < b)"

It is not same as:
EXPECT_GE(a, b) => check "a >= b"

Very handy to add this.
Thanx.

Original issue reported on code.google.com by NN1436401@gmail.com on 3 Oct 2011 at 4:02

GoogleCodeExporter commented 9 years ago
In most situations, a >= b is the same as !(a < b). Defining it differently is 
counter-intuitive ind will most likely lead to bugs.  Likewise, providing 
corresponding test macros in a general-purpose library will be confusing for 
people. 

It may be necessary in some situations, but the negatives outweigh the 
advantages here, IMO. You, however, can define just such a macro for your own 
purposes using predicate formatters 
(http://code.google.com/p/googletest/wiki/AdvancedGuide#Using_a_Predicate-Format
ter). You can look at the definition of the standard EXPECT_XX macros for an 
expample: they are defined via the  same mechanism.

Original comment by vladlosev on 7 Oct 2011 at 10:55

GoogleCodeExporter commented 9 years ago
It is correct that a >= b is same as !(a < b)
But I wanted to do the opposite:
Check that !(a < b) is same as a >= b.

Original comment by NN1436401@gmail.com on 8 Oct 2011 at 4:21