Changeset 59

Show
Ignore:
Timestamp:
06/27/08 03:00:48 (2 months ago)
Author:
baxissimo
Message:

Added tests for the interface handling fix in the previous checkin.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/util/serializer/FunctionTest.d

    r54 r59  
    319319} 
    320320 
     321interface IInterface { 
     322    void aMethod(); 
     323} 
     324 
     325class ClassWithInterface : IInterface { 
     326    int x; int y; int z; 
     327 
     328    this() {} 
     329    this(int x_, int y_, int z_) { 
     330        x = x_; y = y_; z = z_; 
     331    } 
     332    int opEquals(ClassWithInterface test) { 
     333        if (test.x == x && 
     334            test.y == y && 
     335            test.z == z) return 1; 
     336        return 0; 
     337    } 
     338 
     339    override void aMethod() { x = 99; } 
     340} 
     341 
     342 
     343 
    321344//------------------------------------------------------------------------------ 
    322345 
     
    648671//------------------------------------------------------------------------------ 
    649672 
     673unittest { testCase.execute("load/dump - classes with interfaces", { 
     674    alias ClassWithInterface TestT; 
     675    alias serializer S; 
     676    TestT input; 
     677    string output; 
     678 
     679    input = new TestT(8,-43,2); 
     680    output = S.dump(input); 
     681    assert(S.load!(TestT)(output) == input); 
     682});} 
     683 
     684 
     685//------------------------------------------------------------------------------ 
     686 
    650687unittest { testCase.execute("load/dump - transparent structs", { 
    651688    TransparentStruct input; 
     
    9631000    assert(serializer.load!(MyClass)(output) == input); 
    9641001});} 
     1002 
    9651003 
    9661004//------------------------------------------------------------------------------ 
     
    13101348        == new TransparentClass(50, 4.5, "another text", 25, -1)); 
    13111349});} 
     1350 
     1351//------------------------------------------------------------------------------ 
     1352 
     1353unittest { testCase.execute("load/dump - classes with interfaces", { 
     1354    alias ClassWithInterface TestT; 
     1355    alias jsonserializer S; 
     1356    TestT input; 
     1357    string output; 
     1358 
     1359    input = new TestT(8,-43,2); 
     1360    output = S.dump(input); 
     1361    assert(S.load!(TestT)(output) == input); 
     1362});} 
     1363 
    13121364 
    13131365//------------------------------------------------------------------------------ 
     
    20272079//------------------------------------------------------------------------------ 
    20282080 
     2081unittest { testCase.execute("load/dump - classes with interfaces", { 
     2082    alias ClassWithInterface TestT; 
     2083    alias binserializer S; 
     2084    TestT input; 
     2085    S.STORAGETYPE output; 
     2086 
     2087    input = new TestT(8,-43,2); 
     2088    output = S.dump(input); 
     2089    assert(S.load!(TestT)(output) == input); 
     2090});} 
     2091 
     2092//------------------------------------------------------------------------------ 
     2093 
    20292094unittest { testCase.execute("load/dump - transparent structs", { 
    20302095    TransparentStruct input;