]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add unit test for ippDeleteValues.
authorMichael R Sweet <michael.r.sweet@gmail.com>
Sat, 26 Nov 2022 15:33:09 +0000 (10:33 -0500)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Sat, 26 Nov 2022 15:33:09 +0000 (10:33 -0500)
CHANGES.md
cups/testipp.c

index 2b497faa7713a89dd60b7530006a1a8453b65333..3dcc3fba8f3d7ad2f7a0a12923551334c697fc36 100644 (file)
@@ -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)
index aad53e46fcbae45fdc5aaedcba17076023cb504a..e33d5ceed77cb1ce5e72da2117f0664c9c345866 100644 (file)
@@ -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