Esempio n. 1
0
void Utc::new_quest(int i)
{
qDebug() << "new_quest " << i;	
	current_quest = i;
	Question* qq = &current_test.value().q[current_quest - 1];
qDebug() << i << ": " << qq->ans_student[0] << qq->ans_student[1] << qq->ans_student[2]  << qq->ans_student[3];	
	if (qq->ans_correct[0] == 1) ui.label_a->setText("A)");
	else ui.label_a->setText("a)");
	ui.a0->setChecked(true);
	if (qq->ans_student[0] == 1) ui.a1->setChecked(true);
	else if (qq->ans_student[0] == 2) ui.a2->setChecked(true);

	if (qq->ans_correct[1] == 1) ui.label_b->setText("B)");
	else ui.label_b->setText("b)");
	ui.b0->setChecked(true);
	if (qq->ans_student[1] == 1) ui.b1->setChecked(true);
	else if (qq->ans_student[1] == 2) ui.b2->setChecked(true);

	if (qq->ans_correct[2] == 1) ui.label_c->setText("C)");
	else ui.label_c->setText("c)");
	ui.c0->setChecked(true);
	if (qq->ans_student[2] == 1) ui.c1->setChecked(true);
	else if (qq->ans_student[2] == 2) ui.c2->setChecked(true);

	if (qq->ans_correct[3] == 1) ui.label_d->setText("D)");
	else ui.label_d->setText("d)");
	ui.d0->setChecked(true);
	if (qq->ans_student[3] == 1) ui.d1->setChecked(true);
	else if (qq->ans_student[3] == 2) ui.d2->setChecked(true);

	abcd();
}
Esempio n. 2
0
    void multiCompare() const {
        // Test for found
        Token one(0);
        one.str("one");
        ASSERT_EQUALS(1, Token::multiCompare(&one, "one|two", 0));

        Token two(0);
        two.str("two");
        ASSERT_EQUALS(1, Token::multiCompare(&two, "one|two", 0));
        ASSERT_EQUALS(1, Token::multiCompare(&two, "verybig|two|", 0));

        // Test for empty string found
        Token notfound(0);
        notfound.str("notfound");
        ASSERT_EQUALS(0, Token::multiCompare(&notfound, "|one|two", 0));
        ASSERT_EQUALS(0, Token::multiCompare(&notfound, "one||two", 0));
        ASSERT_EQUALS(0, Token::multiCompare(&notfound, "one|two|", 0));

        // Test for not found
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&notfound, "one|two", 0)));

        Token s(0);
        s.str("s");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&s, "verybig|two", 0)));

        Token ne(0);
        ne.str("ne");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&ne, "one|two", 0)));

        Token a(0);
        a.str("a");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&a, "abc|def", 0)));

        Token abcd(0);
        abcd.str("abcd");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&abcd, "abc|def", 0)));

        Token def(0);
        def.str("default");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&def, "abc|def", 0)));

        // %op%
        Token plus(0);
        plus.str("+");
        ASSERT_EQUALS(1, Token::multiCompare(&plus, "one|%op%", 0));
        ASSERT_EQUALS(1, Token::multiCompare(&plus, "%op%|two", 0));
        Token x(0);
        x.str("x");
        ASSERT_EQUALS(-1, Token::multiCompare(&x, "one|%op%", 0));
        ASSERT_EQUALS(-1, Token::multiCompare(&x, "%op%|two", 0));
    }
Esempio n. 3
0
void
StringTest::TestStringPieceComparisons() {
    StringPiece empty;
    StringPiece null(NULL);
    StringPiece abc("abc");
    StringPiece abcd("abcdefg", 4);
    StringPiece abx("abx");
    if(empty!=null) {
        errln("empty!=null");
    }
    if(empty==abc) {
        errln("empty==abc");
    }
    if(abc==abcd) {
        errln("abc==abcd");
    }
    abcd.remove_suffix(1);
    if(abc!=abcd) {
        errln("abc!=abcd.remove_suffix(1)");
    }
    if(abc==abx) {
        errln("abc==abx");
    }
}
Esempio n. 4
0
 forceinline TieBreakVarBranchOptions
 tiebreak(VarBranchOptions a, VarBranchOptions b, VarBranchOptions c,
          VarBranchOptions d) {
   TieBreakVarBranchOptions abcd(a,b,c,d);
   return abcd;
 }
Esempio n. 5
0
 forceinline TieBreakVarBranch<VarBranch>
 tiebreak(VarBranch a, VarBranch b, VarBranch c, VarBranch d) {
   TieBreakVarBranch<VarBranch> abcd(a,b,c,d);
   return abcd;
 }
