diff options
author | Jens Geyer <jensg@apache.org> | 2016-12-28 14:25:41 +0100 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2016-12-28 15:13:48 +0100 |
commit | 540e346d6ec3be9893ff1f29ef89e000c314edf4 (patch) | |
tree | 424a75eb8b4d79d7feaf617332baa1b51bf36115 /lib | |
parent | 60ac165aeb6b86ae10bb554b107c273bfcde7a83 (diff) | |
download | thrift-540e346d6ec3be9893ff1f29ef89e000c314edf4.tar.gz |
THRIFT-4016 testInsanity() impl does not conform to test spec in ThriftTest.thrift
Client: Delphi
Patch: Jens Geyer
Diffstat (limited to 'lib')
-rw-r--r-- | lib/delphi/test/TestClient.pas | 59 | ||||
-rw-r--r-- | lib/delphi/test/TestServer.pas | 39 |
2 files changed, 44 insertions, 54 deletions
diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas index 9f45a91dd..a6567fa7e 100644 --- a/lib/delphi/test/TestClient.pas +++ b/lib/delphi/test/TestClient.pas @@ -449,7 +449,7 @@ var looney : IInsanity; first_map : IThriftDictionary<TNumberz, IInsanity>; second_map : IThriftDictionary<TNumberz, IInsanity>; - + pair : TPair<TNumberz, TUserId>; begin client := TThriftTest.TClient.Create( FProtocol); FTransport.Open; @@ -772,9 +772,9 @@ begin insane.UserMap.AddOrSetValue( TNumberz.FIVE, 5000); truck := TXtructImpl.Create; truck.String_thing := 'Truck'; - truck.Byte_thing := 8; - truck.I32_thing := 8; - truck.I64_thing := 8; + truck.Byte_thing := -8; // byte is signed + truck.I32_thing := 32; + truck.I64_thing := 64; insane.Xtructs := TThriftListImpl<IXtruct>.Create; insane.Xtructs.Add( truck ); whoa := client.testInsanity( insane ); @@ -823,6 +823,18 @@ begin end; Console.WriteLine('}'); + (** + * So you think you've got this all worked, out eh? + * + * Creates a the returned map with these values and prints it out: + * { 1 => { 2 => argument, + * 3 => argument, + * }, + * 2 => { 6 => <empty Insanity struct>, }, + * } + * @return map<UserId, map<Numberz,Insanity>> - a map with the above values + *) + // verify result data Expect( whoa.Count = 2, 'whoa.Count = '+IntToStr(whoa.Count)); // @@ -843,31 +855,20 @@ begin 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 = 'Hello2', '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)); + Expect( crazy.UserMap.Count = insane.UserMap.Count, 'crazy.UserMap.Count = '+IntToStr(crazy.UserMap.Count)); + for pair in insane.UserMap do begin + Expect( crazy.UserMap[pair.Key] = pair.Value, 'crazy.UserMap['+IntToStr(Ord(pair.key))+'] = '+IntToStr(crazy.UserMap[pair.Key])); + end; + + Expect( crazy.Xtructs.Count = insane.Xtructs.Count, 'crazy.Xtructs.Count = '+IntToStr(crazy.Xtructs.Count)); + for arg0 := 0 to insane.Xtructs.Count-1 do begin + hello := insane.Xtructs[arg0]; + goodbye := crazy.Xtructs[arg0]; + Expect( goodbye.String_thing = hello.String_thing, 'goodbye.String_thing = '+goodbye.String_thing); + Expect( goodbye.Byte_thing = hello.Byte_thing, 'goodbye.Byte_thing = '+IntToStr(goodbye.Byte_thing)); + Expect( goodbye.I32_thing = hello.I32_thing, 'goodbye.I32_thing = '+IntToStr(goodbye.I32_thing)); + Expect( goodbye.I64_thing = hello.I64_thing, 'goodbye.I64_thing = '+IntToStr(goodbye.I64_thing)); + end; end; diff --git a/lib/delphi/test/TestServer.pas b/lib/delphi/test/TestServer.pas index d7917ca0e..97041d0b9 100644 --- a/lib/delphi/test/TestServer.pas +++ b/lib/delphi/test/TestServer.pas @@ -185,44 +185,33 @@ end; function TTestServer.TTestHandlerImpl.testInsanity( const argument: IInsanity): IThriftDictionary<Int64, IThriftDictionary<TNumberz, IInsanity>>; var - hello, goodbye : IXtruct; - crazy : IInsanity; looney : IInsanity; first_map : IThriftDictionary<TNumberz, IInsanity>; second_map : IThriftDictionary<TNumberz, IInsanity>; insane : IThriftDictionary<Int64, IThriftDictionary<TNumberz, IInsanity>>; begin - Console.WriteLine('testInsanity()'); - hello := TXtructImpl.Create; - hello.String_thing := 'Hello2'; - hello.Byte_thing := 2; - hello.I32_thing := 2; - hello.I64_thing := 2; - - goodbye := TXtructImpl.Create; - goodbye.String_thing := 'Goodbye4'; - goodbye.Byte_thing := 4; - goodbye.I32_thing := 4; - goodbye.I64_thing := 4; - - crazy := TInsanityImpl.Create; - crazy.UserMap := TThriftDictionaryImpl<TNumberz, Int64>.Create; - crazy.UserMap.AddOrSetValue( TNumberz.EIGHT, 8); - crazy.Xtructs := TThriftListImpl<IXtruct>.Create; - crazy.Xtructs.Add(goodbye); - looney := TInsanityImpl.Create; - crazy.UserMap.AddOrSetValue( TNumberz.FIVE, 5); - crazy.Xtructs.Add(hello); + (** + * So you think you've got this all worked, out eh? + * + * Creates a the returned map with these values and prints it out: + * { 1 => { 2 => argument, + * 3 => argument, + * }, + * 2 => { 6 => <empty Insanity struct>, }, + * } + * @return map<UserId, map<Numberz,Insanity>> - a map with the above values + *) first_map := TThriftDictionaryImpl<TNumberz, IInsanity>.Create; second_map := TThriftDictionaryImpl<TNumberz, IInsanity>.Create; - first_map.AddOrSetValue( TNumberz.TWO, crazy); - first_map.AddOrSetValue( TNumberz.THREE, crazy); + first_map.AddOrSetValue( TNumberz.TWO, argument); + first_map.AddOrSetValue( TNumberz.THREE, argument); + looney := TInsanityImpl.Create; second_map.AddOrSetValue( TNumberz.SIX, looney); insane := TThriftDictionaryImpl<Int64, IThriftDictionary<TNumberz, IInsanity>>.Create; |