mirror of
https://github.com/boostorg/utility.git
synced 2025-08-03 06:44:37 +02:00
Augment and correct tribool test cases
---------------------------------------------------------------------- [SVN r1573]
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2002 Doug Gregor (gregod@cs.rpi.edu)
|
// Copyright (C) 2002-2003 Doug Gregor (gregod@cs.rpi.edu)
|
||||||
//
|
//
|
||||||
// Permission to copy, use, sell and distribute this software is granted
|
// Permission to copy, use, sell and distribute this software is granted
|
||||||
// provided this copyright notice appears in all copies.
|
// provided this copyright notice appears in all copies.
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
//
|
//
|
||||||
// This software is provided "as is" without express or implied warranty,
|
// This software is provided "as is" without express or implied warranty,
|
||||||
// and with no claim as to its suitability for any purpose.
|
// and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
// For more information, see http://www.boost.org
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
#include <boost/tribool.hpp>
|
#include <boost/tribool.hpp>
|
||||||
@@ -30,10 +30,10 @@ int main()
|
|||||||
assert(false == x);
|
assert(false == x);
|
||||||
assert(x != true);
|
assert(x != true);
|
||||||
assert(true != x);
|
assert(true != x);
|
||||||
assert(!(x == maybe));
|
assert(maybe(x == maybe));
|
||||||
assert(!(maybe == x));
|
assert(maybe(maybe == x));
|
||||||
assert(x != maybe);
|
assert(maybe(x != maybe));
|
||||||
assert(maybe != x);
|
assert(maybe(maybe != x));
|
||||||
assert(x == x);
|
assert(x == x);
|
||||||
assert(!(x != x));
|
assert(!(x != x));
|
||||||
assert(!(x && true));
|
assert(!(x && true));
|
||||||
@@ -46,39 +46,39 @@ int main()
|
|||||||
assert(true == y);
|
assert(true == y);
|
||||||
assert(y != false);
|
assert(y != false);
|
||||||
assert(false != y);
|
assert(false != y);
|
||||||
assert(!(y == maybe));
|
assert(maybe(y == maybe));
|
||||||
assert(!(maybe == y));
|
assert(maybe(maybe == y));
|
||||||
assert(y != maybe);
|
assert(maybe(y != maybe));
|
||||||
assert(maybe != y);
|
assert(maybe(maybe != y));
|
||||||
assert(y == y);
|
assert(y == y);
|
||||||
assert(!(y != y));
|
assert(!(y != y));
|
||||||
|
|
||||||
assert((z || !z) == maybe);
|
assert(maybe(z || !z));
|
||||||
assert(maybe(z == true));
|
assert(maybe(z == true));
|
||||||
assert(maybe(true == z));
|
assert(maybe(true == z));
|
||||||
assert(maybe(z == false));
|
assert(maybe(z == false));
|
||||||
assert(maybe(false == z));
|
assert(maybe(false == z));
|
||||||
assert(z == maybe);
|
assert(maybe(z == maybe));
|
||||||
assert(maybe == z);
|
assert(maybe(maybe == z));
|
||||||
assert(!(z != maybe));
|
assert(maybe(z != maybe));
|
||||||
assert(!(maybe != z));
|
assert(maybe(maybe != z));
|
||||||
assert((z == z) == maybe);
|
assert(maybe(z == z));
|
||||||
assert((z != z) == maybe);
|
assert(maybe(z != z));
|
||||||
|
|
||||||
assert(!(x == y));
|
assert(!(x == y));
|
||||||
assert(x != y);
|
assert(x != y);
|
||||||
assert((x == z) == maybe);
|
assert(maybe(x == z));
|
||||||
assert((x != z) == maybe);
|
assert(maybe(x != z));
|
||||||
assert((y == z) == maybe);
|
assert(maybe(y == z));
|
||||||
assert((y != z) == maybe);
|
assert(maybe(y != z));
|
||||||
|
|
||||||
assert(!(x && y));
|
assert(!(x && y));
|
||||||
assert(x || y);
|
assert(x || y);
|
||||||
assert(!(x && z));
|
assert(!(x && z));
|
||||||
assert((y && z) == maybe);
|
assert(maybe(y && z));
|
||||||
assert((z && z) == maybe);
|
assert(maybe(z && z));
|
||||||
assert(maybe(z || z));
|
assert(maybe(z || z));
|
||||||
assert(x || z == maybe);
|
assert(maybe(x || z));
|
||||||
assert(y || z);
|
assert(y || z);
|
||||||
|
|
||||||
assert(maybe(y && maybe));
|
assert(maybe(y && maybe));
|
||||||
@@ -91,6 +91,7 @@ int main()
|
|||||||
assert(maybe(x || maybe));
|
assert(maybe(x || maybe));
|
||||||
assert(maybe(maybe || x));
|
assert(maybe(maybe || x));
|
||||||
|
|
||||||
|
// Test the if (z) ... else (!z) ... else ... idiom
|
||||||
if (z) {
|
if (z) {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -101,6 +102,28 @@ int main()
|
|||||||
assert(true);
|
assert(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
z = true;
|
||||||
|
if (z) {
|
||||||
|
assert(true);
|
||||||
|
}
|
||||||
|
else if (!z) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
z = false;
|
||||||
|
if (z) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
else if (!z) {
|
||||||
|
assert(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "no errors detected\n";
|
std::cout << "no errors detected\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2002 Doug Gregor (gregod@cs.rpi.edu)
|
// Copyright (C) 2002-2003 Doug Gregor (gregod@cs.rpi.edu)
|
||||||
//
|
//
|
||||||
// Permission to copy, use, sell and distribute this software is granted
|
// Permission to copy, use, sell and distribute this software is granted
|
||||||
// provided this copyright notice appears in all copies.
|
// provided this copyright notice appears in all copies.
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
//
|
//
|
||||||
// This software is provided "as is" without express or implied warranty,
|
// This software is provided "as is" without express or implied warranty,
|
||||||
// and with no claim as to its suitability for any purpose.
|
// and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
// For more information, see http://www.boost.org
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
#include <boost/tribool.hpp>
|
#include <boost/tribool.hpp>
|
||||||
@@ -28,10 +28,10 @@ int main()
|
|||||||
assert(false == x);
|
assert(false == x);
|
||||||
assert(x != true);
|
assert(x != true);
|
||||||
assert(true != x);
|
assert(true != x);
|
||||||
assert(!(x == indeterminate));
|
assert(indeterminate(x == indeterminate));
|
||||||
assert(!(indeterminate == x));
|
assert(indeterminate(indeterminate == x));
|
||||||
assert(x != indeterminate);
|
assert(indeterminate(x != indeterminate));
|
||||||
assert(indeterminate != x);
|
assert(indeterminate(indeterminate != x));
|
||||||
assert(x == x);
|
assert(x == x);
|
||||||
assert(!(x != x));
|
assert(!(x != x));
|
||||||
assert(!(x && true));
|
assert(!(x && true));
|
||||||
@@ -44,39 +44,39 @@ int main()
|
|||||||
assert(true == y);
|
assert(true == y);
|
||||||
assert(y != false);
|
assert(y != false);
|
||||||
assert(false != y);
|
assert(false != y);
|
||||||
assert(!(y == indeterminate));
|
assert(indeterminate(y == indeterminate));
|
||||||
assert(!(indeterminate == y));
|
assert(indeterminate(indeterminate == y));
|
||||||
assert(y != indeterminate);
|
assert(indeterminate(y != indeterminate));
|
||||||
assert(indeterminate != y);
|
assert(indeterminate(indeterminate != y));
|
||||||
assert(y == y);
|
assert(y == y);
|
||||||
assert(!(y != y));
|
assert(!(y != y));
|
||||||
|
|
||||||
assert((z || !z) == indeterminate);
|
assert(indeterminate(z || !z));
|
||||||
assert(indeterminate(z == true));
|
assert(indeterminate(z == true));
|
||||||
assert(indeterminate(true == z));
|
assert(indeterminate(true == z));
|
||||||
assert(indeterminate(z == false));
|
assert(indeterminate(z == false));
|
||||||
assert(indeterminate(false == z));
|
assert(indeterminate(false == z));
|
||||||
assert(z == indeterminate);
|
assert(indeterminate(z == indeterminate));
|
||||||
assert(indeterminate == z);
|
assert(indeterminate(indeterminate == z));
|
||||||
assert(!(z != indeterminate));
|
assert(indeterminate(z != indeterminate));
|
||||||
assert(!(indeterminate != z));
|
assert(indeterminate(indeterminate != z));
|
||||||
assert((z == z) == indeterminate);
|
assert(indeterminate(z == z));
|
||||||
assert((z != z) == indeterminate);
|
assert(indeterminate(z != z));
|
||||||
|
|
||||||
assert(!(x == y));
|
assert(!(x == y));
|
||||||
assert(x != y);
|
assert(x != y);
|
||||||
assert((x == z) == indeterminate);
|
assert(indeterminate(x == z));
|
||||||
assert((x != z) == indeterminate);
|
assert(indeterminate(x != z));
|
||||||
assert((y == z) == indeterminate);
|
assert(indeterminate(y == z));
|
||||||
assert((y != z) == indeterminate);
|
assert(indeterminate(y != z));
|
||||||
|
|
||||||
assert(!(x && y));
|
assert(!(x && y));
|
||||||
assert(x || y);
|
assert(x || y);
|
||||||
assert(!(x && z));
|
assert(!(x && z));
|
||||||
assert((y && z) == indeterminate);
|
assert(indeterminate(y && z));
|
||||||
assert((z && z) == indeterminate);
|
assert(indeterminate(z && z));
|
||||||
assert(indeterminate(z || z));
|
assert(indeterminate(z || z));
|
||||||
assert(x || z == indeterminate);
|
assert(indeterminate(x || z));
|
||||||
assert(y || z);
|
assert(y || z);
|
||||||
|
|
||||||
assert(indeterminate(y && indeterminate));
|
assert(indeterminate(y && indeterminate));
|
||||||
@@ -89,6 +89,7 @@ int main()
|
|||||||
assert(indeterminate(x || indeterminate));
|
assert(indeterminate(x || indeterminate));
|
||||||
assert(indeterminate(indeterminate || x));
|
assert(indeterminate(indeterminate || x));
|
||||||
|
|
||||||
|
// Test the if (z) ... else (!z) ... else ... idiom
|
||||||
if (z) {
|
if (z) {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@@ -99,6 +100,28 @@ int main()
|
|||||||
assert(true);
|
assert(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
z = true;
|
||||||
|
if (z) {
|
||||||
|
assert(true);
|
||||||
|
}
|
||||||
|
else if (!z) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
z = false;
|
||||||
|
if (z) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
else if (!z) {
|
||||||
|
assert(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "no errors detected\n";
|
std::cout << "no errors detected\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user