Add unit test for sanitizeLatexOption()

This is a prerequisite for safe removal of regex::match_partial.
This commit is contained in:
Georg Baum 2014-12-28 13:23:35 +01:00
parent 59ab49846a
commit 1db9224cff
4 changed files with 75 additions and 0 deletions

View 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

View File

@ -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();
}

View File

@ -0,0 +1,14 @@
[a]
[a]
[a]
[a]
[a,b]
[a,b]
[a,b]
[a]
[a]
[a]

View File

@ -0,0 +1,7 @@
#!/bin/sh
regfile=`cat ${srcdir}/tests/regfiles/ExternalTransforms`
output=`./check_ExternalTransforms`
test "$regfile" = "$output"
exit $?