UPSTREAM: Add unit test for ippDeleteValues.
(cherry picked from commit a3457b416e0af8f0d46f146c615164867a043801)
Dropped changes made to the CHANGES.md file, because the difference
between two versions of this file is too big.
BUG=b:266786090
TEST=tested manually
Change-Id: Iacb59ea52380587bcdaf7d1fff253fe63bd4faae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/cups/+/4218376
Tested-by: Andrei Nedoluzhko <nedol@google.com>
Reviewed-by: Sparik Hayrapetyan <ust@google.com>
Commit-Queue: Andrei Nedoluzhko <nedol@google.com>
Reviewed-by: Benjamin Gordon <bmgordon@chromium.org>
diff --git a/cups/testipp.c b/cups/testipp.c
index aad53e4..e33d5ce 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 @@
#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 @@
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