示例#1
0
int  checkWorkPlace(void)
{
  char * n1=malloc(strlen(modelDir)+50);
  char * n2=malloc(strlen(compDir)+50);
  char *fList[5]= {"vars","prtcls","extlib","func","lgrng",};
  int i;
  for(i=0;i<5;i++)
  { sprintf(n1,"%s/%s%d.mdl",modelDir,fList[i],modelNum);
    sprintf(n2,"%s/models/%s1.mdl",compDir,fList[i]);
    if(fcompare(n1,n2)) break;
  }   
  free(n1);
  free(n2);
  if(i==5) return 0;
  if(modelDir && modelNum)
  { 
     char* command=malloc(strlen(modelDir)+strlen(compDir)+200);
     sprintf(command,
     "for FILE in vars func prtcls lgrng extlib\n do\n"
     "  cp %s/\"$FILE\"%d.mdl %s/models/\"$FILE\"1.mdl\n" 
     "done\n", modelDir,modelNum,  compDir);  
     system(command);
     free(command);
     delAllLib();
  }
  return 1;
}  
示例#2
0
int testEngineCommandPacket(void)
{
    testPacket_t pkt;
    float command = 0.5678f;

    if(getEngineCommandMinDataLength() != 4)
    {
        std::cout << "Engine Command minimum data length is wrong" << std::endl;
        return 0;
    }

    encodeEngineCommandPacket(&pkt, command);


    if(pkt.length != 4 )
    {
        std::cout << "Engine command packet has the wrong length" << std::endl;
        return 0;
    }

    if(pkt.pkttype != 10)
    {
        std::cout << "Engine command packet has the wrong type" << std::endl;
        return 0;
    }

    command = 0;
    if(decodeEngineCommandPacket(&pkt, &command))
    {
        if(fcompare(command, 0.5678, 0.0000001))
        {
            std::cout << "decodeEngineCommandPacket() yielded incorrect data" << std::endl;
            return 0;
        }
    }
    else
    {
        std::cout << "decodeEngineCommandPacket() failed" << std::endl;
        return 0;
    }

    return 1;

}
static  void checkAuxDir( int nmod)
{  char  n1[50],n2[50];
   char *fList[5]= {"vars","prtcls","extlib","func","lgrng",};   
   int i;
   for(i=0;i<5;i++)
   { sprintf(n1,"models/%s%d.mdl",fList[i],nmod); 
     sprintf(n2,"results/aux/models/%s1.mdl",fList[i]);
     if(fcompare(n1,n2)) break;
   }   
   if(i!=5)
   {
     delAllLib();
     system("if(test -d results/aux) then\n"
            "rm  -r results/aux\n"
            "fi\n"
            "mkdir results/aux; cd results/aux;\n"
            " mkdir models tmp results so_generated");
     for(i=0;i<5;i++)
     { char command[100];
       sprintf(command,"cp models/%s%d.mdl results/aux/models/%s1.mdl", fList[i],nmod,fList[i]);
       system(command); 
     } 
   }
}  
示例#4
0
/*************************************************************************
 *
 *N  query_table
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function returns the set of selected rows of a VPF table
 *     based upon the evaluation of the given selection expression string.
 *
 *     The expression is strictly evaluated left to right.  No nesting
 *     is supported, so parentheses are not allowed.  The expression
 *     must match the form:
 *        <field><log op><value> [ <join> <field><log op><value>]
 *     where,
 *        <field> is a valid field name of the table.
 *        <log op> is one of the following: =, <, >, <=, >=, <> (not equal).
 *        <value> is a valid value for the field.
 *        <join> is either " AND " or " OR ".
 *     Any number of clauses (<field><log op><value>) may be joined
 *     together with AND or OR to form the expression.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    expression <input>==(char *) selection expression string.
 *    table      <input>==(vpf_table_type) VPF table structure.
 *    return    <output>==(set_type) set of selected rows.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels    May 1991                          DOS Turbo C
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   External Variables:
 *X
 *    None
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Functions Called:
 *F
 *    set_type set_init( rspf_int32 n ) SET.C
 *    void set_insert( rspf_int32 element, set_type set ) SET.C
 *    linked_list_type parse_expression( char *expression,
 *                     vpf_table_type table ) VPFQUERY.C
 *    row_type read_next_row( vpf_table_type table ) VPFREAD.C
 *    position_type ll_first( linked_list_type list ) LINKLIST.C
 *    int ll_end( position_type position ) LINKLIST.C
 *    void ll_element( position_type position, void *element ) LINKLIST.C
 *    void *get_table_element( rspf_int32 field_number,
 * 			 row_type row,
 *			 vpf_table_type table,
 *			 void *value,
 *			 rspf_int32  *count ) VPFREAD.C
 *    void display_message( char *info ) USER DEFINED
 *    static int strcompare( char *val1, char *val2, char op ) VPFQUERY.C
 *    static int icompare( rspf_int32 val1, rspf_int32 val2, char op ) VPFQUERY.C
 *    static int fcompare( float val1, float val2, char op ) VPFQUERY.C
 *    void ll_reset( linked_list_type list ) LINKLIST.C
      void free_row( row_type row, vpf_table_type table) VPFREAD.C
 *E
 *************************************************************************/
