#!/usr/bin/env python3 # Copyright 2021-2023 David Robillard # SPDX-License-Identifier: ISC """Test filtering statements inclusively and exclusively.""" import serd_test_util as util DOCS = { "ntriples": """ . . """, "nquads": """ . . """, } args = util.wrapper_args(__doc__) def check_pattern(syntax, pattern, expected_inclusive, expected_exclusive): """Run a check with an exclusive pattern.""" command = [args.tool, "-I", syntax, pattern] inclusive = util.command_output(args.wrapper, command, DOCS[syntax]) assert inclusive == expected_inclusive command = [args.tool, "-I", syntax, "-v", pattern] exclusive = util.command_output(args.wrapper, command, DOCS[syntax]) assert exclusive == expected_exclusive check_pattern( "ntriples", "?s .", " .\n", " .\n", ) check_pattern( "ntriples", " ?p .", " .\n", " .\n", ) check_pattern( "ntriples", " ?o .", " .\n", " .\n", ) check_pattern( "nquads", "?s .", " .\n", " .\n", ) check_pattern( "nquads", " ?p .", " .\n", " .\n", ) check_pattern( "nquads", " ?o .", " .\n", " .\n", ) check_pattern( "nquads", " ?g .", " .\n", " .\n", )