LCOV - code coverage report
Current view: top level - tests - catch_is_string_literal.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 16 16
Test Date: 2026-02-16 17:48:13 Functions: 100.0 % 1 1
Legend: Lines: hit not hit

            Line data    Source code
       1              : // Copyright (c) 2026  Made to Order Software Corp.  All Rights Reserved
       2              : //
       3              : // https://snapwebsites.org/project/snapdev
       4              : // contact@m2osw.com
       5              : //
       6              : // This program is free software: you can redistribute it and/or modify
       7              : // it under the terms of the GNU General Public License as published by
       8              : // the Free Software Foundation, either version 3 of the License, or
       9              : // (at your option) any later version.
      10              : //
      11              : // This program is distributed in the hope that it will be useful,
      12              : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13              : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14              : // GNU General Public License for more details.
      15              : //
      16              : // You should have received a copy of the GNU General Public License
      17              : // along with this program.  If not, see <https://www.gnu.org/licenses/>.
      18              : 
      19              : /** \file
      20              :  * \brief Verify that the is_string_literal works.
      21              :  *
      22              :  * This file makes sure we can compile with the is_string_literal and
      23              :  * all the different type of strings.
      24              :  */
      25              : 
      26              : // self
      27              : //
      28              : #include    <snapdev/is_string_literal.h>
      29              : 
      30              : #include    "catch_main.h"
      31              : 
      32              : 
      33              : // last include
      34              : //
      35              : #include    <snapdev/poison.h>
      36              : 
      37              : 
      38              : 
      39              : namespace
      40              : {
      41              : 
      42              : 
      43              : constexpr char const            g_char_literal[] = "it is!";
      44              : constexpr wchar_t const         g_wchar_literal[] = L"it is!";
      45              : constexpr char8_t const         g_char8_literal[] = u8"it is!";
      46              : constexpr char16_t const        g_char16_literal[] = u"it is!";
      47              : constexpr char32_t const        g_char32_literal[] = U"it is!";
      48              : 
      49              : 
      50              : } // no name namespace
      51              : 
      52              : 
      53              : 
      54            2 : CATCH_TEST_CASE("is_string_literal", "[string]")
      55              : {
      56            2 :     CATCH_START_SECTION("is_string_literal: check all string literals inline")
      57              :     {
      58            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal("it is!"));        // char
      59            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(L"it is!"));       // wchar_t
      60            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(u8"it is!"));      // char8_t
      61            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(u"it is!"));       // char16_t
      62            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(U"it is!"));       // char32_t
      63              : 
      64              :         // a way to test other types to make sure it actually works
      65              :         //char const * const s = "blah";
      66              :         //CATCH_REQUIRE(snapdev::is_a_string_literal(s));
      67              :     }
      68            2 :     CATCH_END_SECTION()
      69              : 
      70            2 :     CATCH_START_SECTION("is_string_literal: check all constexpr string literals")
      71              :     {
      72            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(g_char_literal));    // char
      73            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(g_wchar_literal));   // wchar_t
      74            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(g_char8_literal));   // char8_t
      75            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(g_char16_literal));  // char16_t
      76            1 :         CATCH_REQUIRE(snapdev::is_a_string_literal(g_char32_literal));  // char32_t
      77              :     }
      78            2 :     CATCH_END_SECTION()
      79            2 : }
      80              : 
      81              : 
      82              : 
      83              : // vim: ts=4 sw=4 et
        

Generated by: LCOV version 2.0-1

Snap C++ | List of projects | List of versions