set_type query_table( char *expression, vpf_table_type table )
{
   row_type row;
   position_type pos;
   expr_type expr;
   register rspf_int32 i;
   int boolval=FALSE, booltemp=0, join = OR;
   rspf_int32 lval, lval2, count;
   float fval, fval2;
   char tval, tval2, *tptr;
   linked_list_type exprlist;
   set_type select_set;

   select_set = set_init(table.nrows+1);

   if (strcmp(expression,"*")==0) {
      set_on(select_set);
      return select_set;
   }

   exprlist = parse_expression( expression, table );

   if (!exprlist) return select_set;

   if (table.storage == DISK)
      fseek( table.fp, index_pos(1,table), SEEK_SET );

   for (i=1;i<=table.nrows;i++) {

      if (table.storage == DISK)
	 row = read_next_row(table);
      else
	 row = get_row( i, table );

      pos = ll_first(exprlist);
      while (!ll_end(pos)) {
	 ll_element( pos, &expr );
	 switch (table.header[expr.field].type) {
	    case 'I':
	       if (table.header[expr.field].count == 1) {
		  get_table_element( expr.field, row, table, &lval, &count );
		  lval2 = atol(expr.value);
		  booltemp = icompare( lval, lval2, expr.op );
	       } else {
		  display_message(
		     "Selection may not be performed upon arrays");
		  i=table.nrows+1;
	       }
	       break;
	    case 'T':
	       if (table.header[expr.field].count == 1) {
		  get_table_element( expr.field, row, table, &tval, &count );
		  tval2 = expr.value[0];
		  booltemp = comp( &tval, &tval2, sizeof(tval), expr.op );
	       } else {
		  tptr = (char *)get_table_element( expr.field, row, table,
				   NULL, &count );
		  booltemp = strcompare( tptr, expr.value, expr.op );
		  free(tptr);
	       }
	       break;
	    case 'F':
	       if (table.header[expr.field].count == 1) {
		  get_table_element( expr.field, row, table, &fval, &count );
		  if (!is_vpf_null_float(fval)) {
		     fval2 = (float)atof(expr.value);
		     booltemp = fcompare( fval, fval2, expr.op );
		  } else booltemp = FALSE;
	       } else {
		  display_message(
		     "Selection may not be performed upon arrays");
		  i=table.nrows+3;
	       }
	       break;
	    default:
	       display_message("Field type not supported for query");
	       i=table.nrows+3;
	       break;
	 }

	 if (i>table.nrows) break;

	 if (join==OR)
	    boolval = boolval || booltemp;
	 else
	    boolval = boolval && booltemp;

	 join = expr.join;

	 pos = pos->next;
      }
      free_row( row, table );
      if (boolval) set_insert(i,select_set);
      boolval = FALSE;
      join = OR;

      if (i==table.nrows+3) break;

   }

   ll_reset(exprlist);

   return select_set;
}
示例#5
0
int testConstantPacket(void)
{
    testPacket_t pkt;
    Constant_t constant;

    memset(&constant, 0, sizeof(constant));

    encodeConstantPacket(&pkt, 127);

    if(pkt.length != (2 + 19 + 4 + 3*1 + 4 + 1) )
    {
        std::cout << "Constant packet has the wrong length" << std::endl;
        return 0;
    }

    if(pkt.pkttype != 23)
    {
        std::cout << "Constant packet has the wrong type" << std::endl;
        return 0;
    }

    if(decodeConstantPacket(&pkt, constant.constant2, &constant.cos45, constant.sin45, &constant.constant3, &constant.token))
    {
        if( (pkt.data[0] != 0x12)   ||
                (pkt.data[1] != 0x34)   ||
                (constant.token != 127) ||
                (strcmp(constant.constant2, "To be or not to be") != 0) ||
                fcompare(constant.cos45, 0.70710678118654752440084436210485f, 0.00000001f) ||
                fcompare(constant.sin45[0], 0.70710678118654752440084436210485f, 1.0/127) ||
                fcompare(constant.sin45[1], 0.70710678118654752440084436210485f, 1.0/127) ||
                fcompare(constant.sin45[2], 0.70710678118654752440084436210485f, 1.0/127) ||
                (constant.constant3 != 327612))
        {
            std::cout << "decodeConstantPacket() yielded incorrect data" << std::endl;
            return 0;
        }
    }
    else
    {
        std::cout << "decodeConstantPacket() failed" << std::endl;
        return 0;
    }


    encodeConstantPacketStructure(&pkt, &constant);
    memset(&constant, 0, sizeof(constant));
    if(decodeConstantPacketStructure(&pkt, &constant))
    {
        if( (pkt.data[0] != 0x12)   ||
                (pkt.data[1] != 0x34)   ||
                (constant.token != 127) ||
                (strcmp(constant.constant2, "To be or not to be") != 0) ||
                fcompare(constant.cos45, 0.70710678118654752440084436210485f, 0.00000001f) ||
                fcompare(constant.sin45[0], 0.70710678118654752440084436210485f, 1.0/127) ||
                fcompare(constant.sin45[1], 0.70710678118654752440084436210485f, 1.0/127) ||
                fcompare(constant.sin45[2], 0.70710678118654752440084436210485f, 1.0/127) ||
                (constant.constant3 != 327612))
        {
            std::cout << "decodeConstantPacketStructure() yielded incorrect data" << std::endl;
            return 0;
        }
    }
    else
    {
        std::cout << "decodeConstantPacketStructure() failed" << std::endl;
        return 0;
    }


    return 1;

}
示例#6
0
int verifyGPSData(GPS_t gps)
{
    if(gps.ITOW != ((((5*24) + 11)*60 + 32)*60 + 59)*1000 + 251) return 0;
    if(gps.Week != 1234) return 0;
    if(fcompare(gps.PDOP, 0, 0.1)) return 0;
    if(fcompare(gps.PositionLLA.altitude, 169.4, 1.0/1000)) return 0;
    if(fcompare(gps.PositionLLA.latitude, deg2rad(45.6980142), 1.0/1367130551.152863)) return 0;
    if(fcompare(gps.PositionLLA.longitude, deg2rad(-121.5618339), 1.0/683565275.2581217)) return 0;
    if(fcompare(gps.VelocityNED.north, 23.311, 1.0/100)) return 0;
    if(fcompare(gps.VelocityNED.east, -42.399, 1.0/100)) return 0;
    if(fcompare(gps.VelocityNED.down, -.006, 1.0/100)) return 0;
    if(gps.numSvInfo != 5) return 0;
    if(fcompare(gps.svInfo[0].azimuth, deg2rad(91), 1.0/40.42535554534142)) return 0;
    if(fcompare(gps.svInfo[0].elevation, deg2rad(77), 1.0/40.42535554534142)) return 0;
    if(gps.svInfo[0].healthy != 1) return 0;
    if(gps.svInfo[0].L1CNo != 50) return 0;
    if(gps.svInfo[0].L2CNo != 33) return 0;
    if(gps.svInfo[0].PRN != 12) return 0;
    if(gps.svInfo[0].tracked != 1) return 0;
    if(gps.svInfo[0].used != 1) return 0;
    if(gps.svInfo[0].visible != 1) return 0;

    if(fcompare(gps.svInfo[1].azimuth, deg2rad(-179.99), 1.0/40.42535554534142)) return 0;
    if(fcompare(gps.svInfo[1].elevation, deg2rad(-23), 1.0/40.42535554534142)) return 0;
    if(gps.svInfo[1].healthy != 1) return 0;
    if(gps.svInfo[1].L1CNo != 50) return 0;
    if(gps.svInfo[1].L2CNo != 33) return 0;
    if(gps.svInfo[1].PRN != 13) return 0;
    if(gps.svInfo[1].tracked != 1) return 0;
    if(gps.svInfo[1].used != 1) return 0;
    if(gps.svInfo[1].visible != 1) return 0;

    if(fcompare(gps.svInfo[2].azimuth, deg2rad(179.1), 1.0/40.42535554534142)) return 0;
    if(fcompare(gps.svInfo[2].elevation, deg2rad(66), 1.0/40.42535554534142)) return 0;
    if(gps.svInfo[2].healthy != 1) return 0;
    if(gps.svInfo[2].L1CNo != 50) return 0;
    if(gps.svInfo[2].L2CNo != 33) return 0;
    if(gps.svInfo[2].PRN != 23) return 0;
    if(gps.svInfo[2].tracked != 1) return 0;
    if(gps.svInfo[2].used != 1) return 0;
    if(gps.svInfo[2].visible != 1) return 0;

    if(fcompare(gps.svInfo[3].azimuth, deg2rad(90), 1.0/40.42535554534142)) return 0;
    if(fcompare(gps.svInfo[3].elevation, deg2rad(0), 1.0/40.42535554534142)) return 0;
    if(gps.svInfo[3].healthy != 0) return 0;
    if(gps.svInfo[3].L1CNo != 50) return 0;
    if(gps.svInfo[3].L2CNo != 33) return 0;
    if(gps.svInfo[3].PRN != 1) return 0;
    if(gps.svInfo[3].tracked != 1) return 0;
    if(gps.svInfo[3].used != 0) return 0;
    if(gps.svInfo[3].visible != 1) return 0;

    if(fcompare(gps.svInfo[4].azimuth, deg2rad(0), 1.0/40.42535554534142)) return 0;
    if(fcompare(gps.svInfo[4].elevation, deg2rad(0), 1.0/40.42535554534142)) return 0;
    if(gps.svInfo[4].healthy != 0) return 0;
    if(gps.svInfo[4].L1CNo != 0) return 0;
    if(gps.svInfo[4].L2CNo != 0) return 0;
    if(gps.svInfo[4].PRN != 0) return 0;
    if(gps.svInfo[4].tracked != 0) return 0;
    if(gps.svInfo[4].used != 0) return 0;
    if(gps.svInfo[4].visible != 0) return 0;

    return 1;

}// verifyGPSData
示例#7
0
int testEngineSettingsPacket(void)
{
    testPacket_t pkt;
    EngineSettings_t settings;

    if(getEngineSettingsMinDataLength() != 1)
    {
        std::cout << "Engine Settings minimum data length is wrong" << std::endl;
        return 0;
    }

    settings.gain[0] = 0.1f;
    settings.gain[1] = (float)(-PI);
    settings.gain[2] = 200.0f;
    settings.maxRPM = 8000;
    settings.mode = directRPM;

    encodeEngineSettingsPacketStructure(&pkt, &settings);

    if(pkt.length != 15 )
    {
        std::cout << "Engine settings packet has the wrong length" << std::endl;
        return 0;
    }

    if(pkt.pkttype != 11)
    {
        std::cout << "Engine settings packet has the wrong type" << std::endl;
        return 0;
    }

    memset(&settings, 0, sizeof(settings));
    if(decodeEngineSettingsPacketStructure(&pkt, &settings))
    {
        if( fcompare(settings.gain[0], 0.1f, 0.00000001)   ||
                fcompare(settings.gain[1], (float)(-PI), 0.00000001)    ||
                fcompare(settings.gain[2], 200.0f, 0.00000001) ||
                fcompare(settings.maxRPM, 8000, 1/4.0959375)   ||
                (settings.mode != directRPM))
        {
            std::cout << "decodeEngineSettingsPacketStructure() yielded incorrect data" << std::endl;
            return 0;
        }
    }
    else
    {
        std::cout << "decodeEngineSettingsPacketStructure() failed" << std::endl;
        return 0;
    }

    // now test the default case
    pkt.length = 1;
    memset(&settings, 0, sizeof(settings));
    if(decodeEngineSettingsPacketStructure(&pkt, &settings))
    {
        if( fcompare(settings.gain[0], 0.1f, 0.00000001) ||
                fcompare(settings.gain[1], 0.1f, 0.00000001) ||
                fcompare(settings.gain[2], 0.1f, 0.00000001) ||
                fcompare(settings.maxRPM, 10000, 1/4.0959375)||
                (settings.mode != directRPM))
        {
            std::cout << "decodeEngineSettingsPacketStructure() yielded incorrect default data" << std::endl;
            return 0;
        }
    }
    else
    {
        std::cout << "decodeEngineSettingsPacketStructure() failed with defaults" << std::endl;
        return 0;
    }


    return 1;

}
示例#8
0
int testThrottleSettingsPacket(void)
{
    testPacket_t pkt;
    ThrottleSettings_t settings;

    if(getThrottleSettingsMinDataLength() != 1)
    {
        std::cout << "Throttle Settings minimum data length is wrong" << std::endl;
        return 0;
    }

    settings.numCurvePoints = 5;
    settings.enableCurve = 1;
    settings.highPWM = 2000;
    settings.lowPWM = 1000;
    for(int i = 0; i < settings.numCurvePoints; i++)
    {
        settings.curvePoint[i].PWM = settings.lowPWM + i*100;
        settings.curvePoint[i].throttle = i*0.2f;
    }

    encodeThrottleSettingsPacketStructure(&pkt, &settings);

    if(pkt.length != (1+3*5+4) )
    {
        std::cout << "Throttle settings packet has the wrong length" << std::endl;
        return 0;
    }

    if(pkt.pkttype != 12)
    {
        std::cout << "Throttle settings packet has the wrong type" << std::endl;
        return 0;
    }

    memset(&settings, 0, sizeof(settings));
    if(decodeThrottleSettingsPacketStructure(&pkt, &settings))
    {
        if( (settings.numCurvePoints != 5)                 ||
                (settings.enableCurve != 1)                    ||
                (settings.lowPWM != 1000)                      ||
                (settings.highPWM != 2000)  )
        {
            std::cout << "decodeThrottleSettingsPacketStructure() yielded incorrect data" << std::endl;
            return 0;
        }

        for(int i = 0; i < settings.numCurvePoints; i++)
        {
            if( (settings.curvePoint[i].PWM != settings.lowPWM + i*100) ||
                    fcompare(settings.curvePoint[i].throttle, i*0.2f, 1.0/255))
            {
                std::cout << "decodeThrottleSettingsPacketStructure() yielded incorrect data" << std::endl;
                return 0;
            }
        }
    }
    else
    {
        std::cout << "decodeThrottleSettingsPacketStructure() failed" << std::endl;
        return 0;
    }


    // simpler case using defaults
    memset(&settings, 0, sizeof(settings));
    encodeThrottleSettingsPacketStructure(&pkt, &settings);
    if(pkt.length != (1+4) )
    {
        std::cout << "Throttle settings packet (#2) has the wrong length" << std::endl;
        return 0;
    }

    // now test the default case
    pkt.length = 1;
    if(decodeThrottleSettingsPacketStructure(&pkt, &settings))
    {
        if( (settings.numCurvePoints != 0)                 ||
                (settings.enableCurve != 0)                    ||
                (settings.lowPWM != 1100)                      ||
                (settings.highPWM != 1900)  )
        {
            std::cout << "decodeThrottleSettingsPacketStructure() with defaults yielded incorrect data" << std::endl;
            return 0;
        }

    }
    else
    {
        std::cout << "decodeThrottleSettingsPacketStructure() with defaults failed" << std::endl;
        return 0;
    }

    return 1;

}
示例#9
0
int verifyTelemetryData(Telemetry_t telemetry)
{
    if(telemetry.insMode != insModeRun) return 0;

    if(telemetry.numGPSs != 1) return 0;
    if(verifyGPSData(telemetry.gpsData[0]) == 0) return 0;

    // ECEF are not encoded, so they should be zero from our memset
    if(telemetry.ECEF[0] != 0) return 0;
    if(telemetry.ECEF[1] != 0) return 0;
    if(telemetry.ECEF[2] != 0) return 0;

    if(telemetry.numFueltanks != 3) return 0;
    if(fcompare(telemetry.fuel[0], 0, 0.0001f)) return 0;
    if(fcompare(telemetry.fuel[1], 0.001f, 0.0001f)) return 0;
    if(fcompare(telemetry.fuel[2], 1000.0f, 0.0001f)) return 0;

    if(telemetry.airDataIncluded != 1) return 0;
    if(fcompare(telemetry.OAT, 300.0f, 200/256.0)) return 0;
    if(fcompare(telemetry.staticP, 101325.0f, 115000.0/65536.0)) return 0;
    if(fcompare(telemetry.dynamicP, 254.0f, 16200/65536.0)) return 0;

    if(telemetry.laserIncluded != 1) return 0;
    if(fcompare(telemetry.laserAGL, 131.256, 150/65536.0)) return 0;

    // We don't test this one because we do both cases
    // if(telemetry.magIncluded != 1) return 0;

    if(telemetry.magIncluded)
    {
        if(fcompare(telemetry.mag[0], 12.56, 100000/32768.0)) return 0;
        if(fcompare(telemetry.mag[1], 85.76, 100000/32768.0)) return 0;
        if(fcompare(telemetry.mag[2], -999.9, 100000/32768.0)) return 0;
        if(fcompare(telemetry.compassHeading, deg2rad(-64.56), deg2rad(180)/32768.0)) return 0;
    }
    else
    {
        // these should have been set to zero and then not changed
        if(telemetry.mag[0] != 0) return 0;
        if(telemetry.mag[1] != 0) return 0;
        if(telemetry.mag[2] != 0) return 0;
        if(telemetry.compassHeading != 0) return 0;
    }

    if(telemetry.numControls != 14) return 0;
    for(int i = 0; i < telemetry.numControls; i++)
    {
        if(fcompare(telemetry.controls[i], deg2rad(i), 1.5/32768.0)) return 0;
    }

    return 1;
}
示例#10
0
bool
tStr08( LibTest & tester )
{
  {
    // compare( const Str & ) const
    // compare( const Str &, size_t ) const
    // compare( const Str &, size_t, size_t ) const

    Str t( "abcdefg" );
    Str s( "abcdefg" );

    TEST( t.compare( s ) == 0 );

    s += 'h';
    TEST( t.compare( s ) < 0 );
    
    t += "hi";

    TEST( t.compare( s ) > 0 );

    s = "b";

    TEST( t.compare( s ) < 0 );

    s = "abcdef";
    t = "yyyabcdef";
    
    TEST( t.compare( s, 3 ) == 0 );

    t += "yyy";

    TEST( t.compare( s, 3, 6 ) == 0 );

  }

  {
    // compare( const SubStr & ) const
    // compare( const SubStr &, size_t ) const
    // compare( const SubStr &, size_t, size_t ) const

    Str t( T2 T3 );
    Str s( T1 T2 T3 T4 );

    TEST( t.compare( s.substr( strlen( T1 ), strlen( T2 T3 ) ) ) == 0 );
    TEST( t.compare( s.substr( strlen( T1 ), strlen( T2 T3 ) + 1 ) ) < 0 );
    TEST( t.compare( s.substr( strlen( T1 ), strlen( T2 T3 ) - 1 ) ) > 0 );

    TEST( t.compare( s.substr( strlen(T1 T2), strlen(T3) ), strlen( T2 ) ) == 0 );
    TEST( t.compare( s.substr( strlen(T1), strlen(T2 T3 T4) ),
		     0, strlen(T2) ) == 0 );
  }

  {
    // compare( const char * ) const
    // compare( const char *, size_t ) const
    // compare( const char *, size_t, size_t ) const

    Str t( T1 T2 T3 );

    TEST( t.compare( T1 T2 T3 ) == 0 );
    TEST( t.compare( "zz" ) < 0 );
    TEST( t.compare( "aa" ) > 0 );
    TEST( t.compare( T1 T2 T3 "a" ) < 0 );
    TEST( t.compare( T1 T2 ) > 0 );

    TEST( t.compare( T2 T3, strlen( T1 ) ) == 0 );
    TEST( t.compare( T2, strlen(T1), strlen(T2) ) == 0 );
  }

  {
    // ::compare( const SubStr &, const Str & )
    // ::compare( const SubStr &, const Str &, size_t )

    Str t( T2 T3 );
    Str s( T1 T2 T3 T4 );

    TEST( compare( s.substr( strlen( T1 ), strlen( T2 T3 ) ), t ) == 0 );
    TEST( compare( s.substr( strlen( T1 ), strlen( T2 T3 ) + 1 ), t ) > 0 );
    TEST( compare( s.substr( strlen( T1 ), strlen( T2 T3 ) - 1 ), t ) < 0 );

    t = T2 T1;
    TEST( compare( s.substr( strlen(T1), strlen(T2) ), t, strlen( T2 ) )
	  == 0 );
  }
  
  {
    // ::compare( const char *, const Str & ) const
    // ::compare( const char *, const Str & t, size_t ) const

    Str t( T1 T2 T3 );

    TEST( compare( T1 T2 T3, t ) == 0 );
    TEST( compare( "zz", t ) > 0 );
    TEST( compare( "aa", t ) < 0 );
    TEST( compare( T1 T2 T3 "a", t ) > 0 );
    TEST( compare( T1 T2, t ) < 0 );

    TEST( compare( T1 T3, t, strlen( T1 ) ) == 0 );
  }

  {
    // fcompare( const Str & ) const
    // fcompare( const Str &, size_t ) const
    // fcompare( const Str &, size_t, size_t ) const

    Str t( "ABCDEFG" );
    Str s( "abcdefg" );

    TEST( t.fcompare( s ) == 0 );

    s += 'h';
    TEST( t.fcompare( s ) < 0 );
    
    t += "hi";

    TEST( t.fcompare( s ) > 0 );

    s = "b";

    TEST( t.fcompare( s ) < 0 );

    s = "ABCDEF";
    t = "yyyabcdef";
    
    TEST( t.fcompare( s, 3 ) == 0 );

    t += "yyy";

    TEST( t.fcompare( s, 3, 6 ) == 0 );

  }

  {
    // fcompare( const SubStr & ) const
    // fcompare( const SubStr &, size_t ) const
    // fcompare( const SubStr &, size_t, size_t ) const

    Str t( T2 T3 );
    Str s( T1u T2u T3u T4u );

    TEST( t.fcompare( s.substr( strlen( T1 ), strlen( T2 T3 ) ) ) == 0 );
    TEST( t.fcompare( s.substr( strlen( T1 ), strlen( T2 T3 ) + 1 ) ) < 0 );
    TEST( t.fcompare( s.substr( strlen( T1 ), strlen( T2 T3 ) - 1 ) ) > 0 );

    TEST( t.fcompare( s.substr( strlen(T1 T2), strlen(T3) ), strlen( T2 ) ) == 0 );
    TEST( t.fcompare( s.substr( strlen(T1), strlen(T2 T3 T4) ),
		     0, strlen(T2) ) == 0 );
  }

  {
    // fcompare( const char * ) const
    // fcompare( const char *, size_t ) const
    // fcompare( const char *, size_t, size_t ) const

    Str t( T1 T2 T3 );

    TEST( t.fcompare( T1 T2u T3 ) == 0 );
    TEST( t.fcompare( "zz" ) < 0 );
    TEST( t.fcompare( "aa" ) > 0 );
    TEST( t.fcompare( T1u T2u T3u "a" ) < 0 );
    TEST( t.fcompare( T1 T2 ) > 0 );

    TEST( t.fcompare( T2u T3, strlen( T1 ) ) == 0 );
    TEST( t.fcompare( T2u, strlen(T1), strlen(T2) ) == 0 );
  }

  {
    // ::fcompare( const SubStr &, const Str & )
    // ::fcompare( const SubStr &, const Str & size_t )

    Str t( T2 T3 );
    Str s( T1u T2u T3u T4u );

    TEST( fcompare( s.substr( strlen( T1 ), strlen( T2 T3 ) ), t ) == 0 );
    TEST( fcompare( s.substr( strlen( T1 ), strlen( T2 T3 ) + 1 ), t ) > 0 );
    TEST( fcompare( s.substr( strlen( T1 ), strlen( T2 T3 ) - 1 ), t ) < 0 );

    TEST( fcompare( s.substr( strlen(T1), strlen(T2 T3 T4) ), t, strlen(T2) )
	  == 0 );
  }

  {
    // ::fcompare( const char *, const Str & )
    // ::fcompare( const char *, const Str &, size_t )

    Str t( T1 T2 T3 );

    TEST( fcompare( T1 T2u T3, t  ) == 0 );
    TEST( fcompare( "zz", t ) > 0 );
    TEST( fcompare( "aa", t ) < 0 );
    TEST( fcompare( T1u T2u T3u "a", t ) > 0 );
    TEST( fcompare( T1 T2, t ) < 0 );

    TEST( fcompare( T1u T3u, t, strlen(T1) ) == 0 );
  }
  
  return( true );
}