LCOV - code coverage report
Current view: top level - buildbot/coverage/build/test/unit/node - node_white.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 35 35 100.0 %
Date: 2026-03-19 10:41:11 Functions: 16 16 100.0 %
Branches: 39 78 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                 :            :  * White box testing of cvc5::Node.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include <string>
      14                 :            : 
      15                 :            : #include "base/check.h"
      16                 :            : #include "expr/node_builder.h"
      17                 :            : #include "test_node.h"
      18                 :            : #include "util/rational.h"
      19                 :            : 
      20                 :            : namespace cvc5::internal {
      21                 :            : 
      22                 :            : using namespace expr;
      23                 :            : 
      24                 :            : namespace test {
      25                 :            : 
      26                 :            : class TestNodeWhiteNode : public TestNode
      27                 :            : {
      28                 :            : };
      29                 :            : 
      30 [ -  + ][ +  - ]:          5 : TEST_F(TestNodeWhiteNode, null) { ASSERT_EQ(Node::null(), Node::s_null); }
      31                 :            : 
      32                 :          4 : TEST_F(TestNodeWhiteNode, copy_ctor) { Node e(Node::s_null); }
      33                 :            : 
      34                 :          4 : TEST_F(TestNodeWhiteNode, builder)
      35                 :            : {
      36                 :          1 :   NodeBuilder b(d_nodeManager.get());
      37 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(b.d_nv->getId() == 0);
      38 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(b.d_nv->getKind() == Kind::UNDEFINED_KIND);
      39 [ -  + ][ +  - ]:          1 :   ASSERT_EQ(b.d_nv->d_nchildren, 0u);
      40                 :            :   /* etc. */
      41         [ +  - ]:          1 : }
      42                 :            : 
      43                 :          4 : TEST_F(TestNodeWhiteNode, iterators)
      44                 :            : {
      45                 :          2 :   Node x = d_nodeManager->mkVar("x", d_nodeManager->integerType());
      46                 :          2 :   Node y = d_nodeManager->mkVar("y", d_nodeManager->integerType());
      47                 :          2 :   Node x_plus_y = d_nodeManager->mkNode(Kind::ADD, x, y);
      48                 :          1 :   Node two = d_nodeManager->mkConstInt(Rational(2));
      49                 :          2 :   Node x_times_2 = d_nodeManager->mkNode(Kind::MULT, x, two);
      50                 :            : 
      51                 :          2 :   Node n = d_nodeManager->mkNode(Kind::ADD, x_times_2, x_plus_y, y);
      52                 :            : 
      53                 :          1 :   Node::iterator i;
      54                 :            : 
      55                 :          1 :   i = std::find(n.begin(), n.end(), x_plus_y);
      56 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(i != n.end());
      57 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(*i == x_plus_y);
      58                 :            : 
      59                 :          1 :   i = std::find(n.begin(), n.end(), x);
      60 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(i == n.end());
      61                 :            : 
      62                 :          1 :   i = std::find(x_times_2.begin(), x_times_2.end(), two);
      63 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(i != x_times_2.end());
      64 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(*i == two);
      65                 :            : 
      66                 :          1 :   i = std::find(n.begin(), n.end(), y);
      67 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(i != n.end());
      68 [ -  + ][ +  - ]:          1 :   ASSERT_TRUE(*i == y);
      69                 :            : 
      70                 :          1 :   std::vector<Node> v;
      71                 :          1 :   copy(n.begin(), n.end(), back_inserter(v));
      72 [ -  + ][ +  - ]:          1 :   ASSERT_EQ(n.getNumChildren(), v.size());
      73 [ -  + ][ +  - ]:          1 :   ASSERT_EQ(3, v.size());
      74 [ -  + ][ +  - ]:          1 :   ASSERT_EQ(v[0], x_times_2);
      75 [ -  + ][ +  - ]:          1 :   ASSERT_EQ(v[1], x_plus_y);
      76 [ -  + ][ +  - ]:          1 :   ASSERT_EQ(v[2], y);
      77 [ +  - ][ +  - ]:          1 : }
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      78                 :            : }  // namespace test
      79                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14