test_pdf.c (3387B)
1 /* 2 This file is part of libextractor. 3 Copyright (C) 2026 Vidyut Samanta and Christian Grothoff 4 5 libextractor is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 libextractor is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with libextractor; see the file COPYING. If not, write to the 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 /** 21 * @file plugins/test_pdf.c 22 * @brief testcase for pdf plugin 23 * @author Christian Grothoff 24 */ 25 #include "platform.h" 26 #include "test_lib.h" 27 28 29 /** 30 * Main function for the PDF testcase. 31 * 32 * @param argc number of arguments (ignored) 33 * @param argv arguments (ignored) 34 * @return 0 on success 35 */ 36 int 37 main (int argc, char *argv[]) 38 { 39 struct SolutionData pdf_extract_sol[] = { 40 { 41 EXTRACTOR_METATYPE_MIMETYPE, 42 EXTRACTOR_METAFORMAT_UTF8, 43 "text/plain", 44 "application/pdf", 45 strlen ("application/pdf") + 1, 46 0 47 }, 48 { 49 EXTRACTOR_METATYPE_TITLE, 50 EXTRACTOR_METAFORMAT_UTF8, 51 "text/plain", 52 "GNU libextractor PDF Test", 53 strlen ("GNU libextractor PDF Test") + 1, 54 0 55 }, 56 { 57 EXTRACTOR_METATYPE_SUBJECT, 58 EXTRACTOR_METAFORMAT_UTF8, 59 "text/plain", 60 "Metadata extraction", 61 strlen ("Metadata extraction") + 1, 62 0 63 }, 64 { 65 EXTRACTOR_METATYPE_KEYWORDS, 66 EXTRACTOR_METAFORMAT_UTF8, 67 "text/plain", 68 "PDF, libextractor, test", 69 strlen ("PDF, libextractor, test") + 1, 70 0 71 }, 72 { 73 EXTRACTOR_METATYPE_AUTHOR_NAME, 74 EXTRACTOR_METAFORMAT_UTF8, 75 "text/plain", 76 "Vidyut Samanta", 77 strlen ("Vidyut Samanta") + 1, 78 0 79 }, 80 { 81 EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, 82 EXTRACTOR_METAFORMAT_UTF8, 83 "text/plain", 84 "WritePDF", 85 strlen ("WritePDF") + 1, 86 0 87 }, 88 { 89 EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE, 90 EXTRACTOR_METAFORMAT_UTF8, 91 "text/plain", 92 "libextractor testsuite", 93 strlen ("libextractor testsuite") + 1, 94 0 95 }, 96 { 97 EXTRACTOR_METATYPE_FORMAT, 98 EXTRACTOR_METAFORMAT_UTF8, 99 "text/plain", 100 "PDF 1.4", 101 strlen ("PDF 1.4") + 1, 102 0 103 }, 104 { 105 EXTRACTOR_METATYPE_PAGE_COUNT, 106 EXTRACTOR_METAFORMAT_UTF8, 107 "text/plain", 108 "1", 109 strlen ("1") + 1, 110 0 111 }, 112 { 113 EXTRACTOR_METATYPE_CREATION_DATE, 114 EXTRACTOR_METAFORMAT_UTF8, 115 "text/plain", 116 "2020-01-15 12:30:00", 117 strlen ("2020-01-15 12:30:00") + 1, 118 0 119 }, 120 { 121 EXTRACTOR_METATYPE_MODIFICATION_DATE, 122 EXTRACTOR_METAFORMAT_UTF8, 123 "text/plain", 124 "2020-01-16 08:00:00", 125 strlen ("2020-01-16 08:00:00") + 1, 126 0 127 }, 128 { 0, 0, NULL, NULL, 0, -1 } 129 }; 130 struct ProblemSet ps[] = { 131 { "testdata/pdf_extract.pdf", 132 pdf_extract_sol }, 133 { NULL, NULL } 134 }; 135 return ET_main ("pdf", ps); 136 } 137 138 139 /* end of test_pdf.c */