MCPcopy Create free account
hub / github.com/dcleblanc/SafeInt / NegationVerifyT

Function NegationVerifyT

Test/SubVerify.cpp:6962–7004  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6960{
6961 template < typename T >
6962 void NegationVerifyT()
6963 {
6964 T minInt = std::numeric_limits<T>::min();
6965 T test = 2;
6966 bool result = false;
6967 T out = 0;
6968
6969 try
6970 {
6971 out = -SafeInt< T >(minInt);
6972 }
6973 catch (...)
6974 {
6975 result = true;
6976 }
6977
6978 if (result == false)
6979 cerr << "Error in NegationVerifyT throw (1): ";
6980
6981 try
6982 {
6983 out = -SafeInt< T >(test);
6984 }
6985 catch (...)
6986 {
6987 result = false;
6988 }
6989
6990 if (result == false)
6991 cerr << "Error in NegationVerifyT throw (2): ";
6992
6993 // Now try the non-throwing version
6994
6995 result = SafeNegation(minInt, out);
6996
6997 if (result != false)
6998 cerr << "Error in NegationVerifyT nothrow (1): ";
6999
7000 result = SafeNegation(test, out);
7001
7002 if (result == false)
7003 cerr << "Error in NegationVerifyT nothrow (2): ";
7004 }
7005
7006 void NegationVerifyAll()
7007 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected