commit 1db9224cfff615f3ec90245fed1ce018811f7e5d
Author: Georg Baum <[email protected]>
Date: Sun Dec 28 13:23:35 2014 +0100
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 195a583..81f8ec7 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 0000000..fe7c6f8
--- /dev/null
+++ b/src/tests/check_ExternalTransforms.cpp
@@ -0,0 +1,37 @@
+#include <config.h>
+
+#include "../insets/ExternalTransforms.h"
+#include "../support/debug.h"
+
+#include <iostream>
+
+
+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 0000000..92a0e56
--- /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 0000000..02de0c5
--- /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 $?