]> git.lyx.org Git - features.git/commitdiff
Add unit test for sanitizeLatexOption()
authorGeorg Baum <baum@lyx.org>
Sun, 28 Dec 2014 12:23:35 +0000 (13:23 +0100)
committerGeorg Baum <baum@lyx.org>
Sun, 28 Dec 2014 12:23:35 +0000 (13:23 +0100)
This is a prerequisite for safe removal of regex::match_partial.

src/Makefile.am
src/tests/check_ExternalTransforms.cpp [new file with mode: 0644]
src/tests/regfiles/ExternalTransforms [new file with mode: 0644]
src/tests/test_ExternalTransforms [new file with mode: 0755]

index 195a583670d700b747be92929432e69a681217c5..81f8ec762550ad6b5f911dff8015383fb4f2092c 100644 (file)
@@ -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 (file)
index 0000000..fe7c6f8
--- /dev/null
@@ -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 (file)
index 0000000..92a0e56
--- /dev/null
@@ -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 (executable)
index 0000000..02de0c5
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+regfile=`cat ${srcdir}/tests/regfiles/ExternalTransforms`
+output=`./check_ExternalTransforms`
+
+test "$regfile" = "$output"
+exit $?