#######################################################################
# nuggets: An R framework for exploration of patterns in data
# Copyright (C) 2025 Michal Burda
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#######################################################################
test_that("highlightCondition highlights single predicate correctly", {
res <- highlightCondition("A=1")
expect_match(res, "^A=1$")
})
test_that("highlightCondition highlights multiple predicates separated by commas", {
res <- highlightCondition("A=1,B=2")
# It should insert
between predicates
expect_match(res, "A=1
B=2")
# Exactly two predicate-name spans
expect_equal(length(regmatches(res, gregexpr("class=\"pred_n\"", res))[[1]]), 2)
})
test_that("highlightCondition removes braces", {
res <- highlightCondition("{A=1,B=2}")
expect_false(grepl("[{}]", res))
})
test_that("highlightCondition escapes HTML special characters", {
res <- highlightCondition("A=