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