Changeset 1915 for trunk


Ignore:
Timestamp:
Feb 8, 2012, 5:10:33 PM (7 years ago)
Author:
ksherdy
Message:

Added mask_hash function tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/test/hash_util_test.cpp

    r1913 r1915  
    88    char b1[] = {"ABCDEFGH"};
    99    char b2[] = {"AAAAAAAA"};
     10    char b3[] = {"FFFFFFFF"};
    1011
    1112    uint64_t r = 0;
     
    1516    print_register("b1", *(uint64_t *) b1);
    1617    print_register("b2", *(uint64_t *) b2);
     18    print_register("b3", *(uint64_t *) b3);
     19
     20    for(uint32_t mask_bits=1;mask_bits<64;mask_bits++) {
     21        r = mask_hash<8>((uint8_t *) &b3, mask_bits, 8);
     22        print_register("r", r);
     23    }
    1724
    1825    // Length 8 (bits), Expect 41
     
    102109
    103110        // shift_hash<1>
    104         r = shift_hash<1>((uint8_t *) &b0,(uint8_t *) &b2, idx*8, 8, hash_size);
     111        r = shift_hash<1>((uint8_t *) &b0,(uint8_t *) &b2, idx*8, hash_size, 8);
    105112        cout << dec << "shift_hash<1> = " << r << endl << endl;
    106113        cout << endl << endl;
    107114
    108         r = shift_hash<8>((uint8_t *) &b0,(uint8_t *) &b2, idx, 1, hash_size);
     115        r = shift_hash<8>((uint8_t *) &b0,(uint8_t *) &b2, idx, hash_size, 1);
    109116        cout << dec << "shift_hash<8> = " << r << endl << endl;
    110117        cout << endl << endl;
     
    119126
    120127        // shift_hash<1>
    121         r = shift_hash<1>((uint8_t *) &b1,(uint8_t *) &b2, idx*8, 16, hash_size);
     128        r = shift_hash<1>((uint8_t *) &b1,(uint8_t *) &b2, idx*8, hash_size, 16);
    122129        cout << dec << "shift_hash<1> = " << r << endl << endl;
    123130        cout << endl << endl;
    124131
    125         r = shift_hash<8>((uint8_t *) &b1,(uint8_t *) &b2, idx, 2, hash_size);
     132        r = shift_hash<8>((uint8_t *) &b1,(uint8_t *) &b2, idx, hash_size, 2);
    126133        cout << dec << "shift_hash<8> = " << r << endl << endl;
    127134        cout << endl << endl;
     
    131138
    132139    // Some shift_hash<1> cases.
    133         /*
     140    /*
    134141    hash_size = 9;
    135142    for(uint32_t lgth=16;lgth<sizeof(uint64_t)*8+1;lgth+=16) {
    136143        for(uint32_t idx=1;idx<sizeof(uint64_t)*8-lgth+1;idx++) {
    137              r = shift_hash<1>((uint8_t *) &b0,(uint8_t *) &b1, idx, lgth, hash_size);
     144             r = shift_hash<1>((uint8_t *) &b0,(uint8_t *) &b1, idx, hash_size, lgth);
    138145             cout << dec << "shift_hash<1> = " << r << endl << endl;
    139146             cout  << endl;
    140147        }
    141148    }
    142         */
     149    */
    143150
    144151    // Some shift_hash<8> cases.
     152    /*
    145153    hash_size = 8;
    146154    for(uint32_t lgth=2;lgth<sizeof(uint64_t)+1;lgth++) {
    147155        for(uint32_t idx=0;idx<sizeof(uint64_t)-lgth+1;idx++) {
    148              r = shift_hash<8>((uint8_t *) &b0,(uint8_t *) &b1, idx, lgth, hash_size);
     156             r = shift_hash<8>((uint8_t *) &b0,(uint8_t *) &b1, idx, hash_size, lgth);
    149157             cout << dec << "shift_hash<8> = " << r << endl;
    150158             cout << endl << endl;
    151159        }
    152160    }
     161    */
    153162
    154163    return 1;
Note: See TracChangeset for help on using the changeset viewer.