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: 30 30 100.0 %
Date: 2026-02-27 11:41:18 Functions: 8 8 100.0 %
Branches: 11 22 50.0 %

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

Generated by: LCOV version 1.14