#include #include "validate.h" #include "funcList.h" static bool ValidateDivide( const string& operation ) { if( operation != "divide" ) return false; ln a, b, c, d, e, f; cin >> a >> b >> c >> d; a.Divide( b, &e, &f ); CheckForError( e, c, "Divide( ln ); quotient" ); CheckForError( f, d, "Divide( ln ); remainder" ); e = a / b; CheckForError( e, c, "operator/( ln )" ); e = a; e /= b; CheckForError( e, c, "operator/=( ln )" ); // mod returns f in [0, n-1], so adjust the test value ln g = d; if( d.IsNegative( ) ) g += b; f = a % b; if( CheckForError( f, g, "operator%( ln )" ) ) { cout << "a = " << a << endl; cout << "b = " << b << endl; cout << "a % b = " << f << endl; cout << "real + b = " << ( d + b ) << endl; cout << "real = " << d << endl; } f = a; f %= b; CheckForError( f, g, "operator%=( ln )" ); // scalar case... return true; } static TestFunctionList RegFunc( ValidateDivide );