Exemplo n.º 1
0
	void TestBounds() 
	{
		this->adder.Add( INT_MAX );
		CFIXCC_ASSERT_LESS( 0, this->adder.GetSum() );
		CFIXCC_ASSERT_EQUALS( INT_MAX, this->adder.GetSum() );

		this->adder.Reset();

		this->adder.Add( INT_MIN );
		CFIXCC_ASSERT_GREATER( 0, this->adder.GetSum() );
		CFIXCC_ASSERT_EQUALS( INT_MIN, this->adder.GetSum() );
	}
Exemplo n.º 2
0
	void Throw()
	{
		CFIXCC_ASSERT( setupCalled );
		CFIXCC_ASSERT_EQUALS( counter, 1 );
		counter++;
		throw TestException();
	}
	void TestStringCalc()
	{
		StringCalculatorNamespace::StringCalculator strCalc;

		// TestEmptyString
		CFIXCC_ASSERT_EQUALS(0, strCalc.add(""));

		// TestOneNumber
		CFIXCC_ASSERT_EQUALS(1, strCalc.add("1"));
		CFIXCC_ASSERT_EQUALS(99, strCalc.add("99"));

		// TestTwoNumbers
		CFIXCC_ASSERT_EQUALS(3, strCalc.add("1,2"));

		// Test Three Numbers
		CFIXCC_ASSERT_EQUALS(6, strCalc.add("1,2,3"));
	}
Exemplo n.º 4
0
	void Before()
	{
		//
		// A freshly created Adder should have the sum 0. Mind you,
		// a new instance of ImprovedAdderTest is created for each
		// test
		//
		CFIXCC_ASSERT_EQUALS( 0, this->adder.GetSum() );
	}
Exemplo n.º 5
0
		/**-------------------------------------------------------------------------------
			TestValuesDouble
			
			@brief
			@return void
		---------------------------------------------------------------------------------*/
		void TestValuesDouble()
		{

			MyControllerDouble controller;
			
			controller.setSetpoint(10);
			controller.setInput(1);
			controller.calculate(0,0);

			double ret;
			controller.getOutput(ret);
			CFIXCC_ASSERT_EQUALS(11.0,ret);

			controller.getSetpoint(ret);
			CFIXCC_ASSERT_EQUALS(10.0,ret);

			controller.getInput(ret);
			CFIXCC_ASSERT_EQUALS(1.0,ret);

		}		
Exemplo n.º 6
0
    /**-------------------------------------------------------------------------------
    	TestOne

    	@brief
    	@return void
    ---------------------------------------------------------------------------------*/
    void TestOne()
    {
        const wchar_t* testString = L"test model";
        CFIX_LOG(L"Testing %s", testString);

        // samples
        CFIXCC_ASSERT_EQUALS(1, 1);
        CFIXCC_ASSERT_EQUALS(L"test model", testString);
        CFIXCC_ASSERT_EQUALS(wcslen(testString), (size_t) 10);
        CFIX_ASSERT(wcslen(testString) == 10);
        CFIX_ASSERT_MESSAGE(testString[0] == 't', "Test string should start with a 't'");


        double expected[]= {0,1.000000000000000,0.500000000000000,0.750000000000000,0.625000000000000,0.687500000000000,0.656250000000000,0.671875000000000,0.664062500000000,0.667968750000000,0.666015625000000,0.666992187500000,0.666503906250000,0.666748046875000,0.666625976562500,0.666687011718750,0.666656494140625};

        for (int i=0; i<17; ++i) {
            double out=getSystemOutput(1);
            CFIXCC_ASSERT_EQUALS(expected[i], out);
        }

    }
Exemplo n.º 7
0
		/**-------------------------------------------------------------------------------
			TestValuesVector
			
			@brief
			@return void
		---------------------------------------------------------------------------------*/
		void TestValuesVector() 
		{
			MyControllerVector controller;

			std::vector<double> sp;
			std::vector<double>* pv=new std::vector<double>();
			std::vector<double> ret;

			sp.push_back(1);
			sp.push_back(2);
			sp.push_back(3);
			controller.setSetpoint(sp);
			pv->push_back(1);
			pv->push_back(2);
			pv->push_back(10);
			controller.setInput(*pv);
			pv->clear();
			delete pv;
			pv=NULL;

			controller.calculate(0,0);

			controller.getOutput(ret);
			CFIXCC_ASSERT_EQUALS(ret[0],2.0);
			CFIXCC_ASSERT_EQUALS(ret[1],4.0);
			CFIXCC_ASSERT_EQUALS(ret[2],13.0);

			controller.getInput(ret);
			CFIXCC_ASSERT_EQUALS(ret[0],1.0);
			CFIXCC_ASSERT_EQUALS(ret[1],2.0);
			CFIXCC_ASSERT_EQUALS(ret[2],10.0);

			controller.getSetpoint(ret);
			CFIXCC_ASSERT_EQUALS(ret[0],1.0);
			CFIXCC_ASSERT_EQUALS(ret[1],2.0);
			CFIXCC_ASSERT_EQUALS(ret[2],3.0);

		}
