#include #include "validate.h" #include "funcList.h" bool ValidateGetBit( const string& operation ) // // Data file format: // // GetBit // { if( operation != "GetBit" ) return false; ln inputNumber; long inputBitIndex; short inputBitValue; cin >> inputNumber >> inputBitIndex >> inputBitValue; short testBitValue = inputNumber.GetBit( inputBitIndex ); if( CheckForError( testBitValue, inputBitValue, "GetBit" ) ) { cout << "ln = " << inputNumber << endl; cout << "bit# = " << inputBitIndex << endl; cout << "bit value = " << inputBitValue << endl; cout << "GetBit( ) = " << testBitValue << endl; } return true; } // ============================================================ bool ValidateSetBit( const string& operation ) // // Data file format: // // SetBit // { if( operation != "SetBit" ) return false; ln inputNumber; long inputBitIndex; short inputBitValue; ln inputNewNumber; cin >> inputNumber >> inputBitIndex >> inputBitValue >> inputNewNumber; ln testNumber = inputNumber; testNumber.SetBit( inputBitIndex, inputBitValue ); if( CheckForError( testNumber, inputNewNumber, "SetBit" ) ) { cout << "ln = " << inputNumber << endl; cout << "bit# = " << inputBitIndex << endl; cout << "bit value = " << inputBitValue << endl; cout << "new ln = " << inputNewNumber << endl; cout << "after SetBit = " << testNumber << endl; } return true; } // ============================================================ bool ValidateNumBits( const string& operation ) // // Data file format: // // NumBits <# of bits> // { if( operation != "NumBits" ) return false; ln inputNumber; size_t inputNumBits; cin >> inputNumber >> inputNumBits; size_t testNumBits = inputNumber.NumBits( ); if( CheckForError( testNumBits, inputNumBits, "NumBits" ) ) { cout << "input ln = " << inputNumber << endl; cout << "input bits = " << inputNumBits << endl; cout << "test bits = " << testNumBits << endl; } return true; } static TestFunctionList RegFunc1( ValidateGetBit ); static TestFunctionList RegFunc2( ValidateSetBit ); static TestFunctionList RegFunc3( ValidateNumBits );