3 #include "../support/debug.h"
4 #include "../support/regex.h"
13 // This function is unfortunately copied from ../insets/InsetListing.cpp, so we
14 // should try to make sure to keep the two in sync.
15 string test_ListingsCaption(string const & cap)
18 // blah1\label{blah2} blah3
20 // blah1 blah3},label={blah2
22 // caption={blah1 blah3},label={blah2}
24 // NOTE that } is not allowed in blah2.
25 regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)");
26 string const new_cap("$1$3},label={$2");
27 return regex_replace(cap, reg, new_cap);
30 void test_test_ListingsCaptions()
32 cout << test_ListingsCaption("\\label{}") << endl;
33 cout << test_ListingsCaption("\\label{blah2}") << endl;
34 cout << test_ListingsCaption("\\label{blah2} blah3") << endl;
35 cout << test_ListingsCaption("\\label{} blah3") << endl;
36 cout << test_ListingsCaption("blah1\\label{}") << endl;
37 cout << test_ListingsCaption("blah1\\label{} blah3") << endl;
38 cout << test_ListingsCaption("blah1\\label{blah2}") << endl;
39 cout << test_ListingsCaption("blah1\\label{blah2} blah3") << endl;
43 int main(int, char **)
45 // Connect lyxerr with cout instead of cerr to catch error output
46 lyx::lyxerr.setStream(cout);
47 test_test_ListingsCaptions();