Example #1
0
int main()
{
	ZGGZ   gz[N];//60个职工
	FILE   *fp;
	int    select;
	char   choice;
	int    count=0;
	fp=fopen("db","ab+");

  //判断文件是否打开成功
	if(fp==NULL) {
		printf("\n----------cannot open file");
		exit(0);
	}

	while(!feof(fp)) {
		if(fread( &gz[count], sizeof(ZGGZ),1,fp )==1)
			count++;
	}

	fclose(fp);
	menu();
	while(1) {
    printf("please enter your choice(0-9)\n");
    scanf("%d",&select);
    if(select==0) {
      if(saveflag==1) {
        printf("file has changed,do you save it?(y/n)");
        getchar();
        scanf("%c",&choice);
        if(choice=='y'||choice=='Y') {
          Save(gz,count);
          printf("thank you for your useness\n");
        } else
          printf("thank you for your useness\n");
        break;
      } else {
        printf("thank you for your useness\n");
        break;
      }
    }
    switch(select)
    {
      case 1:count=Add(gz,count);break;
      case 2:count=Del(gz,count);break;
      case 3:Qur(gz,count);break;
      case 4:Modify(gz,count);break;
      case 5:Insert(gz,count);break;
      case 6:Count(gz,count);break;
      case 7:Sort(gz,count);break;
      case 8:Save(gz,count);break;
      case 9:Disp(gz,count);break;
      default :Wrong();break;
    }
  }
  return 0;
}
Example #2
0
  // This method differs from the Java version in that we must go towards STRING for value comparisons versus using
  // TypeAdapter.equals() which works on Object's.  Here the CELLADAPTER is used to parse and filter values as well
  // as convey return data from method invocations.
  void ceefit_call_spec FIXTURE::Check(PTR<PARSE>& cell, PTR<CELLADAPTER>& aAdapter, PTR<FIXTURE>& target)
  {
      PTR<FIXTURE> targetPtr(target);
      if(targetPtr == null)
      {
        targetPtr = this;      // set the default fixture target to this...
      }

      STRING text(cell->Text());

      if(aAdapter == null)
      {
        Ignore(cell);
      }
      else if(text.IsEqual(""))
      {
        try
        {
          STRING aTemp;

          if(aAdapter->IsMethod())
          {
            PTR<CELLADAPTER> result;

            aAdapter->Invoke(result, targetPtr);
            result->ReadFromFixtureVar(aTemp);
          }
          else // if(aAdpater->IsField())
          {
            if(targetPtr == this)
            {
              aAdapter->ReadFromFixtureVar(aTemp);
            }
            else
            {
              aAdapter->ReadFromFixtureVar(aTemp, targetPtr);
            }
          }

          Info(cell, aTemp);
        }
        catch(FAILURE* failure)
        {
          Info(cell, "error");

          delete failure;
        }
        catch(EXCEPTION* e)
        {
          Info(cell, "error");

          delete e;
        }
        catch(...)
        {
          Info(cell, "error");
        }
      }
      else if (text.IsEqual("error"))
      {
        try
        {
          STRING aTemp;
          PTR<CELLADAPTER> aResult;

          aAdapter->Invoke(aResult, targetPtr);

          aResult->ReadFromFixtureVar(aTemp);
          Wrong(cell, aTemp);
        }
        catch(FITFAILED* fitFailed)
        {
          Right(cell);

          delete fitFailed;
        }
        catch(FITASSERTIONFAILED* fitAssertionFailed)
        {
          Right(cell);

          delete fitAssertionFailed;
        }
        catch(EXCEPTION* e)
        {
          Right(cell);

          delete e;
        }
        catch(...)
        {
          Right(cell);
        }
      }
      else
      {
        PTR<CELLADAPTER> callResults;
        PTR<CELLADAPTER> checkValueCell;

        try
        {
          STRING result;
          STRING checkValue;

          if(aAdapter->IsField())
          {
            // The "callResults" is the field we are comparing
            if(targetPtr == this) 
            {
              callResults = aAdapter;
            }
            else
            {
              PTR<FIXTURE> notNeeded;
              callResults = targetPtr->FindField(notNeeded, aAdapter->GetName());

              if(callResults == null) 
              {
                throw new EXCEPTION(STRING("Field not found in FIXTURE:  ") + aAdapter->GetName());
              }
            }

            aAdapter->NewInstanceParse(targetPtr.GetPointer(), checkValueCell, text);
          }
          else // if(aAdapter->IsMethod())
          {
            aAdapter->Invoke(callResults, targetPtr);
            callResults->NewInstanceParse(targetPtr.GetPointer(), checkValueCell, text);
          }

          // checkValueCell must exactly equal result for the test to pass
          if (checkValueCell->IsEqual(*callResults))   // note:  this calls through to CELLCOMPARABLE implementations if available
          {
            Right(cell);
          }
          else
          {
            callResults->ReadFromFixtureVar(result);
            Wrong(cell, result);
          }
        }
        catch (EXCEPTION* e)
        {
          Exception(cell, e);
        }
        catch(...)
        {
          EXCEPTION* systemException = new EXCEPTION("System generated exception or unknown user exception type (exceptions thrown from a FIXTURE class should extend CEEFIT::EXCEPTION.)");

          Exception(cell, systemException);
        }
      }
  }
Example #3
0
 void ceefit_call_spec FIXTURE::Wrong(PTR<PARSE>& cell, const STRING& actual)
 {
   Wrong(cell);
   cell->AddToBody(Label("expected") + "<hr>" + this->Escape(actual) + Label("actual"));
 }
auto Wrong(int i){
  if(i != 1)
    return Wrong(i-1)+i;  // Too soon to call this. No prior return statement.
  else
    return i;             // return type deduced as int
}