示例#1
0
 inline uint32_t rgba() const
 {
   return ((a8() << 24) |
           (b8() << 16) |
           (g8() <<  8) |
           (r8() <<  0));
 }
/**
* @test Verify field deployments of an extended structure. Use a faulty struct member.
*/
TEST_F(DeploymentTest, ExtendedStructAttrFieldDeploymentsFaultyStructMember) {
    CommonAPI::CallStatus callStatus;
    {
        v1_0::commonapi::someip::deploymenttest::TestInterface::tStructExtended outv;

        v1_0::commonapi::someip::deploymenttest::TestInterface::tUnion_d3 unionMember;
        v1_0::commonapi::someip::deploymenttest::TestInterface::tStruct_w1 structMember;

        std::vector<int16_t> a(20);
        outv.setEarrayMember(a);

        std::string v1("abcd"); // this is the corrent value.
        unionMember = v1;
        outv.setEunionMember(unionMember);

        structMember.setBooleanMember(true);
        std::vector<int8_t> a8(2000);
        structMember.setArrayMember(a8);
        outv.setEstructMember(structMember);

        v1_0::commonapi::someip::deploymenttest::TestInterface::tStructExtended inv;

        testProxy_->getAStructExtendedAttribute().setValue(outv, callStatus, inv);
        // will fail because the deployment of the struct member prohibits the value
        ASSERT_NE(callStatus, CommonAPI::CallStatus::SUCCESS);
    }
}
/**
* @test Verify field deployments of an extended structure.
*/
TEST_F(DeploymentTest, ExtendedStructAttrFieldDeploymentsOK) {
    CommonAPI::CallStatus callStatus;
    {
        v1_0::commonapi::someip::deploymenttest::TestInterface::tStructExtended outv;

        v1_0::commonapi::someip::deploymenttest::TestInterface::tUnion_d3 unionMember;
        v1_0::commonapi::someip::deploymenttest::TestInterface::tStruct_w1 structMember;

        std::vector<int16_t> a(20);
        outv.setEarrayMember(a);

        std::string v1("abcd");
        unionMember = v1;
        outv.setEunionMember(unionMember);

        structMember.setBooleanMember(true);
        std::vector<int8_t> a8(20);
        structMember.setArrayMember(a8);
        outv.setEstructMember(structMember);

        v1_0::commonapi::someip::deploymenttest::TestInterface::tStructExtended inv;

        testProxy_->getAStructExtendedAttribute().setValue(outv, callStatus, inv);
        ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
        EXPECT_EQ(outv, inv);
    }
}
// This case tests that the union member has the deployment set up correctly.
// It sets up a value that should be invalid, according to the union deployment.
// If the union field member deployment is missing, the setting of the attribute would succeed.
TEST_F(DeploymentTest, StructAttrFieldDeploymentsFaultyUnionMember) {
    CommonAPI::CallStatus callStatus;
    {
        v1_0::commonapi::someip::deploymenttest::TestInterface::tStruct_field_type_depls outv;

        v1_0::commonapi::someip::deploymenttest::TestInterface::tUnion_d3 unionMember;
        v1_0::commonapi::someip::deploymenttest::TestInterface::tStruct_w1 structMember;

        std::vector<int16_t> a(20);
        outv.setArrayMember(a);

        std::string v1("abcde"); // this is the wrong length and should fail.
        unionMember = v1;
        outv.setUnionMember(unionMember);

        structMember.setBooleanMember(true);
        std::vector<int8_t> a8(20);
        structMember.setArrayMember(a8);
        outv.setStructMember(structMember);

        v1_0::commonapi::someip::deploymenttest::TestInterface::tStruct_field_type_depls inv;

        testProxy_->getAStruct_field_type_deplsAttribute().setValue(outv, callStatus, inv);
        // will fail because the deployment of the union member prohibits the value
        ASSERT_NE(callStatus, CommonAPI::CallStatus::SUCCESS);
    }
}
示例#5
0
void drive_get_misc_functions()
{

    try {
        // Get function tests
        CQLValue a1(Uint64(123));
        CQLValue a2(Sint64(-123));
        CQLValue a3(Real64(25.24));
        CQLValue a4(String("Hellow"));
        CQLValue a5(Boolean(true));

        String _date("20040811105625.000000-360");
        CIMDateTime date(_date);
        CQLValue a6(date);
        String _date1("20040811105626.000000-360");
        CIMDateTime date1(_date1);
        CQLValue a61(date1);

        String opStr("MyClass.z=true,y=1234,x=\"Hello World\"");
        CIMObjectPath op(opStr);
        CQLValue a7(op);

        const CIMName _cimName(String("CIM_OperatingSystem"));
        CIMInstance _i1(_cimName);

        CQLValue a8(_i1);

        PEGASUS_TEST_ASSERT(a1.getUint() == Uint64(123));
        PEGASUS_TEST_ASSERT(a2.getSint() == Sint64(-123));
        PEGASUS_TEST_ASSERT(a3.getReal() == Real64(25.24));
        PEGASUS_TEST_ASSERT(a4.getString() == String("Hellow"));
        PEGASUS_TEST_ASSERT(a5.getBool() == Boolean(true));
        PEGASUS_TEST_ASSERT(a6.getDateTime() == CIMDateTime(_date));
        PEGASUS_TEST_ASSERT(a6 != a61);
        PEGASUS_TEST_ASSERT(a6 < a61);
        PEGASUS_TEST_ASSERT(a7.getReference() ==
                            CIMObjectPath(opStr));

        try
        {
            a1.getSint();
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }
    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }

    return;
}
示例#6
0
void yylex()
{

/* Declaracao de Variaveis Locais */

int l,s;               /* Variaveis de controle do AF */

/* Inicializacao de Variaveis Locais */

l=0;s=0;

saida.classe[0]=EOF;
saida.classe[1]='\0';

/* AUTOMATO FINITO (AF) */
peg_ch();
while(ch != EOF && s!= FINAL_STATE)
   {
    if(compara_simbolo(ch,tab_trans[l])==TRUE)
       {
          s=tab_trans[l]->proximo_estado;
          switch(tab_trans[l]->acao_semantica)
            {
	     case 1: a1();break;
	     case 2: a2();break;
	     case 3: a3();break;
	     case 4: a4();break;
	     case 5: a5();break;
	     case 6: a6();break;
	     case 7: a7();break;
	     case 8: a8();break;
	     case 9: a9();break;
	     case 10: a10();break;
	     case 11: a11();break;
	     default:;
	    }
	  if(s!=FINAL_STATE) {
		  peg_ch();
		  l=tab_trans[l]->proxima_transicao;
		  }
        }
        else
            {
             ++l;
             if(s==tab_trans[l]->estado_atual) continue;
             else
		  error("* * Erro Fatal: transicao errada no ANALISADOR LEXICO * *\n");
            }
    }
return;
}
示例#7
0
void level_three()
{
	vector<DPipe> DirectPipes(13);
		vector<DoublePipe> DoublePipes(13);
		vector<CrossPipe> CrossPipes(2);
				DPipe a0(50,SCREEN_HEIGHT-50,100,40);
				DoublePipe b0(150,SCREEN_HEIGHT-50,70,40);
				DPipe a1(150,SCREEN_HEIGHT-150,100,40);
				DoublePipe b1(150,SCREEN_HEIGHT-250,70,40);
				DPipe a2(250,SCREEN_HEIGHT-350,100,40);
				DoublePipe b2(350,SCREEN_HEIGHT-250,70,40);
				DPipe a3(350,SCREEN_HEIGHT-350,100,40);
				DPipe a4(350,SCREEN_HEIGHT-150,100,40);
				DoublePipe b3(250,SCREEN_HEIGHT-450,70,40);
				DoublePipe b4(350,SCREEN_HEIGHT-450,70,40);
				CrossPipe c0(250,SCREEN_HEIGHT-250,100,40);
				DPipe a5(550,SCREEN_HEIGHT-50,100,40);
				DoublePipe b5(250,SCREEN_HEIGHT-150,70,40);
				DoublePipe b6(450,SCREEN_HEIGHT-50,70,40);
				DoublePipe b7(650,SCREEN_HEIGHT-150,70,40);
				DPipe a6(550,SCREEN_HEIGHT-50,100,40);
				DPipe a7(550,SCREEN_HEIGHT-150,100,40);
				DoublePipe b8(750,SCREEN_HEIGHT-50,70,40);
				DPipe a8(550,SCREEN_HEIGHT-250,100,40);
				DoublePipe b9(750,SCREEN_HEIGHT-350,70,40);
				CrossPipe c1(450,SCREEN_HEIGHT-150,100,40);
				DoublePipe b10(350,SCREEN_HEIGHT-450,70,40);
				DPipe a9(750,SCREEN_HEIGHT-150,100,40);
				DPipe a10(750,SCREEN_HEIGHT-250,100,40);
				DoublePipe b11(450,SCREEN_HEIGHT-250,70,40);
				DoublePipe b12(650,SCREEN_HEIGHT-250,70,40);
				DPipe a11(650,SCREEN_HEIGHT-50,100,40);
				DPipe a12(850,SCREEN_HEIGHT-350,100,40);

				DirectPipes[0] = a0; DoublePipes[0] = b0;
				DirectPipes[1] = a1; DoublePipes[1] = b1;
				DirectPipes[2] = a2; DoublePipes[2] = b2;
				DirectPipes[3] = a3; DoublePipes[3] = b3;
				DirectPipes[4] = a4; DoublePipes[4] = b4;
				DirectPipes[5] = a5; DoublePipes[5] = b5;
				DirectPipes[6] = a6; DoublePipes[6] = b6;
				DirectPipes[7] = a7; DoublePipes[7] = b7;
				DirectPipes[8] = a8; DoublePipes[8] = b8;
				DirectPipes[9] = a9; DoublePipes[9] = b9;
				DirectPipes[10] = a10; DoublePipes[10] = b10;
				DirectPipes[11] = a11; DoublePipes[11] = b11;
				DirectPipes[12] = a12; DoublePipes[12] = b12;
				CrossPipes[0] = c0; CrossPipes[1] = c1;
				Water a(20,SCREEN_HEIGHT-50,40,40);
}
示例#8
0
int main()
{
    // Några saker som ska fungera:
    UIntVector a(10);               // initiering med 7 element
    std::cout << "a(10)"<< a.length << std::endl;
    std::cout << "kopiering" << std::endl;
    UIntVector b(a);           // kopieringskonstruktor 
    std::cout << "kopiering" << std::endl;
    a = a;
    std::cout << "s**t" << std::endl;
    UIntVector c = a;          // kopieringskonstruktor 

    //Extra tester för alla Requirments
    a = b;                 // tilldelning genom kopiering
    a[5] = 7;              // tilldelning till element

    const UIntVector e(100000);    // konstant objekt med 10 element
    int i = e[5];          // const int oper[](int) const körs
    i = a[0];              // vektorn är nollindexerad
    i = a[5];              // int oper[](int) körs
    
    a[5]++;                // öka värdet till 8
    
    //Extra tester för alla Requirments
    std::cout << "(1)TEST" << std::endl;
    int aa = e[9];
    int ab = e[0];
    std::cout << "(1)S**T" << aa << ab << std::endl;


    std::cout << "(2)TEST" << std::endl;
    for(long int i = 0; i < 100000; i++)
    {
        e[i];
    } 
    std::cout << "(2)S**T" << std::endl;




    std::cout << "(3)TEST" << std::endl;
    UIntVector a3(10); UIntVector b3(0); UIntVector c3(0);
    b3 = a3;
    a3 = c3;
    std::cout << "(3)S**T" << std::endl;




    std::cout << "(4) START" << std::endl;
    std::initializer_list<unsigned int> list = {1,2,3};
    UIntVector a4(list); UIntVector b4(0);
    a4 = b4;
    std::cout << "length a" << a4.size() << "len b " << b4.size() << std::endl;
    std::cout << "(4) S**T" << std::endl;



    std::cout << "(5)TEST" << std::endl;
    UIntVector b5(list);
    UIntVector a5(std::move(b5));
    std::cout << "(5)S**T" << std::endl;





    std::cout << "(6)TEST" << std::endl;
    UIntVector a6(30);
    UIntVector b6(a6);
    std::cout << "(6)S**T" << std::endl;


    std::cout << "(7)TEST" << std::endl;
    UIntVector a7(1); 
    std::cout << "a) len innan " <<a7.length << std::endl;
    UIntVector b7(std::move(a7));
    std::cout << "b) len " <<b7.length << std::endl;
    std::cout << "a) len " <<a7.length << std::endl;
    std::cout << "(7)S**T" << std::endl;

    std::cout << "(8)TEST" << std::endl;
    UIntVector a8(10);
    a8.reset();
    UIntVector b8(11);
    std::cout << "a) INNAN len " <<a8.size() << "ptr " << a8.vector_ptr <<std::endl;
    UIntVector c8(std::move(a8));
    std::cout << "c) len " <<c8.size() << "ptr" << c8.vector_ptr <<std::endl;
    std::cout << "a) len " <<a8.size() << "ptr " << a8.vector_ptr <<std::endl;
    std::cout << "(8)S**T" << std::endl;


    std::cout << "(9)TEST COPY TO SELF" << std::endl;
    b8 = b8;
    std::cout << "(9)S**T" << std::endl;
    try {
        i = e[10];             // försöker hämta element som ligger utanför e
    } catch (std::out_of_range e) {
        std::cout << e.what() << std::endl;
    }

    
#if 0
    // Diverse saker att testa
    e[5] = 3;              // fel: (kompilerar ej) tilldelning till const
    b = b;                 // hmm: se till att inte minnet som skall behållas frigörs
#endif

    return 0;
}
示例#9
0
void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq)
{
    typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
    typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
    typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
    typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;

    typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
    typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
    typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
    typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;

    typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<iterator>::type iterator_category;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type iterator_difference;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type iterator_pointer;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<iterator>::type iterator_reference;

    typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<local_iterator>::type local_iterator_category;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<local_iterator>::type local_iterator_difference;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type local_iterator_pointer;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<local_iterator>::type local_iterator_reference;

    typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<const_iterator>::type const_iterator_category;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_iterator>::type const_iterator_difference;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::type const_iterator_pointer;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_iterator>::type const_iterator_reference;

    typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<const_local_iterator>::type const_local_iterator_category;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_local_iterator>::type const_local_iterator_difference;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_local_iterator>::type const_local_iterator_pointer;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_local_iterator>::type const_local_iterator_reference;

    BOOST_MPL_ASSERT((boost::is_same<Key, key_type>));
    boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
    boost::function_requires<boost::AssignableConcept<key_type> >();

    BOOST_MPL_ASSERT((boost::is_same<Hash, hasher>));
    test::check_return_type<std::size_t>::equals(hf(k));

    BOOST_MPL_ASSERT((boost::is_same<Pred, key_equal>));
    test::check_return_type<bool>::convertible(eq(k, k));

    boost::function_requires<boost::InputIteratorConcept<local_iterator> >();
    BOOST_MPL_ASSERT((boost::is_same<local_iterator_category, iterator_category>));
    BOOST_MPL_ASSERT((boost::is_same<local_iterator_difference, iterator_difference>));
    BOOST_MPL_ASSERT((boost::is_same<local_iterator_pointer, iterator_pointer>));
    BOOST_MPL_ASSERT((boost::is_same<local_iterator_reference, iterator_reference>));

    boost::function_requires<boost::InputIteratorConcept<const_local_iterator> >();
    BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_category, const_iterator_category>));
    BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_difference, const_iterator_difference>));
    BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_pointer, const_iterator_pointer>));
    BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_reference, const_iterator_reference>));

    X(10, hf, eq);
    X a(10, hf, eq);
    X(10, hf);
    X a2(10, hf);
    X(10);
    X a3(10);
    X();
    X a4;

    BOOST_DEDUCED_TYPENAME X::value_type* i = 0;
    BOOST_DEDUCED_TYPENAME X::value_type* j = 0;

    X(i, j, 10, hf, eq);
    X a5(i, j, 10, hf, eq);
    X(i, j, 10, hf);
    X a6(i, j, 10, hf);
    X(i, j, 10);
    X a7(i, j, 10);
    X(i, j);
    X a8(i, j);

    X const b;
    sink(X(b));
    X a9(b);
    a = b;

    test::check_return_type<hasher>::equals(b.hash_function());
    test::check_return_type<key_equal>::equals(b.key_eq());

    const_iterator q = a.cbegin();
    test::check_return_type<iterator>::equals(a.insert(q, t));
    test::check_return_type<iterator>::equals(a.emplace_hint(q, t));

    a.insert(i, j);
    test::check_return_type<size_type>::equals(a.erase(k));

    BOOST_TEST(a.empty());
    if(a.empty()) {
        a.insert(t);
        q = a.cbegin();
        test::check_return_type<iterator>::equals(a.erase(q));
    }

    const_iterator q1 = a.cbegin(), q2 = a.cend();
    test::check_return_type<iterator>::equals(a.erase(q1, q2));

    a.clear();

    test::check_return_type<iterator>::equals(a.find(k));
    test::check_return_type<const_iterator>::equals(b.find(k));
    test::check_return_type<size_type>::equals(b.count(k));
    test::check_return_type<std::pair<iterator, iterator> >::equals(
            a.equal_range(k));
    test::check_return_type<std::pair<const_iterator, const_iterator> >::equals(
            b.equal_range(k));
    test::check_return_type<size_type>::equals(b.bucket_count());
    test::check_return_type<size_type>::equals(b.max_bucket_count());
    test::check_return_type<size_type>::equals(b.bucket(k));
    test::check_return_type<size_type>::equals(b.bucket_size(0));

    test::check_return_type<local_iterator>::equals(a.begin(0));
    test::check_return_type<const_local_iterator>::equals(b.begin(0));
    test::check_return_type<local_iterator>::equals(a.end(0));
    test::check_return_type<const_local_iterator>::equals(b.end(0));

    test::check_return_type<const_local_iterator>::equals(a.cbegin(0));
    test::check_return_type<const_local_iterator>::equals(b.cbegin(0));
    test::check_return_type<const_local_iterator>::equals(a.cend(0));
    test::check_return_type<const_local_iterator>::equals(b.cend(0));

    test::check_return_type<float>::equals(b.load_factor());
    test::check_return_type<float>::equals(b.max_load_factor());
    a.max_load_factor((float) 2.0);
    a.rehash(100);
}
示例#10
0
int main(int argc,char **argv)
{
	setlocale(LC_ALL,"RUSSIAN");

	SDL_DisplayMode displayMode;

	if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
	{
    cout << "SDL_Init Error: " << SDL_GetError() << endl;
    return 1;
	}

	int request = SDL_GetDesktopDisplayMode(0,&displayMode); 

	SDL_Window *win = SDL_CreateWindow("Trubi", 300, 300,800, 800, SDL_WINDOW_SHOWN);
	if (win == nullptr)
	{
		cout << "SDL_CreateWindow Error: " << SDL_GetError() << endl;
	    return 1;
	}

	SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
	if (ren == nullptr)
	{
		cout << "SDL_CreateRenderer Error: " << SDL_GetError() << endl;
	    return 1;
	}

	vector<DPipe> DPIPES(13);
	vector<DoublePipe> DOUBPIPES(6);

	DPipe background(400,400,800,800);
	DPipe a0(70,300,100,40);
	DPipe a1(170,300,100,40);
	DPipe a2(270,300,100,40);
	DPipe a3(370,400,100,40);
	DPipe a4(370,500,100,40);
	DPipe a5(470,600,100,40);
	DPipe a6(570,600,100,40);
	DPipe a7(670,500,100,40);
	DPipe a8(670,400,100,40);
	
	DPipe a9(370,200,100,40);
	DPipe a10(470,100,100,40);
	DPipe a11(570,100,100,40);
	DPipe a12(670,200,100,40);
	DPipe kletka(370,300,100,100);

	DoublePipe b0(370,300,70,40);
	DoublePipe b1(370,600,70,40);
	DoublePipe b2(670,600,70,40);
	DoublePipe b3(670,300,70,40);
	DoublePipe b4(370,100,70,40);
	DoublePipe b5(670,100,70,40);

	DPIPES[0]=a0;
	DPIPES[1]=a1;
	DPIPES[2]=a2;
	DPIPES[3]=a3;
	DPIPES[4]=a4;
	DPIPES[5]=a5;
	DPIPES[6]=a6;
	DPIPES[7]=a7;
	DPIPES[8]=a8;
	DPIPES[9]=a9;
	DPIPES[10]=a10;
	DPIPES[11]=a11;
	DPIPES[12]=a12;
	
	DOUBPIPES[0]=b0;
	DOUBPIPES[1]=b1;
	DOUBPIPES[2]=b2;
	DOUBPIPES[3]=b3;
	DOUBPIPES[4]=b4;
	DOUBPIPES[5]=b5;

	SDL_RenderClear(ren);
	background.default_create(ren,"newbackground.bmp");
	for(int i=0;i<DPIPES.size();++i)
	{
		DPIPES[i].default_create(ren,"text1.bmp");
	}
	for(int i=0;i<DOUBPIPES.size();++i)
	{
		DOUBPIPES[i].default_create1(ren,"double1.bmp","double2.bmp");
	}
	SDL_RenderPresent(ren); 

	bool quit=false;
	while(!quit)
	{
		 while(SDL_PollEvent(&event))
		 {
			SDL_PumpEvents(); 

			if(event.type == SDL_QUIT)
				quit=true;
			else if(event.type==SDL_MOUSEBUTTONDOWN &&  event.button.button==SDL_BUTTON_LEFT)
			{
				for(int i=0;i<DPIPES.size();++i)
				{
					if(DPIPES[i].ismouse())
					{
						SDL_RenderClear(ren);
						background.default_create(ren,"newbackground.bmp");
						nochangesDoub(ren,DOUBPIPES);
						somechanges(ren,DPIPES,i);
					}
				}
				for(int i=0;i<DOUBPIPES.size();++i)
				{
					if(DOUBPIPES[i].ismouse())
					{
						SDL_RenderClear(ren);
						background.default_create(ren,"newbackground.bmp");
						nochanges(ren,DPIPES);
						somechangesDoub(ren,DOUBPIPES,i);
					}
				}
			}
		 }
	}
	return 1;
}
示例#11
0
文件: main.cpp 项目: murak/BigInteger
int main() {
    /* test cases */

    /*
    * case 1: addition a>b and b>a and a=b 
    */
    BigInt a1("99");
    BigInt b1("9131");
    std::cout<<"\na = "<<a1.toString();
    std::cout<<"\nb = "<<b1.toString();
    std::cout<<"\nsum = "<<(a1+b1).toString();
    std::cout<<"\na-b = "<<(a1-b1).toString();

    BigInt a2("99");
    BigInt b2("91");
    std::cout<<"\na = "<<a2.toString();
    std::cout<<"\nb = "<<b2.toString();
    std::cout<<"\nsum = "<<(a2+b2).toString();
    std::cout<<"\nproduct = "<<(a2*b2).toString();
    std::cout<<"\na-b = "<<(a2-b2).toString();

    /*
    * case 2: a=b and one is negative
    */
    BigInt a3("-99");
    BigInt b3("91");
    std::cout<<"\na = "<<a3.toString();
    std::cout<<"\nb = "<<b3.toString();
    std::cout<<"\nsum = "<<(a3+b3).toString();
    std::cout<<"\nsum = "<<(b3+a3).toString();
    std::cout<<"\nproduct = "<<(b3*a3).toString();
    std::cout<<"\na-b = "<<(a3-b3).toString();

    /*
    * case 2: abs(a)>abs(b) and a is negative
    */
    BigInt a4("-999");
    BigInt b4("91");
    std::cout<<"\na = "<<a4.toString();
    std::cout<<"\nb = "<<b4.toString();
    std::cout<<"\nsum = "<<(a4+b4).toString();
    std::cout<<"\nsum = "<<(b4+a4).toString();
    std::cout<<"\nproduct = "<<(b4*a4).toString();
    std::cout<<"\na-b = "<<(a4-b4).toString();

    /*
    * case 3: abs(b)>abs(a) and b is negative
    */
    BigInt a5("99");
    BigInt b5("-991");
    std::cout<<"\na = "<<a5.toString();
    std::cout<<"\nb = "<<b5.toString();
    std::cout<<"\nsum = "<<(a5+b5).toString();
    std::cout<<"\nsum = "<<(b5+a5).toString();
    std::cout<<"\nproduct = "<<(b5*a5).toString();
    std::cout<<"\na-b = "<<(a5-b5).toString();

    /*
    * case 4: abs(b)>abs(a) and a,b is negative
    */
    BigInt a6("-99");
    BigInt b6("-991");
    std::cout<<"\na = "<<a6.toString();
    std::cout<<"\nb = "<<b6.toString();
    std::cout<<"\nsum = "<<(a6+b6).toString();
    std::cout<<"\nsum = "<<(b6+a6).toString();
    std::cout<<"\na-b = "<<(a6-b6).toString();

    /*
    * case 4: abs(b)=abs(a) and a,b is negative
    */
    BigInt a7("-999");
    BigInt b7("-991");
    std::cout<<"\na = "<<a7.toString();
    std::cout<<"\nb = "<<b7.toString();
    std::cout<<"\nsum = "<<(a7+b7).toString();
    std::cout<<"\nsum = "<<(b7+a7).toString();
    std::cout<<"\nproduct = "<<(b7*a7).toString();
    std::cout<<"\na-b = "<<(a7-b7).toString();

    /*
    * case 5: a-b
    */
    BigInt a8("-999");
    BigInt b8("-991");
    std::cout<<"\na = "<<a8.toString();
    std::cout<<"\nb = "<<b8.toString();
    std::cout<<"\na-b = "<<(a8-b8).toString();
    std::cout<<"\na-b = "<<(a8-b8).toString();



    BigInt fact("1");
    clock_t time = clock();
    fact = fact.factorial(1000);
    time = clock() - time;
    std::cout<<"\n\n10000 Factorial:\n"<<fact.toString()<<std::endl;
    std::cout<<"\n\ntime taken to find 1000! = "<<time/CLOCKS_PER_SEC<<" seconds";

    BigInt rd;
    rd = rd.random();
    std::cout<<"\n\n\nRandom number = "<<rd.toString()<<"\n\n";

    rd = rd.random();
    std::cout<<"\n\n\nRandom number = "<<rd.toString()<<"\n\n";

    rd = rd.random();
    std::cout<<"\n\n\nRandom number = "<<rd.toString()<<"\n\n";

    return 0;
}
示例#12
0
 SDL_Color to_sdl_color() const
 {
   return { r8(), g8(), b8(), a8() };
 }
