From: Georg Baum Date: Sun, 28 Dec 2014 12:23:35 +0000 (+0100) Subject: Add unit test for sanitizeLatexOption() X-Git-Tag: 2.2.0alpha1~1420 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1db9224cfff615f3ec90245fed1ce018811f7e5d;p=features.git Add unit test for sanitizeLatexOption() This is a prerequisite for safe removal of regex::match_partial. --- diff --git a/src/Makefile.am b/src/Makefile.am index 195a583670..81f8ec7625 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -681,8 +681,12 @@ endif ############################## Tests ################################## EXTRA_DIST += \ + tests/test_ExternalTransforms \ + tests/regfiles/ExternalTransforms \ tests/test_layout +TESTS = tests/test_ExternalTransforms + alltests: check alltests-recursive alltests-recursive: check_layout @@ -698,6 +702,7 @@ updatetests: cd tex2lyx; $(MAKE) updatetests check_PROGRAMS = \ + check_ExternalTransforms \ check_layout if INSTALL_MACOSX @@ -724,4 +729,16 @@ check_layout_SOURCES = \ tests/boost.cpp \ tests/dummy_functions.cpp +check_ExternalTransforms_CPPFLAGS = $(AM_CPPFLAGS) +check_ExternalTransforms_LDADD = support/liblyxsupport.a $(LIBICONV) $(BOOST_LIBS) @LIBS@ $(QT_CORE_LIBS) $(LIBSHLWAPI) +check_ExternalTransforms_LDFLAGS = $(QT_CORE_LDFLAGS) $(ADD_FRAMEWORKS) +check_ExternalTransforms_SOURCES = \ + graphics/GraphicsParams.cpp \ + insets/ExternalTransforms.cpp \ + Length.cpp \ + lengthcommon.cpp \ + tests/check_ExternalTransforms.cpp \ + tests/boost.cpp \ + tests/dummy_functions.cpp + .PHONY: alltests alltests-recursive updatetests diff --git a/src/tests/check_ExternalTransforms.cpp b/src/tests/check_ExternalTransforms.cpp new file mode 100644 index 0000000000..fe7c6f8569 --- /dev/null +++ b/src/tests/check_ExternalTransforms.cpp @@ -0,0 +1,37 @@ +#include + +#include "../insets/ExternalTransforms.h" +#include "../support/debug.h" + +#include + + +using namespace lyx; +using namespace std; + + +void test_sanitizeLatexOption() +{ + using external::sanitizeLatexOption; + cout << sanitizeLatexOption("[]") << endl; + cout << sanitizeLatexOption("[,]") << endl; + cout << sanitizeLatexOption("[,,]") << endl; + cout << sanitizeLatexOption("[,,,]") << endl; + cout << sanitizeLatexOption("[a]") << endl; + cout << sanitizeLatexOption("[,a]") << endl; + cout << sanitizeLatexOption("[,,a]") << endl; + cout << sanitizeLatexOption("[,,,a]") << endl; + cout << sanitizeLatexOption("[a,b]") << endl; + cout << sanitizeLatexOption("[a,,b]") << endl; + cout << sanitizeLatexOption("[a,,,b]") << endl; + cout << sanitizeLatexOption("[a,]") << endl; + cout << sanitizeLatexOption("[a,,]") << endl; + cout << sanitizeLatexOption("[a,,,]") << endl; +} + + +int main(int, char **) +{ + lyx::lyxerr.setStream(cerr); + test_sanitizeLatexOption(); +} diff --git a/src/tests/regfiles/ExternalTransforms b/src/tests/regfiles/ExternalTransforms new file mode 100644 index 0000000000..92a0e56328 --- /dev/null +++ b/src/tests/regfiles/ExternalTransforms @@ -0,0 +1,14 @@ + + + + +[a] +[a] +[a] +[a] +[a,b] +[a,b] +[a,b] +[a] +[a] +[a] diff --git a/src/tests/test_ExternalTransforms b/src/tests/test_ExternalTransforms new file mode 100755 index 0000000000..02de0c5004 --- /dev/null +++ b/src/tests/test_ExternalTransforms @@ -0,0 +1,7 @@ +#!/bin/sh + +regfile=`cat ${srcdir}/tests/regfiles/ExternalTransforms` +output=`./check_ExternalTransforms` + +test "$regfile" = "$output" +exit $?