当前位置: 首页>>代码示例>>C++>>正文


C++ TestCase::addInput方法代码示例

本文整理汇总了C++中TestCase::addInput方法的典型用法代码示例。如果您正苦于以下问题:C++ TestCase::addInput方法的具体用法?C++ TestCase::addInput怎么用?C++ TestCase::addInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestCase的用法示例。


在下文中一共展示了TestCase::addInput方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestCase

	// This method is cloned from Operator, just resetting sign and exception bits
	// (because we don't have any exception support in this toy example)
	TestCase* FPSumOf3Squares::buildRandomTestCase(int i){

		TestCase *tc;
		/* Generate test cases using random input numbers */
			tc = new TestCase(this); // TODO free all this memory when exiting TestBench
			/* Fill inputs */
			for (unsigned int j = 0; j < ioList_.size(); j++) {
				Signal* s = ioList_[j]; 
				if (s->type() == Signal::in) {
					// ****** Modification: positive normal numbers with small exponents 
					mpz_class m = getLargeRandom(wF);
					mpz_class bias = (mpz_class(1)<<(wE-1)) - 1; 
					mpz_class e = getLargeRandom(wE-2) - (mpz_class(1)<<(wE-3)) + bias; // ensure no overflow
					mpz_class a = (mpz_class(1)<<(wE+wF+1)) // 01 to denote a normal number
						+ (e<<wF) + m;
					tc->addInput(s->getName(), a);
				}
			}
			/* Get correct outputs */
			emulate(tc);

			//		cout << tc->getInputVHDL();
			//    cout << tc->getExpectedOutputVHDL();

			return tc;
	}
开发者ID:jpdoyle,项目名称:flopoco,代码行数:28,代码来源:FPSumOf3Squares.cpp

示例2: buildStandardTestCases

	void FixComplexKCM::buildStandardTestCases(TestCaseList * tcl) {
		TestCase* tc;

		int one = 1;
		if(lsb_in < 0 && msb_in >= 0)
		{
			//Real one
			one = one << -lsb_in;
		}

		tc = new TestCase(this);		
		tc->addInput("ReIN", 0);
		tc->addInput("ImIN", 0);
		emulate(tc);
		tcl->add(tc);
		
		tc = new TestCase(this);		
		tc->addInput("ReIN", one);
		tc->addInput("ImIN", 0);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this);		
		tc->addInput("ReIN", 0);
		tc->addInput("ImIN", one);
		emulate(tc);
		tcl->add(tc);
		
		tc = new TestCase(this);		
		tc->addInput("ReIN", one);
		tc->addInput("ImIN", one);
		emulate(tc);
		tcl->add(tc);

		if(signedInput)
		{
			tc = new TestCase(this);		
			tc->addInput("ReIN", -1 * one);
			tc->addInput("ImIN", -1 * one);
			emulate(tc);
			tcl->add(tc);
		}

		tc = new TestCase(this);		
		tc->addInput("ReIN", 2 * one);
		tc->addInput("ImIN", 0);
		emulate(tc);
		tcl->add(tc);

	}
开发者ID:jpdoyle,项目名称:flopoco,代码行数:50,代码来源:FixComplexKCM.cpp

示例3: buildStandardTestCases

	void FixFunctionBySimplePoly::buildStandardTestCases(TestCaseList* tcl){
		TestCase *tc;
		int lsbIn = f->lsbIn;
		bool signedIn = f->signedIn;
		// Testing the extremal cases
		tc = new TestCase(this);
		tc->addInput("X", 0);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this);
		tc->addInput("X", (mpz_class(1)<<(-lsbIn) ) -1);
		tc -> addComment("largest positive value, corresponding to 1");
		emulate(tc);
		tcl->add(tc);

		if(signedIn) {
			tc = new TestCase(this);
			tc->addInput("X", (mpz_class(1)<<(-lsbIn) ));
			tc -> addComment("Smallest two's complement value, corresponding to -1");
			emulate(tc);
			tcl->add(tc);
		}
	}
开发者ID:jpdoyle,项目名称:flopoco,代码行数:24,代码来源:FixFunctionBySimplePoly.cpp

