wpkg test coverage results

Coverage test results of the Windows Packager by Made to Order Software Corporation.

LCOV - code coverage report
Current view: top level - tests/unittests - unittest_libutf8.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 24 24 100.0 %
Date: 2013-06-17 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*    unittest_libutf8.cpp
       2             :  *    Copyright (C) 2013  Made to Order Software Corporation
       3             :  *
       4             :  *    This program is free software; you can redistribute it and/or modify
       5             :  *    it under the terms of the GNU General Public License as published by
       6             :  *    the Free Software Foundation; either version 2 of the License, or
       7             :  *    (at your option) any later version.
       8             :  *
       9             :  *    This program is distributed in the hope that it will be useful,
      10             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  *    GNU General Public License for more details.
      13             :  *
      14             :  *    You should have received a copy of the GNU General Public License along
      15             :  *    with this program; if not, write to the Free Software Foundation, Inc.,
      16             :  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  *
      18             :  *    Authors
      19             :  *    Alexis Wilke   alexis@m2osw.com
      20             :  */
      21             : 
      22             : #include "unittest_libutf8.h"
      23             : #include "libutf8/libutf8.h"
      24             : 
      25             : //#include <cppunit/config/SourcePrefix.h>
      26             : //#include <string.h>
      27             : //#include <math.h>
      28             : 
      29             : 
      30           1 : CPPUNIT_TEST_SUITE_REGISTRATION( LibUtf8UnitTests );
      31             : 
      32             : 
      33             : 
      34           1 : void LibUtf8UnitTests::setUp()
      35             : {
      36           1 : }
      37             : 
      38             : 
      39             : 
      40           1 : void LibUtf8UnitTests::conversions()
      41             : {
      42           1 :     std::string str;
      43           1 :     std::wstring wstr, back;
      44             :     int i;
      45             : 
      46             :     // create a string with all the characters defined in plane 1
      47       65534 :     for(i = 1; i < 0x0FFFE; ++i)
      48             :     {
      49             :         // skip the surrogate because those are not encoded under
      50             :         // MS-Windows (these are not valid characters anyway)
      51       65533 :         if(i < 0xD800 || i > 0xDFFF)
      52             :         {
      53       63485 :             wstr += static_cast<wchar_t>(i);
      54             :         }
      55             :     }
      56             : 
      57           1 :     str = libutf8::wcstombs(wstr);
      58             : 
      59             :     // verify the UTF-8 string
      60           1 :     const char *s(str.c_str());
      61         128 :     for(i = 1; i < 0x080; ++i)
      62             :     {
      63         127 :         CPPUNIT_ASSERT(*s++ == static_cast<char>(i));
      64             :     }
      65        1921 :     for(; i < 0x0800; ++i)
      66             :     {
      67        1920 :         CPPUNIT_ASSERT(*s++ == static_cast<char>((i >> 6) | 0xC0));
      68        1920 :         CPPUNIT_ASSERT(*s++ == static_cast<char>((i & 0x3F) | 0x80));
      69             :     }
      70       63487 :     for(; i < 0x0FFFE; ++i)
      71             :     {
      72       63486 :         if(i < 0xD800 || i > 0xDFFF)
      73             :         {
      74       61438 :             CPPUNIT_ASSERT(*s++ == static_cast<char>((i >> 12) | 0xE0));
      75       61438 :             CPPUNIT_ASSERT(*s++ == static_cast<char>(((i >> 6) & 0x3F) | 0x80));
      76       61438 :             CPPUNIT_ASSERT(*s++ == static_cast<char>((i & 0x3F) | 0x80));
      77             :         }
      78             :     }
      79             : 
      80             :     // verify the UTF-8 to wchar_t
      81           1 :     back = libutf8::mbstowcs(str);
      82           1 :     CPPUNIT_ASSERT(back == wstr);
      83           4 : }
      84             : 
      85             : 
      86             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.9

The wpkg tool is an open source tool created by Made to Order Software Corporation.