1231200Smm/*- 2231200Smm * Copyright (c) 2011 Tim Kientzle 3231200Smm * All rights reserved. 4231200Smm * 5231200Smm * Redistribution and use in source and binary forms, with or without 6231200Smm * modification, are permitted provided that the following conditions 7231200Smm * are met: 8231200Smm * 1. Redistributions of source code must retain the above copyright 9231200Smm * notice, this list of conditions and the following disclaimer. 10231200Smm * 2. Redistributions in binary form must reproduce the above copyright 11231200Smm * notice, this list of conditions and the following disclaimer in the 12231200Smm * documentation and/or other materials provided with the distribution. 13231200Smm * 14231200Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15231200Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16231200Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17231200Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18231200Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19231200Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20231200Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21231200Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22231200Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23231200Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24231200Smm */ 25231200Smm 26231200Smm#include "test.h" 27231200Smm__FBSDID("$FreeBSD$"); 28231200Smm 29231200Smmstatic void 30231200Smmtest(struct archive *a, int code, const char *msg) 31231200Smm{ 32231200Smm archive_set_error(a, code, "%s", msg); 33231200Smm 34231200Smm assertEqualInt(code, archive_errno(a)); 35231200Smm assertEqualString(msg, archive_error_string(a)); 36231200Smm} 37231200Smm 38231200SmmDEFINE_TEST(test_archive_set_error) 39231200Smm{ 40231200Smm struct archive* a = archive_read_new(); 41231200Smm 42231200Smm /* unlike printf("%s", NULL), 43231200Smm * archive_set_error(a, code, "%s", NULL) 44231200Smm * segfaults, so it's not tested here */ 45231200Smm test(a, 12, "abcdefgh"); 46231200Smm test(a, 0, "123456"); 47231200Smm test(a, -1, "tuvw"); 48231200Smm test(a, 34, "XYZ"); 49231200Smm 50248616Smm archive_read_free(a); 51231200Smm} 52