summaryrefslogtreecommitdiff
path: root/gl/tests/test-di-set.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-02-07 15:46:09 +0100
committerJim Meyering <meyering@redhat.com>2011-02-07 15:50:44 +0100
commitb9fc790ddc0db2522b0d20d08fd2b8d40ef0fa4e (patch)
tree96b967b3a0e5ca208933a97494fee2dd142c4855 /gl/tests/test-di-set.c
parent2e636af1ef3f6a5ef872bdd2297dd25198c69395 (diff)
downloadcoreutils-b9fc790ddc0db2522b0d20d08fd2b8d40ef0fa4e.tar.xz
di-set: provide a lookup method
This is required for patch, and hence is about to move to gnulib. * gl/lib/di-set.c (di_set_lookup): New function. * gl/lib/di-set.h: Declare it. * gl/tests/test-di-set.c (main): Exercise it. The bug was introduced on 2004-12-04 via commit 7380cf79.
Diffstat (limited to 'gl/tests/test-di-set.c')
-rw-r--r--gl/tests/test-di-set.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gl/tests/test-di-set.c b/gl/tests/test-di-set.c
index 7fca4d462..5de8da2ff 100644
--- a/gl/tests/test-di-set.c
+++ b/gl/tests/test-di-set.c
@@ -42,10 +42,12 @@ main (void)
struct di_set *dis = di_set_alloc ();
ASSERT (dis);
+ ASSERT (di_set_lookup (dis, 2, 5) == 0); /* initial lookup fails */
ASSERT (di_set_insert (dis, 2, 5) == 1); /* first insertion succeeds */
ASSERT (di_set_insert (dis, 2, 5) == 0); /* duplicate fails */
ASSERT (di_set_insert (dis, 3, 5) == 1); /* diff dev, duplicate inode is ok */
ASSERT (di_set_insert (dis, 2, 8) == 1); /* same dev, different inode is ok */
+ ASSERT (di_set_lookup (dis, 2, 5) == 1); /* now, the lookup succeeds */
/* very large (or negative) inode number */
ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 1);