test_archive_read_set_format_option.c revision 259065
1214152Sed/*- 2214152Sed * Copyright (c) 2011 Tim Kientzle 3214152Sed * All rights reserved. 4214152Sed * 5222656Sed * Redistribution and use in source and binary forms, with or without 6222656Sed * modification, are permitted provided that the following conditions 7214152Sed * are met: 8214152Sed * 1. Redistributions of source code must retain the above copyright 9214152Sed * notice, this list of conditions and the following disclaimer. 10214152Sed * 2. Redistributions in binary form must reproduce the above copyright 11214152Sed * notice, this list of conditions and the following disclaimer in the 12214152Sed * documentation and/or other materials provided with the distribution. 13214152Sed * 14214152Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15239138Sandrew * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16239138Sandrew * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17263763Sdim * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18214152Sed * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19214152Sed * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20214152Sed * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21214152Sed * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22214152Sed * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23214152Sed * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24214152Sed */ 25214152Sed 26214152Sed#include "test.h" 27214152Sed__FBSDID("$FreeBSD$"); 28214152Sed 29214152Sed#define should(__a, __code, __m, __o, __v) \ 30214152SedassertEqualInt(__code, archive_read_set_format_option(__a, __m, __o, __v)) 31214152Sed 32214152Sedstatic void 33214152Sedtest(int pristine) 34214152Sed{ 35214152Sed struct archive* a = archive_read_new(); 36214152Sed int known_option_rv = pristine ? ARCHIVE_FAILED : ARCHIVE_OK; 37214152Sed 38214152Sed if (!pristine) 39214152Sed archive_read_support_format_all(a); 40214152Sed 41214152Sed /* NULL and "" denote `no option', so they're ok no matter 42214152Sed * what, if any, formats are registered */ 43214152Sed should(a, ARCHIVE_OK, NULL, NULL, NULL); 44214152Sed should(a, ARCHIVE_OK, "", "", ""); 45214152Sed 46214152Sed /* unknown modules and options */ 47214152Sed should(a, ARCHIVE_FAILED, "fubar", "snafu", NULL); 48214152Sed should(a, ARCHIVE_FAILED, "fubar", "snafu", "betcha"); 49214152Sed 50214152Sed /* unknown modules and options */ 51214152Sed should(a, ARCHIVE_FAILED, NULL, "snafu", NULL); 52214152Sed should(a, ARCHIVE_FAILED, NULL, "snafu", "betcha"); 53214152Sed 54214152Sed /* ARCHIVE_OK with iso9660 loaded, ARCHIVE_WARN otherwise */ 55214152Sed should(a, known_option_rv, "iso9660", "joliet", NULL); 56214152Sed should(a, known_option_rv, "iso9660", "joliet", NULL); 57214152Sed should(a, known_option_rv, NULL, "joliet", NULL); 58214152Sed should(a, known_option_rv, NULL, "joliet", NULL); 59214152Sed 60214152Sed archive_read_free(a); 61214152Sed} 62214152Sed 63214152SedDEFINE_TEST(test_archive_read_set_format_option) 64214152Sed{ 65214152Sed test(1); 66214152Sed test(0); 67214152Sed} 68214152Sed