| 
    KiCad PCB EDA Suite
    
   | 
 
Files | |
| test_text_eval_numeric_compat.cpp | |
| Test suite for text_eval system using examples adapted from numeric_evaluator tests.  | |
| test_text_eval_parser.cpp | |
| Test suite for text_eval_parser routines.  | |
| test_text_eval_parser_core.cpp | |
| Test suite for low-level text_eval_parser functionality.  | |
| test_text_eval_parser_datetime.cpp | |
| Test suite for text_eval_parser date and time functionality.  | |
| test_text_eval_parser_integration.cpp | |
| Integration tests for text_eval_parser functionality including real-world scenarios.  | |
| test_text_eval_render.cpp | |
| Test rendering helper functions with expression evaluation.  | |
This directory contains test suites for the KiCad text evaluation parser functionality.
test_text_eval_parser.cppHigh-level integration tests using the EXPRESSION_EVALUATOR wrapper class.
abs, sqrt, pow, floor, ceil, round, min, max, sum, avgupper, lower, concat, beforefirst, beforelast, afterfirst, afterlastformat, fixed, currencytoday, now, dateformat, weekdaynameif statements with boolean logicrandom() number generationtest_text_eval_parser_core.cppLow-level unit tests for the core parser components. Tests the internal API including:
test_text_eval_parser_datetime.cppSpecialized tests for date and time functionality:
today() and now() function validationtest_text_eval_parser_integration.cppIntegration tests simulating real-world KiCad usage scenarios:
abs(x) - Absolute valuesqrt(x) - Square root (with negative input validation)pow(x, y) - Power/exponentiationfloor(x) - Round down to integerceil(x) - Round up to integerround(x, [precision]) - Round to specified decimal placesmin(...) - Minimum of multiple valuesmax(...) - Maximum of multiple valuessum(...) - Sum of multiple valuesavg(...) - Average of multiple valuesupper(str) - Convert to uppercaselower(str) - Convert to lowercaseconcat(...) - Concatenate multiple valuesbeforefirst(str, c) - Substringbeforelast(str, c) - Substringafterfirst(str, c) - Substringafterlast(str, c) - Substringformat(num, [decimals]) - Format number with specified precisionfixed(num, [decimals]) - Fixed decimal formattingcurrency(amount, [symbol]) - Currency formattingtoday() - Current date as days since epochnow() - Current timestamp as seconds since epochdateformat(days, [format]) - Format date stringweekdayname(days) - Get weekday name for dateif(condition, true_value, false_value) - Conditional evaluationrandom() - Random number between 0 and 1+ - Addition (also string concatenation)- - Subtraction (also unary minus)* - Multiplication/ - Division (with zero-division error handling)% - Modulo (with zero-modulo error handling)^ - Exponentiation (right-associative)Variables are referenced using ${variable_name} syntax and can be:
evaluator.SetVariable()Calculations are embedded in text using @{expression} syntax:
"Result: @{2 + 3}" → "Result: 5""Hello ${name}!" → "Hello World!" (with variable substitution)"Area: @{${width} * ${height}} mm²" → "Area: 100 mm²"The parser collects errors for later diagnostics. However, a string with multiple expressions may be partially evaluated. It will return an error for every expression that was not fully evaluated.