LCOV - code coverage report
Current view: top level - buildbot/coverage/build/test/api/c - smt2_compliance.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 34 34 100.0 %
Date: 2025-03-24 11:48:42 Functions: 2 2 100.0 %
Branches: 6 8 75.0 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Aina Niemetz
       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                 :            :  * A test of SMT-LIBv2 commands, checks for compliant output.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include <assert.h>
      17                 :            : #include <cvc5/c/cvc5.h>
      18                 :            : #include <cvc5/c/cvc5_parser.h>
      19                 :            : #include <stdio.h>
      20                 :            : #include <stdlib.h>
      21                 :            : #include <string.h>
      22                 :            : 
      23                 :         10 : void test_get_info(Cvc5* solver, const char* s)
      24                 :            : {
      25                 :         10 :   Cvc5SymbolManager* sm = cvc5_symbol_manager_new(cvc5_get_tm(solver));
      26                 :         10 :   Cvc5InputParser* parser = cvc5_parser_new(solver, sm);
      27                 :            : 
      28                 :         10 :   char* str = malloc((strlen(s) + strlen("(get-info )") + 1) * sizeof(char));
      29                 :         10 :   sprintf(str, "(get-info %s)", s);
      30                 :         10 :   cvc5_parser_set_str_input(
      31                 :            :       parser, CVC5_INPUT_LANGUAGE_SMT_LIB_2_6, str, "<internal>");
      32                 :            :   Cvc5Command cmd;
      33                 :            :   do
      34                 :            :   {
      35                 :            :     const char* error_msg;
      36                 :         20 :     cmd = cvc5_parser_next_command(parser, &error_msg);
      37         [ -  + ]:         20 :     assert(error_msg == NULL);
      38         [ +  + ]:         20 :     if (cmd)
      39                 :            :     {
      40                 :         10 :       printf("%s", cvc5_cmd_invoke(cmd, solver, sm));
      41                 :            :     }
      42         [ +  + ]:         20 :   } while (cmd);
      43         [ -  + ]:         10 :   assert(cvc5_parser_done(parser));  // parser should be done
      44                 :         10 :   cvc5_parser_delete(parser);
      45                 :         10 :   cvc5_symbol_manager_delete(sm);
      46                 :         10 :   free(str);
      47                 :         10 : }
      48                 :            : 
      49                 :          1 : int main()
      50                 :            : {
      51                 :          1 :   Cvc5TermManager* tm = cvc5_term_manager_new();
      52                 :          1 :   Cvc5* solver = cvc5_new(tm);
      53                 :          1 :   cvc5_set_option(solver, "input-language", "smtlib2");
      54                 :          1 :   cvc5_set_option(solver, "output-language", "smtlib2");
      55                 :          1 :   test_get_info(solver, ":error-behavior");
      56                 :          1 :   test_get_info(solver, ":name");
      57                 :          1 :   test_get_info(solver, ":authors");
      58                 :          1 :   test_get_info(solver, ":version");
      59                 :          1 :   test_get_info(solver, ":status");
      60                 :          1 :   test_get_info(solver, ":reason-unknown");
      61                 :          1 :   test_get_info(solver, ":arbitrary-undefined-keyword");
      62                 :          1 :   test_get_info(solver, ":<=");  // legal
      63                 :          1 :   test_get_info(solver, ":->");  // legal
      64                 :          1 :   test_get_info(solver, ":all-statistics");
      65                 :            : 
      66                 :          1 :   cvc5_delete(solver);
      67                 :          1 :   cvc5_term_manager_delete(tm);
      68                 :          1 :   return 0;
      69                 :            : }

Generated by: LCOV version 1.14