Esempio n. 6
0
int  main()
{
     int a,i,ki;
     char b;
     mkdir("d:/缓存");
     int shijian=5,xunhuan=3,nandu=4;
     char u[10]={0},s[3]={"5"},r1[3]={"3"},r2[3]={"4"};
     char shuoming[]={"1>>:此文件夹是你玩“测试输入速度游戏”时自动创建的,用于保存你对游戏做的更改。以便下次进入时不用再次设置。\n\n2>>:文本格式为text格式,用户可后台对数据进行更改,程序再次运行时生效。\n\n3>>:不用时可以自行删除,当再次运行游戏时将会再次被创建。"};
     FILE *fp1,*fp2;
     fp1=fopen("d:/缓存/说明read me.txt","w");
           fwrite(shuoming,2,120,fp1);
               fclose(fp1);
     if((fp1=fopen("d:/缓存/时间.txt","r"))==NULL)
    {
    	fp1=fopen("d:/缓存/时间.txt","w");
            fwrite(s,2,3,fp1);
                fclose(fp1);
    }
    fp2=fopen("d:/缓存/时间.txt","r+");
        fread(u,2,10,fp2);
           fclose(fp2);
              shijian=atoi(u);
	//printf("s=%d",shijian);
	
    if((fp1=fopen("d:/缓存/循环.txt","r"))==NULL)
    {
    	fp1=fopen("d:/缓存/循环.txt","w");
            fwrite(r1,2,3,fp1);
               fclose(fp1);
    }
    fp2=fopen("d:/缓存/循环.txt","r+");
        fread(u,2,10,fp2);
           fclose(fp2);
              xunhuan=atoi(u);
	//printf("s=%d",xunhuan);
	
	if((fp1=fopen("d:/缓存/个数.txt","r"))==NULL)
    {
    	fp1=fopen("d:/缓存/个数.txt","w");
           fwrite(r2,2,3,fp1);
              fclose(fp1);
    }
    fp2=fopen("d:/缓存/个数.txt","r+");
        fread(u,2,10,fp2);
           fclose(fp2);
              nandu=atoi(u);
	//printf("s=%d",nandu);
	//getch();
	do{
        begin:
            caidan();
	            scanf("%d",&a);
    switch(a)
    {
       case 1:abc(shijian,xunhuan,nandu);break;
       case 2:abcd(&shijian,&xunhuan,&nandu);goto begin;break;  
       case 3:printf("说明:\n1>>>w,s,a,d控制上下左右,输入空格即为输入结束。\n");
              printf("2>>>输入有误则为FOLL!!但输入时的时间有限制,初始时间为5秒。\n");
              printf("3>>>时间结束即使输入正确也为foll!!。时间可自行设置更改。\n");
              printf("4>>>程序会在你的D盘创建一文件夹以保存你对游戏的设置。\n");
              printf("5>>>输入后不可以更改,即使改正确后也会显示“FOLL!!”\n"); 
              system("pause");
              goto begin;
              break;
       case 4:exit(1);
              break;
       default:printf("输入错误!");
               fflush(stdin);
               goto begin;
               break; 
    } 
    printf("是否继续?[Y/N]");
       b=getche();
          printf("\n");
    }while(b=='y'||b=='Y');
}
Esempio n. 7
0
void
StringTest::TestStringPiece() {
    // Default constructor.
    StringPiece empty;
    if(!empty.empty() || empty.data()!=NULL || empty.length()!=0 || empty.size()!=0) {
        errln("StringPiece() failed");
    }
    // Construct from NULL const char * pointer.
    StringPiece null(NULL);
    if(!null.empty() || null.data()!=NULL || null.length()!=0 || null.size()!=0) {
        errln("StringPiece(NULL) failed");
    }
    // Construct from const char * pointer.
    static const char *abc_chars="abc";
    StringPiece abc(abc_chars);
    if(abc.empty() || abc.data()!=abc_chars || abc.length()!=3 || abc.size()!=3) {
        errln("StringPiece(abc_chars) failed");
    }
    // Construct from const char * pointer and length.
    static const char *abcdefg_chars="abcdefg";
    StringPiece abcd(abcdefg_chars, 4);
    if(abcd.empty() || abcd.data()!=abcdefg_chars || abcd.length()!=4 || abcd.size()!=4) {
        errln("StringPiece(abcdefg_chars, 4) failed");
    }
#if U_HAVE_STD_STRING
    // Construct from std::string.
    std::string uvwxyz_string("uvwxyz");
    StringPiece uvwxyz(uvwxyz_string);
    if(uvwxyz.empty() || uvwxyz.data()!=uvwxyz_string.data() || uvwxyz.length()!=6 || uvwxyz.size()!=6) {
        errln("StringPiece(uvwxyz_string) failed");
    }
#endif
    // Substring constructor with pos.
    StringPiece sp(abcd, -1);
    if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
        errln("StringPiece(abcd, -1) failed");
    }
    sp=StringPiece(abcd, 5);
    if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
        errln("StringPiece(abcd, 5) failed");
    }
    sp=StringPiece(abcd, 2);
    if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
        errln("StringPiece(abcd, -1) failed");
    }
    // Substring constructor with pos and len.
    sp=StringPiece(abcd, -1, 8);
    if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
        errln("StringPiece(abcd, -1, 8) failed");
    }
    sp=StringPiece(abcd, 5, 8);
    if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
        errln("StringPiece(abcd, 5, 8) failed");
    }
    sp=StringPiece(abcd, 2, 8);
    if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
        errln("StringPiece(abcd, -1) failed");
    }
    sp=StringPiece(abcd, 2, -1);
    if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
        errln("StringPiece(abcd, 5, -1) failed");
    }
    // static const npos
    const int32_t *ptr_npos=&StringPiece::npos;
    if(StringPiece::npos!=0x7fffffff || *ptr_npos!=0x7fffffff) {
        errln("StringPiece::npos!=0x7fffffff");
    }
    // substr() method with pos, using len=npos.
    sp=abcd.substr(-1);
    if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
        errln("abcd.substr(-1) failed");
    }
    sp=abcd.substr(5);
    if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
        errln("abcd.substr(5) failed");
    }
    sp=abcd.substr(2);
    if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
        errln("abcd.substr(-1) failed");
    }
    // substr() method with pos and len.
    sp=abcd.substr(-1, 8);
    if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
        errln("abcd.substr(-1, 8) failed");
    }
    sp=abcd.substr(5, 8);
    if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
        errln("abcd.substr(5, 8) failed");
    }
    sp=abcd.substr(2, 8);
    if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
        errln("abcd.substr(-1) failed");
    }
    sp=abcd.substr(2, -1);
    if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
        errln("abcd.substr(5, -1) failed");
    }
    // clear()
    sp=abcd;
    sp.clear();
    if(!sp.empty() || sp.data()!=NULL || sp.length()!=0 || sp.size()!=0) {
        errln("abcd.clear() failed");
    }
    // remove_prefix()
    sp=abcd;
    sp.remove_prefix(-1);
    if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
        errln("abcd.remove_prefix(-1) failed");
    }
    sp=abcd;
    sp.remove_prefix(2);
    if(sp.empty() || sp.data()!=abcdefg_chars+2 || sp.length()!=2 || sp.size()!=2) {
        errln("abcd.remove_prefix(2) failed");
    }
    sp=abcd;
    sp.remove_prefix(5);
    if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
        errln("abcd.remove_prefix(5) failed");
    }
    // remove_suffix()
    sp=abcd;
    sp.remove_suffix(-1);
    if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=4 || sp.size()!=4) {
        errln("abcd.remove_suffix(-1) failed");
    }
    sp=abcd;
    sp.remove_suffix(2);
    if(sp.empty() || sp.data()!=abcdefg_chars || sp.length()!=2 || sp.size()!=2) {
        errln("abcd.remove_suffix(2) failed");
    }
    sp=abcd;
    sp.remove_suffix(5);
    if(!sp.empty() || sp.length()!=0 || sp.size()!=0) {
        errln("abcd.remove_suffix(5) failed");
    }
}
Esempio n. 8
0
Utc::Utc(QWidget *parent) : QDialog(parent)
{
qDebug() << "start Utc";
ui.setupUi(this);
	filename = "data.tex";
	connect(ui.a0, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.a1, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.a2, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.b0, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.b1, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.b2, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.c0, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.c1, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.c2, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.d0, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.d1, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.d2, SIGNAL(clicked()), this, SLOT(abcd()));
	connect(ui.test_no, SIGNAL(valueChanged(int)), this, SLOT(new_test(int)));
	connect(ui.quest_no, SIGNAL(valueChanged(int)), this, SLOT(new_quest(int)));
	connect(ui.save, SIGNAL(clicked()), this, SLOT(save()));
	connect(ui.load, SIGNAL(clicked()), this, SLOT(load/*read_students_tests*/()));
	connect(ui.calc, SIGNAL(clicked()), this, SLOT(calc()));

	read_data_tests();	
//	print();
//	read_data();
	go();
qDebug() << "stop Utc";
}