Exemplo n.º 8
0
void Test_encrypt::stringSizeCorrespondDoubleSizeOfMatrix()
{
	input=fopen("test.txt","w+");
	char string[50]="Example text for testing this  algorithm";
	fwrite((void*)string,1,strlen(string),input);
	fclose(input);

	input=fopen("test.txt","w+");
	output=fopen("result.txt","w+");
	int vector[5]={0,2,4,3,1};
	encrypt(5,4,vector);
	fclose(output);
	fclose(input);

	output=fopen("result.txt","w+");
	fread((void*)string,1,100,output);
	CFIXCC_ASSERT_EQUALS(string,"Elxra  tplosmtfexet tt rnilt  omgsgh ihai");
	fclose(output);
}
Exemplo n.º 9
0
void Test_encrypt::stringUnderThanMatrix()
{
	input=fopen("test.txt","w+");
	char string[50]="Example text for testing this algorithm";
	fwrite((void*)string,1,strlen(string),input);
	fclose(input);

	input=fopen("test.txt","w+");
	output=fopen("result.txt","w+");
	int vector[5]={0,2,4,3,1};
	encrypt(5,8,vector);
	fclose(output);
	fclose(input);

	output=fopen("result.txt","w+");
	fread((void*)string,1,100,output);
	CFIXCC_ASSERT_EQUALS(string,"Elxrttaia  tnighpeos  r\0mtfegsomxet inlt");
	fclose(output);
}
Exemplo n.º 10
0
void Test_encrypt::emptyString()
{
	input=fopen("test.txt","w+");	
	char string[50]="";
	fwrite((void*)string,1,strlen(string),input);
	fclose(input);

	input=fopen("test.txt","w+");
	output=fopen("result.txt","w+");
	int vector[5]={0,2,4,3,1};
	encrypt(5,8,vector);
	fclose(output);
	fclose(input);

	output=fopen("result.txt","w+");
	fread((void*)string,1,100,output);
	CFIXCC_ASSERT_EQUALS(string,"\0                                       ");
	fclose(output);
}
Exemplo n.º 11
0
void Test_encrypt::columnMatrix()
{
	input=fopen("test.txt","w+");
	char string[50]="Exam";
	fwrite((void*)string,1,strlen(string),input);
	fclose(input);
	

	input=fopen("test.txt","w+");
	output=fopen("result.txt","w+");
	int vector[4]={0,3,2,1};
	encrypt(4,1,vector);
	fclose(output);
	fclose(input);

	output=fopen("result.txt","w+");
	fread((void*)string,1,100,output);
	CFIXCC_ASSERT_EQUALS(string,"Emax");
	fclose(output);
}
Exemplo n.º 12
0
void Test_encrypt::matrixSize1()
{
	input=fopen("test.txt","w+");
	char string[50]="E";
	fwrite((void*)string,1,strlen(string),input);
	fclose(input);
	

	input=fopen("test.txt","w+");
	output=fopen("result.txt","w+");
	int vector[1]={0};
	encrypt(1,1,vector);
	fclose(output);
	fclose(input);

	output=fopen("result.txt","w+");
	fread((void*)string,1,100,output);
	CFIXCC_ASSERT_EQUALS(string,"E");
	fclose(output);
}
Exemplo n.º 13
0
void Test_encrypt::rowMatrix()
{
	input=fopen("test.txt","w+");
	char string[50]="Example text for testing this  algorithm";
	fwrite((void*)string,1,strlen(string),input);
	fclose(input);
	

	input=fopen("test.txt","w+");
	output=fopen("result.txt","w+");
	int vector[1]={0};
	encrypt(1,40,vector);
	fclose(output);
	fclose(input);

	output=fopen("result.txt","w+");
	fread((void*)string,1,100,output);
	CFIXCC_ASSERT_EQUALS(string,"Example text for testing this  algorithm");
	fclose(output);
}
Exemplo n.º 14
0
	void Method01() 
	{
		CFIX_ASSERT( setupCalled );
		CFIXCC_ASSERT_EQUALS( counter, 1 );
		counter++;
	}
Exemplo n.º 15
0
	virtual void Before()
	{
		CFIX_ASSERT( setupCalled );
		CFIXCC_ASSERT_EQUALS( counter, 0 );
		counter++;
	}
Exemplo n.º 16
0
	~FixtureWithSetUpAndTearDown()
	{
		CFIXCC_ASSERT_EQUALS( counter, 3 );
	}
Exemplo n.º 17
0
	virtual void After()
	{
		CFIXCC_ASSERT_EQUALS( counter, 2 );
		counter++;
	}
Exemplo n.º 18
0
	void Method02() 
	{
		CFIXCC_ASSERT_EQUALS( counter, 1 );
		counter++;
	}
Exemplo n.º 19
0
	virtual void Before()
	{
		CFIXCC_ASSERT_EQUALS( counter, 0 );
		counter++;
	}
Exemplo n.º 20
0
	~SimpleFixture()
	{
		CFIXCC_ASSERT_EQUALS( counter, 3 );
	}