示例4: buildStandardTestCases

	void InputIEEE::buildStandardTestCases(TestCaseList* tcl){
		TestCase *tc;
		mpz_class x, r;

		tc = new TestCase(this); 
		tc->addComment("a typical normal number: 1.0");
		x = ((mpz_class(1) << 10)-1) << 52 ;
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this); 
		tc->addComment("another one: -1.0");
		x += (mpz_class(1) << 63);
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this);
		tc->addComment("a subnormal that is converted to a normal number");
		x = mpz_class(1) << 51;
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);	

		if(wFO==52 && wEO==11) {
			tc = new TestCase(this);
			tc->addComment("the same, but defined explicitely (to check emulate())");
			x = mpz_class(1) << 51;
			tc->addInput("X", x);
			r = mpz_class(1) << 64; // normal number, exp=0, mantissa=1
			tc->addExpectedOutput("R", r);
			tcl->add(tc);
		}

		tc = new TestCase(this);
		tc->addComment("the same, negative");
		x += (mpz_class(1) << 63);
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this);
		tc->addComment("a subnormal that is flushed to zero");
		x = mpz_class(1) << 50;
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this);
		tc->addComment("the same, negative");
		x += (mpz_class(1) << 63);
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this);
		tc->addComment("another subnormal that is flushed to zero");
		x = mpz_class(1) << 49;
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this);
		tc->addComment("the same, negative");
		x += (mpz_class(1) << 63);
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);

		tc = new TestCase(this);
		tc->addComment("The largest finite number. ");
		x = (((mpz_class(1) << 11)-1) << 52) -1 ;
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);

		if (wEI>wEO && wFI>wFO) {
			tc = new TestCase(this);
			tc->addComment("a number whose rounding will trigger an overflow");
			x =  overflowThreshold << wFI; // maximal exponent
			x += ((mpz_class(1) << wFI)-1); // largest mantissa
			tc->addInput("X", x);
			emulate(tc);
			tcl->add(tc);

			tc = new TestCase(this);
			tc->addComment("just to check: the previous input minus one ulp");
			x -= 1; 
			tc->addInput("X", x);
			emulate(tc);
			tcl->add(tc);
		}

		tc = new TestCase(this);
		tc->addComment("the same, negative");
		x += (mpz_class(1) << 63);
		tc->addInput("X", x);
		emulate(tc);
		tcl->add(tc);
//.........这里部分代码省略.........
开发者ID:jpdoyle,项目名称:flopoco,代码行数:101,代码来源:InputIEEE.cpp

示例5: buildRandomTestCase

	TestCase* FPAddDualPath::buildRandomTestCase(int i){

		TestCase *tc;
		mpz_class x,y;
		mpz_class normalExn = mpz_class(1)<<(wE+wF+1);
		mpz_class negative  = mpz_class(1)<<(wE+wF);

		tc = new TestCase(this);
		/* Fill inputs */
		if ((i & 7) == 0) {// cancellation, same exponent
			mpz_class e = getLargeRandom(wE);
			x  = getLargeRandom(wF) + (e << wF) + normalExn;
			y  = getLargeRandom(wF) + (e << wF) + normalExn + negative;
		}
		else if ((i & 7) == 1) {// cancellation, exp diff=1
			mpz_class e = getLargeRandom(wE);
			x  = getLargeRandom(wF) + (e << wF) + normalExn;
			e++; // may rarely lead to an overflow, who cares
			y  = getLargeRandom(wF) + (e << wF) + normalExn + negative;
		}
		else if ((i & 7) == 2) {// cancellation, exp diff=1
			mpz_class e = getLargeRandom(wE);
			x  = getLargeRandom(wF) + (e << wF) + normalExn + negative;
			e++; // may rarely lead to an overflow, who cares
			y  = getLargeRandom(wF) + (e << wF) + normalExn;
		}
		else if ((i & 7) == 3) {// alignment within the mantissa sizes
			mpz_class e = getLargeRandom(wE);
			x  = getLargeRandom(wF) + (e << wF) + normalExn + negative;
			e +=	getLargeRandom(intlog2(wF)); // may lead to an overflow, who cares
			y  = getLargeRandom(wF) + (e << wF) + normalExn;
		}
		else if ((i & 7) == 4) {// subtraction, alignment within the mantissa sizes
			mpz_class e = getLargeRandom(wE);
			x  = getLargeRandom(wF) + (e << wF) + normalExn;
			e +=	getLargeRandom(intlog2(wF)); // may lead to an overflow
			y  = getLargeRandom(wF) + (e << wF) + normalExn + negative;
		}
		else if ((i & 7) == 5 || (i & 7) == 6) {// addition, alignment within the mantissa sizes
			mpz_class e = getLargeRandom(wE);
			x  = getLargeRandom(wF) + (e << wF) + normalExn;
			e +=	getLargeRandom(intlog2(wF)); // may lead to an overflow
			y  = getLargeRandom(wF) + (e << wF) + normalExn;
		}
		else{ //fully random
			x = getLargeRandom(wE+wF+3);
			y = getLargeRandom(wE+wF+3);
		}
		// Random swap
		mpz_class swap = getLargeRandom(1);
		if (swap == mpz_class(0)) {
			tc->addInput("X", x);
			tc->addInput("Y", y);
		}
		else {
			tc->addInput("X", y);
			tc->addInput("Y", x);
		}
		/* Get correct outputs */
		emulate(tc);
		return tc;
	}
开发者ID:jpdoyle,项目名称:flopoco,代码行数:62,代码来源:FPAddDualPath.cpp


注:本文中的TestCase::addInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。