示例#13
0
void test01()
{
    CIMParamValue pv;
    PEGASUS_TEST_ASSERT(pv.isUninitialized());

    String p1("message");
    CIMValue v1(String("argument_Test"));
    CIMParamValue a1(p1, v1);

//  Test call to CIMParamValue::setValue(CIMValue& value)
//  this test uses the above values for a1, p1 and v1.
    CIMParamValue a7(p1, v1);
    CIMValue v7(String("argument_Test7"));
    a7.setValue( v7);
    PEGASUS_TEST_ASSERT(a1.getValue().toString() != a7.getValue().toString());
    PEGASUS_TEST_ASSERT(a1.getParameterName() == a7.getParameterName());

//  Test call to CIMParamValue::setParameterName(String& parameterName)
//  this test uses the above values for a1, p1 and v1.
    CIMParamValue a8(p1, v1);
    String p8("message8");
    a8.setParameterName( p8);
    PEGASUS_TEST_ASSERT(a1.getValue().toString() == a8.getValue().toString());
    PEGASUS_TEST_ASSERT(a1.getParameterName() != a8.getParameterName());
    PEGASUS_TEST_ASSERT(a8.isTyped());
    a8.setIsTyped(false);
    PEGASUS_TEST_ASSERT(!a8.isTyped());

    String p2("message2");
    CIMValue v2(String("argument_Test2"));
    CIMParamValue a2(p2, v2);

    String p3("message3");
    CIMValue v3(String("argument_Test3"));
    CIMParamValue a3(p3, v3);

    String p4("message4");
    CIMValue v4(String("argument_Test4"));
    CIMParamValue a4(p4, v4);
    CIMParamValue a5 = a4;

    String p6("message6");
    CIMValue v6(String("argument_Test6"));
    CIMParamValue a6(p6, v6);

    Array<CIMParamValue> aa;
    aa.append(a1);
    aa.append(a2);

    aa.append(CIMParamValue("message3", CIMValue(200000)));

    aa.append(CIMParamValue("message4", CIMValue(String("test4"))));
    
    //
    // clone
    //
    CIMParamValue a4clone = a4.clone();
    aa.append(a4clone);

    if (verbose)
    {
        for (Uint32 i=0; i< aa.size(); i++)
        {
            XmlWriter::printParamValueElement(aa[i], cout);
        }
    }

    //
    // toXml
    //
    Buffer xmlOut;
    XmlWriter::appendParamValueElement(xmlOut, a4clone);
}
示例#14
0
void level_two()
{
		vector<DPipe> DPIPES(44);
	vector<DoublePipe> DOUBPIPES(18);
	vector<CrossPipe> CROSSPIPES(3);

	DPipe background(600,400,1200,800);

	DPipe a0(50,750,100,40);
	DPipe a1(150,650,100,40);
	DPipe a2(150,550,100,40);
	DPipe a3(650,450,100,40);
	DPipe a4(550,550,100,40);
	DPipe a5(450,350,100,40);
	DPipe a6(550,250,100,40);
	DPipe a7(650,250,100,40);
	DPipe a8(750,350,100,40);
	DPipe a9(750,450,100,40);
	DPipe a10(750,550,100,40);
	DPipe a11(650,650,100,40);
	DPipe a12(550,650,100,40);
	DPipe a13(450,650,100,40);
	DPipe a14(350,550,100,40);
	DPipe a15(350,350,100,40);
	DPipe a16(350,250,100,40);
	DPipe a17(450,150,100,40);
	DPipe a18(550,150,100,40);
	DPipe a19(650,150,100,40);
	DPipe a20(750,150,100,40);
	DPipe a21(850,250,100,40);
	DPipe a22(850,350,100,40);
	DPipe a23(850,450,100,40);
	DPipe a24(850,550,100,40);
	DPipe a25(850,650,100,40);
	DPipe a26(750,750,100,40);
	DPipe a27(650,750,100,40);
	DPipe a28(550,750,100,40);
	DPipe a29(450,750,100,40);
	DPipe a30(350,750,100,40);
	DPipe a31(250,650,100,40);
	DPipe a32(250,550,100,40);
	DPipe a33(250,350,100,40);
	DPipe a34(250,250,100,40);
	DPipe a35(250,150,100,40);
	DPipe a36(350,50,100,40);
	DPipe a37(450,50,100,40);
	DPipe a38(550,50,100,40);
	DPipe a39(650,50,100,40);
	DPipe a40(750,50,100,40);
	DPipe a41(850,50,100,40);
	DPipe a42(950,150,100,40);
	DPipe a43(950,250,100,40);

	DoublePipe b0(150,750,70,40);
	DoublePipe b1(150,450,70,40);
	DoublePipe b2(550,450,70,40);
	DoublePipe b3(550,350,70,40);
	DoublePipe b4(650,350,70,40);
	DoublePipe b5(650,550,70,40);
	DoublePipe b6(450,550,70,40);
	DoublePipe b7(450,250,70,40);
	DoublePipe b8(750,250,70,40);
	DoublePipe b9(750,650,70,40);
	DoublePipe b10(350,650,70,40);
	DoublePipe b11(350,150,70,40);
	DoublePipe b12(850,150,70,40);
	DoublePipe b13(850,750,70,40);
	DoublePipe b14(250,750,70,40);
	DoublePipe b15(250,50,70,40);
	DoublePipe b16(950,50,70,40);
	DoublePipe b17(950,350,70,40);

	CrossPipe c0(250,450,100,40);
	CrossPipe c1(350,450,100,40);
	CrossPipe c2(450,450,100,40);

	DPIPES[0]=a0;
	DPIPES[1]=a1;
	DPIPES[2]=a2;
	DPIPES[3]=a3;
	DPIPES[4]=a4;
	DPIPES[5]=a5;
	DPIPES[6]=a6;
	DPIPES[7]=a7;
	DPIPES[8]=a8;
	DPIPES[9]=a9;
	DPIPES[10]=a10;
	DPIPES[11]=a11;
	DPIPES[12]=a12;
	DPIPES[13]=a13;
	DPIPES[14]=a14;
	DPIPES[15]=a15;
	DPIPES[16]=a16;
	DPIPES[17]=a17;
	DPIPES[18]=a18;
	DPIPES[19]=a19;
	DPIPES[20]=a20;
	DPIPES[21]=a21;
	DPIPES[22]=a22;
	DPIPES[23]=a23;
	DPIPES[24]=a24;
	DPIPES[25]=a25;
	DPIPES[26]=a26;
	DPIPES[27]=a27;
	DPIPES[28]=a28;
	DPIPES[29]=a29;
	DPIPES[30]=a30;
	DPIPES[31]=a31;
	DPIPES[32]=a32;
	DPIPES[33]=a33;
	DPIPES[34]=a34;
	DPIPES[35]=a35;
	DPIPES[36]=a36;
	DPIPES[37]=a37;
	DPIPES[38]=a38;
	DPIPES[39]=a39;
	DPIPES[40]=a40;
	DPIPES[41]=a41;
	DPIPES[42]=a42;
	DPIPES[43]=a43;

	DOUBPIPES[0]=b0;
	DOUBPIPES[1]=b1;
	DOUBPIPES[2]=b2;
	DOUBPIPES[3]=b3;
	DOUBPIPES[4]=b4;
	DOUBPIPES[5]=b5;
	DOUBPIPES[6]=b6;
	DOUBPIPES[7]=b7;
	DOUBPIPES[8]=b8;
	DOUBPIPES[9]=b9;
	DOUBPIPES[10]=b10;
	DOUBPIPES[11]=b11;
	DOUBPIPES[12]=b12;
	DOUBPIPES[13]=b13;
	DOUBPIPES[14]=b14;
	DOUBPIPES[15]=b15;
	DOUBPIPES[16]=b16;
	DOUBPIPES[17]=b17;

	CROSSPIPES[0]=c0;
	CROSSPIPES[1]=c1;
	CROSSPIPES[2]=c2;
}
int main()
{
    tQ4 a4( 1.1 );
    tQ4 b4( 1 );
    tQ12 a12( 3.3 );
    tQ12 b12( 3 );
    tQ18 a18;
    double ad;
    double bd;
    
    tQ8 a8( -2.3 );
    tQ8 b8( 2 );
    tQ8 c8( Q8CONST( -2,3 ) );
    tQ8 d8( a8 );
    tQ8 e8( a4 );
//  tQ8 f8( a12 );      // Warning: left shift count is negative
    tQ8 g8( a12.roundedTo< tQ8 >() );
    tQ8 h8( a12.roundedTo< 8 >() );
    
//  a8 = a4.roundedTo( h8 );  //Warning: left/right shift is negative
    
    a8 = 1;
    a8 = -2;
    a8 = 3;
    a8 = Q8CONST( 3,001 );
    a8 = tQ8( 3.001 );
    a8 = tQ8::truncated( 3.001 );
    a8 = tQ8::rounded( 3.001 );
    a8.setTruncated( 3.2 );
    a8.setRounded( 3.3 );
    a8 = tQ8( 123, 8 );
    a8 = tQ8::create( 123 << 8 );
    
    a8 = a4;
    a8 = a8;
//  a8 = a12;          // Warning: left shift count is negative
    a8 = a12.roundedTo< tQ8 >();
    a8 = a12.roundedTo( a8 );
    a8.setRounded( a12 );
    a8 = -a4;
    a8 = -a8;

    a8 += 3;
    a8 += 4u;
    a8 += 5l;
    a8 += 6lu;
    a8 += tQ8( 3.2 );
    a8 += truncatedTo( a8, 3.3 );
    a8 += roundedTo( a8, 3.4 );
    a8 += a4;
//  a8 += a12;          // Warning: left shift count is negative
    a8 += a12.roundedTo< tQ8 >();
    a8 += a12.roundedTo( a8 );
    a8 = a8 + 2;
    a8 = 3 + a8;
    a8 = a8 + a4;
//  a8 = a4 + a8;       // Warning: left shift count is negative
    
    a8 -= 3;
    a8 -= 4u;
    a8 -= 5l;
    a8 -= 6lu;
    a8 -= roundedTo< tQ8::cQBits >( 3.2 );
    a8 -= roundedTo( a8, 3.3 );
    a8 -= a4;
//  a8 -= a12;          // Warning: left shift count is negative
    a8 -= a12.roundedTo< tQ8 >();
    a8 -= a12.roundedTo( a8 );
    a8 = a8 - 2;
    a8 = 3 - a8;
    a8 = a8 - a4;
//  a8 = a4 - a8;       // Warning: left shift count is negative
    
    a8 *= 3;
    a8 *= 4u;
    a8 *= 5l;
    a8 *= 6lu;
//  a8 *= 3.2;          // Warning: converting to int from double
    a8 *= a4;
    a8 *= a12;
    a8 = a8 * 2;
    a8 = 3 * a8;
    a12 = a8 * a4;
    a12 = a4 * a8;
    
    a8 /= 3;
    a8 /= 4u;
    a8 /= 5l;
    a8 /= 6lu;
//  a8 /= 3.2;          // Warning: converting to int from double
    a8 /= a4;           // Note: possible overflow due to pre-shifting "(a8 << 4) / a4"
//  a8 /= a12;          // Warning: left shift count is negative
    a8 = a8.increasedBy( a12 ) / a12;
    a8 = a8 / 2;
//  a8 = 3 / a8;        // Error: no match for 'operator/'
    a8 = tQ16( 3 ) / a8;
    a12 = a8 / a4;
    a12 = a4 / a8;
    
    a8 == 3;
    a8 == 4u;
    a8 == 5l;
    a8 == 6lu;
    a8 == tQ8( 3.2 );
    a8 == truncatedTo( a8, 3.3 );
    a8 == roundedTo( a8, 3.4 );
    a8 == a4;
//  a8 == a12;          // Warning: left shift count is negative
    a8 == a12.roundedTo< tQ8 >();
    a8 == a12.roundedTo( a8 );
    3 == a8;
    int(4u) == a8;
    int(5l) == a8;
    int(6lu) == a8;
    
    a8 < 3;
    a8 < 4u;
    a8 < 5l;
    a8 < 6lu;
    a8 < tQ8( 3.2 );
    a8 < a4;
//  a8 < a12;          // Warning: left shift count is negative
    3 < a8;
    int(4u) < a8;
    int(5l) < a8;
    int(6lu) < a8;
    
    a8 > 3;
    a8 > 4u;
    a8 > 5l;
    a8 > 6lu;
    a8 > tQ8( 3.2 );
    a8 > a4;
//  a8 > a12;          // Warning: left shift count is negative
    3 > a8;
    int(4u) > a8;
    int(5l) > a8;
    int(6lu) > a8;
    
    !a8;
    int intPart = a8.intPart();
    int fracPart = a8.fracPart();
    int fracPlaces = a8.fracPlaces( 3 );
    unsigned abs = a8.absolute();

    ad = a8.toDouble();
    a8 = ad;
//  a8.set( ad );    // Warning: conversion from int to double, possible loss of data
    a8.setRounded( ad );
    a8 = truncatedTo( a8, ad );
    a8 = truncatedTo<8>( ad );
    a8 = truncatedTo<tQ8>( ad );
    
//  tBigQ36 aB36( 123567890 );     // Error: ambiguous
    tBigQ36 aB36( 123567890ll );
    tBigQ36 bB36( a8 );
    
    aB36 = tBigQ18( a18 ) * a18;
}