Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 478

Show
Ignore:
Timestamp:
01/06/11 07:30:35 (14 years ago)
Author:
braddr
Message:

Add more unit testing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/rt/aaA.d

    r476 r478  
    543543    assert(keys.length == 1); 
    544544    assert(memcmp(keys[0].ptr, cast(char*)"hello", 5) == 0); 
    545545 
    546546    int[] values = aa.values; 
    547547    assert(values.length == 1); 
    548548    assert(values[0] == 4); 
    549549 
    550550    aa.rehash; 
    551551    assert(aa.length == 1); 
    552552    assert(aa["hello"] == 4); 
     553 
     554    aa["foo"] = 1; 
     555    aa["bar"] = 2; 
     556    aa["batz"] = 3; 
     557 
     558    assert(aa.keys.length == 4); 
     559    assert(aa.values.length == 4); 
     560 
     561    foreach(a; aa.keys) 
     562    { 
     563        assert(a.length != 0); 
     564        assert(a.ptr != null); 
     565        //printf("key: %.*s -> value: %d\n", a.length, a.ptr, aa[a]); 
     566    } 
     567 
     568    foreach(v; aa.values) 
     569    { 
     570        assert(v != 0); 
     571        //printf("value: %d\n", v); 
     572    } 
    553573} 
    554574 
    555575 
    556576/********************************************** 
    557577 * 'apply' for associative arrays - to support foreach 
    558578 */ 
    559579 
    560580// dg is D, but _aaApply() is C 
    561581extern (D) typedef int delegate(void *) dg_t; 
    562582