]> git.ipfire.org Git - location/libloc.git/commitdiff
tests: Ensure loc_database_lookup finds a match
authorValters Jansons <valter.jansons@gmail.com>
Mon, 7 Apr 2025 01:29:29 +0000 (04:29 +0300)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 7 Apr 2025 08:55:23 +0000 (08:55 +0000)
Commit 9e72b8a modified the lookup function to return 0 even if no
matches are found. As result, the test case could pass even if the
database lookup did not find any matches.

This commit restores the original intent of the test case, by adding
a failure condition when `network1` is NULL. This is similar to how
the subsequent test case was modified for the inverse condition.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/test-network.c

index 0cac1a48e5e2582326410fb955a75c822d1b348a..73062f4c41bffe238f45a153e5f72c7097c7aec0 100644 (file)
@@ -351,7 +351,7 @@ int main(int argc, char** argv) {
 
        // Lookup an address in the subnet
        err = loc_database_lookup_from_string(db, "2001:db8::", &network1);
-       if (err) {
+       if (err || !network1) {
                fprintf(stderr, "Could not look up 2001:db8::\n");
                exit(EXIT_FAILURE);
        }