source: trunk/libtest/hash_test.cpp @ 4050

Last change on this file since 4050 was 1949, checked in by ksherdy, 7 years ago

Updated tests.

File size: 3.3 KB
RevLine 
[1920]1#include "../lib/hash.hpp"
2#include <iostream>
3using namespace std;
4
5int main() {
6
[1949]7    char b0[] = {"abcdefgh        "};
8    char b1[] = {"ABCDEFGH        "};
9    char b2[] = {"AAAAAAAA        "};
10    char b3[] = {"FFFFFFFF        "};
[1920]11
12    uint64_t r = 0;
[1949]13    uint32_t hash_bits = 0;
[1920]14
15    uint64_t a = 1;
16    uint64_t b = 2;
17
18    print_register("b0", *(uint64_t *) b0);
19    print_register("b1", *(uint64_t *) b1);
20    print_register("b2", *(uint64_t *) b2);
21    print_register("b3", *(uint64_t *) b3);
22
23    // Expect 41
24
[1949]25//    for(uint32_t idx=0;idx<64;idx+=8) {
26//      r = bit_slice((uint8_t *) &b2,idx,8);
27//      print_register("r", r);
28//      printf("\n");
29//    }
30
31
[1920]32    // Expect 4141
33
[1949]34//    for(uint32_t idx=0;idx<64-8;idx+=8) {
35//      r = bit_slice((uint8_t *) &b2,idx,16);
36//      print_register("r", r);
37//      printf("\n");
38//    }
[1920]39
40
[1949]41    // Length 8 (bits), idx 1,9,..., Expect A0
[1920]42
[1949]43//    for(uint32_t idx=1;idx<64-8;idx+=8) {
44//      r = bit_slice((uint8_t *) &b2,idx,8);
45//      print_register("r", r);
46//      printf("\n");
47//    }
[1920]48
49
[1949]50    // Length 16 (bits), idx 1,9,..., Expect A0A0
[1920]51
[1949]52//    for(uint32_t idx=1;idx<64-16;idx+=8) {
53//      r = bit_slice((uint8_t *) &b2,idx,16);
54//      print_register("r", r);
55//      printf("\n");
56//    }
[1920]57
58
[1949]59    // Length 8 (bits), idx 2,10,..., Expect 50
[1920]60
[1949]61//    for(uint32_t idx=2;idx<64-8;idx+=8) {
62//      r = bit_slice((uint8_t *) &b2,idx,8);
63//      print_register("r", r);
64//      printf("\n");
65//    }
[1920]66
67
[1949]68    // Length 16 (bits), idx 2,10,..., Expect 5050
[1920]69
[1949]70//    for(uint32_t idx=2;idx<64-16;idx+=8) {
71//      r = bit_slice((uint8_t *) &b2,idx,16);
72//      print_register("r", r);
73//      printf("\n");
74//    }
[1920]75
76
[1949]77    // Length 8 (bits), idx 3,11,..., Expect 28
[1920]78
[1949]79//    for(uint32_t idx=3;idx<64-8;idx+=8) {
80//      r = bit_slice((uint8_t *) &b2,idx,8);
81//      print_register("r", r);
82//      printf("\n");
83//    }
[1920]84
85
[1949]86    // Length 16 (bits), idx 3,11,..., Expect 2828
[1920]87
[1949]88//    for(uint32_t idx=3;idx<64-16;idx+=8) {
89//      r = bit_slice((uint8_t *) &b2,idx,16);
90//      print_register("r", r);
91//      printf("\n");
92//    }
[1920]93
[1949]94
95    // Length 8 (bits), idx 3,11,..., Expect 05
96
97//    for(uint32_t idx=6;idx<64-8;idx+=8) {
98//      r = bit_slice((uint8_t *) &b2,idx,8);
99//      print_register("r", r);
100//      printf("\n");
101//    }
102
103    // Length 16 (bits), idx 3,11,..., Expect 0505
104
105//    for(uint32_t idx=6;idx<64-16;idx+=8) {
106//      r = bit_slice((uint8_t *) &b2,idx,16);
107//      print_register("r", r);
108//      printf("\n");
109//    }
110
111
112//    uint8_t idx, slice_bits;
113//    hash_bits = 8;
114
115//    slice_bits = 16;
116//    idx = 0;
117//    r = compress_hash((uint8_t *) &b0, (uint8_t *) &b0, idx, slice_bits, hash_bits);
118
119//    idx = 1;
120//    r = compress_hash((uint8_t *) &b0, (uint8_t *) &b0, idx, slice_bits, hash_bits);
121
122//    slice_bits = 24;
123//    idx = 0;
124//    r = compress_hash((uint8_t *) &b0, (uint8_t *) &b0, idx, slice_bits, hash_bits);
125
126//    idx = 1;
127//    r = compress_hash((uint8_t *) &b0, (uint8_t *) &b0, idx, slice_bits, hash_bits);
128
129//    slice_bits = 32;
130
131//    idx = 0;
132//    r = compress_hash((uint8_t *) &b0, (uint8_t *) &b0, idx, slice_bits, hash_bits);
133
134//    idx = 1;
135//    r = compress_hash((uint8_t *) &b0, (uint8_t *) &b0, idx, slice_bits, hash_bits);
136
137//    idx = 2;
138//    r = compress_hash((uint8_t *) &b0, (uint8_t *) &b0, idx, slice_bits, hash_bits);
139
140//    idx = 0;
141//    slice_bits = 8*10;
142//    hash_bits = 16;
143//    r = compress_hash((uint8_t *) &b0, (uint8_t *) &b0, idx, slice_bits, hash_bits);
144
145
[1920]146    return 1;
147}
Note: See TracBrowser for help on using the repository browser.