[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pdf-devel] Error module Tests
From: |
gerel |
Subject: |
[pdf-devel] Error module Tests |
Date: |
Fri, 13 Jun 2008 20:57:23 -0300 |
Well here I have the tests for the error module. Sorry for my delay.
Note that these functions have no return code so I just did argument testing.
BTW, there's still the issue of the PDF_EINVAL status code. Not of much
importance but... just for the record.
##
Index: src/base/pdf-error.c
===================================================================
RCS file: /sources/pdf/libgnupdf/src/base/pdf-error.c,v
retrieving revision 1.3
diff -u -r1.3 pdf-error.c
--- src/base/pdf-error.c 6 May 2008 18:53:44 -0000 1.3
+++ src/base/pdf-error.c 14 Jun 2008 00:02:12 -0000
@@ -1,4 +1,4 @@
-/* -*- mode: C -*- Time-stamp: "2008-05-06 14:30:50 gerel"
+/* -*- mode: C -*- Time-stamp: "2008-06-13 20:41:21 gerel"
*
* File: pdf-error.c
* Date: Sun Feb 24 20:22:05 2008
@@ -45,7 +45,13 @@
"no node found",
"invalid range",
"error in text encoding",
- "no matching found"
+ "no matching found",
+ "PDF_EINVAL",
+ "not enough permissions",
+ "invalid path name",
+ "operation can't be performed now, maybe later",
+ "no space left on device",
+ "operation requires some entity be empty"
};
@@ -63,6 +69,11 @@
int errnum;
errnum = (int) status;
+
+ if (fd == NULL)
+ {
+ fd = stderr;
+ }
fprintf (fd, "%s", program_name);
Index: src/base/pdf-error.h
===================================================================
RCS file: /sources/pdf/libgnupdf/src/base/pdf-error.h,v
retrieving revision 1.9
diff -u -r1.9 pdf-error.h
--- src/base/pdf-error.h 28 May 2008 19:43:02 -0000 1.9
+++ src/base/pdf-error.h 14 Jun 2008 00:02:12 -0000
@@ -1,4 +1,4 @@
-/* -*- mode: C -*- Time-stamp: "08/05/28 16:39:00 jemarch"
+/* -*- mode: C -*- Time-stamp: "2008-06-03 12:28:05 gerel"
*
* File: pdf-error.h
* Date: Sun Feb 24 20:22:05 2008
@@ -62,6 +62,10 @@
/* BEGIN PUBLIC */
+/* If you add a status code don't forget to add the corresponding string
+ * to pdf_error_stlist[] defined in pdf-error.c.
+ * Also PDF_STATUS_ITEMS must be the last entry.
+ */
enum pdf_status_e
{
PDF_OK = 0,
@@ -75,12 +79,12 @@
PDF_ETEXTENC,
PDF_ENOMATCH,
PDF_EINVAL,
- PDF_STATUS_ITEMS,
PDF_EBADPERMS,
PDF_EBADNAME,
PDF_EAGAIN,
PDF_ENOSPC,
- PDF_ENOTEMPTY
+ PDF_ENOTEMPTY,
+ PDF_STATUS_ITEMS
};
typedef enum pdf_status_e pdf_status_t;
Index: torture/unit/Makefile.am
===================================================================
RCS file: /sources/pdf/libgnupdf/torture/unit/Makefile.am,v
retrieving revision 1.12
diff -u -r1.12 Makefile.am
--- torture/unit/Makefile.am 5 May 2008 09:31:10 -0000 1.12
+++ torture/unit/Makefile.am 14 Jun 2008 00:02:12 -0000
@@ -56,6 +56,9 @@
TESTS = runtests
+TEST_SUITE_ERROR = base/error/pdf-error.c \
+ base/error/pdf-perror.c
+
# Unit tests for the Stream Module test suite
TEST_SUITE_STM = base/stm/pdf-create-file-stm.c
@@ -147,6 +150,7 @@
$(TEST_SUITE_LIST) \
$(TEST_SUITE_TEXT) \
$(TEST_SUITE_HASH) \
+ $(TEST_SUITE_ERROR) \
$(TEST_SUITE_TYPES)
TSUITE_FILES = base/alloc/tsuite-alloc.c \
@@ -154,6 +158,7 @@
base/list/tsuite-list.c \
base/text/tsuite-text.c \
base/hash/tsuite-hash.c \
+ base/error/tsuite-error.c \
base/types/tsuite-types.c
runtests_SOURCES = $(NOCHECK_SRC) \
Index: torture/unit/runtests.c
===================================================================
RCS file: /sources/pdf/libgnupdf/torture/unit/runtests.c,v
retrieving revision 1.9
diff -u -r1.9 runtests.c
--- torture/unit/runtests.c 5 May 2008 09:31:10 -0000 1.9
+++ torture/unit/runtests.c 14 Jun 2008 00:02:12 -0000
@@ -15,6 +15,7 @@
extern Suite *tsuite_text (void);
extern Suite *tsuite_hash (void);
extern Suite *tsuite_types (void);
+extern Suite *tsuite_error (void);
int
main (int argc, char **argv)
@@ -34,6 +35,7 @@
srunner_add_suite (sr, tsuite_text ());
srunner_add_suite (sr, tsuite_hash ());
srunner_add_suite (sr, tsuite_types ());
+ srunner_add_suite (sr, tsuite_error ());
/* Set log file */
srunner_set_log (sr, "ut.log");
/* Run all test suites */
###
New files,
##
/* -*- mode: C -*- Time-stamp: "2008-06-13 20:29:38 gerel"
*
* File: pdf-perror.c
* Date: Wed Mar 12 12:43:00 2008
*
* GNU PDF Library - Unit tests for pdf_perror
*
*/
/* Copyright (C) 2008 Free Software Foundation, Inc. */
/* 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, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <pdf.h>
#include <check.h>
/*
* Test: pdf_perror_001
* Description:
* Try to trigger an error code with NULL string.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_perror_001)
{
pdf_perror (PDF_OK, NULL);
}
END_TEST
/*
* Test: pdf_perror_002
* Description:
* Try to trigger an error code with valid string.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_perror_002)
{
pdf_perror (PDF_OK, "test");
}
END_TEST
/*
* Test case creation function
*/
TCase *
test_pdf_perror (void)
{
TCase *tc = tcase_create("pdf_perror");
tcase_add_test(tc, pdf_perror_001);
tcase_add_test(tc, pdf_perror_002);
return tc;
}
/* End of pdf-perror.c */
/* -*- mode: C -*- Time-stamp: "2008-06-13 20:37:18 gerel"
*
* File: pdf-error.c
* Date: Wed Mar 12 12:43:00 2008
*
* GNU PDF Library - Unit tests for pdf_error
*
*/
/* Copyright (C) 2008 Free Software Foundation, Inc. */
/* 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, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <pdf.h>
#include <check.h>
/*
* Test: pdf_error_001
* Description:
* Try to trigger an error code with NULL fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_001)
{
pdf_error (PDF_OK, NULL, "test");
}
END_TEST
/*
* Test: pdf_error_002
* Description:
* Try to trigger an error code with NULL format.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_002)
{
pdf_error (PDF_OK, stdout, NULL);
}
END_TEST
/*
* Test: pdf_error_003
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_003)
{
pdf_error (PDF_OK, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_004
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_004)
{
pdf_error (PDF_ERROR, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_005
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_005)
{
pdf_error (PDF_EBADDATA, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_006
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_006)
{
pdf_error (PDF_ENOMEM, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_007
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_007)
{
pdf_error (PDF_EEOF, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_008
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_008)
{
pdf_error (PDF_EDIVBYZERO, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_009
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_009)
{
pdf_error (PDF_ENONODE, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_010
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_010)
{
pdf_error (PDF_EINVRANGE, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_011
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_011)
{
pdf_error (PDF_ETEXTENC, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_012
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_012)
{
pdf_error (PDF_ENOMATCH, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_013
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_013)
{
pdf_error (PDF_EINVAL, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_014
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_014)
{
pdf_error (PDF_EBADPERMS, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_015
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_015)
{
pdf_error (PDF_EBADNAME, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_016
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_016)
{
pdf_error (PDF_EAGAIN, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_017
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_017)
{
pdf_error (PDF_ENOSPC, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_018
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_018)
{
pdf_error (PDF_ENOTEMPTY, stdout, "test");
}
END_TEST
/*
* Test: pdf_error_019
* Description:
* Try to trigger an error code with valid format and fd.
* Success condition:
* The program doesn't crash.
*/
START_TEST (pdf_error_019)
{
pdf_error (PDF_STATUS_ITEMS, stdout, "test");
}
END_TEST
/*
* Test case creation function
*/
TCase *
test_pdf_error (void)
{
TCase *tc = tcase_create("pdf_error");
tcase_add_test(tc, pdf_error_001);
tcase_add_test(tc, pdf_error_002);
tcase_add_test(tc, pdf_error_003);
tcase_add_test(tc, pdf_error_004);
tcase_add_test(tc, pdf_error_005);
tcase_add_test(tc, pdf_error_006);
tcase_add_test(tc, pdf_error_007);
tcase_add_test(tc, pdf_error_008);
tcase_add_test(tc, pdf_error_009);
tcase_add_test(tc, pdf_error_010);
tcase_add_test(tc, pdf_error_011);
tcase_add_test(tc, pdf_error_012);
tcase_add_test(tc, pdf_error_013);
tcase_add_test(tc, pdf_error_014);
tcase_add_test(tc, pdf_error_015);
tcase_add_test(tc, pdf_error_016);
tcase_add_test(tc, pdf_error_017);
tcase_add_test(tc, pdf_error_018);
tcase_add_test(tc, pdf_error_019);
return tc;
}
/* End of pdf-error.c */
/* -*- mode: C -*- Time-stamp: "2008-06-03 12:06:12 gerel"
*
* File: tsuite-error.c
* Date: Wed Mar 12 12:43:00 2008
*
* GNU PDF Library - Testcase definition for the Error module
*
*/
/* Copyright (C) 2008 Free Software Foundation, Inc. */
/* 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, see <http://www.gnu.org/licenses/>.
*/
#include <check.h>
extern TCase *test_pdf_error (void);
extern TCase *test_pdf_perror (void);
Suite *
tsuite_error ()
{
Suite *s;
s = suite_create("error");
suite_add_tcase (s, test_pdf_perror ());
suite_add_tcase (s, test_pdf_error ());
return s;
}
/* End of tsuite-error.c */
###
Cheers
-gerel
- [pdf-devel] Error module Tests,
gerel <=