From: Michael R Sweet Date: Sat, 26 Nov 2022 15:33:09 +0000 (-0500) Subject: Add unit test for ippDeleteValues. X-Git-Tag: v2.4.3~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3457b416e0af8f0d46f146c615164867a043801;p=thirdparty%2Fcups.git Add unit test for ippDeleteValues. --- diff --git a/CHANGES.md b/CHANGES.md index 2b497faa77..3dcc3fba8f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ Changes in CUPS v2.4.3 (TBA) - Fixed invalid memory access during generating IPP Everywhere queue (Issue #466) - Fixed memory leaks in `create_local_bg_thread()` (Issue #466) - Fixed TLS certificate generation bugs. +- `ippDeleteValues` would not delete the last value (Issue #556) - Ignore some of IPP defaults if the application sends its PPD alternative (Issue #484) - Now look for default printer on network if needed (Issue #452) - Now report fax attributes and values as needed (Issue #459) diff --git a/cups/testipp.c b/cups/testipp.c index aad53e46fc..e33d5ceed7 100644 --- a/cups/testipp.c +++ b/cups/testipp.c @@ -1,6 +1,7 @@ /* * IPP test program for CUPS. * + * Copyright © 2022 by OpenPrinting. * Copyright © 2007-2019 by Apple Inc. * Copyright © 1997-2005 by Easy Software Products. * @@ -318,6 +319,13 @@ main(int argc, /* I - Number of command-line arguments */ #ifdef DEBUG const char *name; /* Option name */ #endif /* DEBUG */ + static const char * const test_strings[] = + { /* Test strings */ + "one-string", + "two-string", + "red-string", + "blue-string" + }; status = 0; @@ -746,6 +754,28 @@ main(int argc, /* I - Number of command-line arguments */ else puts("PASS"); + fputs("ippDeleteValues: ", stdout); + attr = ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "test-strings", 4, NULL, test_strings); + if (ippGetCount(attr) != 4) + { + printf("FAIL (got %d values, expected 4 values)\n", ippGetCount(attr)); + status = 1; + } + else if (!ippDeleteValues(request, &attr, 3, 1)) + { + puts("FAIL (returned 0)"); + status = 1; + } + else if (ippGetCount(attr) != 3) + { + printf("FAIL (got %d values, expected 3 values)\n", ippGetCount(attr)); + status = 1; + } + else + { + puts("PASS"); + } + ippDelete(request); #ifdef DEBUG