syslog-ng source
test_lexer.c File Reference
#include <criterion/criterion.h>
#include "libtest/mock-cfg-parser.h"
#include "libtest/grab-logging.h"
#include "cfg-lexer.h"
#include "cfg-grammar.h"
#include "apphook.h"
Include dependency graph for test_lexer.c:

Macros

#define TESTDATA_DIR   TOP_SRCDIR "/lib/tests/testdata-lexer"
 
#define assert_token_type(expected)    cr_assert_eq(_current_token()->type, expected, "Unexpected token type %d != %d", _current_token()->type, expected);
 
#define assert_parser_string(expected)
 
#define assert_parser_token(expected)
 
#define assert_parser_block(expected)
 
#define assert_parser_error()
 
#define assert_parser_pragma()
 
#define assert_parser_number(expected)
 
#define assert_parser_float(expected)
 
#define assert_parser_identifier(expected)
 
#define assert_parser_char(expected)
 
#define assert_location(line, column)
 
#define assert_location_range(_first_line, _first_column, _last_line, _last_column)
 
#define assert_location_tag(expected)
 

Functions

 Test (lexer, test_string)
 
 Test (lexer, test_unquoted_string)
 
 Test (lexer, test_qstring)
 
 Test (lexer, block_token_is_taken_literally_between_a_pair_of_enclosing_characters)
 
 Test (lexer, block_new_lines_in_text_leading_to_the_opening_bracket_are_tracked_properly)
 
 Test (lexer, block_closing_brackets_in_embedded_strings_or_comments_dont_close_the_block)
 
 Test (lexer, block_imbalanced_closing_dont_close_the_block)
 
 Test (lexer, block_complex_input)
 
 Test (lexer, block_input_without_opening_character_is_reported_as_an_error)
 
 Test (lexer, block_empty_input_in_parens_is_processed_as_a_NULL_pointer)
 
 Test (lexer, block_empty_string_in_parens_input_is_processed_as_an_empty_string)
 
 Test (lexer, at_version_stores_config_version_in_parsed_version_in_hex_form)
 
 Test (lexer, current_version)
 
 Test (lexer, test_lexer_others)
 
 Test (lexer, test_location_tracking)
 
 Test (lexer, test_multiline_string_literals)
 
 Test (lexer, test_multiline_qstring_literals)
 
 Test (lexer, defined_variables_are_substituted_when_enclosed_in_backticks)
 
 Test (lexer, include_file_expands_the_content_of_that_file_in_the_token_stream)
 
 Test (lexer, include_wildcard_files_expands_the_content_of_all_files_in_the_token_stream_in_alphabetical_order)
 
 Test (lexer, include_directory_expands_the_content_of_all_files_in_that_directory_in_alphabetical_ordre)
 
 Test (lexer, include_finds_files_in_include_path)
 
 Test (lexer, include_finds_wildcards_files_in_include_path)
 
CfgBlockGenerator * fake_generator_new (void)
 
 Test (lexer, generator_plugins_are_expanded)
 
 Test (lexer, context_name_lookup)
 
 TestSuite (lexer,.init=setup,.fini=teardown)
 

Variables

CfgParserMock * parser = NULL
 

Macro Definition Documentation

◆ assert_location

#define assert_location (   line,
  column 
)
Value:
cr_assert_eq(_current_lloc()->first_line, line, \
"The line number in the location information " \
"does not match the expected value, %d != %d", _current_lloc()->first_line, line); \
cr_assert_eq(_current_lloc()->first_column, column, \
"The column number in the location information " \
"does not match the expected value, %d != %d", _current_lloc()->first_column, column);

◆ assert_location_range

#define assert_location_range (   _first_line,
  _first_column,
  _last_line,
  _last_column 
)
Value:
assert_location(_first_line, _first_column); \
cr_assert_eq(_current_lloc()->last_line, _last_line, \
"The last_line number in the location information " \
"does not match the expected value, %d != %d", _current_lloc()->last_line, _last_line); \
cr_assert_eq(_current_lloc()->last_column, _last_column, \
"The last_column number in the location information " \
"does not match the expected value, %d != %d", _current_lloc()->last_column, _last_column);
#define assert_location(line, column)
Definition: test_lexer.c:107

◆ assert_location_tag

#define assert_location_tag (   expected)
Value:
({ \
char *msg = _format_location_tag_message(); \
const gchar *tag_repr; \
tag_repr = strstr(msg, "; "); \
tag_repr = tag_repr ? tag_repr + 2 : NULL; \
cr_assert_str_eq(tag_repr, expected, "Formatted location tag does not match %s <> %s", tag_repr, expected); \
free(msg); \
\
})
LogMessage * msg
Definition: test_rename.c:35

◆ assert_parser_block

#define assert_parser_block (   expected)
Value:
_next_token(); \
assert_token_type(LL_BLOCK); \
cr_assert_str_eq(_current_token()->cptr, expected, "Unexpected block value parsed >>>%s<<< != >>>%s<<<", _current_token()->cptr, expected);

◆ assert_parser_char

#define assert_parser_char (   expected)
Value:
_next_token(); \
cr_assert_eq(_current_token()->type, expected, "Unexpected character parsed %c != %c", _current_token()->type, expected);

