From: Gabriel F. T. Gomes Date: Sun, 13 Mar 2016 19:34:54 +0000 (-0300) Subject: Test parsing of header and encoding X-Git-Tag: v2016.0~1 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Frnetclient.git;a=commitdiff_plain;h=4623dc854f1320cb40231becdc2d036eaef2ccb2 Test parsing of header and encoding This test opens DEC files from the years supported by rnetclient, parse their headers and encode the data for transmission. The DEC files contain only fictitious information. --- diff --git a/.gitignore b/.gitignore index c62646f..37d408a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,8 @@ config.h* # Object files *.o rnetclient + +# Test files +*.log +*.trs +t-parse diff --git a/Makefile.am b/Makefile.am index 2b45a72..02dc7e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,12 @@ -SUBDIRS = doc +SUBDIRS = doc data bin_PROGRAMS = rnetclient rnetclient_SOURCES = rnetclient.c decfile.c decfile.h pmhash.c pmhash.h \ rnet_message.c rnet_message.h rnet_encode.c rnet_encode.h + +check_PROGRAMS = t-parse +t_parse_SOURCES = t-parse.c decfile.c decfile.h pmhash.c pmhash.h \ + rnet_message.c rnet_message.h rnet_encode.c rnet_encode.h +t_parse_CFLAGS = -DSRCDIR=\"$(abs_top_srcdir)\" + +TESTS = $(check_PROGRAMS) diff --git a/configure.ac b/configure.ac index 03d2e92..53dc60c 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,7 @@ $CFLAGS" dnl Outputting the necessary files for the build. AC_CONFIG_HEADERS([config.h]) AC_OUTPUT([Makefile] + [data/Makefile] [doc/Makefile] [doc/man/Makefile] [doc/man/pt_BR/Makefile]) diff --git a/data/12345678909-IRPF-A-2013-2012-ORIGI.DEC b/data/12345678909-IRPF-A-2013-2012-ORIGI.DEC new file mode 100644 index 0000000..c2e6b9e --- /dev/null +++ b/data/12345678909-IRPF-A-2013-2012-ORIGI.DEC @@ -0,0 +1,8 @@ +IRPF 201320122300012345678909 1150JOAQUIM MARIA MACHADO DE ASSIS RJ1321200096101012000S0S 2LINUX 4.2.6-31.8.0_72 6001 000000000000001234567890200002100000000000000 000000000000000000000 0000000000000 RIO DE JANEIRO JOAQUIM MARIA MACHADO DE ASSIS 94DE807B0F8D00000000 0000000000000000 000000000000000000000000000000000000000 0888818345 +1612345678909JOAQUIM MARIA MACHADO DE ASSIS RUA COSME VELHO 1 21000000 6001RIO DE JANEIRO RJ 105 01012000123456780396 266110SNSN 0000000N N0 1234567890A0268768295 +1912345678909 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000193070458 +2012345678909000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004291363080 +T912345678909000004000010000000000000010000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002116812726 +HR12345678909 1670646968 +DR12345678909 SJOAQUIM MARIA MACHADO DE ASSIS RUA COSME VELHO 1 21000000 6001RIO DE JANEIRO RJ N0000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000 00000000000002583852340 +R912345678909 39582221450644435249 diff --git a/data/12345678909-IRPF-A-2014-2013-ORIGI.DEC b/data/12345678909-IRPF-A-2014-2013-ORIGI.DEC new file mode 100644 index 0000000..6180a83 --- /dev/null +++ b/data/12345678909-IRPF-A-2014-2013-ORIGI.DEC @@ -0,0 +1,8 @@ +IRPF 201420132400012345678909 1160JOAQUIM MARIA MACHADO DE ASSIS RJ4007331496101012000S0S 2LINUX 4.2.6-31.8.0_72 6001 000000000000001234567890200002100000000000000 000000000000000000000 0000000000000 RIO DE JANEIRO JOAQUIM MARIA MACHADO DE ASSIS 94DE807B0F8D00000000 0000000000000000 000000000000000000000000000000000000000 0 2867674185 +1612345678909JOAQUIM MARIA MACHADO DE ASSIS RUA COSME VELHO 1 21000000 6001RIO DE JANEIRO RJ 105 01012000123456780396 266110SNSN 0000000N0 N0 1234567890A 1259370438 +1912345678909 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000193070458 +2012345678909000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004291363080 +T912345678909000004000010000000000000010000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003464148678 +HR12345678909 1670646968 +DR12345678909 SJOAQUIM MARIA MACHADO DE ASSIS RUA COSME VELHO 1 21000000 6001RIO DE JANEIRO RJ N0000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000 00000000000002583852340 +R912345678909 28634939210340387355 diff --git a/data/12345678909-IRPF-A-2015-2014-ORIGI.DEC b/data/12345678909-IRPF-A-2015-2014-ORIGI.DEC new file mode 100644 index 0000000..779c7d8 --- /dev/null +++ b/data/12345678909-IRPF-A-2015-2014-ORIGI.DEC @@ -0,0 +1,8 @@ +IRPF 201520142500012345678909 1130JOAQUIM MARIA MACHADO DE ASSIS RJ1115462690101012000S0S 2LINUX 4.2.6-31.8.0_72 6001 000000000000001234567890200002100000000000000 000000000000000000000 0000000000000 RIO DE JANEIRO JOAQUIM MARIA MACHADO DE ASSIS 94DE807B0F8D00000000 0000000000000000 000000000000000000000000000000000000000 011 1100000001 0468715280 +1612345678909JOAQUIM MARIA MACHADO DE ASSIS RUA COSME VELHO 1 21000000 6001RIO DE JANEIRO RJ 105 01012000123456780396 266110SNSN 0000000N0 N0 1234567890A 1259370438 +1912345678909 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000193070458 +2012345678909000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004291363080 +T912345678909000004000010000000000000010000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004010792585 +HR12345678909 1670646968 +DR12345678909 SJOAQUIM MARIA MACHADO DE ASSIS RUA COSME VELHO 1 21000000 6001RIO DE JANEIRO RJ N0000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000 00000000000002583852340 +R912345678909 17860739000115671359 diff --git a/data/12345678909-IRPF-A-2016-2015-ORIGI.DEC b/data/12345678909-IRPF-A-2016-2015-ORIGI.DEC new file mode 100644 index 0000000..ff35d52 --- /dev/null +++ b/data/12345678909-IRPF-A-2016-2015-ORIGI.DEC @@ -0,0 +1,8 @@ +IRPF 201620152600012345678909 1110JOAQUIM MARIA MACHADO DE ASSIS RJ2119917808101012000S0S 2LINUX 4.2.6-31.8.0_72 6001 000000000000001234567890200002100000000000000 000000000000000000000 0000000000000 RIO DE JANEIRO JOAQUIM MARIA MACHADO DE ASSIS 94DE807B0F8D00000000 0000000000000000 000000000000000000000000000000000000000 011 1100000001 1034069486 +1612345678909JOAQUIM MARIA MACHADO DE ASSIS RUA COSME VELHO 1 21000000 6001RIO DE JANEIRO RJ 105 01012000123456780396 266110SNSN 0000000N0 N0 1234567890A 0439317218 +1912345678909 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003417993840 +2012345678909000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004291363080 +T912345678909000004000010000000000000010000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000665831501 +HR12345678909 1670646968 +DR12345678909 SJOAQUIM MARIA MACHADO DE ASSIS RUA COSME VELHO 1 21000000 6001RIO DE JANEIRO RJ N0000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000 00000000000002583852340 +R912345678909 42895113931825258592 diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..1288709 --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1 @@ +EXTRA_DIST = . diff --git a/t-parse.c b/t-parse.c new file mode 100644 index 0000000..827dcec --- /dev/null +++ b/t-parse.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2016 Gabriel F. T. Gomes + * + * 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 3 of the License, 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "decfile.h" +#include "rnet_encode.h" + +int main(void) +{ + int i, r; + struct rnet_decfile *decfile; + struct rnet_message *message = NULL; + char *filename[4] = { + SRCDIR"/data/12345678909-IRPF-A-2013-2012-ORIGI.DEC", + SRCDIR"/data/12345678909-IRPF-A-2014-2013-ORIGI.DEC", + SRCDIR"/data/12345678909-IRPF-A-2015-2014-ORIGI.DEC", + SRCDIR"/data/12345678909-IRPF-A-2016-2015-ORIGI.DEC" + }; + + for (i = 0; i < 4; i++) { + + decfile = rnet_decfile_open(filename[i]); + if (decfile == NULL) { + fprintf(stderr, "Error opening DEC file.\n"); + return -1; + } + + r = rnet_encode(decfile, &message); + if (r < 0) { + fprintf(stderr, "Error encoding message\n"); + return -1; + } + + rnet_message_del(message); + } + + return 0; +}