123 lines
3.9 KiB
C
123 lines
3.9 KiB
C
/* -*- c -*- */
|
|
/*
|
|
* Copyright 2007 - 2011 Dominic Spill, Michael Ossmann
|
|
*
|
|
* This file is part of libbtbb
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with libbtbb; see the file COPYING. If not, write to
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "../bluetooth_packet.h"
|
|
#include <stdio.h>
|
|
|
|
int test_unfec23() {
|
|
char *optr;
|
|
int i, j, ret, err;
|
|
ret = 0;
|
|
|
|
printf("Testing unfec23\n");
|
|
printf("---------------\n");
|
|
|
|
char input[20][15] = {
|
|
/* No errors */
|
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0},
|
|
{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1},
|
|
{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0},
|
|
{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0},
|
|
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
|
|
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1},
|
|
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0},
|
|
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0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, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
{0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
{0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
|
|
{0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
|
|
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
|
|
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0},
|
|
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
|
|
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
|
|
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
|
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
|
|
};
|
|
|
|
for(i = 0; i < 20; i++) {
|
|
if (optr = unfec23(input[i], 1)) {
|
|
err = 0;
|
|
for(j = 0; j < 10; j++) {
|
|
if (optr[j] != output[i][j]) {
|
|
err = 1;
|
|
break;
|
|
}
|
|
}
|
|
if (err == 1) {
|
|
printf("E");
|
|
ret++;
|
|
}
|
|
else
|
|
printf(".");
|
|
} else {
|
|
printf("F");
|
|
ret++;
|
|
}
|
|
}
|
|
|
|
if (ret > 0)
|
|
printf("%d errors\n", ret);
|
|
printf("\n--------------------\n");
|
|
printf("Done testing unfec23\n");
|
|
return ret;
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
int ret = 0;
|
|
|
|
ret += test_unfec23();
|
|
|
|
exit(ret);
|
|
}
|