LCOV - code coverage report
Current view: top level - autotest/cpp - testlog.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 13 13 100.0 %
Date: 2024-11-21 22:18:42 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  GDAL
       5             :  * Purpose:  Test CPL_LOG
       6             :  * Author:   Even Rouault, even.rouault at spatialys.com
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2021, Even Rouault <even.rouault at spatialys.com>
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #include "cpl_conv.h"
      15             : #include "cpl_error.h"
      16             : #include "cpl_vsi.h"
      17             : 
      18             : #include "gtest_include.h"
      19             : 
      20             : namespace
      21             : {
      22             : 
      23             : // ---------------------------------------------------------------------------
      24             : 
      25           4 : TEST(testlog, test)
      26             : {
      27           1 :     const char *logname = "log_with_âccent.txt";
      28           1 :     CPLSetConfigOption("CPL_LOG", logname);
      29           1 :     CPLError(CE_Failure, CPLE_AppDefined, "test");
      30           1 :     VSILFILE *fp = VSIFOpenL(logname, "rb");
      31             :     char szGot[20 + 1];
      32           1 :     size_t nRead = VSIFReadL(szGot, 1, 20, fp);
      33           1 :     szGot[nRead] = 0;
      34           1 :     VSIFCloseL(fp);
      35           1 :     CPLCleanupErrorMutex();
      36           1 :     VSIUnlink(logname);
      37             : 
      38           1 :     EXPECT_TRUE(strstr(szGot, "ERROR 1") != nullptr) << szGot;
      39           1 :     EXPECT_TRUE(strstr(szGot, "test") != nullptr) << szGot;
      40           1 : }
      41             : 
      42             : }  // namespace

Generated by: LCOV version 1.14