]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/testpwg.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / cups / testpwg.c
index 9cf2faadc278c2a08f9e14523f6fe780720296b7..6473c8cf91ff3b52e012d22e7325b10eeb3c0a55 100644 (file)
@@ -1,23 +1,9 @@
 /*
- * "$Id$"
+ * PWG unit test program for CUPS.
  *
- *   PWG test program for CUPS.
+ * Copyright 2009-2016 by Apple Inc.
  *
- *   Copyright 2009-2011 by Apple Inc.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- *   This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- *   main()           - Main entry.
- *   test_pagesize()  - Test the PWG mapping functions.
- *   test_ppd_cache() - Test the PPD cache functions.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
@@ -45,11 +31,15 @@ int                                 /* O - Exit status */
 main(int  argc,                                /* I - Number of command-line args */
      char *argv[])                     /* I - Command-line arguments */
 {
-  int          status;                 /* Status of tests (0 = success, 1 = fail) */
-  const char   *ppdfile;               /* PPD filename */
-  ppd_file_t   *ppd;                   /* PPD file */
-  _ppd_cache_t *pc;                    /* PPD cache and PWG mapping data */
-  _pwg_media_t *pwgmedia;              /* PWG media size */
+  int                  status;         /* Status of tests (0 = success, 1 = fail) */
+  const char           *ppdfile;       /* PPD filename */
+  ppd_file_t           *ppd;           /* PPD file */
+  _ppd_cache_t         *pc;            /* PPD cache and PWG mapping data */
+  const pwg_media_t    *pwgmedia;      /* PWG media size */
+  size_t               i,              /* Looping var */
+                       num_media;      /* Number of media sizes */
+  const pwg_media_t    *mediatable;    /* Media size table */
+  int                  dupmedia = 0;   /* Duplicate media sizes? */
 
 
   status = 0;
@@ -124,7 +114,7 @@ main(int  argc,                             /* I - Number of command-line args */
          puts("FAIL (Not Found)");
          status = 1;
        }
-       else if (media && strcasecmp(pagesize, media->values[0].string.text))
+       else if (media && _cups_strcasecmp(pagesize, media->values[0].string.text))
        {
          printf("FAIL (Got \"%s\", Expected \"%s\")\n", pagesize,
                 media->values[0].string.text);
@@ -151,8 +141,8 @@ main(int  argc,                             /* I - Number of command-line args */
     puts("PASS");
   }
 
-  fputs("_pwgMediaForPWG(\"iso_a4_210x297mm\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForPWG("iso_a4_210x297mm")) == NULL)
+  fputs("pwgMediaForPWG(\"iso_a4_210x297mm\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPWG("iso_a4_210x297mm")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -170,8 +160,36 @@ main(int  argc,                            /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForLegacy(\"na-letter\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForLegacy("na-letter")) == NULL)
+  fputs("pwgMediaForPWG(\"roll_max_36.1025x3622.0472in\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPWG("roll_max_36.1025x3622.0472in")) == NULL)
+  {
+    puts("FAIL (not found)");
+    status ++;
+  }
+  else if (pwgmedia->width != 91700 || pwgmedia->length != 9199999)
+  {
+    printf("FAIL (%dx%d)\n", pwgmedia->width, pwgmedia->length);
+    status ++;
+  }
+  else
+    printf("PASS (%dx%d)\n", pwgmedia->width, pwgmedia->length);
+
+  fputs("pwgMediaForPWG(\"disc_test_10x100mm\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPWG("disc_test_10x100mm")) == NULL)
+  {
+    puts("FAIL (not found)");
+    status ++;
+  }
+  else if (pwgmedia->width != 10000 || pwgmedia->length != 10000)
+  {
+    printf("FAIL (%dx%d)\n", pwgmedia->width, pwgmedia->length);
+    status ++;
+  }
+  else
+    printf("PASS (%dx%d)\n", pwgmedia->width, pwgmedia->length);
+
+  fputs("pwgMediaForLegacy(\"na-letter\"): ", stdout);
+  if ((pwgmedia = pwgMediaForLegacy("na-letter")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -189,8 +207,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForPPD(\"4x6\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForPPD("4x6")) == NULL)
+  fputs("pwgMediaForPPD(\"4x6\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPPD("4x6")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -208,8 +226,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForPPD(\"10x15cm\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForPPD("10x15cm")) == NULL)
+  fputs("pwgMediaForPPD(\"10x15cm\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPPD("10x15cm")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -227,8 +245,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForPPD(\"Custom.10x15cm\"): ", stdout);
-  if ((pwgmedia = _pwgMediaForPPD("Custom.10x15cm")) == NULL)
+  fputs("pwgMediaForPPD(\"Custom.10x15cm\"): ", stdout);
+  if ((pwgmedia = pwgMediaForPPD("Custom.10x15cm")) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -246,8 +264,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     puts("PASS");
 
-  fputs("_pwgMediaForSize(29700, 42000): ", stdout);
-  if ((pwgmedia = _pwgMediaForSize(29700, 42000)) == NULL)
+  fputs("pwgMediaForSize(29700, 42000): ", stdout);
+  if ((pwgmedia = pwgMediaForSize(29700, 42000)) == NULL)
   {
     puts("FAIL (not found)");
     status ++;
@@ -260,6 +278,61 @@ main(int  argc,                            /* I - Number of command-line args */
   else
     puts("PASS");
 
+  fputs("pwgMediaForSize(9842, 19050): ", stdout);
+  if ((pwgmedia = pwgMediaForSize(9842, 19050)) == NULL)
+  {
+    puts("FAIL (not found)");
+    status ++;
+  }
+  else if (strcmp(pwgmedia->pwg, "na_monarch_3.875x7.5in"))
+  {
+    printf("FAIL (%s)\n", pwgmedia->pwg);
+    status ++;
+  }
+  else
+    printf("PASS (%s)\n", pwgmedia->pwg);
+
+  fputs("pwgMediaForSize(9800, 19000): ", stdout);
+  if ((pwgmedia = pwgMediaForSize(9800, 19000)) == NULL)
+  {
+    puts("FAIL (not found)");
+    status ++;
+  }
+  else if (strcmp(pwgmedia->pwg, "jpn_you6_98x190mm"))
+  {
+    printf("FAIL (%s)\n", pwgmedia->pwg);
+    status ++;
+  }
+  else
+    printf("PASS (%s)\n", pwgmedia->pwg);
+
+  fputs("Duplicate size test: ", stdout);
+  for (mediatable = _pwgMediaTable(&num_media);
+       num_media > 1;
+       num_media --, mediatable ++)
+  {
+    for (i = num_media - 1, pwgmedia = mediatable + 1; i > 0; i --, pwgmedia ++)
+    {
+      if (pwgmedia->width == mediatable->width &&
+          pwgmedia->length == mediatable->length)
+      {
+        if (!dupmedia)
+        {
+          dupmedia = 1;
+          status ++;
+          puts("FAIL");
+        }
+
+        printf("    %s and %s have the same dimensions (%dx%d)\n",
+               pwgmedia->pwg, mediatable->pwg, pwgmedia->width,
+               pwgmedia->length);
+      }
+    }
+  }
+  if (!dupmedia)
+    puts("PASS");
+
+
   return (status);
 }
 
@@ -288,7 +361,7 @@ test_pagesize(_ppd_cache_t *pc,             /* I - PWG mapping data */
       puts("FAIL (Not Found)");
       status = 1;
     }
-    else if (strcasecmp(pagesize, ppdsize))
+    else if (_cups_strcasecmp(pagesize, ppdsize))
     {
       printf("FAIL (Got \"%s\", Expected \"%s\")\n", pagesize, ppdsize);
       status = 1;
@@ -307,7 +380,7 @@ test_pagesize(_ppd_cache_t *pc,             /* I - PWG mapping data */
       puts("FAIL (Not Found)");
       status = 1;
     }
-    else if (strcasecmp(pagesize, ppdsize))
+    else if (_cups_strcasecmp(pagesize, ppdsize))
     {
       printf("FAIL (Got \"%s\", Expected \"%s\")\n", pagesize, ppdsize);
       status = 1;
@@ -333,9 +406,9 @@ test_ppd_cache(_ppd_cache_t *pc,    /* I - PWG mapping data */
   int          i,                      /* Looping var */
                status = 0;             /* Return status */
   _ppd_cache_t *pc2;                   /* Loaded data */
-  _pwg_size_t  *size,                  /* Size from original */
+  pwg_size_t   *size,                  /* Size from original */
                *size2;                 /* Size from saved */
-  _pwg_map_t   *map,                   /* Map from original */
+  pwg_map_t    *map,                   /* Map from original */
                *map2;                  /* Map from saved */
 
 
@@ -490,8 +563,3 @@ test_ppd_cache(_ppd_cache_t *pc,    /* I - PWG mapping data */
 
   return (status);
 }
-
-
-/*
- * End of "$Id$".
- */