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

Function MultVerifyInt8Int8

Test/MultVerify.cpp:1930–1970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1928#endif
1929
1930void MultVerifyInt8Int8()
1931{
1932 size_t i;
1933
1934 for( i = 0; i < COUNTOF(int8_int8); ++i )
1935 {
1936 std::int8_t ret;
1937 if( SafeMultiply(int8_int8[i].x, int8_int8[i].y, ret) != int8_int8[i].fExpected )
1938 {
1939 //assert(false);
1940 // printf("Error in case int8_int8: %02X, %02X, expected = %s\n",
1941 // int8_int8[i].x, int8_int8[i].y, int8_int8[i].fExpected ? "true" : "false");
1942 cerr << "Error in case int8_int8: ";
1943 cerr << hex << setw(2) << setfill('0') << (unsigned int)int8_int8[i].x << ", ";
1944 cerr << hex << setw(2) << setfill('0') << (unsigned int)int8_int8[i].y << ", ";
1945 cerr << "expected = " << int8_int8[i].fExpected << endl;
1946 }
1947
1948 // Now test throwing version
1949 bool fSuccess = true;
1950 try
1951 {
1952 SafeInt<std::int8_t> si(int8_int8[i].x);
1953 si *= int8_int8[i].y;
1954 }
1955 catch(...)
1956 {
1957 fSuccess = false;
1958 }
1959
1960 if( fSuccess != int8_int8[i].fExpected )
1961 {
1962 // printf("Error in case int8_int8 throw: %02X, %02X, expected = %s\n",
1963 // int8_int8[i].x, int8_int8[i].y, int8_int8[i].fExpected ? "true" : "false");
1964 cerr << "Error in case int8_int8 throw: ";
1965 cerr << hex << setw(2) << setfill('0') << (unsigned int)int8_int8[i].x << ", ";
1966 cerr << hex << setw(2) << setfill('0') << (unsigned int)int8_int8[i].y << ", ";
1967 cerr << "expected = " << int8_int8[i].fExpected << endl;
1968 }
1969 }
1970}
1971
1972void MultVerify()
1973{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected