LCOV - code coverage report
Current view: top level - buildbot/coverage/build/test/unit/util - didyoumean_black.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 22 22 100.0 %
Date: 2026-02-09 12:26:33 Functions: 4 4 100.0 %
Branches: 11 22 50.0 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Gereon Kremer
       4                 :            :  *
       5                 :            :  * This file is part of the cvc5 project.
       6                 :            :  *
       7                 :            :  * Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
       8                 :            :  * in the top-level source directory and their institutional affiliations.
       9                 :            :  * All rights reserved.  See the file COPYING in the top-level source
      10                 :            :  * directory for licensing information.
      11                 :            :  * ****************************************************************************
      12                 :            :  *
      13                 :            :  * Black box testing of cvc5::Stat and associated classes.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "test.h"
      17                 :            : 
      18                 :            : #include "util/didyoumean.h"
      19                 :            : 
      20                 :            : namespace cvc5::internal::test {
      21                 :            : 
      22                 :            : class TestUtilDidYouMean : public TestInternal
      23                 :            : {
      24                 :            : };
      25                 :            : 
      26                 :          2 : TEST_F(TestUtilDidYouMean, getMatch)
      27                 :            : {
      28                 :            :   {
      29                 :          2 :     DidYouMean dym;
      30 [ +  + ][ -  - ]:          4 :     dym.addWords({"abfish", "cdfish", "whale"});
      31                 :            :     {
      32                 :          5 :       auto expected = std::vector<std::string>{"abfish"};
      33         [ -  + ]:          2 :       EXPECT_EQ(dym.getMatch("abfish"), expected);
      34                 :            :     }
      35                 :            :     {
      36                 :          5 :       auto expected = std::vector<std::string>{"whale"};
      37         [ -  + ]:          2 :       EXPECT_EQ(dym.getMatch("wahl"), expected);
      38                 :            :     }
      39                 :            :     {
      40                 :          6 :       auto expected = std::vector<std::string>{"abfish", "cdfish"};
      41         [ -  + ]:          2 :       EXPECT_EQ(dym.getMatch("fish"), expected);
      42                 :            :     }
      43                 :            :     {
      44                 :          2 :       auto expected = std::vector<std::string>{};
      45         [ -  + ]:          2 :       EXPECT_EQ(dym.getMatch("elephant"), expected);
      46                 :            :     }
      47                 :            :   }
      48                 :          1 : }
      49                 :            : 
      50                 :          2 : TEST_F(TestUtilDidYouMean, getMatchAsString)
      51                 :            : {
      52                 :          2 :     DidYouMean dym;
      53 [ +  + ][ -  - ]:          4 :     dym.addWords({"abfish", "cdfish", "whale"});
      54                 :            :     {
      55                 :          2 :       std::string expected = "";
      56         [ -  + ]:          2 :       EXPECT_EQ(dym.getMatchAsString("elephant"), expected);
      57                 :            :     }
      58                 :            :     {
      59                 :          2 :       std::string expected = R"FOOBAR(
      60                 :            : 
      61                 :            : Did you mean this?
      62                 :            :         whale)FOOBAR";
      63         [ -  + ]:          2 :       EXPECT_EQ(dym.getMatchAsString("wahl"), expected);
      64                 :            :     }
      65                 :            :     {
      66                 :          2 :       std::string expected = R"FOOBAR(
      67                 :            : 
      68                 :            : Did you mean any of these?
      69                 :            :         abfish
      70                 :            :         cdfish)FOOBAR";
      71         [ -  + ]:          2 :       EXPECT_EQ(dym.getMatchAsString("fish"), expected);
      72                 :            :     }
      73                 :          1 : }
      74                 :            : 
      75                 :            : }  // namespace cvc5::internal::test

Generated by: LCOV version 1.14