1 /* Test of exact or abbreviated match search.
2 Copyright (C) 1990, 1998-1999, 2001-2007 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* Written by Bruno Haible <bruno@clisp.org>, 2007, based on test code
19 by David MacKenzie <djm@gnu.ai.mit.edu>. */
31 #define ASSERT(expr) if (!(expr)) abort ();
37 numbered_existing_backups,
41 static const char *const backup_args[] =
44 "simple", "never", "single",
45 "existing", "nil", "numbered-existing",
46 "numbered", "t", "newstyle",
50 static const enum backup_type backup_vals[] =
52 no_backups, no_backups, no_backups,
53 simple_backups, simple_backups, simple_backups,
54 numbered_existing_backups, numbered_existing_backups, numbered_existing_backups,
55 numbered_backups, numbered_backups, numbered_backups
59 main (int argc, char *argv[])
61 set_program_name (argv[0]);
64 ASSERT (ARGMATCH ("klingon", backup_args, backup_vals) == -1);
67 ASSERT (ARGMATCH ("none", backup_args, backup_vals) == 1);
68 ASSERT (ARGMATCH ("nil", backup_args, backup_vals) == 7);
71 ASSERT (ARGMATCH ("nilpotent", backup_args, backup_vals) == -1);
74 ASSERT (ARGMATCH ("simpl", backup_args, backup_vals) == 3);
75 ASSERT (ARGMATCH ("simp", backup_args, backup_vals) == 3);
76 ASSERT (ARGMATCH ("sim", backup_args, backup_vals) == 3);
78 /* Exact match and abbreviated. */
79 ASSERT (ARGMATCH ("numbered", backup_args, backup_vals) == 9);
80 ASSERT (ARGMATCH ("numbere", backup_args, backup_vals) == -2);
81 ASSERT (ARGMATCH ("number", backup_args, backup_vals) == -2);
82 ASSERT (ARGMATCH ("numbe", backup_args, backup_vals) == -2);
83 ASSERT (ARGMATCH ("numb", backup_args, backup_vals) == -2);
84 ASSERT (ARGMATCH ("num", backup_args, backup_vals) == -2);
85 ASSERT (ARGMATCH ("nu", backup_args, backup_vals) == -2);
86 ASSERT (ARGMATCH ("n", backup_args, backup_vals) == -2);
88 /* Ambiguous abbreviated. */
89 ASSERT (ARGMATCH ("ne", backup_args, backup_vals) == -2);
91 /* Ambiguous abbreviated, but same value. */
92 ASSERT (ARGMATCH ("si", backup_args, backup_vals) == 3);
93 ASSERT (ARGMATCH ("s", backup_args, backup_vals) == 3);