|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69318 - in branches/quickbook-filenames/tools/quickbook: src test/unit
From: dnljms_at_[hidden]
Date: 2011-02-27 05:09:54
Author: danieljames
Date: 2011-02-27 05:09:53 EST (Sun, 27 Feb 2011)
New Revision: 69318
URL: http://svn.boost.org/trac/boost/changeset/69318
Log:
Make post_process a little less crashy.
Added:
branches/quickbook-filenames/tools/quickbook/test/unit/post_process_test.cpp (contents, props changed)
Text files modified:
branches/quickbook-filenames/tools/quickbook/src/post_process.cpp | 3 +++
branches/quickbook-filenames/tools/quickbook/src/post_process.hpp | 4 ++--
branches/quickbook-filenames/tools/quickbook/test/unit/Jamfile.v2 | 1 +
3 files changed, 6 insertions(+), 2 deletions(-)
Modified: branches/quickbook-filenames/tools/quickbook/src/post_process.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/post_process.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/post_process.cpp 2011-02-27 05:09:53 EST (Sun, 27 Feb 2011)
@@ -402,6 +402,9 @@
void do_end_tag(iter_type f, iter_type l) const
{
+ if (state.tags.empty())
+ throw quickbook::post_process_failure("Mismatched tags.");
+
bool is_flow_tag = state.is_flow_tag(state.tags.top());
if (!is_flow_tag)
{
Modified: branches/quickbook-filenames/tools/quickbook/src/post_process.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/post_process.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/post_process.hpp 2011-02-27 05:09:53 EST (Sun, 27 Feb 2011)
@@ -16,8 +16,8 @@
{
std::string post_process(
std::string const& in
- , int indent
- , int linewidth);
+ , int indent = -1
+ , int linewidth = -1);
class post_process_failure : std::runtime_error
{
Modified: branches/quickbook-filenames/tools/quickbook/test/unit/Jamfile.v2
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/unit/Jamfile.v2 (original)
+++ branches/quickbook-filenames/tools/quickbook/test/unit/Jamfile.v2 2011-02-27 05:09:53 EST (Sun, 27 Feb 2011)
@@ -5,3 +5,4 @@
;
run values_test.cpp ../../src/values.cpp ;
+run post_process_test.cpp ../../src/post_process.cpp ;
Added: branches/quickbook-filenames/tools/quickbook/test/unit/post_process_test.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/unit/post_process_test.cpp 2011-02-27 05:09:53 EST (Sun, 27 Feb 2011)
@@ -0,0 +1,30 @@
+/*=============================================================================
+ Copyright (c) 2011 Daniel James
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include "post_process.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+#define EXPECT_EXCEPTION(test, msg) \
+ try { \
+ test; \
+ BOOST_ERROR(msg); \
+ } \
+ catch(quickbook::post_process_failure&) { \
+ }
+
+int main()
+{
+ EXPECT_EXCEPTION(
+ quickbook::post_process("</thing>"),
+ "Succeeded with unbalanced tag");
+ EXPECT_EXCEPTION(
+ quickbook::post_process("<"),
+ "Succeeded with badly formed tag");
+
+ return boost::report_errors();
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk