testexceptions.h

来自「The goal of this library is to make ODBC」· C头文件 代码 · 共 99 行

H
99
字号
// code in which we intentionally cause DTL to trip and throw exceptions// in order to make sure they work// Initial: 12/27/2000 - MG#ifndef _TEST_EXCEPTIONS_H#define _TEST_EXCEPTIONS_H#include "Example.h"// a BCA using an invalid column nameclass BadBCAExampleObj{public:	void operator()(BoundIOs &boundIOs, Example &rowbuf)    {	   boundIOs["INT_VALUE"] 	   == rowbuf.exampleInt;	   boundIOs["STRING_VALUE"]    == rowbuf.exampleStr;	   boundIOs["DOUBLE_VALUE"]    == rowbuf.exampleDouble;	   boundIOs["EXAMPLE_FOO"]   == rowbuf.exampleLong; // doesn't exist, should throw on Execute	   boundIOs["EXAMPLE_DATE"]   == rowbuf.exampleDate;	}};// a BPA using a parameter that's out of boundsclass BadBPAExampleObj{public:	void operator()(BoundIOs &boundIOs, DefaultParamObj<Example> &paramObj)	{	  boundIOs[0] == paramObj.lowIntValue;	  boundIOs[1] == paramObj.highIntValue;	  boundIOs[2] == paramObj.strValue;	  boundIOs[4] == paramObj.dateValue; // param # out of bounds, should throw on Execute	}};class BadDelBCAExampleObj{public:	void operator()(BoundIOs &boundIOs, Example &rowbuf)	{      boundIOs["STRING_VALUE"]       == rowbuf.exampleStr;	  boundIOs["EXAMPLE_DATE_BAD"]   == rowbuf.exampleDate; // throw	}};class BadDelBPAExampleObj{public:	void operator()(BoundIOs &boundIOs, DefaultParamObj<Example> &paramObj)	{	  boundIOs[0] == paramObj.strValue;	  boundIOs[2] == paramObj.lowIntValue; // throw	}};// SelValidate() which throws if INT_VALUE ends in a 3class BadSelValidate{public:	bool operator()(BoundIOs &boundIOs, Example &rowbuf)	{      return (rowbuf.exampleInt % 10 != 1);	}};// InsValidate() which throws if INT_VALUE equals 5class BadInsValidate{public:	bool operator()(Example &rowbuf)	{		return (rowbuf.exampleInt != 7);	}};// SelValidate() which throws on every third element read// bool BadSelValidate(BoundIOs &boundIOs, Example &rowbuf);// master function to test different exception casesvoid TestExceptions();// a function for each different casevoid TestBadBCASelect();void TestBadBPASelect();void TestBadSelValidate();void TestBadBCAInsert();void TestBadInsValidate();void TestBadBCAUpdate();void TestBadUpdateValidate();void TestBadBCADelete();void TestBadBPADelete();#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?