1279264Sdelphij/*- 296593Smarkm * Copyright (c) 2011 Tim Kientzle 396593Smarkm * All rights reserved. 4142429Snectar * 596593Smarkm * Redistribution and use in source and binary forms, with or without 696593Smarkm * modification, are permitted provided that the following conditions 796593Smarkm * are met: 896593Smarkm * 1. Redistributions of source code must retain the above copyright 996593Smarkm * notice, this list of conditions and the following disclaimer. 1096593Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1196593Smarkm * notice, this list of conditions and the following disclaimer in the 1296593Smarkm * documentation and/or other materials provided with the distribution. 1396593Smarkm * 1496593Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 1596593Smarkm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1696593Smarkm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1796593Smarkm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 1896593Smarkm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1996593Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20215698Ssimon * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21215698Ssimon * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22215698Ssimon * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23215698Ssimon * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24215698Ssimon */ 2596593Smarkm 2696593Smarkm#include "test.h" 2796593Smarkm__FBSDID("$FreeBSD$"); 2896593Smarkm 2996593Smarkmstatic void 3096593Smarkmtest(struct archive *a, int code, const char *msg) 3196593Smarkm{ 3296593Smarkm archive_set_error(a, code, "%s", msg); 3396593Smarkm 3496593Smarkm assertEqualInt(code, archive_errno(a)); 3596593Smarkm assertEqualString(msg, archive_error_string(a)); 3696593Smarkm} 3796593Smarkm 3896593SmarkmDEFINE_TEST(test_archive_set_error) 3996593Smarkm{ 4096593Smarkm struct archive* a = archive_read_new(); 41279264Sdelphij 42279264Sdelphij /* unlike printf("%s", NULL), 4396593Smarkm * archive_set_error(a, code, "%s", NULL) 4496593Smarkm * segfaults, so it's not tested here */ 45215698Ssimon test(a, 12, "abcdefgh"); 46215698Ssimon test(a, 0, "123456"); 47215698Ssimon test(a, -1, "tuvw"); 48215698Ssimon test(a, 34, "XYZ"); 49142429Snectar 50215698Ssimon archive_read_free(a); 51142429Snectar} 52142429Snectar