anchor.diff:    truck.I64_thing := 8;
     insane.Xtructs := TThriftListImpl<IXtruct>.Create;
     insane.Xtructs.Add( truck );
  -  Console.Write('testInsanity()');
     whoa := client.testInsanity( insane );
     Console.Write(' = {');
     for key64 in whoa.Keys do
  
positive.code:   finally
      stm.Free;
      prot := nil;  //-> Release
    end;
  end;
  
  
negative.code:   end;
    Console.WriteLine('}');
  
    // verify result data
    Expect( whoa.Count = 2, 'whoa.Count = '+IntToStr(whoa.Count));
    //
    first_map  := whoa[1];
    second_map := whoa[2];
    Expect( first_map.Count = 2, 'first_map.Count = '+IntToStr(first_map.Count));
    Expect( second_map.Count = 1, 'second_map.Count = '+IntToStr(second_map.Count));
    //
    looney := second_map[TNumberz.SIX];
    Expect( Assigned(looney), 'Assigned(looney) = '+BoolToString(Assigned(looney)));
    Expect( not looney.__isset_UserMap, 'looney.__isset_UserMap = '+BoolToString(looney.__isset_UserMap));
    Expect( not looney.__isset_Xtructs, 'looney.__isset_Xtructs = '+BoolToString(looney.__isset_Xtructs));
    //
    for ret in [TNumberz.SIX, TNumberz.THREE] do begin
      crazy := first_map[ret];
      Console.WriteLine('first_map['+intToStr(Ord(ret))+']');
  
      Expect( crazy.__isset_UserMap, 'crazy.__isset_UserMap = '+BoolToString(crazy.__isset_UserMap));
      Expect( crazy.__isset_Xtructs, 'crazy.__isset_Xtructs = '+BoolToString(crazy.__isset_Xtructs));
  
      Expect( crazy.UserMap.Count = 2, 'crazy.UserMap.Count = '+IntToStr(crazy.UserMap.Count));
      Expect( crazy.UserMap[TNumberz.FIVE] = 5, 'crazy.UserMap[TNumberz.FIVE] = '+IntToStr(crazy.UserMap[TNumberz.FIVE]));
      Expect( crazy.UserMap[TNumberz.EIGHT] = 8, 'crazy.UserMap[TNumberz.EIGHT] = '+IntToStr(crazy.UserMap[TNumberz.EIGHT]));
  
      Expect( crazy.Xtructs.Count = 2, 'crazy.Xtructs.Count = '+IntToStr(crazy.Xtructs.Count));
      goodbye := crazy.Xtructs[0];  // lists are ordered, so we are allowed to assume this order
  	  hello   := crazy.Xtructs[1];
  
      Expect( goodbye.String_thing = 'Goodbye4', 'goodbye.String_thing = "'+goodbye.String_thing+'"');
      Expect( goodbye.Byte_thing = 4, 'goodbye.Byte_thing = '+IntToStr(goodbye.Byte_thing));
      Expect( goodbye.I32_thing = 4, 'goodbye.I32_thing = '+IntToStr(goodbye.I32_thing));
      Expect( goodbye.I64_thing = 4, 'goodbye.I64_thing = '+IntToStr(goodbye.I64_thing));
      Expect( goodbye.__isset_String_thing, 'goodbye.__isset_String_thing = '+BoolToString(goodbye.__isset_String_thing));
      Expect( goodbye.__isset_Byte_thing, 'goodbye.__isset_Byte_thing = '+BoolToString(goodbye.__isset_Byte_thing));
      Expect( goodbye.__isset_I32_thing, 'goodbye.__isset_I32_thing = '+BoolToString(goodbye.__isset_I32_thing));
      Expect( goodbye.__isset_I64_thing, 'goodbye.__isset_I64_thing = '+BoolToString(goodbye.__isset_I64_thing));
  
      Expect( hello.String_thing = 'hello', 'hello.String_thing = "'+hello.String_thing+'"');
      Expect( hello.Byte_thing = 2, 'hello.Byte_thing = '+IntToStr(hello.Byte_thing));
      Expect( hello.I32_thing = 2, 'hello.I32_thing = '+IntToStr(hello.I32_thing));
      Expect( hello.I64_thing = 2, 'hello.I64_thing = '+IntToStr(hello.I64_thing));
      Expect( hello.__isset_String_thing, 'hello.__isset_String_thing = '+BoolToString(hello.__isset_String_thing));
      Expect( hello.__isset_Byte_thing, 'hello.__isset_Byte_thing = '+BoolToString(hello.__isset_Byte_thing));
      Expect( hello.__isset_I32_thing, 'hello.__isset_I32_thing = '+BoolToString(hello.__isset_I32_thing));
      Expect( hello.__isset_I64_thing, 'hello.__isset_I64_thing = '+BoolToString(hello.__isset_I64_thing));
    end;
  
  
    // multi args
    StartTestGroup( 'testMulti');
    arg0 := 1;
    arg1 := 2;
    arg2 := High(Int64);
    arg3 := TThriftDictionaryImpl<SmallInt, string>.Create;
    arg3.AddOrSetValue( 1, 'one');
    arg4 := TNumberz.FIVE;
    arg5 := 5000000;
    Console.WriteLine('Test Multi(' + IntToStr( arg0) + ',' +
      IntToStr( arg1) + ',' + IntToStr( arg2) + ',' +
      arg3.ToString + ',' + IntToStr( Integer( arg4)) + ',' +
        IntToStr( arg5) + ')');
  
    i := client.testMulti( arg0, arg1, arg2, arg3, arg4, arg5);
    Expect( i.String_thing = 'Hello2', 'testMulti: i.String_thing = "'+i.String_thing+'"');
    Expect( i.Byte_thing = arg0, 'testMulti: i.Byte_thing = '+IntToStr(i.Byte_thing));
    Expect( i.I32_thing = arg1, 'testMulti: i.I32_thing = '+IntToStr(i.I32_thing));
    Expect( i.I64_thing = arg2, 'testMulti: i.I64_thing = '+IntToStr(i.I64_thing));
    Expect( i.__isset_String_thing, 'testMulti: i.__isset_String_thing = '+BoolToString(i.__isset_String_thing));
    Expect( i.__isset_Byte_thing, 'testMulti: i.__isset_Byte_thing = '+BoolToString(i.__isset_Byte_thing));
    Expect( i.__isset_I32_thing, 'testMulti: i.__isset_I32_thing = '+BoolToString(i.__isset_I32_thing));
    Expect( i.__isset_I64_thing, 'testMulti: i.__isset_I64_thing = '+BoolToString(i.__isset_I64_thing));
  
    // multi exception
    StartTestGroup( 'testMultiException(1)');
    try
      i := client.testMultiException( 'need more pizza', 'run out of beer');
      Expect( i.String_thing = 'run out of beer', 'i.String_thing = "' +i.String_thing+ '"');
      Expect( i.__isset_String_thing, 'i.__isset_String_thing = '+BoolToString(i.__isset_String_thing));
      Expect( not i.__isset_Byte_thing, 'i.__isset_Byte_thing = '+BoolToString(i.__isset_Byte_thing));
      Expect( not i.__isset_I32_thing, 'i.__isset_I32_thing = '+BoolToString(i.__isset_I32_thing));
      Expect( not i.__isset_I64_thing, 'i.__isset_I64_thing = '+BoolToString(i.__isset_I64_thing));
    except
      on e:Exception do Expect( FALSE, 'Unexpected exception "'+e.ClassName+'"');
    end;
  
    StartTestGroup( 'testMultiException(Xception)');
    try
      i := client.testMultiException( 'Xception', 'second test');
      Expect( FALSE, 'testMultiException(''Xception''): must trow an exception');
    except
      on x:TXception do begin
        Expect( x.__isset_ErrorCode, 'x.__isset_ErrorCode = '+BoolToString(x.__isset_ErrorCode));
        Expect( x.__isset_Message_,  'x.__isset_Message_ = '+BoolToString(x.__isset_Message_));
        Expect( x.ErrorCode = 1001, 'x.ErrorCode = '+IntToStr(x.ErrorCode));
        Expect( x.Message_ = 'This is an Xception', 'x.Message = "'+x.Message_+'"');
      end;
      on e:Exception do Expect( FALSE, 'Unexpected exception "'+e.ClassName+'"');
    end;
  
    StartTestGroup( 'testMultiException(Xception2)');
    try
      i := client.testMultiException( 'Xception2', 'third test');
      Expect( FALSE, 'testMultiException(''Xception2''): must trow an exception');
    except
      on x:TXception2 do begin
        Expect( x.__isset_ErrorCode, 'x.__isset_ErrorCode = '+BoolToString(x.__isset_ErrorCode));
        Expect( x.__isset_Struct_thing,  'x.__isset_Struct_thing = '+BoolToString(x.__isset_Struct_thing));
        Expect( x.ErrorCode = 2002, 'x.ErrorCode = '+IntToStr(x.ErrorCode));
        Expect( x.Struct_thing.String_thing = 'This is an Xception2', 'x.Struct_thing.String_thing = "'+x.Struct_thing.String_thing+'"');
        Expect( x.Struct_thing.__isset_String_thing, 'x.Struct_thing.__isset_String_thing = '+BoolToString(x.Struct_thing.__isset_String_thing));
        Expect( not x.Struct_thing.__isset_Byte_thing, 'x.Struct_thing.__isset_Byte_thing = '+BoolToString(x.Struct_thing.__isset_Byte_thing));
        Expect( not x.Struct_thing.__isset_I32_thing, 'x.Struct_thing.__isset_I32_thing = '+BoolToString(x.Struct_thing.__isset_I32_thing));
        Expect( not x.Struct_thing.__isset_I64_thing, 'x.Struct_thing.__isset_I64_thing = '+BoolToString(x.Struct_thing.__isset_I64_thing));
      end;
      on e:Exception do Expect( FALSE, 'Unexpected exception "'+e.ClassName+'"');
    end;
  
  
    // oneway functions
    StartTestGroup( 'Test Oneway(1)');
    client.testOneway(1);
    Expect( TRUE, 'Test Oneway(1)');  // success := no exception
  
    // call time
    StartTestGroup( 'Test Calltime()');
    StartTick := GetTIckCount;
    for k := 0 to 1000 - 1 do
    begin
      client.testVoid();
    end;
    Console.WriteLine(' = ' + FloatToStr( (GetTickCount - StartTick) / 1000 ) + ' ms a testVoid() call' );
  
    // no more tests here
    StartTestGroup( '');
  end;
  
  
  