dpkg (1.18.25) stretch; urgency=medium
[dpkg] / lib / dpkg / t / t-ar.c
CommitLineData
1479465f
GJ
1/*
2 * libdpkg - Debian packaging suite library routines
3 * t-ar.c - test ar implementation
4 *
5 * Copyright © 2010 Guillem Jover <guillem@debian.org>
6 *
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <config.h>
22#include <compat.h>
23
24#include <dpkg/test.h>
25#include <dpkg/ar.h>
26
27static void
28test_ar_normalize_name(void)
29{
30 struct dpkg_ar_hdr arh;
31
32 strncpy(arh.ar_name, "member-name/ ", sizeof(arh.ar_name));
33 dpkg_ar_normalize_name(&arh);
34 test_str(arh.ar_name, ==, "member-name");
35
36 strncpy(arh.ar_name, "member-name ", sizeof(arh.ar_name));
37 dpkg_ar_normalize_name(&arh);
38 test_str(arh.ar_name, ==, "member-name");
39}
40
41static void
42test_ar_member_is_illegal(void)
43{
44 struct dpkg_ar_hdr arh;
45
46 memset(&arh, ' ', sizeof(arh));
47 test_pass(dpkg_ar_member_is_illegal(&arh));
48
49 memcpy(arh.ar_fmag, DPKG_AR_FMAG, sizeof(arh.ar_fmag));
50 test_fail(dpkg_ar_member_is_illegal(&arh));
51}
52
53TEST_ENTRY(test)
54{
55 test_plan(4);
56
57 test_ar_normalize_name();
58 test_ar_member_is_illegal();
59}