mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 14:30:36 +00:00
make sure that we always cause maximum damage
This commit is contained in:
parent
02a0c4269f
commit
bc535c6d04
2 changed files with 8 additions and 6 deletions
|
|
@ -34,7 +34,7 @@ void bch_reference_test(ENC *encode, DEC *decode, int trials)
|
|||
for (int i = 0; i < ENC::NP; ++i)
|
||||
orig_parity[i] = parity[i];
|
||||
int error_count = rnd_cnt() / 2;
|
||||
typename ENC::value_type errors[error_count];
|
||||
typename ENC::value_type errors[ENC::NR];
|
||||
for (int i = 0; i < error_count; ++i) {
|
||||
int pos = rnd_pos();
|
||||
for (int j = 0; j < i; ++j) {
|
||||
|
|
@ -53,12 +53,13 @@ void bch_reference_test(ENC *encode, DEC *decode, int trials)
|
|||
typename ENC::value_type erasures[erasures_count];
|
||||
for (int i = 0; i < erasures_count; ++i) {
|
||||
int pos = rnd_pos();
|
||||
for (int j = 0; j < i; ++j) {
|
||||
if (erasures[j] == pos) {
|
||||
for (int j = 0; j < error_count + i; ++j) {
|
||||
if (errors[j] == pos) {
|
||||
pos = rnd_pos();
|
||||
j = -1;
|
||||
}
|
||||
}
|
||||
errors[error_count + i] = pos;
|
||||
erasures[i] = pos;
|
||||
if (pos < data_len)
|
||||
data[pos] ^= 1;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void rs_test(ENC *encode, DEC *decode, int trials)
|
|||
for (int i = 0; i < ENC::NP; ++i)
|
||||
orig_parity[i] = parity[i];
|
||||
int error_count = rnd_cnt() / 2;
|
||||
typename ENC::value_type errors[error_count];
|
||||
typename ENC::value_type errors[ENC::NR];
|
||||
for (int i = 0; i < error_count; ++i) {
|
||||
int pos = rnd_pos();
|
||||
for (int j = 0; j < i; ++j) {
|
||||
|
|
@ -53,12 +53,13 @@ void rs_test(ENC *encode, DEC *decode, int trials)
|
|||
typename ENC::value_type erasures[erasures_count];
|
||||
for (int i = 0; i < erasures_count; ++i) {
|
||||
int pos = rnd_pos();
|
||||
for (int j = 0; j < i; ++j) {
|
||||
if (erasures[j] == pos) {
|
||||
for (int j = 0; j < error_count + i; ++j) {
|
||||
if (errors[j] == pos) {
|
||||
pos = rnd_pos();
|
||||
j = -1;
|
||||
}
|
||||
}
|
||||
errors[error_count + i] = pos;
|
||||
erasures[i] = pos;
|
||||
if (pos < data_len)
|
||||
data[pos] = rnd_val();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue