[Cmake-commits] [cmake-commits] king committed CMakeLists.txt 1.2 1.3 testXMLSafe.cxx NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Dec 8 15:44:47 EST 2009


Update of /cvsroot/CMake/CMake/Tests/CMakeLib
In directory public:/mounts/ram/cvs-serv1714/Tests/CMakeLib

Modified Files:
	CMakeLists.txt 
Added Files:
	testXMLSafe.cxx 
Log Message:
Test XML encoding with UTF-8 character validation

This creates a unit test for cmXMLSafe.  See issue #10003.


Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/CMakeLib/CMakeLists.txt,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** CMakeLists.txt	8 Dec 2009 20:44:22 -0000	1.2
--- CMakeLists.txt	8 Dec 2009 20:44:45 -0000	1.3
***************
*** 8,11 ****
--- 8,12 ----
    testUTF8
    testXMLParser
+   testXMLSafe
    )
  

--- NEW FILE: testXMLSafe.cxx ---
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium

  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.

  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
#include <cmXMLSafe.h>

#include "cmStandardIncludes.h"

struct test_pair
{
  const char* in;
  const char* out;
};

static test_pair const pairs[] = {
  {"copyright \xC2\xA9", "copyright \xC2\xA9"},
  {"form-feed \f", "form-feed [NON-XML-CHAR-0xC]"},
  {"angles <>", "angles &lt;&gt;"},
  {"ampersand &", "ampersand &amp;"},
  {"bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]"},
  {0,0}
};

int testXMLSafe(int, char*[])
{
  int result = 0;
  for(test_pair const* p = pairs; p->in; ++p)
    {
    cmXMLSafe xs(p->in);
    cmOStringStream oss;
    oss << xs;
    std::string out = oss.str();
    if(out != p->out)
      {
      printf("expected [%s], got [%s]\n", p->out, out.c_str());
      result = 1;
      }
    }
  return result;
}



More information about the Cmake-commits mailing list