-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
49 lines (42 loc) · 1.12 KB
/
test.cpp
File metadata and controls
49 lines (42 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "erasure_online_codes_decoder.h"
#include "erasure_online_codes_encoder.h"
#include <time.h>
#include <iostream>
#include "test.h"
#include "rand.h"
#include "mtrand.h"
test_result test_int_Ain_Aout_1(int* data, int len)
{
erasure_online_codes_encoder<int> enc(0.01, 0.005, 3,
[](int& a, int &b, int *dest){*dest = a^b; return dest; },
[](int n){return new int[n]; },
[](int* data){delete data; });
erasure_online_codes_decoder<int> dec(0.01, 0.005, 3,
[](int& a, int &b, int *dest){*dest = a^b; return dest; },
[](int n){return new int[n]; },
[](int* data){delete data; });
enc.input(data, len, 1);
dec.start(len, 1);
int i = 0;
MTRand_int32 random(time(0));
while (!(dec.is_finished()))
{
int degree;
int* out=new int(0);
int sd = random();
//int sd = i * 2;
enc.output(sd, °ree, out);
dec.input(out, sd);
i++;
}
int* dest = new int[len];
dec.copy_to(dest);
int err_num = 0;
for (int i = 0; i < len; i++)
if (dest[i] != data[i]){
std::cout << "error occur: " << i << " " << dest[i] << " " << data[i] << std::endl;
err_num++;
}
delete(dest);
return test_result(len, i, err_num);
}