◆ assert_parser_error

#define assert_parser_error ( )
Value:
_next_token(); \
assert_token_type(LL_ERROR);

◆ assert_parser_float

#define assert_parser_float (   expected)
Value:
_next_token(); \
assert_token_type(LL_FLOAT); \
cr_assert_float_eq(_current_token()->fnum, expected, 1e-7, "Unexpected float parsed %lf != %lf", _current_token()->fnum, expected);

◆ assert_parser_identifier

#define assert_parser_identifier (   expected)
Value:
_next_token(); \
assert_token_type(LL_IDENTIFIER); \
cr_assert_str_eq(_current_token()->cptr, expected, "Unexpected identifier parsed >>>%s<<< != >>>%s<<<", _current_token()->cptr, expected);

◆ assert_parser_number

#define assert_parser_number (   expected)
Value:
_next_token(); \
assert_token_type(LL_NUMBER); \
cr_assert_eq(_current_token()->num, expected, "Unexpected number parsed %" G_GINT64_FORMAT " != %" G_GINT64_FORMAT, (gint64) _current_token()->num, (gint64) expected);

◆ assert_parser_pragma

#define assert_parser_pragma ( )
Value:
_next_token(); \
assert_token_type(LL_PRAGMA);

◆ assert_parser_string

#define assert_parser_string (   expected)
Value:
_next_token(); \
assert_token_type(LL_STRING); \
cr_assert_str_eq(_current_token()->cptr, expected, "Unexpected string value parsed >>>%s<<< != >>>%s<<<", _current_token()->cptr, expected);

◆ assert_parser_token

#define assert_parser_token (   expected)
Value:
_next_token(); \
assert_token_type(expected);

◆ assert_token_type

#define assert_token_type (   expected)     cr_assert_eq(_current_token()->type, expected, "Unexpected token type %d != %d", _current_token()->type, expected);

◆ TESTDATA_DIR

#define TESTDATA_DIR   TOP_SRCDIR "/lib/tests/testdata-lexer"

Function Documentation

◆ fake_generator_new()

CfgBlockGenerator* fake_generator_new ( void  )

◆ Test() [1/25]

Test ( lexer  ,
at_version_stores_config_version_in_parsed_version_in_hex_form   
)

◆ Test() [2/25]

Test ( lexer  ,
block_closing_brackets_in_embedded_strings_or_comments_dont_close_the_block   
)

◆ Test() [3/25]

Test ( lexer  ,
block_complex_input   
)

◆ Test() [4/25]

Test ( lexer  ,
block_empty_input_in_parens_is_processed_as_a_NULL_pointer   
)

◆ Test() [5/25]

Test ( lexer  ,
block_empty_string_in_parens_input_is_processed_as_an_empty_string   
)

◆ Test() [6/25]

Test ( lexer  ,
block_imbalanced_closing_dont_close_the_block   
)

◆ Test() [7/25]

Test ( lexer  ,
block_input_without_opening_character_is_reported_as_an_error   
)

◆ Test() [8/25]

Test ( lexer  ,
block_new_lines_in_text_leading_to_the_opening_bracket_are_tracked_properly   
)

◆ Test() [9/25]

Test ( lexer  ,
block_token_is_taken_literally_between_a_pair_of_enclosing_characters   
)

◆ Test() [10/25]

Test ( lexer  ,
context_name_lookup   
)

◆ Test() [11/25]

Test ( lexer  ,
current_version   
)

◆ Test() [12/25]

Test ( lexer  ,
defined_variables_are_substituted_when_enclosed_in_backticks   
)

◆ Test() [13/25]

Test ( lexer  ,
generator_plugins_are_expanded   
)

◆ Test() [14/25]

Test ( lexer  ,
include_directory_expands_the_content_of_all_files_in_that_directory_in_alphabetical_ordre   
)

◆ Test() [15/25]

Test ( lexer  ,
include_file_expands_the_content_of_that_file_in_the_token_stream   
)

◆ Test() [16/25]

Test ( lexer  ,
include_finds_files_in_include_path   
)

◆ Test() [17/25]

Test ( lexer  ,
include_finds_wildcards_files_in_include_path   
)

◆ Test() [18/25]

Test ( lexer  ,
include_wildcard_files_expands_the_content_of_all_files_in_the_token_stream_in_alphabetical_order   
)

◆ Test() [19/25]

Test ( lexer  ,
test_lexer_others   
)

◆ Test() [20/25]

Test ( lexer  ,
test_location_tracking   
)

◆ Test() [21/25]

Test ( lexer  ,
test_multiline_qstring_literals   
)

◆ Test() [22/25]

Test ( lexer  ,
test_multiline_string_literals   
)

◆ Test() [23/25]

Test ( lexer  ,
test_qstring   
)

◆ Test() [24/25]

Test ( lexer  ,
test_string   
)

◆ Test() [25/25]

Test ( lexer  ,
test_unquoted_string   
)

◆ TestSuite()

TestSuite ( lexer  ,
init = setup,
fini = teardown 
)

Variable Documentation

◆ parser

CfgParserMock* parser = NULL