Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67494 - in trunk/libs/spirit/test: . karma lex qi support
From: admin_at_[hidden]
Date: 2010-12-29 16:17:11


Author: wash
Date: 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
New Revision: 67494
URL: http://svn.boost.org/trac/boost/changeset/67494

Log:
Reorganized Spirit tests, broke down larger tests so they won't time out on
ICC.

Added:
   trunk/libs/spirit/test/karma/alternative1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/alternative.cpp
   trunk/libs/spirit/test/karma/alternative2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/auto.hpp (contents, props changed)
   trunk/libs/spirit/test/karma/auto1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/auto.cpp
   trunk/libs/spirit/test/karma/auto2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/auto3.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/binary1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/binary.cpp
   trunk/libs/spirit/test/karma/binary2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/binary3.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/case_handling1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/case_handling.cpp
   trunk/libs/spirit/test/karma/case_handling2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/case_handling3.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/char1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/char.cpp
   trunk/libs/spirit/test/karma/char2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/int_numerics1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/int_numerics.cpp
   trunk/libs/spirit/test/karma/int_numerics2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/int_numerics3.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/pattern1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/pattern.cpp
   trunk/libs/spirit/test/karma/pattern2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/pattern3.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/karma/pattern2.cpp
   trunk/libs/spirit/test/karma/pattern4.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/karma/pattern3.cpp
   trunk/libs/spirit/test/karma/real_numerics.hpp (contents, props changed)
   trunk/libs/spirit/test/karma/real_numerics1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/real_numerics.cpp
   trunk/libs/spirit/test/karma/real_numerics2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/real_numerics3.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/regression_optional_double.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/karma/karma_optional_double.cpp
   trunk/libs/spirit/test/karma/regression_real_scientific.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/karma/real_scientific.cpp
   trunk/libs/spirit/test/karma/regression_semantic_action_attribute.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/karma/semantic_action_attribute.cpp
   trunk/libs/spirit/test/karma/repeat1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/repeat.cpp
   trunk/libs/spirit/test/karma/repeat2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/sequence1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/sequence.cpp
   trunk/libs/spirit/test/karma/sequence2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/symbols1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/symbols.cpp
   trunk/libs/spirit/test/karma/symbols2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/symbols3.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/utree1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/karma/utree.cpp
   trunk/libs/spirit/test/karma/utree2.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/utree3.cpp (contents, props changed)
   trunk/libs/spirit/test/karma/wstream.cpp (contents, props changed)
   trunk/libs/spirit/test/lex/regression_basic_lexer.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression001.cpp
   trunk/libs/spirit/test/lex/regression_file_iterator1.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression007.cpp
   trunk/libs/spirit/test/lex/regression_file_iterator2.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression008.cpp
   trunk/libs/spirit/test/lex/regression_file_iterator3.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression009.cpp
   trunk/libs/spirit/test/lex/regression_file_iterator4.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression010.cpp
   trunk/libs/spirit/test/lex/regression_matlib_dynamic.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression002.cpp
   trunk/libs/spirit/test/lex/regression_matlib_generate.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression003_generate.cpp
   trunk/libs/spirit/test/lex/regression_matlib_generate_switch.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression003_generate_switch.cpp
   trunk/libs/spirit/test/lex/regression_matlib_static.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression003.cpp
   trunk/libs/spirit/test/lex/regression_matlib_switch.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression003_switch.cpp
   trunk/libs/spirit/test/lex/regression_syntax_error.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression005.cpp
   trunk/libs/spirit/test/lex/regression_wide.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression006.cpp
   trunk/libs/spirit/test/lex/regression_word_count.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/regression004.cpp
   trunk/libs/spirit/test/lex/state_switcher.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/lex/state_switcher_test.cpp
   trunk/libs/spirit/test/qi/attribute1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/qi/attribute.cpp
   trunk/libs/spirit/test/qi/attribute2.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/match_manip.hpp (contents, props changed)
   trunk/libs/spirit/test/qi/match_manip1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/qi/match_manip.cpp
   trunk/libs/spirit/test/qi/match_manip2.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/match_manip3.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/real.hpp (contents, props changed)
   trunk/libs/spirit/test/qi/real1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/qi/real.cpp
   trunk/libs/spirit/test/qi/real2.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/real3.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/real4.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/regression_attr_with_action.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/qi/attr_with_action.cpp
   trunk/libs/spirit/test/qi/regression_clear.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/qi/clear_test.cpp
   trunk/libs/spirit/test/qi/regression_debug_optional.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/qi/debug_optional.cpp
   trunk/libs/spirit/test/qi/regression_one_element_fusion_sequence.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/qi/one_element_fusion_sequence.cpp
   trunk/libs/spirit/test/qi/regression_one_element_sequence_attribute.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/qi/single_element_sequence_attribute.cpp
   trunk/libs/spirit/test/qi/regression_reorder.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/qi/reorder_test.cpp
   trunk/libs/spirit/test/qi/regression_repeat.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/qi/repeat_regression.cpp
   trunk/libs/spirit/test/qi/rule1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/qi/rule.cpp
   trunk/libs/spirit/test/qi/rule2.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/rule3.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/rule4.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/symbols1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/qi/symbols.cpp
   trunk/libs/spirit/test/qi/symbols2.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/utree1.cpp
      - copied, changed from r67483, /trunk/libs/spirit/test/qi/utree.cpp
   trunk/libs/spirit/test/qi/utree2.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/utree3.cpp (contents, props changed)
   trunk/libs/spirit/test/qi/utree4.cpp (contents, props changed)
   trunk/libs/spirit/test/support/regression_multi_pass_functor.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/support/multi_pass_regression002.cpp
   trunk/libs/spirit/test/support/regression_multi_pass_parse.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/support/multi_pass_regression003.cpp
   trunk/libs/spirit/test/support/regression_multi_pass_position_iterator.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/support/multi_pass_regression001.cpp
   trunk/libs/spirit/test/support/utree.cpp
      - copied unchanged from r67483, /trunk/libs/spirit/test/support/utree_test.cpp
Removed:
   trunk/libs/spirit/test/karma/alternative.cpp
   trunk/libs/spirit/test/karma/auto.cpp
   trunk/libs/spirit/test/karma/binary.cpp
   trunk/libs/spirit/test/karma/case_handling.cpp
   trunk/libs/spirit/test/karma/char.cpp
   trunk/libs/spirit/test/karma/int_numerics.cpp
   trunk/libs/spirit/test/karma/karma_optional_double.cpp
   trunk/libs/spirit/test/karma/pattern.cpp
   trunk/libs/spirit/test/karma/real_numerics.cpp
   trunk/libs/spirit/test/karma/real_scientific.cpp
   trunk/libs/spirit/test/karma/repeat.cpp
   trunk/libs/spirit/test/karma/semantic_action_attribute.cpp
   trunk/libs/spirit/test/karma/sequence.cpp
   trunk/libs/spirit/test/karma/symbols.cpp
   trunk/libs/spirit/test/karma/utree.cpp
   trunk/libs/spirit/test/lex/regression001.cpp
   trunk/libs/spirit/test/lex/regression002.cpp
   trunk/libs/spirit/test/lex/regression003.cpp
   trunk/libs/spirit/test/lex/regression003_generate.cpp
   trunk/libs/spirit/test/lex/regression003_generate_switch.cpp
   trunk/libs/spirit/test/lex/regression003_switch.cpp
   trunk/libs/spirit/test/lex/regression004.cpp
   trunk/libs/spirit/test/lex/regression005.cpp
   trunk/libs/spirit/test/lex/regression006.cpp
   trunk/libs/spirit/test/lex/regression007.cpp
   trunk/libs/spirit/test/lex/regression008.cpp
   trunk/libs/spirit/test/lex/regression009.cpp
   trunk/libs/spirit/test/lex/regression010.cpp
   trunk/libs/spirit/test/lex/state_switcher_test.cpp
   trunk/libs/spirit/test/qi/attr_with_action.cpp
   trunk/libs/spirit/test/qi/attribute.cpp
   trunk/libs/spirit/test/qi/clear_test.cpp
   trunk/libs/spirit/test/qi/debug_optional.cpp
   trunk/libs/spirit/test/qi/match_manip.cpp
   trunk/libs/spirit/test/qi/one_element_fusion_sequence.cpp
   trunk/libs/spirit/test/qi/real.cpp
   trunk/libs/spirit/test/qi/reorder_test.cpp
   trunk/libs/spirit/test/qi/repeat_regression.cpp
   trunk/libs/spirit/test/qi/rule.cpp
   trunk/libs/spirit/test/qi/single_element_sequence_attribute.cpp
   trunk/libs/spirit/test/qi/symbols.cpp
   trunk/libs/spirit/test/qi/utree.cpp
   trunk/libs/spirit/test/support/multi_pass_regression001.cpp
   trunk/libs/spirit/test/support/multi_pass_regression002.cpp
   trunk/libs/spirit/test/support/multi_pass_regression003.cpp
   trunk/libs/spirit/test/support/utree_test.cpp
Text files modified:
   trunk/libs/spirit/test/Jamfile | 340 +++++++++++++++++++---------------
   trunk/libs/spirit/test/karma/alternative1.cpp | 108 ----------
   trunk/libs/spirit/test/karma/auto1.cpp | 232 -----------------------
   trunk/libs/spirit/test/karma/binary1.cpp | 179 ------------------
   trunk/libs/spirit/test/karma/case_handling1.cpp | 186 ------------------
   trunk/libs/spirit/test/karma/char1.cpp | 128 -------------
   trunk/libs/spirit/test/karma/int_numerics1.cpp | 223 ----------------------
   trunk/libs/spirit/test/karma/pattern1.cpp | 102 ----------
   trunk/libs/spirit/test/karma/real_numerics1.cpp | 393 ---------------------------------------
   trunk/libs/spirit/test/karma/repeat1.cpp | 135 ++-----------
   trunk/libs/spirit/test/karma/sequence1.cpp | 344 ++++++++++------------------------
   trunk/libs/spirit/test/karma/stream.cpp | 42 ---
   trunk/libs/spirit/test/karma/symbols1.cpp | 204 --------------------
   trunk/libs/spirit/test/karma/utree1.cpp | 207 ---------------------
   trunk/libs/spirit/test/qi/attribute1.cpp | 92 ---------
   trunk/libs/spirit/test/qi/match_manip1.cpp | 214 ---------------------
   trunk/libs/spirit/test/qi/real1.cpp | 317 --------------------------------
   trunk/libs/spirit/test/qi/rule1.cpp | 325 ---------------------------------
   trunk/libs/spirit/test/qi/symbols1.cpp | 163 ----------------
   trunk/libs/spirit/test/qi/utree1.cpp | 261 --------------------------
   20 files changed, 327 insertions(+), 3868 deletions(-)

Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -1,6 +1,7 @@
 #==============================================================================
-# Copyright (c) 2001-2010 Joel de Guzman
-# Copyright (c) 2001-2010 Hartmut Kaiser
+# Copyright (c) 2001-2011 Joel de Guzman
+# Copyright (c) 2001-2011 Hartmut Kaiser
+# Copyright (c) 2011 Bryce Lelbach
 #
 # Use, modification and distribution is subject to the Boost Software
 # License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -11,8 +12,6 @@
         <include>.
         <toolset>gcc:<cxxflags>-ftemplate-depth-300
         <toolset>darwin:<cxxflags>-ftemplate-depth-300
-# <toolset>gcc:<linkflags>-Wl,--enable-auto-import
-# <toolset>darwin:<linkflags>-Wl,--enable-auto-import
     :
     :
     ;
@@ -23,177 +22,220 @@
 import testing ;
 
 {
+ ###########################################################################
     test-suite spirit_v2/qi :
 
- # run Qi tests
- [ run qi/actions.cpp : : : : ]
- [ run qi/alternative.cpp : : : : ]
- [ run qi/attr.cpp : : : : ]
- [ run qi/attribute.cpp : : : : ]
- [ run qi/and_predicate.cpp : : : : ]
- [ run qi/auto.cpp : : : : ]
- [ run qi/binary.cpp : : : : ]
- [ run qi/bool.cpp : : : : ]
- [ run qi/char.cpp : : : : ]
- [ run qi/char_class.cpp : : : : ]
- [ run qi/debug.cpp : : : : ]
- [ run qi/difference.cpp : : : : ]
- [ run qi/encoding.cpp : : : : ]
- [ run qi/end.cpp : : : : ]
- [ run qi/eps.cpp : : : : ]
- [ run qi/expect.cpp : : : : ]
- [ run qi/grammar.cpp : : : : ]
- [ run qi/int.cpp : : : : ]
- [ run qi/kleene.cpp : : : : ]
- [ run qi/lazy.cpp : : : : ]
- [ run qi/lexeme.cpp : : : : ]
- [ run qi/lit.cpp : : : : ]
- [ run qi/list.cpp : : : : ]
- [ run qi/hold.cpp : : : : ]
- [ run qi/match_manip.cpp : : : : ]
- [ run qi/match_manip_attr.cpp : : : : ]
- [ run qi/matches.cpp : : : : ]
- [ run qi/no_case.cpp : : : : ]
- [ run qi/no_skip.cpp : : : : ]
- [ run qi/not_predicate.cpp : : : : ]
- [ run qi/optional.cpp : : : : ]
- [ run qi/parse_attr.cpp : : : : ]
- [ run qi/permutation.cpp : : : : ]
- [ run qi/plus.cpp : : : : ]
- [ run qi/range_run.cpp : : : : ]
- [ run qi/raw.cpp : : : : ]
- [ run qi/real.cpp : : : : ]
- [ run qi/repeat.cpp : : : : ]
- [ run qi/rule.cpp : : : : ]
- [ run qi/sequence.cpp : : : : ]
- [ run qi/sequential_or.cpp : : : : ]
- [ run qi/skip.cpp : : : : ]
- [ run qi/symbols.cpp : : : : ]
- [ run qi/terminal_ex.cpp : : : : ]
- [ run qi/tst.cpp : : : : ]
- [ run qi/uint.cpp : : : : ]
- [ run qi/utree.cpp : : : : ]
+ [ run qi/actions.cpp : : : : qi_actions ]
+ [ run qi/alternative.cpp : : : : qi_alternative ]
+ [ run qi/attr.cpp : : : : qi_attr ]
+ [ run qi/attribute1.cpp : : : : qi_attribute1 ]
+ [ run qi/attribute2.cpp : : : : qi_attribute2 ]
+ [ run qi/and_predicate.cpp : : : : qi_and_predicate ]
+ [ run qi/auto.cpp : : : : qi_auto ]
+ [ run qi/binary.cpp : : : : qi_binary ]
+ [ run qi/bool.cpp : : : : qi_bool ]
+ [ run qi/char.cpp : : : : qi_char ]
+ [ run qi/char_class.cpp : : : : qi_char_class ]
+ [ run qi/debug.cpp : : : : qi_debug ]
+ [ run qi/difference.cpp : : : : qi_difference ]
+ [ run qi/encoding.cpp : : : : qi_encoding ]
+ [ run qi/end.cpp : : : : qi_end ]
+ [ run qi/eps.cpp : : : : qi_eps ]
+ [ run qi/expect.cpp : : : : qi_expect ]
+ [ run qi/grammar.cpp : : : : qi_grammar ]
+ [ run qi/int.cpp : : : : qi_int ]
+ [ run qi/kleene.cpp : : : : qi_kleene ]
+ [ run qi/lazy.cpp : : : : qi_lazy ]
+ [ run qi/lexeme.cpp : : : : qi_lexeme ]
+ [ run qi/lit.cpp : : : : qi_lit ]
+ [ run qi/list.cpp : : : : qi_list ]
+ [ run qi/hold.cpp : : : : qi_hold ]
+ [ run qi/match_manip1.cpp : : : : qi_match_manip1 ]
+ [ run qi/match_manip2.cpp : : : : qi_match_manip2 ]
+ [ run qi/match_manip3.cpp : : : : qi_match_manip3 ]
+ [ run qi/match_manip_attr.cpp : : : : qi_match_manip_attr ]
+ [ run qi/matches.cpp : : : : qi_matches ]
+ [ run qi/no_case.cpp : : : : qi_no_case ]
+ [ run qi/no_skip.cpp : : : : qi_no_skip ]
+ [ run qi/not_predicate.cpp : : : : qi_not_predicate ]
+ [ run qi/optional.cpp : : : : qi_optional ]
+ [ run qi/parse_attr.cpp : : : : qi_parse_attr ]
+ [ run qi/permutation.cpp : : : : qi_permutation ]
+ [ run qi/plus.cpp : : : : qi_plus ]
+ [ run qi/range_run.cpp : : : : qi_range_run ]
+ [ run qi/raw.cpp : : : : qi_raw ]
+ [ run qi/real1.cpp : : : : qi_real1 ]
+ [ run qi/real2.cpp : : : : qi_real2 ]
+ [ run qi/real3.cpp : : : : qi_real3 ]
+ [ run qi/real4.cpp : : : : qi_real4 ]
+ [ run qi/repeat.cpp : : : : qi_repeat ]
+ [ run qi/rule1.cpp : : : : qi_rule1 ]
+ [ run qi/rule2.cpp : : : : qi_rule2 ]
+ [ run qi/rule3.cpp : : : : qi_rule3 ]
+ [ run qi/rule4.cpp : : : : qi_rule4 ]
+ [ run qi/sequence.cpp : : : : qi_sequence ]
+ [ run qi/sequential_or.cpp : : : : qi_sequential_or ]
+ [ run qi/skip.cpp : : : : qi_skip ]
+ [ run qi/symbols1.cpp : : : : qi_symbols1 ]
+ [ run qi/symbols2.cpp : : : : qi_symbols2 ]
+ [ run qi/terminal_ex.cpp : : : : qi_terminal_ex ]
+ [ run qi/tst.cpp : : : : qi_tst ]
+ [ run qi/uint.cpp : : : : qi_uint ]
+ [ run qi/utree1.cpp : : : : qi_utree1 ]
+ [ run qi/utree2.cpp : : : : qi_utree2 ]
+ [ run qi/utree3.cpp : : : : qi_utree3 ]
+ [ run qi/utree4.cpp : : : : qi_utree4 ]
     
     ;
+
+ ###########################################################################
+ test-suite spirit_v2/qi_regressions :
 
- test-suite spirit_v2/karma :
+ [ compile qi/regression_attr_with_action.cpp : : qi_regression_attr_with_action ]
+ [ run qi/regression_clear.cpp : : : : qi_regression_clear ]
+ [ compile qi/regression_debug_optional.cpp : : qi_regression_debug_optional ]
+ [ compile qi/regression_one_element_fusion_sequence.cpp : : qi_regression_one_element_fusion_sequence ]
+ [ compile qi/regression_one_element_sequence_attribute.cpp : : qi_regression_one_element_sequence_attribute ]
+ [ run qi/regression_reorder.cpp : : : : qi_regression_reorder ]
+ [ run qi/regression_repeat.cpp : : : : qi_regression_repeat ]
 
- # run Karma tests
- [ run karma/actions.cpp : : : : karma_actions ]
- [ run karma/and_predicate.cpp : : : : karma_and_predicate ]
- [ run karma/alternative.cpp : : : : karma_alternative ]
- [ run karma/attribute.cpp : : : : karma_attribute ]
- [ run karma/auto.cpp : : : : karma_auto ]
- [ run karma/binary.cpp : : : : karma_binary ]
- [ run karma/bool.cpp : : : : karma_bool ]
- [ run karma/buffer.cpp : : : : karma_buffer ]
- [ run karma/case_handling.cpp : : : : ]
- [ run karma/center_alignment.cpp : : : : ]
- [ run karma/char.cpp : : : : karma_char ]
- [ run karma/char_class.cpp : : : : karma_char_class ]
- [ run karma/columns.cpp : : : : ]
- [ run karma/debug.cpp : : : : karma_debug ]
- [ run karma/delimiter.cpp : : : : ]
- [ run karma/duplicate.cpp : : : : ]
- [ run karma/encoding.cpp : : : : karma_encoding ]
- [ run karma/eol.cpp : : : : karma_eol ]
- [ run karma/eps.cpp : : : : karma_eps ]
- [ run karma/format_manip.cpp : : : : ]
- [ run karma/format_manip_attr.cpp : : : : ]
- [ run karma/format_pointer_container.cpp : : : : ]
- [ run karma/generate_attr.cpp : : : : ]
- [ run karma/grammar.cpp : : : : karma_grammar ]
- [ run karma/int_numerics.cpp : : : : ]
- [ run karma/kleene.cpp : : : : karma_kleene ]
- [ run karma/lazy.cpp : : : : karma_lazy ]
- [ run karma/left_alignment.cpp : : : : ]
- [ run karma/list.cpp : : : : karma_list ]
- [ run karma/lit.cpp : : : : karma_lit ]
- [ run karma/maxwidth.cpp : : : : ]
- [ run karma/not_predicate.cpp : : : : karma_not_predicate ]
- [ run karma/omit.cpp : : : : karma_omit ]
- [ run karma/optional.cpp : : : : karma_optional ]
- [ run karma/pattern.cpp : : : : karma_pattern ]
- [ run karma/pattern2.cpp : : : : karma_pattern2 ]
- [ run karma/pattern3.cpp : : : : karma_pattern3 ]
- [ run karma/plus.cpp : : : : karma_plus ]
- [ run karma/real_numerics.cpp : : : : ]
- [ run karma/repeat.cpp : : : : karma_repeat ]
- [ run karma/right_alignment.cpp : : : : ]
- [ run karma/sequence.cpp : : : : karma_sequence ]
- [ run karma/stream.cpp : : : : karma_stream ]
- [ run karma/symbols.cpp : : : : karma_symbols ]
- [ run karma/tricky_alignment.cpp : : : : ]
- [ run karma/utree.cpp : : : : karma_utree ]
+ ;
 
- [ compile-fail karma/grammar_fail.cpp : : karma_grammar_fail ]
- [ compile-fail karma/rule_fail.cpp : : karma_rule_fail ]
+ ###########################################################################
+ test-suite spirit_v2/karma :
+
+ [ compile-fail karma/grammar_fail.cpp : : karma_grammar_fail ]
+ [ compile-fail karma/rule_fail.cpp : : karma_rule_fail ]
+ [ run karma/actions.cpp : : : : karma_actions ]
+ [ run karma/alternative1.cpp : : : : karma_alternative1 ]
+ [ run karma/alternative2.cpp : : : : karma_alternative2 ]
+ [ run karma/and_predicate.cpp : : : : karma_and_predicate ]
+ [ run karma/attribute.cpp : : : : karma_attribute ]
+ [ run karma/auto1.cpp : : : : karma_auto1 ]
+ [ run karma/auto2.cpp : : : : karma_auto2 ]
+ [ run karma/auto3.cpp : : : : karma_auto3 ]
+ [ run karma/binary1.cpp : : : : karma_binary1 ]
+ [ run karma/binary2.cpp : : : : karma_binary2 ]
+ [ run karma/binary3.cpp : : : : karma_binary3 ]
+ [ run karma/bool.cpp : : : : karma_bool ]
+ [ run karma/buffer.cpp : : : : karma_buffer ]
+ [ run karma/case_handling1.cpp : : : : karma_case_handling1 ]
+ [ run karma/case_handling2.cpp : : : : karma_case_handling2 ]
+ [ run karma/case_handling3.cpp : : : : karma_case_handling3 ]
+ [ run karma/center_alignment.cpp : : : : karma_center_alignment ]
+ [ run karma/char1.cpp : : : : karma_char1 ]
+ [ run karma/char2.cpp : : : : karma_char2 ]
+ [ run karma/char_class.cpp : : : : karma_char_class ]
+ [ run karma/columns.cpp : : : : karma_columns ]
+ [ run karma/debug.cpp : : : : karma_debug ]
+ [ run karma/delimiter.cpp : : : : karma_delimiter ]
+ [ run karma/duplicate.cpp : : : : karma_duplicate ]
+ [ run karma/encoding.cpp : : : : karma_encoding ]
+ [ run karma/eol.cpp : : : : karma_eol ]
+ [ run karma/eps.cpp : : : : karma_eps ]
+ [ run karma/format_manip.cpp : : : : karma_format_manip ]
+ [ run karma/format_manip_attr.cpp : : : : karma_format_manip_attr ]
+ [ run karma/format_pointer_container.cpp : : : : karma_format_pointer_container ]
+ [ run karma/generate_attr.cpp : : : : karma_generate_attr ]
+ [ run karma/grammar.cpp : : : : karma_grammar ]
+ [ run karma/int_numerics1.cpp : : : : karma_int_numerics1 ]
+ [ run karma/int_numerics2.cpp : : : : karma_int_numerics2 ]
+ [ run karma/int_numerics3.cpp : : : : karma_int_numerics3 ]
+ [ run karma/kleene.cpp : : : : karma_kleene ]
+ [ run karma/lazy.cpp : : : : karma_lazy ]
+ [ run karma/left_alignment.cpp : : : : karma_left_alignment ]
+ [ run karma/list.cpp : : : : karma_list ]
+ [ run karma/lit.cpp : : : : karma_lit ]
+ [ run karma/maxwidth.cpp : : : : karma_maxwidth ]
+ [ run karma/not_predicate.cpp : : : : karma_not_predicate ]
+ [ run karma/omit.cpp : : : : karma_omit ]
+ [ run karma/optional.cpp : : : : karma_optional ]
+ [ run karma/pattern1.cpp : : : : karma_pattern1 ]
+ [ run karma/pattern2.cpp : : : : karma_pattern2 ]
+ [ run karma/pattern3.cpp : : : : karma_pattern3 ]
+ [ run karma/pattern4.cpp : : : : karma_pattern4 ]
+ [ run karma/plus.cpp : : : : karma_plus ]
+ [ run karma/real_numerics1.cpp : : : : karma_real_numerics1 ]
+ [ run karma/real_numerics2.cpp : : : : karma_real_numerics2 ]
+ [ run karma/real_numerics3.cpp : : : : karma_real_numerics3 ]
+ [ run karma/repeat1.cpp : : : : karma_repeat1 ]
+ [ run karma/repeat2.cpp : : : : karma_repeat2 ]
+ [ run karma/right_alignment.cpp : : : : karma_right_alignment ]
+ [ run karma/sequence1.cpp : : : : karma_sequence1 ]
+ [ run karma/sequence2.cpp : : : : karma_sequence2 ]
+ [ run karma/stream.cpp : : : : karma_stream ]
+ [ run karma/symbols1.cpp : : : : karma_symbols1 ]
+ [ run karma/symbols2.cpp : : : : karma_symbols2 ]
+ [ run karma/symbols3.cpp : : : : karma_symbols3 ]
+ [ run karma/tricky_alignment.cpp : : : : karma_tricky_alignment ]
+ [ run karma/utree1.cpp : : : : karma_utree1 ]
+ [ run karma/utree2.cpp : : : : karma_utree2 ]
+ [ run karma/utree3.cpp : : : : karma_utree3 ]
+ [ run karma/wstream.cpp : : : : karma_wstream ]
+
+ ;
+
+ ###########################################################################
+ test-suite spirit_v2/karma_regressions :
+
+ [ run karma/regression_optional_double.cpp : : : : karma_regression_optional_double ]
+ [ run karma/regression_semantic_action_attribute.cpp : : : : karma_regression_semantic_action_attribute ]
+ [ run karma/regression_real_scientific.cpp : : : : karma_regression_real_scientific ]
 
     ;
 
+ ###########################################################################
     test-suite spirit_v2/lex :
 
- # run Lex tests
- [ run lex/lexertl1.cpp : : : : ]
- [ run lex/lexertl2.cpp : : : : ]
- [ run lex/lexertl3.cpp : : : : ]
- [ run lex/lexertl4.cpp : : : : ]
- [ run lex/lexertl5.cpp : : : : ]
- [ run lex/state_switcher_test.cpp : : : : ]
- [ run lex/lexer_state_switcher.cpp : : : : ]
- [ run lex/set_token_value.cpp : : : : ]
- [ run lex/dedent_handling_phoenix.cpp : : : : ]
- [ run lex/set_token_value_phoenix.cpp : : : : ]
- [ run lex/semantic_actions.cpp : : : : ]
- [ run lex/auto_switch_lexerstate.cpp : : : : ]
- [ run lex/id_type_enum.cpp : : : : ]
+ [ run lex/lexertl1.cpp : : : : lex_lexertl1 ]
+ [ run lex/lexertl2.cpp : : : : lex_lexertl2 ]
+ [ run lex/lexertl3.cpp : : : : lex_lexertl3 ]
+ [ run lex/lexertl4.cpp : : : : lex_lexertl4 ]
+ [ run lex/lexertl5.cpp : : : : lex_lexertl5 ]
+ [ run lex/state_switcher.cpp : : : : lex_state_switcher ]
+ [ run lex/lexer_state_switcher.cpp : : : : lex_lexer_state_switcher ]
+ [ run lex/set_token_value.cpp : : : : lex_set_token_value ]
+ [ run lex/dedent_handling_phoenix.cpp : : : : lex_dedent_handling_phoenix ]
+ [ run lex/set_token_value_phoenix.cpp : : : : lex_set_token_value_phoenix ]
+ [ run lex/semantic_actions.cpp : : : : lex_semantic_actions ]
+ [ run lex/auto_switch_lexerstate.cpp : : : : lex_auto_switch_lexerstate ]
+ [ run lex/id_type_enum.cpp : : : : lex_id_type_enum ]
     
     ;
 
+ ###########################################################################
     test-suite spirit_v2/lex_regressions :
 
- # run Lex regression tests
- [ run lex/regression001.cpp : : : : lex_regression001 ]
- [ run lex/regression002.cpp : : : : lex_regression002 ]
- [ run lex/regression003_generate.cpp : $(LEX_DIR)/matlib_static.h : : : lex_regression003_generate ]
- [ run lex/regression003.cpp : : : <dependency>.//lex_regression003_generate : lex_regression003 ]
- [ run lex/regression003_generate_switch.cpp : $(LEX_DIR)/matlib_static_switch.h : : : lex_regression003_generate_switch ]
- [ run lex/regression003_switch.cpp : : : <dependency>.//lex_regression003_generate_switch : lex_regression003_switch ]
- [ run lex/regression004.cpp : : : : lex_regression004 ]
- [ run lex/regression005.cpp : : : : lex_regression005 ]
- [ run lex/regression006.cpp : : : : lex_regression006 ]
- [ run lex/regression007.cpp : : : : lex_regression007 ]
- [ run lex/regression008.cpp : : : : lex_regression008 ]
- [ run lex/regression009.cpp : : : : lex_regression009 ]
- [ run lex/regression010.cpp : : : : lex_regression010 ]
+ [ run lex/regression_basic_lexer.cpp : : : : lex_regression_basic_lexer ]
+ [ run lex/regression_matlib_dynamic.cpp : : : : lex_regression_matlib_dynamic ]
+ [ run lex/regression_matlib_generate.cpp : $(LEX_DIR)/matlib_static.h : : : lex_regression_matlib_generate ]
+ [ run lex/regression_matlib_static.cpp : : : <dependency>.//lex_regression_matlib_generate : lex_regression_matlib_static ]
+ [ run lex/regression_matlib_generate_switch.cpp : $(LEX_DIR)/matlib_static_switch.h : : : lex_regression_matlib_generate_switch ]
+ [ run lex/regression_matlib_switch.cpp : : : <dependency>.//lex_regression_matlib_generate_switch : lex_regression_matlib_switch ]
+ [ run lex/regression_word_count.cpp : : : : lex_regression_word_count ]
+ [ run lex/regression_syntax_error.cpp : : : : lex_regression_syntax_error ]
+ [ run lex/regression_wide.cpp : : : : lex_regression_wide ]
+ [ run lex/regression_file_iterator1.cpp : : : : lex_regression_file_iterator1 ]
+ [ run lex/regression_file_iterator2.cpp : : : : lex_regression_file_iterator2 ]
+ [ run lex/regression_file_iterator3.cpp : : : : lex_regression_file_iterator3 ]
+ [ run lex/regression_file_iterator4.cpp : : : : lex_regression_file_iterator4 ]
     
     ;
 
+ ###########################################################################
     test-suite spirit_v2/support :
 
- # support tests
- [ compile support/multi_pass_regression001.cpp : : support_multi_pass_regression001 ]
- [ compile support/multi_pass_regression002.cpp : : support_multi_pass_regression002 ]
- [ compile support/multi_pass_regression003.cpp : : support_multi_pass_regression003 ]
- [ run support/utree_test.cpp : : : : support_utree_test ]
+ [ run support/utree.cpp : : : : support_utree ]
 
     ;
 
- test-suite spirit_v2/regressions :
-
- # regression tests
- [ compile qi/attr_with_action.cpp : : qi_attr_with_action ]
- [ run qi/clear_test.cpp : : : : ]
- [ run qi/reorder_test.cpp : : : : ]
- [ run karma/karma_optional_double.cpp : : : : ]
- [ run karma/semantic_action_attribute.cpp : : : : ]
- [ compile qi/single_element_sequence_attribute.cpp : : qi_single_element_sequence_attribute ]
- [ compile qi/debug_optional.cpp : : qi_debug_optional ]
- [ run karma/real_scientific.cpp : : : : ]
- [ run qi/repeat_regression.cpp : : : : ]
- [ compile qi/one_element_fusion_sequence.cpp : : qi_one_element_fusion_sequence ]
+ ###########################################################################
+ test-suite spirit_v2/support_regressions :
 
- ;
+ [ compile support/regression_multi_pass_position_iterator.cpp : : support_regression_multi_pass_position_iterator ]
+ [ compile support/regression_multi_pass_functor.cpp : : support_regression_multi_pass_functor ]
+ [ compile support/regression_multi_pass_parse.cpp : : support_regression_multi_pass_parse ]
 
+ ;
 }
 

Deleted: trunk/libs/spirit/test/karma/alternative.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/alternative.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,262 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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)
-
-// #define KARMA_TEST_COMPILE_FAIL
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/karma_auxiliary.hpp>
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_string.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_generate.hpp>
-#include <boost/spirit/include/karma_operator.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_nonterminal.hpp>
-#include <boost/spirit/include/karma_auxiliary.hpp>
-
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-int
-main()
-{
- using namespace boost;
- using namespace boost::spirit;
- using namespace boost::spirit::ascii;
-
- {
- BOOST_TEST(test("x", char_('x') | char_('i')));
- BOOST_TEST(test("xi", char_('x') << char_('i') | char_('i')));
- BOOST_TEST(test("i", char_('i') | char_('x') << char_('i')));
-
- BOOST_TEST(test("x", buffer[char_('x')] | char_('i')));
-
- variant<int, char> v (10);
- BOOST_TEST(test("10", char_ | int_, v));
- BOOST_TEST(test("10", int_ | char_, v));
- BOOST_TEST(test("a", lit('a') | char_ | int_, v));
- BOOST_TEST(test("a", char_ | lit('a') | int_, v));
- BOOST_TEST(test("10", int_ | lit('a') | char_, v));
-
- v = 'c';
- BOOST_TEST(test("c", char_ | int_, v));
- BOOST_TEST(test("a", lit('a') | char_ | int_, v));
- BOOST_TEST(test("c", char_ | lit('a') | int_, v));
- BOOST_TEST(test("a", int_ | lit('a') | char_, v));
- BOOST_TEST(test("c", int_ | char_ | lit('a'), v));
- }
-
- // testing for alignment/truncation problems on little endian systems
- // (big endian systems will fail one of the other tests below)
- {
- // test optional attribute
- optional<variant<int, char> > v;
- BOOST_TEST(!test("", char_ | int_, v));
- BOOST_TEST(!test("", int_ | char_, v));
- BOOST_TEST(test("a", lit('a') | char_ | int_, v));
- BOOST_TEST(test("a", char_ | lit('a') | int_, v));
- BOOST_TEST(test("a", int_ | lit('a') | char_, v));
-
- v = 10;
- BOOST_TEST(test("10", char_ | int_, v));
- BOOST_TEST(test("10", int_ | char_, v));
- BOOST_TEST(test("a", lit('a') | char_ | int_, v));
- BOOST_TEST(test("a", char_ | lit('a') | int_, v));
- BOOST_TEST(test("10", int_ | lit('a') | char_, v));
-
- v = 'c';
- BOOST_TEST(test("c", char_ | int_, v));
- BOOST_TEST(test("a", lit('a') | char_ | int_, v));
- BOOST_TEST(test("c", char_ | lit('a') | int_, v));
- BOOST_TEST(test("a", int_ | lit('a') | char_, v));
- BOOST_TEST(test("c", int_ | char_ | lit('a'), v));
- }
-
- {
- // more tests for optional attribute
- optional<int> o;
- BOOST_TEST(test("a", lit('a') | int_, o));
- BOOST_TEST(test("a", int_ | lit('a'), o));
-
- o = 10;
- BOOST_TEST(test("a", lit('a') | int_, o));
- BOOST_TEST(test("10", int_ | lit('a'), o));
- }
-
- {
- int i = 10;
- BOOST_TEST(test("a", lit('a') | int_, i));
- BOOST_TEST(test("10", int_ | lit('a'), i));
- }
-
- {
- BOOST_TEST(test("abc", string | int_, std::string("abc")));
- BOOST_TEST(test("1234", string | int_, 1234));
- BOOST_TEST(test("abc", int_ | string, std::string("abc")));
- BOOST_TEST(test("1234", int_ | string, 1234));
- }
-
- {
- // testing for alignment/truncation problems on little endian systems
- // (big endian systems will fail one of the other tests below)
- std::basic_string<wchar_t> generated;
- std::back_insert_iterator<std::basic_string<wchar_t> > outit(generated);
- boost::variant<int, char> v(10);
- bool result = karma::generate_delimited(outit
- , karma::int_ | karma::char_, karma::char_(' '), v);
- BOOST_TEST(result && generated == L"10 ");
- }
-
- {
- // test if alternatives with all components having unused
- // attribute generate first alternative
- fusion::vector<char, char> v('a', 'b');
- BOOST_TEST(test("axb", char_ << (lit('x') | lit('i')) << char_, v));
- BOOST_TEST(test("axib",
- char_ << (lit('x') << lit('i') | lit('i')) << char_, v));
- }
-
- {
- BOOST_TEST(test_delimited("x ", char_('x') | char_('i'), char_(' ')));
- BOOST_TEST(test_delimited("x i ",
- char_('x') << char_('i') | char_('i'), char_(' ')));
- BOOST_TEST(test_delimited("i ",
- char_('i') | char_('x') << char_('i'), char_(' ')));
-
- variant<int, char> v (10);
- BOOST_TEST(test_delimited("10 ", char_ | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("10 ", int_ | char_, v, char_(' ')));
- BOOST_TEST(test_delimited("a ", lit('a') | char_ | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("a ", char_ | lit('a') | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("10 ", int_ | lit('a') | char_, v, char_(' ')));
-
- v = 'c';
- BOOST_TEST(test_delimited("c ", char_ | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("a ", lit('a') | char_ | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("c ", char_ | lit('a') | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("a ", int_ | lit('a') | char_, v, char_(' ')));
- BOOST_TEST(test_delimited("c ", int_ | char_ | lit('a'), v, char_(' ')));
- }
-
-// this leads to infinite loops
-// {
-// variant<int, std::string> v(10);
-// BOOST_TEST(test("10", int_ | +char_, v));
-//
-// v = "abc";
-// BOOST_TEST(test("abc", int_ | +char_, v));
-// }
-
- {
- // if nothing matches, the first explicit alternative will be chosen
- variant<double, char const*> v (10.0);
- BOOST_TEST(test("11", char_ | lit(11), v));
- BOOST_TEST(test("11", lit(11) | char_ , v));
- BOOST_TEST(test("10.0", double_ | lit(11), v));
- BOOST_TEST(test("11", lit(11) | double_, v));
- BOOST_TEST(!test("", char_ | int_, v));
-
- v = "c";
- BOOST_TEST(test("11", char_ | lit(11), v));
- BOOST_TEST(test("11", double_ | lit(11), v));
- BOOST_TEST(!test("", char_ | int_, v));
- }
-
- {
- // in strict mode if nothing matches, the alternative will fail
- variant<double, char const*> v (10.0);
- BOOST_TEST(!test("11", strict[char_ | lit(11)], v));
- BOOST_TEST(test("11", strict[lit(11) | char_] , v));
-
- v = "c";
- BOOST_TEST(!test("11", strict[char_ | lit(11)], v));
- }
-
- {
- // if nothing matches, the first explicit alternative will be chosen
- variant<double, char const*> v (10.0);
- BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", lit(11) | char_ , v, char_(' ')));
- BOOST_TEST(test_delimited("10.0 ", double_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", lit(11) | double_, v, char_(' ')));
- BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
-
- v = "c";
- BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", double_ | lit(11), v, char_(' ')));
- BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
- }
-
- {
- // if nothing matches, the first explicit alternative will be chosen,
- // optionals need to be accepted
- optional<variant<double, char const*> > v (10.0);
- BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", lit(11) | char_ , v, char_(' ')));
- BOOST_TEST(test_delimited("10.0 ", double_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", lit(11) | double_, v, char_(' ')));
- BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
-
- v = "c";
- BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", double_ | lit(11), v, char_(' ')));
- BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
- }
-
- {
- std::vector<int> v;
- BOOST_TEST(test("[]", '[' << (int_ % ", ") << ']' | "[]", v));
- BOOST_TEST(test("[]", '[' << -(int_ % ", ") << ']', v));
- BOOST_TEST(test("[]", '[' << ((int_ % ", ") | eps) << ']', v));
-
- v.push_back(5);
- v.push_back(5);
- v.push_back(5);
- BOOST_TEST(test("[5, 5, 5]", '[' << (int_ % ", ") << ']' | "[]", v));
- }
-
- {
- boost::optional<int> v;
- BOOST_TEST(test("error", int_ | "error" << omit[-int_], v));
- BOOST_TEST(test("error", int_ | "error" << omit[int_], v));
- v = 1;
- BOOST_TEST(test("1", int_ | "error" << omit[-int_], v));
- BOOST_TEST(test("1", int_ | "error" << omit[int_], v));
- }
-
- {
- typedef spirit_test::output_iterator<char>::type outiter_type;
- namespace karma = boost::spirit::karma;
-
- karma::rule<outiter_type, int()> r = int_;
- std::vector<int> v;
- BOOST_TEST(test("", '>' << r % ',' | karma::eps, v));
-
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- v.push_back(4);
- BOOST_TEST(test(">1,2,3,4", '>' << r % ',' | karma::eps, v));
- }
-
- {
- typedef spirit_test::output_iterator<char>::type outiter_type;
- namespace karma = boost::spirit::karma;
-
- karma::rule<outiter_type, boost::optional<int>()> r = int_;
- boost::optional<int> o;
- BOOST_TEST(test("error", r | "error", o));
-
- o = 10;
- BOOST_TEST(test("10", r | "error", o));
- }
-
- return boost::report_errors();
-}
-

Copied: trunk/libs/spirit/test/karma/alternative1.cpp (from r67483, /trunk/libs/spirit/test/karma/alternative.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/alternative.cpp (original)
+++ trunk/libs/spirit/test/karma/alternative1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -114,114 +114,6 @@
     }
 
     {
- // test if alternatives with all components having unused
- // attribute generate first alternative
- fusion::vector<char, char> v('a', 'b');
- BOOST_TEST(test("axb", char_ << (lit('x') | lit('i')) << char_, v));
- BOOST_TEST(test("axib",
- char_ << (lit('x') << lit('i') | lit('i')) << char_, v));
- }
-
- {
- BOOST_TEST(test_delimited("x ", char_('x') | char_('i'), char_(' ')));
- BOOST_TEST(test_delimited("x i ",
- char_('x') << char_('i') | char_('i'), char_(' ')));
- BOOST_TEST(test_delimited("i ",
- char_('i') | char_('x') << char_('i'), char_(' ')));
-
- variant<int, char> v (10);
- BOOST_TEST(test_delimited("10 ", char_ | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("10 ", int_ | char_, v, char_(' ')));
- BOOST_TEST(test_delimited("a ", lit('a') | char_ | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("a ", char_ | lit('a') | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("10 ", int_ | lit('a') | char_, v, char_(' ')));
-
- v = 'c';
- BOOST_TEST(test_delimited("c ", char_ | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("a ", lit('a') | char_ | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("c ", char_ | lit('a') | int_, v, char_(' ')));
- BOOST_TEST(test_delimited("a ", int_ | lit('a') | char_, v, char_(' ')));
- BOOST_TEST(test_delimited("c ", int_ | char_ | lit('a'), v, char_(' ')));
- }
-
-// this leads to infinite loops
-// {
-// variant<int, std::string> v(10);
-// BOOST_TEST(test("10", int_ | +char_, v));
-//
-// v = "abc";
-// BOOST_TEST(test("abc", int_ | +char_, v));
-// }
-
- {
- // if nothing matches, the first explicit alternative will be chosen
- variant<double, char const*> v (10.0);
- BOOST_TEST(test("11", char_ | lit(11), v));
- BOOST_TEST(test("11", lit(11) | char_ , v));
- BOOST_TEST(test("10.0", double_ | lit(11), v));
- BOOST_TEST(test("11", lit(11) | double_, v));
- BOOST_TEST(!test("", char_ | int_, v));
-
- v = "c";
- BOOST_TEST(test("11", char_ | lit(11), v));
- BOOST_TEST(test("11", double_ | lit(11), v));
- BOOST_TEST(!test("", char_ | int_, v));
- }
-
- {
- // in strict mode if nothing matches, the alternative will fail
- variant<double, char const*> v (10.0);
- BOOST_TEST(!test("11", strict[char_ | lit(11)], v));
- BOOST_TEST(test("11", strict[lit(11) | char_] , v));
-
- v = "c";
- BOOST_TEST(!test("11", strict[char_ | lit(11)], v));
- }
-
- {
- // if nothing matches, the first explicit alternative will be chosen
- variant<double, char const*> v (10.0);
- BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", lit(11) | char_ , v, char_(' ')));
- BOOST_TEST(test_delimited("10.0 ", double_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", lit(11) | double_, v, char_(' ')));
- BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
-
- v = "c";
- BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", double_ | lit(11), v, char_(' ')));
- BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
- }
-
- {
- // if nothing matches, the first explicit alternative will be chosen,
- // optionals need to be accepted
- optional<variant<double, char const*> > v (10.0);
- BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", lit(11) | char_ , v, char_(' ')));
- BOOST_TEST(test_delimited("10.0 ", double_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", lit(11) | double_, v, char_(' ')));
- BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
-
- v = "c";
- BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
- BOOST_TEST(test_delimited("11 ", double_ | lit(11), v, char_(' ')));
- BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
- }
-
- {
- std::vector<int> v;
- BOOST_TEST(test("[]", '[' << (int_ % ", ") << ']' | "[]", v));
- BOOST_TEST(test("[]", '[' << -(int_ % ", ") << ']', v));
- BOOST_TEST(test("[]", '[' << ((int_ % ", ") | eps) << ']', v));
-
- v.push_back(5);
- v.push_back(5);
- v.push_back(5);
- BOOST_TEST(test("[5, 5, 5]", '[' << (int_ % ", ") << ']' | "[]", v));
- }
-
- {
         boost::optional<int> v;
         BOOST_TEST(test("error", int_ | "error" << omit[-int_], v));
         BOOST_TEST(test("error", int_ | "error" << omit[int_], v));

Added: trunk/libs/spirit/test/karma/alternative2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/alternative2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,143 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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)
+
+// #define KARMA_TEST_COMPILE_FAIL
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_auxiliary.hpp>
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_numeric.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_operator.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
+#include <boost/spirit/include/karma_auxiliary.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost;
+ using namespace boost::spirit;
+ using namespace boost::spirit::ascii;
+
+ {
+ // test if alternatives with all components having unused
+ // attribute generate first alternative
+ fusion::vector<char, char> v('a', 'b');
+ BOOST_TEST(test("axb", char_ << (lit('x') | lit('i')) << char_, v));
+ BOOST_TEST(test("axib",
+ char_ << (lit('x') << lit('i') | lit('i')) << char_, v));
+ }
+
+ {
+ BOOST_TEST(test_delimited("x ", char_('x') | char_('i'), char_(' ')));
+ BOOST_TEST(test_delimited("x i ",
+ char_('x') << char_('i') | char_('i'), char_(' ')));
+ BOOST_TEST(test_delimited("i ",
+ char_('i') | char_('x') << char_('i'), char_(' ')));
+
+ variant<int, char> v (10);
+ BOOST_TEST(test_delimited("10 ", char_ | int_, v, char_(' ')));
+ BOOST_TEST(test_delimited("10 ", int_ | char_, v, char_(' ')));
+ BOOST_TEST(test_delimited("a ", lit('a') | char_ | int_, v, char_(' ')));
+ BOOST_TEST(test_delimited("a ", char_ | lit('a') | int_, v, char_(' ')));
+ BOOST_TEST(test_delimited("10 ", int_ | lit('a') | char_, v, char_(' ')));
+
+ v = 'c';
+ BOOST_TEST(test_delimited("c ", char_ | int_, v, char_(' ')));
+ BOOST_TEST(test_delimited("a ", lit('a') | char_ | int_, v, char_(' ')));
+ BOOST_TEST(test_delimited("c ", char_ | lit('a') | int_, v, char_(' ')));
+ BOOST_TEST(test_delimited("a ", int_ | lit('a') | char_, v, char_(' ')));
+ BOOST_TEST(test_delimited("c ", int_ | char_ | lit('a'), v, char_(' ')));
+ }
+
+// this leads to infinite loops
+// {
+// variant<int, std::string> v(10);
+// BOOST_TEST(test("10", int_ | +char_, v));
+//
+// v = "abc";
+// BOOST_TEST(test("abc", int_ | +char_, v));
+// }
+
+ {
+ // if nothing matches, the first explicit alternative will be chosen
+ variant<double, char const*> v (10.0);
+ BOOST_TEST(test("11", char_ | lit(11), v));
+ BOOST_TEST(test("11", lit(11) | char_ , v));
+ BOOST_TEST(test("10.0", double_ | lit(11), v));
+ BOOST_TEST(test("11", lit(11) | double_, v));
+ BOOST_TEST(!test("", char_ | int_, v));
+
+ v = "c";
+ BOOST_TEST(test("11", char_ | lit(11), v));
+ BOOST_TEST(test("11", double_ | lit(11), v));
+ BOOST_TEST(!test("", char_ | int_, v));
+ }
+
+ {
+ // in strict mode if nothing matches, the alternative will fail
+ variant<double, char const*> v (10.0);
+ BOOST_TEST(!test("11", strict[char_ | lit(11)], v));
+ BOOST_TEST(test("11", strict[lit(11) | char_] , v));
+
+ v = "c";
+ BOOST_TEST(!test("11", strict[char_ | lit(11)], v));
+ }
+
+ {
+ // if nothing matches, the first explicit alternative will be chosen
+ variant<double, char const*> v (10.0);
+ BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
+ BOOST_TEST(test_delimited("11 ", lit(11) | char_ , v, char_(' ')));
+ BOOST_TEST(test_delimited("10.0 ", double_ | lit(11), v, char_(' ')));
+ BOOST_TEST(test_delimited("11 ", lit(11) | double_, v, char_(' ')));
+ BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
+
+ v = "c";
+ BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
+ BOOST_TEST(test_delimited("11 ", double_ | lit(11), v, char_(' ')));
+ BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
+ }
+
+ {
+ // if nothing matches, the first explicit alternative will be chosen,
+ // optionals need to be accepted
+ optional<variant<double, char const*> > v (10.0);
+ BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
+ BOOST_TEST(test_delimited("11 ", lit(11) | char_ , v, char_(' ')));
+ BOOST_TEST(test_delimited("10.0 ", double_ | lit(11), v, char_(' ')));
+ BOOST_TEST(test_delimited("11 ", lit(11) | double_, v, char_(' ')));
+ BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
+
+ v = "c";
+ BOOST_TEST(test_delimited("11 ", char_ | lit(11), v, char_(' ')));
+ BOOST_TEST(test_delimited("11 ", double_ | lit(11), v, char_(' ')));
+ BOOST_TEST(!test_delimited("", char_ | int_, v, char_(' ')));
+ }
+
+ {
+ std::vector<int> v;
+ BOOST_TEST(test("[]", '[' << (int_ % ", ") << ']' | "[]", v));
+ BOOST_TEST(test("[]", '[' << -(int_ % ", ") << ']', v));
+ BOOST_TEST(test("[]", '[' << ((int_ % ", ") | eps) << ']', v));
+
+ v.push_back(5);
+ v.push_back(5);
+ v.push_back(5);
+ BOOST_TEST(test("[5, 5, 5]", '[' << (int_ % ", ") << ']' | "[]", v));
+ }
+
+ return boost::report_errors();
+}
+

Deleted: trunk/libs/spirit/test/karma/auto.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/auto.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,334 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/fusion/include/std_pair.hpp>
-#include <boost/spirit/include/karma_bool.hpp>
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_string.hpp>
-#include <boost/spirit/include/karma_nonterminal.hpp>
-#include <boost/spirit/include/karma_operator.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_auto.hpp>
-
-#include "test.hpp"
-
-namespace karma = boost::spirit::karma;
-namespace traits = boost::spirit::traits;
-
-///////////////////////////////////////////////////////////////////////////////
-template <typename Char, typename T>
-bool test_create_generator(Char const *expected, T const& t)
-{
- std::basic_string<Char> generated;
- std::back_insert_iterator<std::basic_string<Char> > sink(generated);
-
- BOOST_TEST((traits::meta_create_exists<karma::domain, T>::value));
- bool result = karma::generate(sink, karma::create_generator<T>(), t);
-
- spirit_test::print_if_failed("test_create_generator", result, generated, expected);
- return result && generated == expected;
-}
-
-template <typename Char, typename T>
-bool test_create_generator_auto(Char const *expected, T const& t)
-{
- std::basic_string<Char> generated;
- std::back_insert_iterator<std::basic_string<Char> > sink(generated);
-
- BOOST_TEST((traits::meta_create_exists<karma::domain, T>::value));
- bool result = karma::generate(sink, t);
-
- spirit_test::print_if_failed("test_create_generator (auto)", result, generated, expected);
- return result && generated == expected;
-}
-
-template <typename Char, typename Attribute>
-bool test_rule(Char const *expected, Attribute const& attr)
-{
- BOOST_TEST((traits::meta_create_exists<karma::domain, Attribute>::value));
-
- typedef typename spirit_test::output_iterator<Char>::type sink_type;
- karma::rule<sink_type, Attribute()> r =
- karma::create_generator<Attribute>();
- return spirit_test::test(expected, r, attr);
-}
-
-template <typename Char, typename Attribute, typename Delimiter>
-bool test_rule_delimited(Char const *expected, Attribute const& attr
- , Delimiter const& d)
-{
- BOOST_TEST((traits::meta_create_exists<karma::domain, Attribute>::value));
-
- typedef typename spirit_test::output_iterator<Char>::type sink_type;
- karma::rule<sink_type, Attribute(), Delimiter> r =
- karma::create_generator<Attribute>();
- return spirit_test::test_delimited(expected, r, attr, d);
-}
-
-struct my_type {};
-
-///////////////////////////////////////////////////////////////////////////////
-int main()
-{
- {
- BOOST_TEST((!traits::meta_create_exists<karma::domain, my_type>::value));
- }
-
- {
- // test primitive types
- BOOST_TEST(test_create_generator("true", true));
- BOOST_TEST(test_create_generator("1", 1));
- BOOST_TEST(test_create_generator("1.1", 1.1));
- BOOST_TEST(test_create_generator("test", std::string("test")));
- BOOST_TEST(test_create_generator("a", 'a'));
- BOOST_TEST(test_create_generator(L"a", L'a'));
-
- // test containers
- std::vector<int> v;
- v.push_back(0);
- v.push_back(1);
- v.push_back(2);
- BOOST_TEST(test_create_generator("012", v));
-
- std::list<int> l;
- l.push_back(0);
- l.push_back(1);
- l.push_back(2);
- BOOST_TEST(test_create_generator("012", l));
-
- // test optional
- boost::optional<int> o;
- BOOST_TEST(test_create_generator("", o));
- o = 1;
- BOOST_TEST(test_create_generator("1", o));
-
- // test alternative
- boost::variant<int, double, float, std::string> vv;
- vv = 1;
- BOOST_TEST(test_create_generator("1", vv));
- vv = 1.0;
- BOOST_TEST(test_create_generator("1.0", vv));
- vv = 1.0f;
- BOOST_TEST(test_create_generator("1.0", vv));
- vv = "some string";
- BOOST_TEST(test_create_generator("some string", vv));
-
- // test fusion sequence
- std::pair<int, double> p (1, 2.0);
- BOOST_TEST(test_create_generator("12.0", p));
- }
-
- {
- // test primitive types
-// BOOST_TEST(test_create_generator_auto("true", true));
-// BOOST_TEST(test_create_generator_auto("1", 1));
-// BOOST_TEST(test_create_generator_auto("1.1", 1.1));
-// BOOST_TEST(test_create_generator_auto("test", std::string("test")));
-// BOOST_TEST(test_create_generator_auto("a", 'a'));
-// BOOST_TEST(test_create_generator_auto(L"a", L'a'));
-
- // test containers
- std::vector<int> v;
- v.push_back(0);
- v.push_back(1);
- v.push_back(2);
- BOOST_TEST(test_create_generator_auto("012", v));
-
- std::list<int> l;
- l.push_back(0);
- l.push_back(1);
- l.push_back(2);
- BOOST_TEST(test_create_generator_auto("012", l));
-
- // test optional
- boost::optional<int> o;
- BOOST_TEST(test_create_generator_auto("", o));
- o = 1;
- BOOST_TEST(test_create_generator_auto("1", o));
-
- // test alternative
- boost::variant<int, double, float, std::string> vv;
- vv = 1;
- BOOST_TEST(test_create_generator_auto("1", vv));
- vv = 1.0;
- BOOST_TEST(test_create_generator_auto("1.0", vv));
- vv = 1.0f;
- BOOST_TEST(test_create_generator_auto("1.0", vv));
- vv = "some string";
- BOOST_TEST(test_create_generator_auto("some string", vv));
-
- // test fusion sequence
- std::pair<int, double> p (1, 2.0);
- BOOST_TEST(test_create_generator_auto("12.0", p));
- }
-
- {
- using karma::auto_;
- using karma::upper;
- using spirit_test::test;
- using spirit_test::test_delimited;
-
- // test primitive types
- BOOST_TEST(test("true", auto_, true));
- BOOST_TEST(test("1", auto_, 1));
- BOOST_TEST(test("1.1", auto_, 1.1));
- BOOST_TEST(test("test", auto_, "test"));
- BOOST_TEST(test(L"test", auto_, L"test"));
- BOOST_TEST(test("a", auto_, 'a'));
- BOOST_TEST(test(L"a", auto_, L'a'));
-
- BOOST_TEST(test("TRUE", upper[auto_], true));
- BOOST_TEST(test("TEST", upper[auto_], "test"));
-
- // test containers
- std::vector<int> v;
- v.push_back(0);
- v.push_back(1);
- v.push_back(2);
- BOOST_TEST(test("012", auto_, v));
- BOOST_TEST(test("0,1,2", auto_ % ',', v));
- BOOST_TEST(test_delimited("0,1,2,", auto_, v, ','));
-
- std::list<int> l;
- l.push_back(0);
- l.push_back(1);
- l.push_back(2);
- BOOST_TEST(test("012", auto_, l));
- BOOST_TEST(test("0,1,2", auto_ % ',', l));
- BOOST_TEST(test_delimited("0,1,2,", auto_, l, ','));
-
- // test optional
- boost::optional<int> o;
- BOOST_TEST(test("", auto_, o));
- o = 1;
- BOOST_TEST(test("1", auto_, o));
-
- // test alternative
- boost::variant<int, double, float, std::string> vv;
- vv = 1;
- BOOST_TEST(test("1", auto_, vv));
- vv = 1.0;
- BOOST_TEST(test("1.0", auto_, vv));
- vv = 1.0f;
- BOOST_TEST(test("1.0", auto_, vv));
- vv = "some string";
- BOOST_TEST(test("some string", auto_, vv));
-
- // test fusion sequence
- std::pair<int, double> p (1, 2.0);
- BOOST_TEST(test("12.0", auto_, p));
- BOOST_TEST(test_delimited("1,2.0,", auto_, p, ','));
- }
-
- {
- using karma::auto_;
- using karma::upper;
- using spirit_test::test;
- using spirit_test::test_delimited;
-
- // test primitive types
- BOOST_TEST(test("true", auto_(true)));
- BOOST_TEST(test("1", auto_(1)));
- BOOST_TEST(test("1.1", auto_(1.1)));
- BOOST_TEST(test("test", auto_("test")));
- BOOST_TEST(test(L"test", auto_(L"test")));
- BOOST_TEST(test("a", auto_('a')));
- BOOST_TEST(test(L"a", auto_(L'a')));
-
- BOOST_TEST(test("TRUE", upper[auto_(true)]));
- BOOST_TEST(test("TEST", upper[auto_("test")]));
-
- // test containers
- std::vector<int> v;
- v.push_back(0);
- v.push_back(1);
- v.push_back(2);
- BOOST_TEST(test("012", auto_(v)));
- BOOST_TEST(test_delimited("0,1,2,", auto_(v), ','));
-
- std::list<int> l;
- l.push_back(0);
- l.push_back(1);
- l.push_back(2);
- BOOST_TEST(test("012", auto_(l)));
- BOOST_TEST(test_delimited("0,1,2,", auto_(l), ','));
-
- // test optional
- boost::optional<int> o;
- BOOST_TEST(test("", auto_(o)));
- o = 1;
- BOOST_TEST(test("1", auto_(o)));
-
- // test alternative
- boost::variant<int, double, float, std::string> vv;
- vv = 1;
- BOOST_TEST(test("1", auto_(vv)));
- vv = 1.0;
- BOOST_TEST(test("1.0", auto_(vv)));
- vv = 1.0f;
- BOOST_TEST(test("1.0", auto_(vv)));
- vv = "some string";
- BOOST_TEST(test("some string", auto_(vv)));
-
- // test fusion sequence
- std::pair<int, double> p (1, 2.0);
- BOOST_TEST(test("12.0", auto_, p));
- BOOST_TEST(test_delimited("1,2.0,", auto_(p), ','));
- }
-
- {
- using spirit_test::test;
- using spirit_test::test_delimited;
-
- // test primitive types
- BOOST_TEST(test_rule("true", true));
- BOOST_TEST(test_rule("1", 1));
- BOOST_TEST(test_rule("1.1", 1.1));
- BOOST_TEST(test_rule("test", std::string("test")));
-
- // test containers
- std::vector<int> v;
- v.push_back(0);
- v.push_back(1);
- v.push_back(2);
- BOOST_TEST(test_rule("012", v));
- BOOST_TEST(test_rule_delimited("0,1,2,", v, ','));
-
- std::list<int> l;
- l.push_back(0);
- l.push_back(1);
- l.push_back(2);
- BOOST_TEST(test_rule("012", l));
- BOOST_TEST(test_rule_delimited("0,1,2,", l, ','));
-
- // test optional
- boost::optional<int> o;
- BOOST_TEST(test_rule("", o));
- o = 1;
- BOOST_TEST(test_rule("1", o));
-
- // test alternative
- boost::variant<int, double, float, std::string> vv;
- vv = 1;
- BOOST_TEST(test_rule("1", vv));
- vv = 1.0;
- BOOST_TEST(test_rule("1.0", vv));
- vv = 1.0f;
- BOOST_TEST(test_rule("1.0", vv));
- vv = "some string";
- BOOST_TEST(test_rule("some string", vv));
-
- // test fusion sequence
- std::pair<int, double> p (1, 2.0);
- BOOST_TEST(test_rule("12.0", p));
- BOOST_TEST(test_rule_delimited("1,2.0,", p, ','));
- }
-
- return boost::report_errors();
-}

Added: trunk/libs/spirit/test/karma/auto.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/auto.hpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,79 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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)
+
+#if !defined(BOOST_SPIRIT_TEST_AUTO_HPP)
+#define BOOST_SPIRIT_TEST_AUTO_HPP
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/fusion/include/std_pair.hpp>
+#include <boost/spirit/include/karma_bool.hpp>
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_numeric.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
+#include <boost/spirit/include/karma_operator.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_auto.hpp>
+
+#include "test.hpp"
+
+namespace karma = boost::spirit::karma;
+namespace traits = boost::spirit::traits;
+
+///////////////////////////////////////////////////////////////////////////////
+template <typename Char, typename T>
+bool test_create_generator(Char const *expected, T const& t)
+{
+ std::basic_string<Char> generated;
+ std::back_insert_iterator<std::basic_string<Char> > sink(generated);
+
+ BOOST_TEST((traits::meta_create_exists<karma::domain, T>::value));
+ bool result = karma::generate(sink, karma::create_generator<T>(), t);
+
+ spirit_test::print_if_failed("test_create_generator", result, generated, expected);
+ return result && generated == expected;
+}
+
+template <typename Char, typename T>
+bool test_create_generator_auto(Char const *expected, T const& t)
+{
+ std::basic_string<Char> generated;
+ std::back_insert_iterator<std::basic_string<Char> > sink(generated);
+
+ BOOST_TEST((traits::meta_create_exists<karma::domain, T>::value));
+ bool result = karma::generate(sink, t);
+
+ spirit_test::print_if_failed("test_create_generator (auto)", result, generated, expected);
+ return result && generated == expected;
+}
+
+template <typename Char, typename Attribute>
+bool test_rule(Char const *expected, Attribute const& attr)
+{
+ BOOST_TEST((traits::meta_create_exists<karma::domain, Attribute>::value));
+
+ typedef typename spirit_test::output_iterator<Char>::type sink_type;
+ karma::rule<sink_type, Attribute()> r =
+ karma::create_generator<Attribute>();
+ return spirit_test::test(expected, r, attr);
+}
+
+template <typename Char, typename Attribute, typename Delimiter>
+bool test_rule_delimited(Char const *expected, Attribute const& attr
+ , Delimiter const& d)
+{
+ BOOST_TEST((traits::meta_create_exists<karma::domain, Attribute>::value));
+
+ typedef typename spirit_test::output_iterator<Char>::type sink_type;
+ karma::rule<sink_type, Attribute(), Delimiter> r =
+ karma::create_generator<Attribute>();
+ return spirit_test::test_delimited(expected, r, attr, d);
+}
+
+struct my_type {};
+
+#endif

Copied: trunk/libs/spirit/test/karma/auto1.cpp (from r67483, /trunk/libs/spirit/test/karma/auto.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/auto.cpp (original)
+++ trunk/libs/spirit/test/karma/auto1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -3,75 +3,7 @@
 // Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/fusion/include/std_pair.hpp>
-#include <boost/spirit/include/karma_bool.hpp>
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_string.hpp>
-#include <boost/spirit/include/karma_nonterminal.hpp>
-#include <boost/spirit/include/karma_operator.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_auto.hpp>
-
-#include "test.hpp"
-
-namespace karma = boost::spirit::karma;
-namespace traits = boost::spirit::traits;
-
-///////////////////////////////////////////////////////////////////////////////
-template <typename Char, typename T>
-bool test_create_generator(Char const *expected, T const& t)
-{
- std::basic_string<Char> generated;
- std::back_insert_iterator<std::basic_string<Char> > sink(generated);
-
- BOOST_TEST((traits::meta_create_exists<karma::domain, T>::value));
- bool result = karma::generate(sink, karma::create_generator<T>(), t);
-
- spirit_test::print_if_failed("test_create_generator", result, generated, expected);
- return result && generated == expected;
-}
-
-template <typename Char, typename T>
-bool test_create_generator_auto(Char const *expected, T const& t)
-{
- std::basic_string<Char> generated;
- std::back_insert_iterator<std::basic_string<Char> > sink(generated);
-
- BOOST_TEST((traits::meta_create_exists<karma::domain, T>::value));
- bool result = karma::generate(sink, t);
-
- spirit_test::print_if_failed("test_create_generator (auto)", result, generated, expected);
- return result && generated == expected;
-}
-
-template <typename Char, typename Attribute>
-bool test_rule(Char const *expected, Attribute const& attr)
-{
- BOOST_TEST((traits::meta_create_exists<karma::domain, Attribute>::value));
-
- typedef typename spirit_test::output_iterator<Char>::type sink_type;
- karma::rule<sink_type, Attribute()> r =
- karma::create_generator<Attribute>();
- return spirit_test::test(expected, r, attr);
-}
-
-template <typename Char, typename Attribute, typename Delimiter>
-bool test_rule_delimited(Char const *expected, Attribute const& attr
- , Delimiter const& d)
-{
- BOOST_TEST((traits::meta_create_exists<karma::domain, Attribute>::value));
-
- typedef typename spirit_test::output_iterator<Char>::type sink_type;
- karma::rule<sink_type, Attribute(), Delimiter> r =
- karma::create_generator<Attribute>();
- return spirit_test::test_delimited(expected, r, attr, d);
-}
-
-struct my_type {};
+#include "auto.hpp"
 
 ///////////////////////////////////////////////////////////////////////////////
 int main()
@@ -168,167 +100,5 @@
         BOOST_TEST(test_create_generator_auto("12.0", p));
     }
 
- {
- using karma::auto_;
- using karma::upper;
- using spirit_test::test;
- using spirit_test::test_delimited;
-
- // test primitive types
- BOOST_TEST(test("true", auto_, true));
- BOOST_TEST(test("1", auto_, 1));
- BOOST_TEST(test("1.1", auto_, 1.1));
- BOOST_TEST(test("test", auto_, "test"));
- BOOST_TEST(test(L"test", auto_, L"test"));
- BOOST_TEST(test("a", auto_, 'a'));
- BOOST_TEST(test(L"a", auto_, L'a'));
-
- BOOST_TEST(test("TRUE", upper[auto_], true));
- BOOST_TEST(test("TEST", upper[auto_], "test"));
-
- // test containers
- std::vector<int> v;
- v.push_back(0);
- v.push_back(1);
- v.push_back(2);
- BOOST_TEST(test("012", auto_, v));
- BOOST_TEST(test("0,1,2", auto_ % ',', v));
- BOOST_TEST(test_delimited("0,1,2,", auto_, v, ','));
-
- std::list<int> l;
- l.push_back(0);
- l.push_back(1);
- l.push_back(2);
- BOOST_TEST(test("012", auto_, l));
- BOOST_TEST(test("0,1,2", auto_ % ',', l));
- BOOST_TEST(test_delimited("0,1,2,", auto_, l, ','));
-
- // test optional
- boost::optional<int> o;
- BOOST_TEST(test("", auto_, o));
- o = 1;
- BOOST_TEST(test("1", auto_, o));
-
- // test alternative
- boost::variant<int, double, float, std::string> vv;
- vv = 1;
- BOOST_TEST(test("1", auto_, vv));
- vv = 1.0;
- BOOST_TEST(test("1.0", auto_, vv));
- vv = 1.0f;
- BOOST_TEST(test("1.0", auto_, vv));
- vv = "some string";
- BOOST_TEST(test("some string", auto_, vv));
-
- // test fusion sequence
- std::pair<int, double> p (1, 2.0);
- BOOST_TEST(test("12.0", auto_, p));
- BOOST_TEST(test_delimited("1,2.0,", auto_, p, ','));
- }
-
- {
- using karma::auto_;
- using karma::upper;
- using spirit_test::test;
- using spirit_test::test_delimited;
-
- // test primitive types
- BOOST_TEST(test("true", auto_(true)));
- BOOST_TEST(test("1", auto_(1)));
- BOOST_TEST(test("1.1", auto_(1.1)));
- BOOST_TEST(test("test", auto_("test")));
- BOOST_TEST(test(L"test", auto_(L"test")));
- BOOST_TEST(test("a", auto_('a')));
- BOOST_TEST(test(L"a", auto_(L'a')));
-
- BOOST_TEST(test("TRUE", upper[auto_(true)]));
- BOOST_TEST(test("TEST", upper[auto_("test")]));
-
- // test containers
- std::vector<int> v;
- v.push_back(0);
- v.push_back(1);
- v.push_back(2);
- BOOST_TEST(test("012", auto_(v)));
- BOOST_TEST(test_delimited("0,1,2,", auto_(v), ','));
-
- std::list<int> l;
- l.push_back(0);
- l.push_back(1);
- l.push_back(2);
- BOOST_TEST(test("012", auto_(l)));
- BOOST_TEST(test_delimited("0,1,2,", auto_(l), ','));
-
- // test optional
- boost::optional<int> o;
- BOOST_TEST(test("", auto_(o)));
- o = 1;
- BOOST_TEST(test("1", auto_(o)));
-
- // test alternative
- boost::variant<int, double, float, std::string> vv;
- vv = 1;
- BOOST_TEST(test("1", auto_(vv)));
- vv = 1.0;
- BOOST_TEST(test("1.0", auto_(vv)));
- vv = 1.0f;
- BOOST_TEST(test("1.0", auto_(vv)));
- vv = "some string";
- BOOST_TEST(test("some string", auto_(vv)));
-
- // test fusion sequence
- std::pair<int, double> p (1, 2.0);
- BOOST_TEST(test("12.0", auto_, p));
- BOOST_TEST(test_delimited("1,2.0,", auto_(p), ','));
- }
-
- {
- using spirit_test::test;
- using spirit_test::test_delimited;
-
- // test primitive types
- BOOST_TEST(test_rule("true", true));
- BOOST_TEST(test_rule("1", 1));
- BOOST_TEST(test_rule("1.1", 1.1));
- BOOST_TEST(test_rule("test", std::string("test")));
-
- // test containers
- std::vector<int> v;
- v.push_back(0);
- v.push_back(1);
- v.push_back(2);
- BOOST_TEST(test_rule("012", v));
- BOOST_TEST(test_rule_delimited("0,1,2,", v, ','));
-
- std::list<int> l;
- l.push_back(0);
- l.push_back(1);
- l.push_back(2);
- BOOST_TEST(test_rule("012", l));
- BOOST_TEST(test_rule_delimited("0,1,2,", l, ','));
-
- // test optional
- boost::optional<int> o;
- BOOST_TEST(test_rule("", o));
- o = 1;
- BOOST_TEST(test_rule("1", o));
-
- // test alternative
- boost::variant<int, double, float, std::string> vv;
- vv = 1;
- BOOST_TEST(test_rule("1", vv));
- vv = 1.0;
- BOOST_TEST(test_rule("1.0", vv));
- vv = 1.0f;
- BOOST_TEST(test_rule("1.0", vv));
- vv = "some string";
- BOOST_TEST(test_rule("some string", vv));
-
- // test fusion sequence
- std::pair<int, double> p (1, 2.0);
- BOOST_TEST(test_rule("12.0", p));
- BOOST_TEST(test_rule_delimited("1,2.0,", p, ','));
- }
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/karma/auto2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/auto2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,126 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 "auto.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+int main()
+{
+ {
+ using karma::auto_;
+ using karma::upper;
+ using spirit_test::test;
+ using spirit_test::test_delimited;
+
+ // test primitive types
+ BOOST_TEST(test("true", auto_, true));
+ BOOST_TEST(test("1", auto_, 1));
+ BOOST_TEST(test("1.1", auto_, 1.1));
+ BOOST_TEST(test("test", auto_, "test"));
+ BOOST_TEST(test(L"test", auto_, L"test"));
+ BOOST_TEST(test("a", auto_, 'a'));
+ BOOST_TEST(test(L"a", auto_, L'a'));
+
+ BOOST_TEST(test("TRUE", upper[auto_], true));
+ BOOST_TEST(test("TEST", upper[auto_], "test"));
+
+ // test containers
+ std::vector<int> v;
+ v.push_back(0);
+ v.push_back(1);
+ v.push_back(2);
+ BOOST_TEST(test("012", auto_, v));
+ BOOST_TEST(test("0,1,2", auto_ % ',', v));
+ BOOST_TEST(test_delimited("0,1,2,", auto_, v, ','));
+
+ std::list<int> l;
+ l.push_back(0);
+ l.push_back(1);
+ l.push_back(2);
+ BOOST_TEST(test("012", auto_, l));
+ BOOST_TEST(test("0,1,2", auto_ % ',', l));
+ BOOST_TEST(test_delimited("0,1,2,", auto_, l, ','));
+
+ // test optional
+ boost::optional<int> o;
+ BOOST_TEST(test("", auto_, o));
+ o = 1;
+ BOOST_TEST(test("1", auto_, o));
+
+ // test alternative
+ boost::variant<int, double, float, std::string> vv;
+ vv = 1;
+ BOOST_TEST(test("1", auto_, vv));
+ vv = 1.0;
+ BOOST_TEST(test("1.0", auto_, vv));
+ vv = 1.0f;
+ BOOST_TEST(test("1.0", auto_, vv));
+ vv = "some string";
+ BOOST_TEST(test("some string", auto_, vv));
+
+ // test fusion sequence
+ std::pair<int, double> p (1, 2.0);
+ BOOST_TEST(test("12.0", auto_, p));
+ BOOST_TEST(test_delimited("1,2.0,", auto_, p, ','));
+ }
+
+ {
+ using karma::auto_;
+ using karma::upper;
+ using spirit_test::test;
+ using spirit_test::test_delimited;
+
+ // test primitive types
+ BOOST_TEST(test("true", auto_(true)));
+ BOOST_TEST(test("1", auto_(1)));
+ BOOST_TEST(test("1.1", auto_(1.1)));
+ BOOST_TEST(test("test", auto_("test")));
+ BOOST_TEST(test(L"test", auto_(L"test")));
+ BOOST_TEST(test("a", auto_('a')));
+ BOOST_TEST(test(L"a", auto_(L'a')));
+
+ BOOST_TEST(test("TRUE", upper[auto_(true)]));
+ BOOST_TEST(test("TEST", upper[auto_("test")]));
+
+ // test containers
+ std::vector<int> v;
+ v.push_back(0);
+ v.push_back(1);
+ v.push_back(2);
+ BOOST_TEST(test("012", auto_(v)));
+ BOOST_TEST(test_delimited("0,1,2,", auto_(v), ','));
+
+ std::list<int> l;
+ l.push_back(0);
+ l.push_back(1);
+ l.push_back(2);
+ BOOST_TEST(test("012", auto_(l)));
+ BOOST_TEST(test_delimited("0,1,2,", auto_(l), ','));
+
+ // test optional
+ boost::optional<int> o;
+ BOOST_TEST(test("", auto_(o)));
+ o = 1;
+ BOOST_TEST(test("1", auto_(o)));
+
+ // test alternative
+ boost::variant<int, double, float, std::string> vv;
+ vv = 1;
+ BOOST_TEST(test("1", auto_(vv)));
+ vv = 1.0;
+ BOOST_TEST(test("1.0", auto_(vv)));
+ vv = 1.0f;
+ BOOST_TEST(test("1.0", auto_(vv)));
+ vv = "some string";
+ BOOST_TEST(test("some string", auto_(vv)));
+
+ // test fusion sequence
+ std::pair<int, double> p (1, 2.0);
+ BOOST_TEST(test("12.0", auto_, p));
+ BOOST_TEST(test_delimited("1,2.0,", auto_(p), ','));
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/karma/auto3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/auto3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,60 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 "auto.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+int main()
+{
+ {
+ using spirit_test::test;
+ using spirit_test::test_delimited;
+
+ // test primitive types
+ BOOST_TEST(test_rule("true", true));
+ BOOST_TEST(test_rule("1", 1));
+ BOOST_TEST(test_rule("1.1", 1.1));
+ BOOST_TEST(test_rule("test", std::string("test")));
+
+ // test containers
+ std::vector<int> v;
+ v.push_back(0);
+ v.push_back(1);
+ v.push_back(2);
+ BOOST_TEST(test_rule("012", v));
+ BOOST_TEST(test_rule_delimited("0,1,2,", v, ','));
+
+ std::list<int> l;
+ l.push_back(0);
+ l.push_back(1);
+ l.push_back(2);
+ BOOST_TEST(test_rule("012", l));
+ BOOST_TEST(test_rule_delimited("0,1,2,", l, ','));
+
+ // test optional
+ boost::optional<int> o;
+ BOOST_TEST(test_rule("", o));
+ o = 1;
+ BOOST_TEST(test_rule("1", o));
+
+ // test alternative
+ boost::variant<int, double, float, std::string> vv;
+ vv = 1;
+ BOOST_TEST(test_rule("1", vv));
+ vv = 1.0;
+ BOOST_TEST(test_rule("1.0", vv));
+ vv = 1.0f;
+ BOOST_TEST(test_rule("1.0", vv));
+ vv = "some string";
+ BOOST_TEST(test_rule("some string", vv));
+
+ // test fusion sequence
+ std::pair<int, double> p (1, 2.0);
+ BOOST_TEST(test_rule("12.0", p));
+ BOOST_TEST(test_rule_delimited("1,2.0,", p, ','));
+ }
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/karma/binary.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/binary.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,276 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/karma_binary.hpp>
-#include <boost/spirit/include/karma_generate.hpp>
-#include <boost/spirit/include/karma_phoenix_attributes.hpp>
-
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-int
-main()
-{
- using namespace boost::spirit;
- using namespace boost::phoenix;
-
- { // test native endian binaries
-#ifdef BOOST_LITTLE_ENDIAN
- BOOST_TEST(binary_test("\x01", 1, byte_, 0x01));
- BOOST_TEST(binary_test("\x80", 1, byte_, 0x80));
- BOOST_TEST(binary_test("\x01\x82", 2, word, 0x8201));
- BOOST_TEST(binary_test("\x81\x02", 2, word, 0x0281));
- BOOST_TEST(binary_test("\x01\x02\x03\x84", 4, dword, 0x84030201));
- BOOST_TEST(binary_test("\x81\x02\x03\x04", 4, dword, 0x04030281));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x88", 8, qword,
- 0x8807060504030201LL));
- BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- 0x0807060504030281LL));
-#endif
-
- BOOST_TEST(binary_test_delimited("\x01\x00\x00\x00", 4, byte_, 0x01, pad(4)));
- BOOST_TEST(binary_test_delimited("\x01\x02\x00\x00", 4, word, 0x0201, pad(4)));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04", 4, dword, 0x04030201, pad(4)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00", 10,
- qword, 0x0807060504030201LL, pad(10)));
-#endif
-
-#else // BOOST_LITTLE_ENDIAN
-
- BOOST_TEST(binary_test("\x01", 1, byte_, 0x01));
- BOOST_TEST(binary_test("\x80", 1, byte_, 0x80));
- BOOST_TEST(binary_test("\x01\x82", 2, word, 0x0182));
- BOOST_TEST(binary_test("\x81\x02", 2, word, 0x8102));
- BOOST_TEST(binary_test("\x01\x02\x03\x84", 4, dword, 0x01020384));
- BOOST_TEST(binary_test("\x81\x02\x03\x04", 4, dword, 0x81020304));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x88", 8, qword,
- 0x0102030405060788LL));
- BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- 0x8102030405060708LL));
-#endif
-
- BOOST_TEST(binary_test_delimited("\x01\x00\x00\x00", 4, byte_, 0x01, pad(4)));
- BOOST_TEST(binary_test_delimited("\x01\x02\x00\x00", 4, word, 0x0102, pad(4)));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04", 4, dword, 0x01020304, pad(4)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00", 10,
- qword, 0x0102030405060708LL, pad(10)));
-#endif
-#endif
- }
-
- { // test native endian binaries
-#ifdef BOOST_LITTLE_ENDIAN
- BOOST_TEST(binary_test("\x01", 1, byte_(0x01)));
- BOOST_TEST(binary_test("\x01\x02", 2, word(0x0201)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword(0x04030201)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
- qword(0x0807060504030201LL)));
-#endif
-#else
- BOOST_TEST(binary_test("\x01", 1, byte_(0x01)));
- BOOST_TEST(binary_test("\x01\x02", 2, word(0x0102)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword(0x01020304)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
- qword(0x0102030405060708LL)));
-#endif
-#endif
- }
-
- { // test big endian binaries
- BOOST_TEST(binary_test("\x01\x82", 2, big_word, 0x0182));
- BOOST_TEST(binary_test("\x81\x02", 2, big_word, 0x8102));
- BOOST_TEST(binary_test("\x01\x02\x03\x84", 4, big_dword, 0x01020384));
- BOOST_TEST(binary_test("\x81\x02\x03\x04", 4, big_dword, 0x81020304));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x88", 8, big_qword,
- 0x0102030405060788LL));
- BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, big_qword,
- 0x8102030405060708LL));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
- 10, big_qword, 0x0102030405060708LL, pad(10)));
-#endif
- }
-
- {
- BOOST_TEST(binary_test("\x01\x02", 2, big_word(0x0102)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, big_dword(0x01020304)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
- big_qword(0x0102030405060708LL)));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
- 10, big_qword(0x0102030405060708LL), pad(10)));
-#endif
- }
-
- { // test little endian binaries
- BOOST_TEST(binary_test("\x01\x82", 2, little_word, 0x8201));
- BOOST_TEST(binary_test("\x81\x02", 2, little_word, 0x0281));
- BOOST_TEST(binary_test("\x01\x02\x03\x84", 4, little_dword, 0x84030201));
- BOOST_TEST(binary_test("\x81\x02\x03\x04", 4, little_dword, 0x04030281));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x88", 8, little_qword,
- 0x8807060504030201LL));
- BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, little_qword,
- 0x0807060504030281LL));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
- 10, little_qword, 0x0807060504030201LL, pad(10)));
-#endif
- }
-
- {
- BOOST_TEST(binary_test("\x01\x02", 2, little_word(0x0201)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, little_dword(0x04030201)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
- little_qword(0x0807060504030201LL)));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
- 10, little_qword(0x0807060504030201LL), pad(10)));
-#endif
- }
-
- { // test native endian binaries
- boost::optional<boost::uint8_t> v8;
- boost::optional<boost::uint16_t> v16;
- boost::optional<boost::uint32_t> v32;
-
-#ifdef BOOST_LITTLE_ENDIAN
-
- BOOST_TEST(!binary_test("", 1, byte_, v8));
- BOOST_TEST(!binary_test("", 2, word, v16));
- BOOST_TEST(!binary_test("", 4, dword, v32));
-#ifdef BOOST_HAS_LONG_LONG
- boost::optional<boost::uint64_t> v64;
- BOOST_TEST(!binary_test("", 8, qword, v64));
-#endif
-
-#else // BOOST_LITTLE_ENDIAN
-
- BOOST_TEST(!binary_test("", 1, byte_, v8));
- BOOST_TEST(!binary_test("", 2, word, v16));
- BOOST_TEST(!binary_test("", 4, dword, v32));
-#ifdef BOOST_HAS_LONG_LONG
- boost::optional<boost::uint64_t> v64;
- BOOST_TEST(!binary_test("", 8, qword, v64));
-#endif
-
-#endif
- }
-
- { // test optional attributes
-
-#ifdef BOOST_LITTLE_ENDIAN
- boost::optional<boost::uint8_t> v8 (0x01);
- BOOST_TEST(binary_test("\x01", 1, byte_, v8));
- boost::optional<boost::uint16_t> v16 (0x0201);
- BOOST_TEST(binary_test("\x01\x02", 2, word, v16));
- boost::optional<boost::uint32_t> v32 (0x04030201);
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, v32));
-#ifdef BOOST_HAS_LONG_LONG
- boost::optional<boost::uint64_t> v64 (0x0807060504030201LL);
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword, v64));
-#endif
-
-#else // BOOST_LITTLE_ENDIAN
-
- boost::optional<boost::uint8_t> v8 (0x01);
- BOOST_TEST(binary_test("\x01", 1, byte_, v8));
- boost::optional<boost::uint16_t> v16 (0x0102);
- BOOST_TEST(binary_test("\x01\x02", 2, word, v16));
- boost::optional<boost::uint32_t> v32 (0x01020304);
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, v32));
-#ifdef BOOST_HAS_LONG_LONG
- boost::optional<boost::uint64_t> v64 (0x0102030405060708LL);
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword, v64));
-#endif
-
-#endif
- }
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- { // test Phoenix expression attributes, only supported if
- // karma_phoenix_attributes.hpp is included
- namespace phoenix = boost::phoenix;
-
-#ifdef BOOST_LITTLE_ENDIAN
- BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::val(0x01)));
- BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::val(0x0201)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword,
- phoenix::val(0x04030201)));
-
- boost::uint8_t v8 (0x01);
- BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::ref(v8)));
- BOOST_TEST(binary_test("\x02", 1, byte_, ++phoenix::ref(v8)));
-
- boost::uint16_t v16 (0x0201);
- BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::ref(v16)));
- BOOST_TEST(binary_test("\x02\x02", 2, word, ++phoenix::ref(v16)));
-
- boost::uint32_t v32 (0x04030201);
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, phoenix::ref(v32)));
- BOOST_TEST(binary_test("\x02\x02\x03\x04", 4, dword, ++phoenix::ref(v32)));
-
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- phoenix::val(0x0807060504030201LL)));
-
- boost::uint64_t v64 (0x0807060504030201LL);
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- phoenix::ref(v64)));
- BOOST_TEST(binary_test("\x02\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- ++phoenix::ref(v64)));
-#endif
-
-#else // BOOST_LITTLE_ENDIAN
-
- BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::val(0x01)));
- BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::val(0x0102)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword,
- phoenix::val(0x01020304)));
-
- boost::uint8_t v8 (0x01);
- BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::ref(v8)));
- BOOST_TEST(binary_test("\x02", 1, byte_, ++phoenix::ref(v8)));
-
- boost::uint16_t v16 (0x0102);
- BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::ref(v16)));
- BOOST_TEST(binary_test("\x01\x03", 2, word, ++phoenix::ref(v16)));
-
- boost::uint32_t v32 (0x01020304);
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, phoenix::ref(v32)));
- BOOST_TEST(binary_test("\x01\x02\x03\x05", 4, dword, ++phoenix::ref(v32)));
-
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- phoenix::val(0x0102030405060708LL)));
-
- boost::uint64_t v64 (0x0102030405060708LL);
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- phoenix::ref(v64)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x09", 8, qword,
- ++phoenix::ref(v64)));
-#endif
-
-#endif
- }
-#endif
-
- return boost::report_errors();
-}

Copied: trunk/libs/spirit/test/karma/binary1.cpp (from r67483, /trunk/libs/spirit/test/karma/binary.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/binary.cpp (original)
+++ trunk/libs/spirit/test/karma/binary1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -93,184 +93,5 @@
 #endif
     }
 
- { // test big endian binaries
- BOOST_TEST(binary_test("\x01\x82", 2, big_word, 0x0182));
- BOOST_TEST(binary_test("\x81\x02", 2, big_word, 0x8102));
- BOOST_TEST(binary_test("\x01\x02\x03\x84", 4, big_dword, 0x01020384));
- BOOST_TEST(binary_test("\x81\x02\x03\x04", 4, big_dword, 0x81020304));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x88", 8, big_qword,
- 0x0102030405060788LL));
- BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, big_qword,
- 0x8102030405060708LL));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
- 10, big_qword, 0x0102030405060708LL, pad(10)));
-#endif
- }
-
- {
- BOOST_TEST(binary_test("\x01\x02", 2, big_word(0x0102)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, big_dword(0x01020304)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
- big_qword(0x0102030405060708LL)));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
- 10, big_qword(0x0102030405060708LL), pad(10)));
-#endif
- }
-
- { // test little endian binaries
- BOOST_TEST(binary_test("\x01\x82", 2, little_word, 0x8201));
- BOOST_TEST(binary_test("\x81\x02", 2, little_word, 0x0281));
- BOOST_TEST(binary_test("\x01\x02\x03\x84", 4, little_dword, 0x84030201));
- BOOST_TEST(binary_test("\x81\x02\x03\x04", 4, little_dword, 0x04030281));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x88", 8, little_qword,
- 0x8807060504030201LL));
- BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, little_qword,
- 0x0807060504030281LL));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
- 10, little_qword, 0x0807060504030201LL, pad(10)));
-#endif
- }
-
- {
- BOOST_TEST(binary_test("\x01\x02", 2, little_word(0x0201)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, little_dword(0x04030201)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
- little_qword(0x0807060504030201LL)));
- BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
- 10, little_qword(0x0807060504030201LL), pad(10)));
-#endif
- }
-
- { // test native endian binaries
- boost::optional<boost::uint8_t> v8;
- boost::optional<boost::uint16_t> v16;
- boost::optional<boost::uint32_t> v32;
-
-#ifdef BOOST_LITTLE_ENDIAN
-
- BOOST_TEST(!binary_test("", 1, byte_, v8));
- BOOST_TEST(!binary_test("", 2, word, v16));
- BOOST_TEST(!binary_test("", 4, dword, v32));
-#ifdef BOOST_HAS_LONG_LONG
- boost::optional<boost::uint64_t> v64;
- BOOST_TEST(!binary_test("", 8, qword, v64));
-#endif
-
-#else // BOOST_LITTLE_ENDIAN
-
- BOOST_TEST(!binary_test("", 1, byte_, v8));
- BOOST_TEST(!binary_test("", 2, word, v16));
- BOOST_TEST(!binary_test("", 4, dword, v32));
-#ifdef BOOST_HAS_LONG_LONG
- boost::optional<boost::uint64_t> v64;
- BOOST_TEST(!binary_test("", 8, qword, v64));
-#endif
-
-#endif
- }
-
- { // test optional attributes
-
-#ifdef BOOST_LITTLE_ENDIAN
- boost::optional<boost::uint8_t> v8 (0x01);
- BOOST_TEST(binary_test("\x01", 1, byte_, v8));
- boost::optional<boost::uint16_t> v16 (0x0201);
- BOOST_TEST(binary_test("\x01\x02", 2, word, v16));
- boost::optional<boost::uint32_t> v32 (0x04030201);
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, v32));
-#ifdef BOOST_HAS_LONG_LONG
- boost::optional<boost::uint64_t> v64 (0x0807060504030201LL);
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword, v64));
-#endif
-
-#else // BOOST_LITTLE_ENDIAN
-
- boost::optional<boost::uint8_t> v8 (0x01);
- BOOST_TEST(binary_test("\x01", 1, byte_, v8));
- boost::optional<boost::uint16_t> v16 (0x0102);
- BOOST_TEST(binary_test("\x01\x02", 2, word, v16));
- boost::optional<boost::uint32_t> v32 (0x01020304);
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, v32));
-#ifdef BOOST_HAS_LONG_LONG
- boost::optional<boost::uint64_t> v64 (0x0102030405060708LL);
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword, v64));
-#endif
-
-#endif
- }
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- { // test Phoenix expression attributes, only supported if
- // karma_phoenix_attributes.hpp is included
- namespace phoenix = boost::phoenix;
-
-#ifdef BOOST_LITTLE_ENDIAN
- BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::val(0x01)));
- BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::val(0x0201)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword,
- phoenix::val(0x04030201)));
-
- boost::uint8_t v8 (0x01);
- BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::ref(v8)));
- BOOST_TEST(binary_test("\x02", 1, byte_, ++phoenix::ref(v8)));
-
- boost::uint16_t v16 (0x0201);
- BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::ref(v16)));
- BOOST_TEST(binary_test("\x02\x02", 2, word, ++phoenix::ref(v16)));
-
- boost::uint32_t v32 (0x04030201);
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, phoenix::ref(v32)));
- BOOST_TEST(binary_test("\x02\x02\x03\x04", 4, dword, ++phoenix::ref(v32)));
-
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- phoenix::val(0x0807060504030201LL)));
-
- boost::uint64_t v64 (0x0807060504030201LL);
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- phoenix::ref(v64)));
- BOOST_TEST(binary_test("\x02\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- ++phoenix::ref(v64)));
-#endif
-
-#else // BOOST_LITTLE_ENDIAN
-
- BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::val(0x01)));
- BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::val(0x0102)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword,
- phoenix::val(0x01020304)));
-
- boost::uint8_t v8 (0x01);
- BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::ref(v8)));
- BOOST_TEST(binary_test("\x02", 1, byte_, ++phoenix::ref(v8)));
-
- boost::uint16_t v16 (0x0102);
- BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::ref(v16)));
- BOOST_TEST(binary_test("\x01\x03", 2, word, ++phoenix::ref(v16)));
-
- boost::uint32_t v32 (0x01020304);
- BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, phoenix::ref(v32)));
- BOOST_TEST(binary_test("\x01\x02\x03\x05", 4, dword, ++phoenix::ref(v32)));
-
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- phoenix::val(0x0102030405060708LL)));
-
- boost::uint64_t v64 (0x0102030405060708LL);
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
- phoenix::ref(v64)));
- BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x09", 8, qword,
- ++phoenix::ref(v64)));
-#endif
-
-#endif
- }
-#endif
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/karma/binary2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/binary2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,109 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_binary.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_phoenix_attributes.hpp>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+ using namespace boost::phoenix;
+
+ { // test big endian binaries
+ BOOST_TEST(binary_test("\x01\x82", 2, big_word, 0x0182));
+ BOOST_TEST(binary_test("\x81\x02", 2, big_word, 0x8102));
+ BOOST_TEST(binary_test("\x01\x02\x03\x84", 4, big_dword, 0x01020384));
+ BOOST_TEST(binary_test("\x81\x02\x03\x04", 4, big_dword, 0x81020304));
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x88", 8, big_qword,
+ 0x0102030405060788LL));
+ BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, big_qword,
+ 0x8102030405060708LL));
+ BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
+ 10, big_qword, 0x0102030405060708LL, pad(10)));
+#endif
+ }
+
+ {
+ BOOST_TEST(binary_test("\x01\x02", 2, big_word(0x0102)));
+ BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, big_dword(0x01020304)));
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
+ big_qword(0x0102030405060708LL)));
+ BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
+ 10, big_qword(0x0102030405060708LL), pad(10)));
+#endif
+ }
+
+ { // test little endian binaries
+ BOOST_TEST(binary_test("\x01\x82", 2, little_word, 0x8201));
+ BOOST_TEST(binary_test("\x81\x02", 2, little_word, 0x0281));
+ BOOST_TEST(binary_test("\x01\x02\x03\x84", 4, little_dword, 0x84030201));
+ BOOST_TEST(binary_test("\x81\x02\x03\x04", 4, little_dword, 0x04030281));
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x88", 8, little_qword,
+ 0x8807060504030201LL));
+ BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, little_qword,
+ 0x0807060504030281LL));
+ BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
+ 10, little_qword, 0x0807060504030201LL, pad(10)));
+#endif
+ }
+
+ {
+ BOOST_TEST(binary_test("\x01\x02", 2, little_word(0x0201)));
+ BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, little_dword(0x04030201)));
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
+ little_qword(0x0807060504030201LL)));
+ BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
+ 10, little_qword(0x0807060504030201LL), pad(10)));
+#endif
+ }
+
+ { // test native endian binaries
+ boost::optional<boost::uint8_t> v8;
+ boost::optional<boost::uint16_t> v16;
+ boost::optional<boost::uint32_t> v32;
+
+#ifdef BOOST_LITTLE_ENDIAN
+
+ BOOST_TEST(!binary_test("", 1, byte_, v8));
+ BOOST_TEST(!binary_test("", 2, word, v16));
+ BOOST_TEST(!binary_test("", 4, dword, v32));
+#ifdef BOOST_HAS_LONG_LONG
+ boost::optional<boost::uint64_t> v64;
+ BOOST_TEST(!binary_test("", 8, qword, v64));
+#endif
+
+#else // BOOST_LITTLE_ENDIAN
+
+ BOOST_TEST(!binary_test("", 1, byte_, v8));
+ BOOST_TEST(!binary_test("", 2, word, v16));
+ BOOST_TEST(!binary_test("", 4, dword, v32));
+#ifdef BOOST_HAS_LONG_LONG
+ boost::optional<boost::uint64_t> v64;
+ BOOST_TEST(!binary_test("", 8, qword, v64));
+#endif
+
+#endif
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/karma/binary3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/binary3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,128 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_binary.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_phoenix_attributes.hpp>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+ using namespace boost::phoenix;
+
+ { // test optional attributes
+
+#ifdef BOOST_LITTLE_ENDIAN
+ boost::optional<boost::uint8_t> v8 (0x01);
+ BOOST_TEST(binary_test("\x01", 1, byte_, v8));
+ boost::optional<boost::uint16_t> v16 (0x0201);
+ BOOST_TEST(binary_test("\x01\x02", 2, word, v16));
+ boost::optional<boost::uint32_t> v32 (0x04030201);
+ BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, v32));
+#ifdef BOOST_HAS_LONG_LONG
+ boost::optional<boost::uint64_t> v64 (0x0807060504030201LL);
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword, v64));
+#endif
+
+#else // BOOST_LITTLE_ENDIAN
+
+ boost::optional<boost::uint8_t> v8 (0x01);
+ BOOST_TEST(binary_test("\x01", 1, byte_, v8));
+ boost::optional<boost::uint16_t> v16 (0x0102);
+ BOOST_TEST(binary_test("\x01\x02", 2, word, v16));
+ boost::optional<boost::uint32_t> v32 (0x01020304);
+ BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, v32));
+#ifdef BOOST_HAS_LONG_LONG
+ boost::optional<boost::uint64_t> v64 (0x0102030405060708LL);
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword, v64));
+#endif
+
+#endif
+ }
+
+// we support Phoenix attributes only starting with V2.2
+#if SPIRIT_VERSION >= 0x2020
+ { // test Phoenix expression attributes, only supported if
+ // karma_phoenix_attributes.hpp is included
+ namespace phoenix = boost::phoenix;
+
+#ifdef BOOST_LITTLE_ENDIAN
+ BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::val(0x01)));
+ BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::val(0x0201)));
+ BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword,
+ phoenix::val(0x04030201)));
+
+ boost::uint8_t v8 (0x01);
+ BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::ref(v8)));
+ BOOST_TEST(binary_test("\x02", 1, byte_, ++phoenix::ref(v8)));
+
+ boost::uint16_t v16 (0x0201);
+ BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::ref(v16)));
+ BOOST_TEST(binary_test("\x02\x02", 2, word, ++phoenix::ref(v16)));
+
+ boost::uint32_t v32 (0x04030201);
+ BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, phoenix::ref(v32)));
+ BOOST_TEST(binary_test("\x02\x02\x03\x04", 4, dword, ++phoenix::ref(v32)));
+
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
+ phoenix::val(0x0807060504030201LL)));
+
+ boost::uint64_t v64 (0x0807060504030201LL);
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
+ phoenix::ref(v64)));
+ BOOST_TEST(binary_test("\x02\x02\x03\x04\x05\x06\x07\x08", 8, qword,
+ ++phoenix::ref(v64)));
+#endif
+
+#else // BOOST_LITTLE_ENDIAN
+
+ BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::val(0x01)));
+ BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::val(0x0102)));
+ BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword,
+ phoenix::val(0x01020304)));
+
+ boost::uint8_t v8 (0x01);
+ BOOST_TEST(binary_test("\x01", 1, byte_, phoenix::ref(v8)));
+ BOOST_TEST(binary_test("\x02", 1, byte_, ++phoenix::ref(v8)));
+
+ boost::uint16_t v16 (0x0102);
+ BOOST_TEST(binary_test("\x01\x02", 2, word, phoenix::ref(v16)));
+ BOOST_TEST(binary_test("\x01\x03", 2, word, ++phoenix::ref(v16)));
+
+ boost::uint32_t v32 (0x01020304);
+ BOOST_TEST(binary_test("\x01\x02\x03\x04", 4, dword, phoenix::ref(v32)));
+ BOOST_TEST(binary_test("\x01\x02\x03\x05", 4, dword, ++phoenix::ref(v32)));
+
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
+ phoenix::val(0x0102030405060708LL)));
+
+ boost::uint64_t v64 (0x0102030405060708LL);
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword,
+ phoenix::ref(v64)));
+ BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x09", 8, qword,
+ ++phoenix::ref(v64)));
+#endif
+
+#endif
+ }
+#endif
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/karma/case_handling.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/case_handling.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,285 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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)
-
-// this file intentionally contains non-ascii characters
-// boostinspect:noascii
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/detail/workaround.hpp>
-
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_string.hpp>
-#include <boost/spirit/include/karma_generate.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-int
-main()
-{
- using namespace boost::spirit;
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("x", lower['X']));
- BOOST_TEST(test("x", lower['x']));
-
- BOOST_TEST(test("x", lower[char_], 'X'));
- BOOST_TEST(test("x", lower[char_], 'x'));
- BOOST_TEST(test("x", lower[char_('X')]));
- BOOST_TEST(test("x", lower[char_('x')]));
-
- BOOST_TEST(test(" ", lower[space]));
- BOOST_TEST(test("\t", lower[space], '\t'));
-
- BOOST_TEST(test("x", lower[lower['X']]));
- BOOST_TEST(test("x", lower[lower['x']]));
-
- BOOST_TEST(test("x", lower[lower[char_]], 'X'));
- BOOST_TEST(test("x", lower[lower[char_]], 'x'));
- BOOST_TEST(test("x", lower[lower[char_('X')]]));
- BOOST_TEST(test("x", lower[lower[char_('x')]]));
-
- BOOST_TEST(test(" ", lower[lower[space]]));
- BOOST_TEST(test("\t", lower[lower[space]], '\t'));
-
- BOOST_TEST(test("X", upper[lower['X']]));
- BOOST_TEST(test("X", upper[lower['x']]));
-
- BOOST_TEST(test("X", upper[lower[char_]], 'X'));
- BOOST_TEST(test("X", upper[lower[char_]], 'x'));
- BOOST_TEST(test("X", upper[lower[char_('X')]]));
- BOOST_TEST(test("X", upper[lower[char_('x')]]));
-
- BOOST_TEST(test(" ", upper[lower[space]]));
- BOOST_TEST(test("\t", upper[lower[space]], '\t'));
-
- BOOST_TEST(test("X", upper['X']));
- BOOST_TEST(test("X", upper['x']));
-
- BOOST_TEST(test("X", upper[char_], 'X'));
- BOOST_TEST(test("X", upper[char_], 'x'));
- BOOST_TEST(test("X", upper[char_('X')]));
- BOOST_TEST(test("X", upper[char_('x')]));
-
- BOOST_TEST(test(" ", upper[space]));
- BOOST_TEST(test("\t", upper[space], '\t'));
-
- BOOST_TEST(test("x", lower[upper['X']]));
- BOOST_TEST(test("x", lower[upper['x']]));
-
- BOOST_TEST(test("x", lower[upper[char_]], 'X'));
- BOOST_TEST(test("x", lower[upper[char_]], 'x'));
- BOOST_TEST(test("x", lower[upper[char_('X')]]));
- BOOST_TEST(test("x", lower[upper[char_('x')]]));
-
- BOOST_TEST(test(" ", lower[upper[space]]));
- BOOST_TEST(test("\t", lower[upper[space]], '\t'));
-
- BOOST_TEST(test("X", upper[upper['X']]));
- BOOST_TEST(test("X", upper[upper['x']]));
-
- BOOST_TEST(test("X", upper[upper[char_]], 'X'));
- BOOST_TEST(test("X", upper[upper[char_]], 'x'));
- BOOST_TEST(test("X", upper[upper[char_('X')]]));
- BOOST_TEST(test("X", upper[upper[char_('x')]]));
-
- BOOST_TEST(test(" ", upper[upper[space]]));
- BOOST_TEST(test("\t", upper[upper[space]], '\t'));
- }
-
- {
- using namespace boost::spirit::standard_wide;
-
- BOOST_TEST(test(L"x", lower[L'X']));
- BOOST_TEST(test(L"x", lower[L'x']));
-
- BOOST_TEST(test(L"x", lower[char_], L'X'));
- BOOST_TEST(test(L"x", lower[char_], L'x'));
- BOOST_TEST(test(L"x", lower[char_(L'X')]));
- BOOST_TEST(test(L"x", lower[char_(L'x')]));
-
- BOOST_TEST(test(L" ", lower[space]));
- BOOST_TEST(test(L"\t", lower[space], L'\t'));
-
- BOOST_TEST(test(L"x", lower[lower[L'X']]));
- BOOST_TEST(test(L"x", lower[lower[L'x']]));
-
- BOOST_TEST(test(L"x", lower[lower[char_]], L'X'));
- BOOST_TEST(test(L"x", lower[lower[char_]], L'x'));
- BOOST_TEST(test(L"x", lower[lower[char_(L'X')]]));
- BOOST_TEST(test(L"x", lower[lower[char_(L'x')]]));
-
- BOOST_TEST(test(L" ", lower[lower[space]]));
- BOOST_TEST(test(L"\t", lower[lower[space]], L'\t'));
-
- BOOST_TEST(test(L"X", upper[lower[L'X']]));
- BOOST_TEST(test(L"X", upper[lower[L'x']]));
-
- BOOST_TEST(test(L"X", upper[lower[char_]], L'X'));
- BOOST_TEST(test(L"X", upper[lower[char_]], L'x'));
- BOOST_TEST(test(L"X", upper[lower[char_(L'X')]]));
- BOOST_TEST(test(L"X", upper[lower[char_(L'x')]]));
-
- BOOST_TEST(test(L" ", upper[lower[space]]));
- BOOST_TEST(test(L"\t", upper[lower[space]], L'\t'));
-
- BOOST_TEST(test(L"X", upper[L'X']));
- BOOST_TEST(test(L"X", upper[L'x']));
-
- BOOST_TEST(test(L"X", upper[char_], L'X'));
- BOOST_TEST(test(L"X", upper[char_], L'x'));
- BOOST_TEST(test(L"X", upper[char_(L'X')]));
- BOOST_TEST(test(L"X", upper[char_(L'x')]));
-
- BOOST_TEST(test(L" ", upper[space]));
- BOOST_TEST(test(L"\t", upper[space], L'\t'));
-
- BOOST_TEST(test(L"x", lower[upper[L'X']]));
- BOOST_TEST(test(L"x", lower[upper[L'x']]));
-
- BOOST_TEST(test(L"x", lower[upper[char_]], L'X'));
- BOOST_TEST(test(L"x", lower[upper[char_]], L'x'));
- BOOST_TEST(test(L"x", lower[upper[char_(L'X')]]));
- BOOST_TEST(test(L"x", lower[upper[char_(L'x')]]));
-
- BOOST_TEST(test(L" ", lower[upper[space]]));
- BOOST_TEST(test(L"\t", lower[upper[space]], L'\t'));
-
- BOOST_TEST(test(L"X", upper[upper[L'X']]));
- BOOST_TEST(test(L"X", upper[upper[L'x']]));
-
- BOOST_TEST(test(L"X", upper[upper[char_]], L'X'));
- BOOST_TEST(test(L"X", upper[upper[char_]], L'x'));
- BOOST_TEST(test(L"X", upper[upper[char_(L'X')]]));
- BOOST_TEST(test(L"X", upper[upper[char_(L'x')]]));
-
- BOOST_TEST(test(L" ", upper[upper[space]]));
- BOOST_TEST(test(L"\t", upper[upper[space]], L'\t'));
- }
-
-// needed for VC7.1 only
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("german")
-#endif
- {
- using namespace boost::spirit::iso8859_1;
-
- BOOST_TEST(test("ä", lower['Ä']));
- BOOST_TEST(test("ä", lower['ä']));
-
- BOOST_TEST(test("Ä", upper['Ä']));
- BOOST_TEST(test("Ä", upper['ä']));
- }
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("")
-#endif
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("a1- ", lower["a1- "]));
- BOOST_TEST(test("a1- ", lower["a1- "]));
- BOOST_TEST(test("a1- ", lower["a1- "]));
- BOOST_TEST(test("a1- ", lower["A1- "]));
-
- BOOST_TEST(test("a1- ", lower[string], "a1- "));
- BOOST_TEST(test("a1- ", lower[string], "A1- "));
- BOOST_TEST(test("a1- ", lower[lit("a1- ")]));
- BOOST_TEST(test("a1- ", lower[lit("A1- ")]));
- BOOST_TEST(test("a1- ", lower[string("a1- ")]));
- BOOST_TEST(test("a1- ", lower[string("A1- ")]));
-
- BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
- BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
- BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
- BOOST_TEST(test("a1- ", lower[lower["A1- "]]));
-
- BOOST_TEST(test("a1- ", lower[lower[string]], "a1- "));
- BOOST_TEST(test("a1- ", lower[lower[string]], "A1- "));
- BOOST_TEST(test("a1- ", lower[lower[lit("a1- ")]]));
- BOOST_TEST(test("a1- ", lower[lower[lit("A1- ")]]));
- BOOST_TEST(test("a1- ", lower[lower[string("a1- ")]]));
- BOOST_TEST(test("a1- ", lower[lower[string("A1- ")]]));
-
- BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
- BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
- BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
- BOOST_TEST(test("A1- ", upper[lower["A1- "]]));
-
- BOOST_TEST(test("A1- ", upper[lower[string]], "a1- "));
- BOOST_TEST(test("A1- ", upper[lower[string]], "A1- "));
- BOOST_TEST(test("A1- ", upper[lower[lit("a1- ")]]));
- BOOST_TEST(test("A1- ", upper[lower[lit("A1- ")]]));
- BOOST_TEST(test("A1- ", upper[lower[string("a1- ")]]));
- BOOST_TEST(test("A1- ", upper[lower[string("A1- ")]]));
-
- BOOST_TEST(test("A1- ", upper["a1- "]));
- BOOST_TEST(test("A1- ", upper["a1- "]));
- BOOST_TEST(test("A1- ", upper["a1- "]));
- BOOST_TEST(test("A1- ", upper["A1- "]));
-
- BOOST_TEST(test("A1- ", upper[string], "a1- "));
- BOOST_TEST(test("A1- ", upper[string], "A1- "));
- BOOST_TEST(test("A1- ", upper[lit("a1- ")]));
- BOOST_TEST(test("A1- ", upper[lit("A1- ")]));
-
- BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
- BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
- BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
- BOOST_TEST(test("a1- ", lower[upper["A1- "]]));
-
- BOOST_TEST(test("a1- ", lower[upper[string]], "a1- "));
- BOOST_TEST(test("a1- ", lower[upper[string]], "A1- "));
- BOOST_TEST(test("a1- ", lower[upper[lit("a1- ")]]));
- BOOST_TEST(test("a1- ", lower[upper[lit("A1- ")]]));
- BOOST_TEST(test("a1- ", lower[upper[string("a1- ")]]));
- BOOST_TEST(test("a1- ", lower[upper[string("A1- ")]]));
-
- BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
- BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
- BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
- BOOST_TEST(test("A1- ", upper[upper["A1- "]]));
-
- BOOST_TEST(test("A1- ", upper[upper[string]], "a1- "));
- BOOST_TEST(test("A1- ", upper[upper[string]], "A1- "));
- BOOST_TEST(test("A1- ", upper[upper[lit("a1- ")]]));
- BOOST_TEST(test("A1- ", upper[upper[lit("A1- ")]]));
- BOOST_TEST(test("A1- ", upper[upper[string("a1- ")]]));
- BOOST_TEST(test("A1- ", upper[upper[string("A1- ")]]));
- }
-
-// needed for VC7.1 only
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("german")
-#endif
- {
- using namespace boost::spirit::iso8859_1;
-
- BOOST_TEST(test("ää", lower["Ää"]));
- BOOST_TEST(test("ää", lower["Ää"]));
-
- BOOST_TEST(test("ÄÄ", upper["Ää"]));
- BOOST_TEST(test("ÄÄ", upper["Ää"]));
- }
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("")
-#endif
-
- {
- using namespace boost::spirit::ascii;
- using boost::phoenix::val;
-
- BOOST_TEST(test("x", lower[val('X')]));
- BOOST_TEST(test("x", lower[val('x')]));
- }
-
- return boost::report_errors();
-}

Copied: trunk/libs/spirit/test/karma/case_handling1.cpp (from r67483, /trunk/libs/spirit/test/karma/case_handling.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/case_handling.cpp (original)
+++ trunk/libs/spirit/test/karma/case_handling1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -95,191 +95,5 @@
         BOOST_TEST(test("\t", upper[upper[space]], '\t'));
     }
 
- {
- using namespace boost::spirit::standard_wide;
-
- BOOST_TEST(test(L"x", lower[L'X']));
- BOOST_TEST(test(L"x", lower[L'x']));
-
- BOOST_TEST(test(L"x", lower[char_], L'X'));
- BOOST_TEST(test(L"x", lower[char_], L'x'));
- BOOST_TEST(test(L"x", lower[char_(L'X')]));
- BOOST_TEST(test(L"x", lower[char_(L'x')]));
-
- BOOST_TEST(test(L" ", lower[space]));
- BOOST_TEST(test(L"\t", lower[space], L'\t'));
-
- BOOST_TEST(test(L"x", lower[lower[L'X']]));
- BOOST_TEST(test(L"x", lower[lower[L'x']]));
-
- BOOST_TEST(test(L"x", lower[lower[char_]], L'X'));
- BOOST_TEST(test(L"x", lower[lower[char_]], L'x'));
- BOOST_TEST(test(L"x", lower[lower[char_(L'X')]]));
- BOOST_TEST(test(L"x", lower[lower[char_(L'x')]]));
-
- BOOST_TEST(test(L" ", lower[lower[space]]));
- BOOST_TEST(test(L"\t", lower[lower[space]], L'\t'));
-
- BOOST_TEST(test(L"X", upper[lower[L'X']]));
- BOOST_TEST(test(L"X", upper[lower[L'x']]));
-
- BOOST_TEST(test(L"X", upper[lower[char_]], L'X'));
- BOOST_TEST(test(L"X", upper[lower[char_]], L'x'));
- BOOST_TEST(test(L"X", upper[lower[char_(L'X')]]));
- BOOST_TEST(test(L"X", upper[lower[char_(L'x')]]));
-
- BOOST_TEST(test(L" ", upper[lower[space]]));
- BOOST_TEST(test(L"\t", upper[lower[space]], L'\t'));
-
- BOOST_TEST(test(L"X", upper[L'X']));
- BOOST_TEST(test(L"X", upper[L'x']));
-
- BOOST_TEST(test(L"X", upper[char_], L'X'));
- BOOST_TEST(test(L"X", upper[char_], L'x'));
- BOOST_TEST(test(L"X", upper[char_(L'X')]));
- BOOST_TEST(test(L"X", upper[char_(L'x')]));
-
- BOOST_TEST(test(L" ", upper[space]));
- BOOST_TEST(test(L"\t", upper[space], L'\t'));
-
- BOOST_TEST(test(L"x", lower[upper[L'X']]));
- BOOST_TEST(test(L"x", lower[upper[L'x']]));
-
- BOOST_TEST(test(L"x", lower[upper[char_]], L'X'));
- BOOST_TEST(test(L"x", lower[upper[char_]], L'x'));
- BOOST_TEST(test(L"x", lower[upper[char_(L'X')]]));
- BOOST_TEST(test(L"x", lower[upper[char_(L'x')]]));
-
- BOOST_TEST(test(L" ", lower[upper[space]]));
- BOOST_TEST(test(L"\t", lower[upper[space]], L'\t'));
-
- BOOST_TEST(test(L"X", upper[upper[L'X']]));
- BOOST_TEST(test(L"X", upper[upper[L'x']]));
-
- BOOST_TEST(test(L"X", upper[upper[char_]], L'X'));
- BOOST_TEST(test(L"X", upper[upper[char_]], L'x'));
- BOOST_TEST(test(L"X", upper[upper[char_(L'X')]]));
- BOOST_TEST(test(L"X", upper[upper[char_(L'x')]]));
-
- BOOST_TEST(test(L" ", upper[upper[space]]));
- BOOST_TEST(test(L"\t", upper[upper[space]], L'\t'));
- }
-
-// needed for VC7.1 only
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("german")
-#endif
- {
- using namespace boost::spirit::iso8859_1;
-
- BOOST_TEST(test("ä", lower['Ä']));
- BOOST_TEST(test("ä", lower['ä']));
-
- BOOST_TEST(test("Ä", upper['Ä']));
- BOOST_TEST(test("Ä", upper['ä']));
- }
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("")
-#endif
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("a1- ", lower["a1- "]));
- BOOST_TEST(test("a1- ", lower["a1- "]));
- BOOST_TEST(test("a1- ", lower["a1- "]));
- BOOST_TEST(test("a1- ", lower["A1- "]));
-
- BOOST_TEST(test("a1- ", lower[string], "a1- "));
- BOOST_TEST(test("a1- ", lower[string], "A1- "));
- BOOST_TEST(test("a1- ", lower[lit("a1- ")]));
- BOOST_TEST(test("a1- ", lower[lit("A1- ")]));
- BOOST_TEST(test("a1- ", lower[string("a1- ")]));
- BOOST_TEST(test("a1- ", lower[string("A1- ")]));
-
- BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
- BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
- BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
- BOOST_TEST(test("a1- ", lower[lower["A1- "]]));
-
- BOOST_TEST(test("a1- ", lower[lower[string]], "a1- "));
- BOOST_TEST(test("a1- ", lower[lower[string]], "A1- "));
- BOOST_TEST(test("a1- ", lower[lower[lit("a1- ")]]));
- BOOST_TEST(test("a1- ", lower[lower[lit("A1- ")]]));
- BOOST_TEST(test("a1- ", lower[lower[string("a1- ")]]));
- BOOST_TEST(test("a1- ", lower[lower[string("A1- ")]]));
-
- BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
- BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
- BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
- BOOST_TEST(test("A1- ", upper[lower["A1- "]]));
-
- BOOST_TEST(test("A1- ", upper[lower[string]], "a1- "));
- BOOST_TEST(test("A1- ", upper[lower[string]], "A1- "));
- BOOST_TEST(test("A1- ", upper[lower[lit("a1- ")]]));
- BOOST_TEST(test("A1- ", upper[lower[lit("A1- ")]]));
- BOOST_TEST(test("A1- ", upper[lower[string("a1- ")]]));
- BOOST_TEST(test("A1- ", upper[lower[string("A1- ")]]));
-
- BOOST_TEST(test("A1- ", upper["a1- "]));
- BOOST_TEST(test("A1- ", upper["a1- "]));
- BOOST_TEST(test("A1- ", upper["a1- "]));
- BOOST_TEST(test("A1- ", upper["A1- "]));
-
- BOOST_TEST(test("A1- ", upper[string], "a1- "));
- BOOST_TEST(test("A1- ", upper[string], "A1- "));
- BOOST_TEST(test("A1- ", upper[lit("a1- ")]));
- BOOST_TEST(test("A1- ", upper[lit("A1- ")]));
-
- BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
- BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
- BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
- BOOST_TEST(test("a1- ", lower[upper["A1- "]]));
-
- BOOST_TEST(test("a1- ", lower[upper[string]], "a1- "));
- BOOST_TEST(test("a1- ", lower[upper[string]], "A1- "));
- BOOST_TEST(test("a1- ", lower[upper[lit("a1- ")]]));
- BOOST_TEST(test("a1- ", lower[upper[lit("A1- ")]]));
- BOOST_TEST(test("a1- ", lower[upper[string("a1- ")]]));
- BOOST_TEST(test("a1- ", lower[upper[string("A1- ")]]));
-
- BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
- BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
- BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
- BOOST_TEST(test("A1- ", upper[upper["A1- "]]));
-
- BOOST_TEST(test("A1- ", upper[upper[string]], "a1- "));
- BOOST_TEST(test("A1- ", upper[upper[string]], "A1- "));
- BOOST_TEST(test("A1- ", upper[upper[lit("a1- ")]]));
- BOOST_TEST(test("A1- ", upper[upper[lit("A1- ")]]));
- BOOST_TEST(test("A1- ", upper[upper[string("a1- ")]]));
- BOOST_TEST(test("A1- ", upper[upper[string("A1- ")]]));
- }
-
-// needed for VC7.1 only
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("german")
-#endif
- {
- using namespace boost::spirit::iso8859_1;
-
- BOOST_TEST(test("ää", lower["Ää"]));
- BOOST_TEST(test("ää", lower["Ää"]));
-
- BOOST_TEST(test("ÄÄ", upper["Ää"]));
- BOOST_TEST(test("ÄÄ", upper["Ää"]));
- }
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("")
-#endif
-
- {
- using namespace boost::spirit::ascii;
- using boost::phoenix::val;
-
- BOOST_TEST(test("x", lower[val('X')]));
- BOOST_TEST(test("x", lower[val('x')]));
- }
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/karma/case_handling2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/case_handling2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,124 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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)
+
+// this file intentionally contains non-ascii characters
+// boostinspect:noascii
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/detail/workaround.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+
+ {
+ using namespace boost::spirit::standard_wide;
+
+ BOOST_TEST(test(L"x", lower[L'X']));
+ BOOST_TEST(test(L"x", lower[L'x']));
+
+ BOOST_TEST(test(L"x", lower[char_], L'X'));
+ BOOST_TEST(test(L"x", lower[char_], L'x'));
+ BOOST_TEST(test(L"x", lower[char_(L'X')]));
+ BOOST_TEST(test(L"x", lower[char_(L'x')]));
+
+ BOOST_TEST(test(L" ", lower[space]));
+ BOOST_TEST(test(L"\t", lower[space], L'\t'));
+
+ BOOST_TEST(test(L"x", lower[lower[L'X']]));
+ BOOST_TEST(test(L"x", lower[lower[L'x']]));
+
+ BOOST_TEST(test(L"x", lower[lower[char_]], L'X'));
+ BOOST_TEST(test(L"x", lower[lower[char_]], L'x'));
+ BOOST_TEST(test(L"x", lower[lower[char_(L'X')]]));
+ BOOST_TEST(test(L"x", lower[lower[char_(L'x')]]));
+
+ BOOST_TEST(test(L" ", lower[lower[space]]));
+ BOOST_TEST(test(L"\t", lower[lower[space]], L'\t'));
+
+ BOOST_TEST(test(L"X", upper[lower[L'X']]));
+ BOOST_TEST(test(L"X", upper[lower[L'x']]));
+
+ BOOST_TEST(test(L"X", upper[lower[char_]], L'X'));
+ BOOST_TEST(test(L"X", upper[lower[char_]], L'x'));
+ BOOST_TEST(test(L"X", upper[lower[char_(L'X')]]));
+ BOOST_TEST(test(L"X", upper[lower[char_(L'x')]]));
+
+ BOOST_TEST(test(L" ", upper[lower[space]]));
+ BOOST_TEST(test(L"\t", upper[lower[space]], L'\t'));
+
+ BOOST_TEST(test(L"X", upper[L'X']));
+ BOOST_TEST(test(L"X", upper[L'x']));
+
+ BOOST_TEST(test(L"X", upper[char_], L'X'));
+ BOOST_TEST(test(L"X", upper[char_], L'x'));
+ BOOST_TEST(test(L"X", upper[char_(L'X')]));
+ BOOST_TEST(test(L"X", upper[char_(L'x')]));
+
+ BOOST_TEST(test(L" ", upper[space]));
+ BOOST_TEST(test(L"\t", upper[space], L'\t'));
+
+ BOOST_TEST(test(L"x", lower[upper[L'X']]));
+ BOOST_TEST(test(L"x", lower[upper[L'x']]));
+
+ BOOST_TEST(test(L"x", lower[upper[char_]], L'X'));
+ BOOST_TEST(test(L"x", lower[upper[char_]], L'x'));
+ BOOST_TEST(test(L"x", lower[upper[char_(L'X')]]));
+ BOOST_TEST(test(L"x", lower[upper[char_(L'x')]]));
+
+ BOOST_TEST(test(L" ", lower[upper[space]]));
+ BOOST_TEST(test(L"\t", lower[upper[space]], L'\t'));
+
+ BOOST_TEST(test(L"X", upper[upper[L'X']]));
+ BOOST_TEST(test(L"X", upper[upper[L'x']]));
+
+ BOOST_TEST(test(L"X", upper[upper[char_]], L'X'));
+ BOOST_TEST(test(L"X", upper[upper[char_]], L'x'));
+ BOOST_TEST(test(L"X", upper[upper[char_(L'X')]]));
+ BOOST_TEST(test(L"X", upper[upper[char_(L'x')]]));
+
+ BOOST_TEST(test(L" ", upper[upper[space]]));
+ BOOST_TEST(test(L"\t", upper[upper[space]], L'\t'));
+ }
+
+// needed for VC7.1 only
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("german")
+#endif
+ {
+ using namespace boost::spirit::iso8859_1;
+
+ BOOST_TEST(test("ää", lower["Ää"]));
+ BOOST_TEST(test("ää", lower["Ää"]));
+
+ BOOST_TEST(test("ÄÄ", upper["Ää"]));
+ BOOST_TEST(test("ÄÄ", upper["Ää"]));
+ }
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("")
+#endif
+
+ {
+ using namespace boost::spirit::ascii;
+ using boost::phoenix::val;
+
+ BOOST_TEST(test("x", lower[val('X')]));
+ BOOST_TEST(test("x", lower[val('x')]));
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/karma/case_handling3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/case_handling3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,120 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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)
+
+// this file intentionally contains non-ascii characters
+// boostinspect:noascii
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/detail/workaround.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+
+// needed for VC7.1 only
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("german")
+#endif
+ {
+ using namespace boost::spirit::iso8859_1;
+
+ BOOST_TEST(test("ä", lower['Ä']));
+ BOOST_TEST(test("ä", lower['ä']));
+
+ BOOST_TEST(test("Ä", upper['Ä']));
+ BOOST_TEST(test("Ä", upper['ä']));
+ }
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("")
+#endif
+
+ {
+ using namespace boost::spirit::ascii;
+
+ BOOST_TEST(test("a1- ", lower["a1- "]));
+ BOOST_TEST(test("a1- ", lower["a1- "]));
+ BOOST_TEST(test("a1- ", lower["a1- "]));
+ BOOST_TEST(test("a1- ", lower["A1- "]));
+
+ BOOST_TEST(test("a1- ", lower[string], "a1- "));
+ BOOST_TEST(test("a1- ", lower[string], "A1- "));
+ BOOST_TEST(test("a1- ", lower[lit("a1- ")]));
+ BOOST_TEST(test("a1- ", lower[lit("A1- ")]));
+ BOOST_TEST(test("a1- ", lower[string("a1- ")]));
+ BOOST_TEST(test("a1- ", lower[string("A1- ")]));
+
+ BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
+ BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
+ BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
+ BOOST_TEST(test("a1- ", lower[lower["A1- "]]));
+
+ BOOST_TEST(test("a1- ", lower[lower[string]], "a1- "));
+ BOOST_TEST(test("a1- ", lower[lower[string]], "A1- "));
+ BOOST_TEST(test("a1- ", lower[lower[lit("a1- ")]]));
+ BOOST_TEST(test("a1- ", lower[lower[lit("A1- ")]]));
+ BOOST_TEST(test("a1- ", lower[lower[string("a1- ")]]));
+ BOOST_TEST(test("a1- ", lower[lower[string("A1- ")]]));
+
+ BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
+ BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
+ BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
+ BOOST_TEST(test("A1- ", upper[lower["A1- "]]));
+
+ BOOST_TEST(test("A1- ", upper[lower[string]], "a1- "));
+ BOOST_TEST(test("A1- ", upper[lower[string]], "A1- "));
+ BOOST_TEST(test("A1- ", upper[lower[lit("a1- ")]]));
+ BOOST_TEST(test("A1- ", upper[lower[lit("A1- ")]]));
+ BOOST_TEST(test("A1- ", upper[lower[string("a1- ")]]));
+ BOOST_TEST(test("A1- ", upper[lower[string("A1- ")]]));
+
+ BOOST_TEST(test("A1- ", upper["a1- "]));
+ BOOST_TEST(test("A1- ", upper["a1- "]));
+ BOOST_TEST(test("A1- ", upper["a1- "]));
+ BOOST_TEST(test("A1- ", upper["A1- "]));
+
+ BOOST_TEST(test("A1- ", upper[string], "a1- "));
+ BOOST_TEST(test("A1- ", upper[string], "A1- "));
+ BOOST_TEST(test("A1- ", upper[lit("a1- ")]));
+ BOOST_TEST(test("A1- ", upper[lit("A1- ")]));
+
+ BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
+ BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
+ BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
+ BOOST_TEST(test("a1- ", lower[upper["A1- "]]));
+
+ BOOST_TEST(test("a1- ", lower[upper[string]], "a1- "));
+ BOOST_TEST(test("a1- ", lower[upper[string]], "A1- "));
+ BOOST_TEST(test("a1- ", lower[upper[lit("a1- ")]]));
+ BOOST_TEST(test("a1- ", lower[upper[lit("A1- ")]]));
+ BOOST_TEST(test("a1- ", lower[upper[string("a1- ")]]));
+ BOOST_TEST(test("a1- ", lower[upper[string("A1- ")]]));
+
+ BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
+ BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
+ BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
+ BOOST_TEST(test("A1- ", upper[upper["A1- "]]));
+
+ BOOST_TEST(test("A1- ", upper[upper[string]], "a1- "));
+ BOOST_TEST(test("A1- ", upper[upper[string]], "A1- "));
+ BOOST_TEST(test("A1- ", upper[upper[lit("a1- ")]]));
+ BOOST_TEST(test("A1- ", upper[upper[lit("A1- ")]]));
+ BOOST_TEST(test("A1- ", upper[upper[string("a1- ")]]));
+ BOOST_TEST(test("A1- ", upper[upper[string("A1- ")]]));
+ }
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/karma/char.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/char.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,306 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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)
-
-//#define KARMA_FAIL_COMPILATION
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_generate.hpp>
-#include <boost/spirit/include/karma_action.hpp>
-#include <boost/spirit/include/karma_phoenix_attributes.hpp>
-
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-int
-main()
-{
- using namespace boost::spirit;
- using namespace boost::phoenix;
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("x", 'x'));
- BOOST_TEST(test(L"x", L'x'));
- BOOST_TEST(!test("x", 'y'));
- BOOST_TEST(!test(L"x", L'y'));
-
- BOOST_TEST(test("x", "x"));
- BOOST_TEST(test(L"x", L"x"));
- BOOST_TEST(!test("x", "y"));
- BOOST_TEST(!test(L"x", L"y"));
-
- BOOST_TEST(test("x", char_, 'x'));
- BOOST_TEST(test(L"x", char_, L'x'));
- BOOST_TEST(!test("x", char_, 'y'));
- BOOST_TEST(!test(L"x", char_, L'y'));
-
- BOOST_TEST(test("x", char_('x')));
- BOOST_TEST(!test("x", char_('y')));
-
- BOOST_TEST(test("x", char_('x'), 'x'));
- BOOST_TEST(!test("", char_('y'), 'x'));
-
- BOOST_TEST(test("x", char_("x")));
-
- BOOST_TEST(test("a", char_('a', 'z'), 'a'));
- BOOST_TEST(test("b", char_('a', 'z'), 'b'));
- BOOST_TEST(!test("", char_('a', 'z'), 'A'));
-
- BOOST_TEST(test("a", char_("a-z"), 'a'));
- BOOST_TEST(test("b", char_("a-z"), 'b'));
- BOOST_TEST(!test("", char_("a-z"), 'A'));
-
-#if defined(KARMA_FAIL_COMPILATION)
- BOOST_TEST(test("x", char_)); // anychar without a parameter doesn't make any sense
- BOOST_TEST(test("", char_('a', 'z'))); // char sets without attribute neither
-#endif
-
- BOOST_TEST(!test("", ~char_('x')));
-
- BOOST_TEST(!test("", ~char_('x'), 'x'));
- BOOST_TEST(test("x", ~char_('y'), 'x'));
-
- BOOST_TEST(!test("", ~char_("x")));
-
- BOOST_TEST(!test("", ~char_('a', 'z'), 'a'));
- BOOST_TEST(!test("", ~char_('a', 'z'), 'b'));
- BOOST_TEST(test("A", ~char_('a', 'z'), 'A'));
-
- BOOST_TEST(!test("", ~char_("a-z"), 'a'));
- BOOST_TEST(!test("", ~char_("a-z"), 'b'));
- BOOST_TEST(test("A", ~char_("a-z"), 'A'));
-
- BOOST_TEST(test("x", ~~char_('x')));
- BOOST_TEST(!test("x", ~~char_('y')));
-
- BOOST_TEST(test("x", ~~char_('x'), 'x'));
- BOOST_TEST(!test("", ~~char_('y'), 'x'));
-
- BOOST_TEST(test("x", ~~char_("x")));
-
- BOOST_TEST(test("a", ~~char_('a', 'z'), 'a'));
- BOOST_TEST(test("b", ~~char_('a', 'z'), 'b'));
- BOOST_TEST(!test("", ~~char_('a', 'z'), 'A'));
-
- BOOST_TEST(test("a", ~~char_("a-z"), 'a'));
- BOOST_TEST(test("b", ~~char_("a-z"), 'b'));
- BOOST_TEST(!test("", ~~char_("a-z"), 'A'));
- }
-
- {
- using namespace boost::spirit::standard_wide;
-
- BOOST_TEST(test(L"x", 'x'));
- BOOST_TEST(test(L"x", L'x'));
- BOOST_TEST(!test(L"x", 'y'));
- BOOST_TEST(!test(L"x", L'y'));
-
- BOOST_TEST(test(L"x", "x"));
- BOOST_TEST(test(L"x", L"x"));
- BOOST_TEST(!test(L"x", "y"));
- BOOST_TEST(!test(L"x", L"y"));
-
- BOOST_TEST(test(L"x", char_, 'x'));
- BOOST_TEST(test(L"x", char_, L'x'));
- BOOST_TEST(!test(L"x", char_, 'y'));
- BOOST_TEST(!test(L"x", char_, L'y'));
-
- BOOST_TEST(test(L"x", char_('x')));
- BOOST_TEST(test(L"x", char_(L'x')));
- BOOST_TEST(!test(L"x", char_('y')));
- BOOST_TEST(!test(L"x", char_(L'y')));
-
- BOOST_TEST(test(L"x", char_(L'x'), L'x'));
- BOOST_TEST(!test(L"", char_('y'), L'x'));
-
- BOOST_TEST(test(L"x", char_(L"x")));
-
- BOOST_TEST(test("a", char_("a", "z"), 'a'));
- BOOST_TEST(test(L"a", char_(L"a", L"z"), L'a'));
-
-#if defined(KARMA_FAIL_COMPILATION)
- BOOST_TEST(test("x", char_)); // anychar without a parameter doesn't make any sense
-#endif
-
- BOOST_TEST(!test(L"", ~char_('x')));
- BOOST_TEST(!test(L"", ~char_(L'x')));
-
- BOOST_TEST(!test(L"", ~char_(L'x'), L'x'));
- BOOST_TEST(test(L"x", ~char_('y'), L'x'));
-
- BOOST_TEST(!test(L"", ~char_(L"x")));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test(" ", space));
- BOOST_TEST(test(L" ", space));
- BOOST_TEST(!test("\t", space));
- BOOST_TEST(!test(L"\t", space));
-
- BOOST_TEST(test(" ", space, ' '));
- BOOST_TEST(test(L" ", space, L' '));
- BOOST_TEST(test("\t", space, '\t'));
- BOOST_TEST(test(L"\t", space, L'\t'));
-
- BOOST_TEST(!test("", space, 'x'));
- BOOST_TEST(!test(L"", space, L'x'));
-
- BOOST_TEST(!test(" ", ~space, ' '));
- BOOST_TEST(!test(L" ", ~space, L' '));
-
- BOOST_TEST(test("x", ~space, 'x'));
- BOOST_TEST(test(L"x", ~space, L'x'));
- }
-
- {
- using namespace boost::spirit::standard_wide;
-
- BOOST_TEST(test(" ", space));
- BOOST_TEST(test(L" ", space));
- BOOST_TEST(!test("\t", space));
- BOOST_TEST(!test(L"\t", space));
-
- BOOST_TEST(test(" ", space, ' '));
- BOOST_TEST(test(L" ", space, L' '));
- BOOST_TEST(test("\t", space, '\t'));
- BOOST_TEST(test(L"\t", space, L'\t'));
-
- BOOST_TEST(!test("", space, 'x'));
- BOOST_TEST(!test(L"", space, L'x'));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test_delimited("x ", 'x', ' '));
- BOOST_TEST(test_delimited(L"x ", L'x', L' '));
- BOOST_TEST(!test_delimited("x ", 'y', ' '));
- BOOST_TEST(!test_delimited(L"x ", L'y', L' '));
-
- BOOST_TEST(test_delimited("x ", 'x', ' '));
- BOOST_TEST(test_delimited(L"x ", L'x', L' '));
- BOOST_TEST(!test_delimited("x ", 'y', ' '));
- BOOST_TEST(!test_delimited(L"x ", L'y', L' '));
-
- BOOST_TEST(test_delimited("x ", char_, 'x', ' '));
- BOOST_TEST(test_delimited(L"x ", char_, L'x', L' '));
- BOOST_TEST(!test_delimited("x ", char_, 'y', ' '));
- BOOST_TEST(!test_delimited(L"x ", char_, L'y', L' '));
-
- BOOST_TEST(test_delimited("x ", char_('x'), ' '));
- BOOST_TEST(!test_delimited("x ", char_('y'), ' '));
-
- BOOST_TEST(test_delimited("x ", char_('x'), 'x', ' '));
- BOOST_TEST(!test_delimited("", char_('y'), 'x', ' '));
-
- BOOST_TEST(test_delimited("x ", char_("x"), ' '));
-
-#if defined(KARMA_FAIL_COMPILATION)
- BOOST_TEST(test_delimited("x ", char_, ' ')); // anychar without a parameter doesn't make any sense
-#endif
- }
-
- { // pre-delimiting
- {
- std::string generated;
- std::back_insert_iterator<std::string> it(generated);
- BOOST_TEST(karma::generate_delimited(it, '_', '^'
- , karma::delimit_flag::predelimit));
- BOOST_TEST(generated == "^_^");
- }
- {
- using namespace boost::spirit::standard_wide;
- std::basic_string<wchar_t> generated;
- std::back_insert_iterator<std::basic_string<wchar_t> > it(generated);
- BOOST_TEST(karma::generate_delimited(it, char_, L'.'
- , karma::delimit_flag::predelimit, L'x'));
- BOOST_TEST(generated == L".x.");
- }
- }
-
- // action tests
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("x", char_[_1 = val('x')]));
- BOOST_TEST(!test("x", char_[_1 = val('y')]));
- }
-
- { // lazy chars
- namespace ascii = boost::spirit::ascii;
- namespace wide = boost::spirit::standard_wide;
-
- using namespace boost::phoenix;
-
- BOOST_TEST((test("x", ascii::char_(val('x')))));
- BOOST_TEST((test(L"x", wide::char_(val(L'x')))));
-
- BOOST_TEST((test("x", ascii::char_(val('x')), 'x')));
- BOOST_TEST((test(L"x", wide::char_(val(L'x')), L'x')));
-
- BOOST_TEST((!test("", ascii::char_(val('y')), 'x')));
- BOOST_TEST((!test(L"", wide::char_(val(L'y')), L'x')));
- }
-
- // we can pass optionals as attributes to any generator
- {
- namespace ascii = boost::spirit::ascii;
- namespace wide = boost::spirit::standard_wide;
-
- boost::optional<char> v;
- boost::optional<wchar_t> w;
-
- BOOST_TEST(!test("", ascii::char_, v));
- BOOST_TEST(!test(L"", wide::char_, w));
-
- BOOST_TEST(!test("", ascii::char_('x'), v));
- BOOST_TEST(!test(L"", wide::char_(L'x'), w));
- }
-
- {
- namespace ascii = boost::spirit::ascii;
- namespace wide = boost::spirit::standard_wide;
-
- boost::optional<char> v ('x');
- boost::optional<wchar_t> w (L'x');
-
- BOOST_TEST(test("x", ascii::char_, v));
- BOOST_TEST(test(L"x", wide::char_, w));
- BOOST_TEST(test("x", ascii::char_('x'), v));
- BOOST_TEST(test(L"x", wide::char_(L'x'), w));
- BOOST_TEST(!test("", ascii::char_('y'), v));
- BOOST_TEST(!test(L"", wide::char_(L'y'), w));
- }
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- // yes, we can use phoenix expressions as attributes as well
- // but only if we include karma_phoenix_attributes.hpp
- {
- namespace ascii = boost::spirit::ascii;
- namespace phoenix = boost::phoenix;
-
- BOOST_TEST(test("x", ascii::char_, phoenix::val('x')));
-
- char c = 'x';
- BOOST_TEST(test("x", ascii::char_, phoenix::ref(c)));
- BOOST_TEST(test("y", ascii::char_, ++phoenix::ref(c)));
- }
-#endif
-
- return boost::report_errors();
-}

Copied: trunk/libs/spirit/test/karma/char1.cpp (from r67483, /trunk/libs/spirit/test/karma/char.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/char.cpp (original)
+++ trunk/libs/spirit/test/karma/char1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -143,103 +143,6 @@
         BOOST_TEST(!test(L"", ~char_(L"x")));
     }
 
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test(" ", space));
- BOOST_TEST(test(L" ", space));
- BOOST_TEST(!test("\t", space));
- BOOST_TEST(!test(L"\t", space));
-
- BOOST_TEST(test(" ", space, ' '));
- BOOST_TEST(test(L" ", space, L' '));
- BOOST_TEST(test("\t", space, '\t'));
- BOOST_TEST(test(L"\t", space, L'\t'));
-
- BOOST_TEST(!test("", space, 'x'));
- BOOST_TEST(!test(L"", space, L'x'));
-
- BOOST_TEST(!test(" ", ~space, ' '));
- BOOST_TEST(!test(L" ", ~space, L' '));
-
- BOOST_TEST(test("x", ~space, 'x'));
- BOOST_TEST(test(L"x", ~space, L'x'));
- }
-
- {
- using namespace boost::spirit::standard_wide;
-
- BOOST_TEST(test(" ", space));
- BOOST_TEST(test(L" ", space));
- BOOST_TEST(!test("\t", space));
- BOOST_TEST(!test(L"\t", space));
-
- BOOST_TEST(test(" ", space, ' '));
- BOOST_TEST(test(L" ", space, L' '));
- BOOST_TEST(test("\t", space, '\t'));
- BOOST_TEST(test(L"\t", space, L'\t'));
-
- BOOST_TEST(!test("", space, 'x'));
- BOOST_TEST(!test(L"", space, L'x'));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test_delimited("x ", 'x', ' '));
- BOOST_TEST(test_delimited(L"x ", L'x', L' '));
- BOOST_TEST(!test_delimited("x ", 'y', ' '));
- BOOST_TEST(!test_delimited(L"x ", L'y', L' '));
-
- BOOST_TEST(test_delimited("x ", 'x', ' '));
- BOOST_TEST(test_delimited(L"x ", L'x', L' '));
- BOOST_TEST(!test_delimited("x ", 'y', ' '));
- BOOST_TEST(!test_delimited(L"x ", L'y', L' '));
-
- BOOST_TEST(test_delimited("x ", char_, 'x', ' '));
- BOOST_TEST(test_delimited(L"x ", char_, L'x', L' '));
- BOOST_TEST(!test_delimited("x ", char_, 'y', ' '));
- BOOST_TEST(!test_delimited(L"x ", char_, L'y', L' '));
-
- BOOST_TEST(test_delimited("x ", char_('x'), ' '));
- BOOST_TEST(!test_delimited("x ", char_('y'), ' '));
-
- BOOST_TEST(test_delimited("x ", char_('x'), 'x', ' '));
- BOOST_TEST(!test_delimited("", char_('y'), 'x', ' '));
-
- BOOST_TEST(test_delimited("x ", char_("x"), ' '));
-
-#if defined(KARMA_FAIL_COMPILATION)
- BOOST_TEST(test_delimited("x ", char_, ' ')); // anychar without a parameter doesn't make any sense
-#endif
- }
-
- { // pre-delimiting
- {
- std::string generated;
- std::back_insert_iterator<std::string> it(generated);
- BOOST_TEST(karma::generate_delimited(it, '_', '^'
- , karma::delimit_flag::predelimit));
- BOOST_TEST(generated == "^_^");
- }
- {
- using namespace boost::spirit::standard_wide;
- std::basic_string<wchar_t> generated;
- std::back_insert_iterator<std::basic_string<wchar_t> > it(generated);
- BOOST_TEST(karma::generate_delimited(it, char_, L'.'
- , karma::delimit_flag::predelimit, L'x'));
- BOOST_TEST(generated == L".x.");
- }
- }
-
- // action tests
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("x", char_[_1 = val('x')]));
- BOOST_TEST(!test("x", char_[_1 = val('y')]));
- }
-
     { // lazy chars
         namespace ascii = boost::spirit::ascii;
         namespace wide = boost::spirit::standard_wide;
@@ -271,36 +174,5 @@
         BOOST_TEST(!test(L"", wide::char_(L'x'), w));
     }
 
- {
- namespace ascii = boost::spirit::ascii;
- namespace wide = boost::spirit::standard_wide;
-
- boost::optional<char> v ('x');
- boost::optional<wchar_t> w (L'x');
-
- BOOST_TEST(test("x", ascii::char_, v));
- BOOST_TEST(test(L"x", wide::char_, w));
- BOOST_TEST(test("x", ascii::char_('x'), v));
- BOOST_TEST(test(L"x", wide::char_(L'x'), w));
- BOOST_TEST(!test("", ascii::char_('y'), v));
- BOOST_TEST(!test(L"", wide::char_(L'y'), w));
- }
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- // yes, we can use phoenix expressions as attributes as well
- // but only if we include karma_phoenix_attributes.hpp
- {
- namespace ascii = boost::spirit::ascii;
- namespace phoenix = boost::phoenix;
-
- BOOST_TEST(test("x", ascii::char_, phoenix::val('x')));
-
- char c = 'x';
- BOOST_TEST(test("x", ascii::char_, phoenix::ref(c)));
- BOOST_TEST(test("y", ascii::char_, ++phoenix::ref(c)));
- }
-#endif
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/karma/char2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/char2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,160 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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)
+
+//#define KARMA_FAIL_COMPILATION
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_action.hpp>
+#include <boost/spirit/include/karma_phoenix_attributes.hpp>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+ using namespace boost::phoenix;
+
+ {
+ using namespace boost::spirit::ascii;
+
+ BOOST_TEST(test(" ", space));
+ BOOST_TEST(test(L" ", space));
+ BOOST_TEST(!test("\t", space));
+ BOOST_TEST(!test(L"\t", space));
+
+ BOOST_TEST(test(" ", space, ' '));
+ BOOST_TEST(test(L" ", space, L' '));
+ BOOST_TEST(test("\t", space, '\t'));
+ BOOST_TEST(test(L"\t", space, L'\t'));
+
+ BOOST_TEST(!test("", space, 'x'));
+ BOOST_TEST(!test(L"", space, L'x'));
+
+ BOOST_TEST(!test(" ", ~space, ' '));
+ BOOST_TEST(!test(L" ", ~space, L' '));
+
+ BOOST_TEST(test("x", ~space, 'x'));
+ BOOST_TEST(test(L"x", ~space, L'x'));
+ }
+
+ {
+ using namespace boost::spirit::standard_wide;
+
+ BOOST_TEST(test(" ", space));
+ BOOST_TEST(test(L" ", space));
+ BOOST_TEST(!test("\t", space));
+ BOOST_TEST(!test(L"\t", space));
+
+ BOOST_TEST(test(" ", space, ' '));
+ BOOST_TEST(test(L" ", space, L' '));
+ BOOST_TEST(test("\t", space, '\t'));
+ BOOST_TEST(test(L"\t", space, L'\t'));
+
+ BOOST_TEST(!test("", space, 'x'));
+ BOOST_TEST(!test(L"", space, L'x'));
+ }
+
+ {
+ using namespace boost::spirit::ascii;
+
+ BOOST_TEST(test_delimited("x ", 'x', ' '));
+ BOOST_TEST(test_delimited(L"x ", L'x', L' '));
+ BOOST_TEST(!test_delimited("x ", 'y', ' '));
+ BOOST_TEST(!test_delimited(L"x ", L'y', L' '));
+
+ BOOST_TEST(test_delimited("x ", 'x', ' '));
+ BOOST_TEST(test_delimited(L"x ", L'x', L' '));
+ BOOST_TEST(!test_delimited("x ", 'y', ' '));
+ BOOST_TEST(!test_delimited(L"x ", L'y', L' '));
+
+ BOOST_TEST(test_delimited("x ", char_, 'x', ' '));
+ BOOST_TEST(test_delimited(L"x ", char_, L'x', L' '));
+ BOOST_TEST(!test_delimited("x ", char_, 'y', ' '));
+ BOOST_TEST(!test_delimited(L"x ", char_, L'y', L' '));
+
+ BOOST_TEST(test_delimited("x ", char_('x'), ' '));
+ BOOST_TEST(!test_delimited("x ", char_('y'), ' '));
+
+ BOOST_TEST(test_delimited("x ", char_('x'), 'x', ' '));
+ BOOST_TEST(!test_delimited("", char_('y'), 'x', ' '));
+
+ BOOST_TEST(test_delimited("x ", char_("x"), ' '));
+
+#if defined(KARMA_FAIL_COMPILATION)
+ BOOST_TEST(test_delimited("x ", char_, ' ')); // anychar without a parameter doesn't make any sense
+#endif
+ }
+
+ { // pre-delimiting
+ {
+ std::string generated;
+ std::back_insert_iterator<std::string> it(generated);
+ BOOST_TEST(karma::generate_delimited(it, '_', '^'
+ , karma::delimit_flag::predelimit));
+ BOOST_TEST(generated == "^_^");
+ }
+ {
+ using namespace boost::spirit::standard_wide;
+ std::basic_string<wchar_t> generated;
+ std::back_insert_iterator<std::basic_string<wchar_t> > it(generated);
+ BOOST_TEST(karma::generate_delimited(it, char_, L'.'
+ , karma::delimit_flag::predelimit, L'x'));
+ BOOST_TEST(generated == L".x.");
+ }
+ }
+
+ // action tests
+ {
+ using namespace boost::spirit::ascii;
+
+ BOOST_TEST(test("x", char_[_1 = val('x')]));
+ BOOST_TEST(!test("x", char_[_1 = val('y')]));
+ }
+
+// we support Phoenix attributes only starting with V2.2
+#if SPIRIT_VERSION >= 0x2020
+ // yes, we can use phoenix expressions as attributes as well
+ // but only if we include karma_phoenix_attributes.hpp
+ {
+ namespace ascii = boost::spirit::ascii;
+ namespace phoenix = boost::phoenix;
+
+ BOOST_TEST(test("x", ascii::char_, phoenix::val('x')));
+
+ char c = 'x';
+ BOOST_TEST(test("x", ascii::char_, phoenix::ref(c)));
+ BOOST_TEST(test("y", ascii::char_, ++phoenix::ref(c)));
+ }
+#endif
+
+ {
+ namespace ascii = boost::spirit::ascii;
+ namespace wide = boost::spirit::standard_wide;
+
+ boost::optional<char> v ('x');
+ boost::optional<wchar_t> w (L'x');
+
+ BOOST_TEST(test("x", ascii::char_, v));
+ BOOST_TEST(test(L"x", wide::char_, w));
+ BOOST_TEST(test("x", ascii::char_('x'), v));
+ BOOST_TEST(test(L"x", wide::char_(L'x'), w));
+ BOOST_TEST(!test("", ascii::char_('y'), v));
+ BOOST_TEST(!test(L"", wide::char_(L'y'), w));
+ }
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/karma/int_numerics.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/int_numerics.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,390 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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)
-
-//#define KARMA_FAIL_COMPILATION
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/mpl/vector.hpp>
-#include <boost/mpl/for_each.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/bool.hpp>
-
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_action.hpp>
-#include <boost/spirit/include/karma_phoenix_attributes.hpp>
-
-#include <limits>
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-struct test_minmax
-{
- template <typename T>
- void operator()(T) const
- {
- using namespace boost::spirit;
- using namespace boost::phoenix;
-
- T minval = (std::numeric_limits<T>::min)();
- T maxval = (std::numeric_limits<T>::max)();
-
- std::string expected_minval = boost::lexical_cast<std::string>(minval);
- std::string expected_maxval = boost::lexical_cast<std::string>(maxval);
-
- // create a correct generator type from the given integer type
- typedef typename
- boost::mpl::if_<
- boost::mpl::bool_<std::numeric_limits<T>::is_signed>,
- karma::int_generator<T>,
- karma::uint_generator<T>
- >::type
- int_generator_type;
-
- int_generator_type const gen = int_generator_type();
-
- BOOST_TEST(test(expected_maxval, gen, maxval));
- BOOST_TEST(test(expected_minval, gen, minval));
- BOOST_TEST(test(expected_maxval, gen(maxval)));
- BOOST_TEST(test(expected_minval, gen(minval)));
- BOOST_TEST(test(expected_maxval, gen(maxval), maxval));
- BOOST_TEST(test(expected_minval, gen(minval), minval));
- BOOST_TEST(!test("", gen(maxval), maxval-1));
- BOOST_TEST(!test("", gen(minval), minval+1));
- BOOST_TEST(test(expected_maxval, lit(maxval)));
- BOOST_TEST(test(expected_minval, lit(minval)));
-
- BOOST_TEST(test_delimited(expected_maxval + " ", gen, maxval, char(' ')));
- BOOST_TEST(test_delimited(expected_minval + " ", gen, minval, char(' ')));
- BOOST_TEST(test_delimited(expected_maxval + " ", gen(maxval), char(' ')));
- BOOST_TEST(test_delimited(expected_minval + " ", gen(minval), char(' ')));
- BOOST_TEST(test_delimited(expected_maxval + " ", gen(maxval), maxval, char(' ')));
- BOOST_TEST(test_delimited(expected_minval + " ", gen(minval), minval, char(' ')));
- BOOST_TEST(!test_delimited("", gen(maxval), maxval-1, char(' ')));
- BOOST_TEST(!test_delimited("", gen(minval), minval+1, char(' ')));
- BOOST_TEST(test_delimited(expected_maxval + " ", lit(maxval), char(' ')));
- BOOST_TEST(test_delimited(expected_minval + " ", lit(minval), char(' ')));
-
- // action tests
- BOOST_TEST(test(expected_maxval, gen[_1 = val(maxval)]));
- BOOST_TEST(test(expected_minval, gen[_1 = val(minval)]));
-
- // optional tests
- boost::optional<T> optmin, optmax(maxval);
-
- BOOST_TEST(!test("", gen, optmin));
- BOOST_TEST(!test("", gen(minval), optmin));
-
- optmin = minval;
- BOOST_TEST(test(expected_minval, gen, optmin));
- BOOST_TEST(test(expected_maxval, gen, optmax));
- BOOST_TEST(test(expected_minval, gen(minval), optmin));
- BOOST_TEST(test(expected_maxval, gen(maxval), optmax));
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- // Phoenix expression tests (only supported while including
- // karma_phoenix_attributes.hpp
- namespace phoenix = boost::phoenix;
-
- BOOST_TEST(test("1", gen, phoenix::val(1)));
-
- T val = 1;
- BOOST_TEST(test("1", gen, phoenix::ref(val)));
- BOOST_TEST(test("2", gen, ++phoenix::ref(val)));
-#endif
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-int
-main()
-{
- using namespace boost::spirit;
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- // this is currently ambiguous with character literals
-// BOOST_TEST(test("0", 0));
-// BOOST_TEST(test("123", 123));
-// BOOST_TEST(test("-123", -123));
-
- BOOST_TEST(test("0", int_, 0));
- BOOST_TEST(test("123", int_, 123));
- BOOST_TEST(test("-123", int_, -123));
-
- BOOST_TEST(test_delimited("0 ", int_, 0, char_(' ')));
- BOOST_TEST(test_delimited("123 ", int_, 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", int_, -123, char_(' ')));
-
- BOOST_TEST(test("0", lower[int_], 0));
- BOOST_TEST(test("123", lower[int_], 123));
- BOOST_TEST(test("-123", lower[int_], -123));
-
- BOOST_TEST(test_delimited("0 ", lower[int_], 0, char_(' ')));
- BOOST_TEST(test_delimited("123 ", lower[int_], 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", lower[int_], -123, char_(' ')));
-
- BOOST_TEST(test("0", upper[int_], 0));
- BOOST_TEST(test("123", upper[int_], 123));
- BOOST_TEST(test("-123", upper[int_], -123));
-
- BOOST_TEST(test_delimited("0 ", upper[int_], 0, char_(' ')));
- BOOST_TEST(test_delimited("123 ", upper[int_], 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", upper[int_], -123, char_(' ')));
-
- ///////////////////////////////////////////////////////////////////////
- BOOST_TEST(test("0", int_(0)));
- BOOST_TEST(test("123", int_(123)));
- BOOST_TEST(test("-123", int_(-123)));
-
- BOOST_TEST(test_delimited("0 ", int_(0), char_(' ')));
- BOOST_TEST(test_delimited("123 ", int_(123), char_(' ')));
- BOOST_TEST(test_delimited("-123 ", int_(-123), char_(' ')));
-
- BOOST_TEST(test("0", lower[int_(0)]));
- BOOST_TEST(test("123", lower[int_(123)]));
- BOOST_TEST(test("-123", lower[int_(-123)]));
-
- BOOST_TEST(test_delimited("0 ", lower[int_(0)], char_(' ')));
- BOOST_TEST(test_delimited("123 ", lower[int_(123)], char_(' ')));
- BOOST_TEST(test_delimited("-123 ", lower[int_(-123)], char_(' ')));
-
- BOOST_TEST(test("0", upper[int_(0)]));
- BOOST_TEST(test("123", upper[int_(123)]));
- BOOST_TEST(test("-123", upper[int_(-123)]));
-
- BOOST_TEST(test_delimited("0 ", upper[int_(0)], char_(' ')));
- BOOST_TEST(test_delimited("123 ", upper[int_(123)], char_(' ')));
- BOOST_TEST(test_delimited("-123 ", upper[int_(-123)], char_(' ')));
- }
-
- { // literals, make sure there are no ambiguities
- BOOST_TEST(test("0", lit(short(0))));
- BOOST_TEST(test("0", lit(0)));
- BOOST_TEST(test("0", lit(0L)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(test("0", lit(0LL)));
-#endif
-
- BOOST_TEST(test("0", lit((unsigned short)0)));
- BOOST_TEST(test("0", lit(0U)));
- BOOST_TEST(test("0", lit(0UL)));
-#ifdef BOOST_HAS_LONG_LONG
- BOOST_TEST(test("0", lit(0ULL)));
-#endif
-
- BOOST_TEST(test("a", lit('a')));
- BOOST_TEST(test("a", 'a'));
- BOOST_TEST(test(L"a", L'a'));
- }
-
- { // lazy numerics
- using namespace boost::phoenix;
-
- BOOST_TEST(test("0", int_(val(0))));
- BOOST_TEST(test("123", int_(val(123))));
- BOOST_TEST(test("-123", int_(val(-123))));
-
- int i1 = 0, i2 = 123, i3 = -123;
- BOOST_TEST(test("0", int_(ref(i1))));
- BOOST_TEST(test("123", int_(ref(i2))));
- BOOST_TEST(test("-123", int_(ref(i3))));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- karma::int_generator<int, 10, true> const signed_int =
- karma::int_generator<int, 10, true>();
-
- ///////////////////////////////////////////////////////////////////////
- BOOST_TEST(test(" 0", signed_int, 0));
- BOOST_TEST(test("+123", signed_int, 123));
- BOOST_TEST(test("-123", signed_int, -123));
-
- BOOST_TEST(test_delimited(" 0 ", signed_int, 0, char_(' ')));
- BOOST_TEST(test_delimited("+123 ", signed_int, 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", signed_int, -123, char_(' ')));
-
- BOOST_TEST(test(" 0", lower[signed_int], 0));
- BOOST_TEST(test("+123", lower[signed_int], 123));
- BOOST_TEST(test("-123", lower[signed_int], -123));
-
- BOOST_TEST(test_delimited(" 0 ", lower[signed_int], 0, char_(' ')));
- BOOST_TEST(test_delimited("+123 ", lower[signed_int], 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", lower[signed_int], -123, char_(' ')));
-
- BOOST_TEST(test(" 0", upper[signed_int], 0));
- BOOST_TEST(test("+123", upper[signed_int], 123));
- BOOST_TEST(test("-123", upper[signed_int], -123));
-
- BOOST_TEST(test_delimited(" 0 ", upper[signed_int], 0, char_(' ')));
- BOOST_TEST(test_delimited("+123 ", upper[signed_int], 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", upper[signed_int], -123, char_(' ')));
-
- ///////////////////////////////////////////////////////////////////////
- BOOST_TEST(test(" 0", signed_int(0)));
- BOOST_TEST(test("+123", signed_int(123)));
- BOOST_TEST(test("-123", signed_int(-123)));
-
- BOOST_TEST(test_delimited(" 0 ", signed_int(0), char_(' ')));
- BOOST_TEST(test_delimited("+123 ", signed_int(123), char_(' ')));
- BOOST_TEST(test_delimited("-123 ", signed_int(-123), char_(' ')));
-
- BOOST_TEST(test(" 0", lower[signed_int(0)]));
- BOOST_TEST(test("+123", lower[signed_int(123)]));
- BOOST_TEST(test("-123", lower[signed_int(-123)]));
-
- BOOST_TEST(test_delimited(" 0 ", lower[signed_int(0)], char_(' ')));
- BOOST_TEST(test_delimited("+123 ", lower[signed_int(123)], char_(' ')));
- BOOST_TEST(test_delimited("-123 ", lower[signed_int(-123)], char_(' ')));
-
- BOOST_TEST(test(" 0", upper[signed_int(0)]));
- BOOST_TEST(test("+123", upper[signed_int(123)]));
- BOOST_TEST(test("-123", upper[signed_int(-123)]));
-
- BOOST_TEST(test_delimited(" 0 ", upper[signed_int(0)], char_(' ')));
- BOOST_TEST(test_delimited("+123 ", upper[signed_int(123)], char_(' ')));
- BOOST_TEST(test_delimited("-123 ", upper[signed_int(-123)], char_(' ')));
-
- using namespace boost::phoenix;
-
- BOOST_TEST(test(" 0", signed_int(val(0))));
- BOOST_TEST(test("+123", signed_int(val(123))));
- BOOST_TEST(test("-123", signed_int(val(-123))));
-
- int i1 = 0, i2 = 123, i3 = -123;
- BOOST_TEST(test(" 0", signed_int(ref(i1))));
- BOOST_TEST(test("+123", signed_int(ref(i2))));
- BOOST_TEST(test("-123", signed_int(ref(i3))));
- }
-
- {
- ///////////////////////////////////////////////////////////////////////
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("1234", uint_, 1234));
- BOOST_TEST(test("ff", hex, 0xff));
- BOOST_TEST(test("1234", oct, 01234));
- BOOST_TEST(test("11110000", bin, 0xf0));
-
- BOOST_TEST(test_delimited("1234 ", uint_, 1234, char_(' ')));
- BOOST_TEST(test_delimited("ff ", hex, 0xff, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", oct, 01234, char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", bin, 0xf0, char_(' ')));
-
- // test unsigned generator with signed integral value
- BOOST_TEST(test("ff", hex, (char)0xff));
- BOOST_TEST(test_delimited("ff ", hex, (char)0xff, char_(' ')));
-
- BOOST_TEST(test("1234", lower[uint_], 1234));
- BOOST_TEST(test("ff", lower[hex], 0xff));
- BOOST_TEST(test("1234", lower[oct], 01234));
- BOOST_TEST(test("11110000", lower[bin], 0xf0));
-
- BOOST_TEST(test_delimited("1234 ", lower[uint_], 1234, char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[hex], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", lower[oct], 01234, char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", lower[bin], 0xf0, char_(' ')));
-
- BOOST_TEST(test("1234", upper[uint_], 1234));
- BOOST_TEST(test("FF", upper[hex], 0xff));
- BOOST_TEST(test("1234", upper[oct], 01234));
- BOOST_TEST(test("11110000", upper[bin], 0xf0));
-
- BOOST_TEST(test_delimited("1234 ", upper[uint_], 1234, char_(' ')));
- BOOST_TEST(test_delimited("FF ", upper[hex], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", upper[oct], 01234, char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", upper[bin], 0xf0, char_(' ')));
-
- // no generator transformation should occur for uint_'s
- BOOST_TEST(test("1234", upper[upper[uint_]], 1234));
- BOOST_TEST(test("1234", upper[lower[uint_]], 1234));
- BOOST_TEST(test("1234", lower[upper[uint_]], 1234));
- BOOST_TEST(test("1234", lower[lower[uint_]], 1234));
-
- BOOST_TEST(test_delimited("1234 ", upper[upper[uint_]], 1234, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", upper[lower[uint_]], 1234, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", lower[upper[uint_]], 1234, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", lower[lower[uint_]], 1234, char_(' ')));
-
- BOOST_TEST(test("FF", upper[upper[hex]], 0xff));
- BOOST_TEST(test("FF", upper[lower[hex]], 0xff));
- BOOST_TEST(test("ff", lower[upper[hex]], 0xff));
- BOOST_TEST(test("ff", lower[lower[hex]], 0xff));
-
- BOOST_TEST(test_delimited("FF ", upper[upper[hex]], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("FF ", upper[lower[hex]], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[upper[hex]], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[lower[hex]], 0xff, char_(' ')));
-
- ///////////////////////////////////////////////////////////////////////
- BOOST_TEST(test("1234", uint_(1234)));
- BOOST_TEST(test("ff", hex(0xff)));
- BOOST_TEST(test("1234", oct(01234)));
- BOOST_TEST(test("11110000", bin(0xf0)));
-
- BOOST_TEST(test_delimited("1234 ", uint_(1234), char_(' ')));
- BOOST_TEST(test_delimited("ff ", hex(0xff), char_(' ')));
- BOOST_TEST(test_delimited("1234 ", oct(01234), char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", bin(0xf0), char_(' ')));
-
- BOOST_TEST(test("1234", lower[uint_(1234)]));
- BOOST_TEST(test("ff", lower[hex(0xff)]));
- BOOST_TEST(test("1234", lower[oct(01234)]));
- BOOST_TEST(test("11110000", lower[bin(0xf0)]));
-
- BOOST_TEST(test_delimited("1234 ", lower[uint_(1234)], char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[hex(0xff)], char_(' ')));
- BOOST_TEST(test_delimited("1234 ", lower[oct(01234)], char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", lower[bin(0xf0)], char_(' ')));
-
- BOOST_TEST(test("1234", upper[uint_(1234)]));
- BOOST_TEST(test("FF", upper[hex(0xff)]));
- BOOST_TEST(test("1234", upper[oct(01234)]));
- BOOST_TEST(test("11110000", upper[bin(0xf0)]));
-
- BOOST_TEST(test_delimited("1234 ", upper[uint_(1234)], char_(' ')));
- BOOST_TEST(test_delimited("FF ", upper[hex(0xff)], char_(' ')));
- BOOST_TEST(test_delimited("1234 ", upper[oct(01234)], char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", upper[bin(0xf0)], char_(' ')));
-
- BOOST_TEST(test("FF", upper[upper[hex(0xff)]]));
- BOOST_TEST(test("FF", upper[lower[hex(0xff)]]));
- BOOST_TEST(test("ff", lower[upper[hex(0xff)]]));
- BOOST_TEST(test("ff", lower[lower[hex(0xff)]]));
-
- BOOST_TEST(test_delimited("FF ", upper[upper[hex(0xff)]], char_(' ')));
- BOOST_TEST(test_delimited("FF ", upper[lower[hex(0xff)]], char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[upper[hex(0xff)]], char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[lower[hex(0xff)]], char_(' ')));
- }
-
-// test boundary values
- typedef boost::mpl::vector<
-#ifdef BOOST_HAS_LONG_LONG
- boost::long_long_type, boost::ulong_long_type,
-#endif
- short, unsigned short,
- int, unsigned int,
- long, unsigned long
- > integer_types;
- boost::mpl::for_each<integer_types>(test_minmax());
-
- return boost::report_errors();
-}
-

Copied: trunk/libs/spirit/test/karma/int_numerics1.cpp (from r67483, /trunk/libs/spirit/test/karma/int_numerics.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/int_numerics.cpp (original)
+++ trunk/libs/spirit/test/karma/int_numerics1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -29,85 +29,6 @@
 using namespace spirit_test;
 
 ///////////////////////////////////////////////////////////////////////////////
-struct test_minmax
-{
- template <typename T>
- void operator()(T) const
- {
- using namespace boost::spirit;
- using namespace boost::phoenix;
-
- T minval = (std::numeric_limits<T>::min)();
- T maxval = (std::numeric_limits<T>::max)();
-
- std::string expected_minval = boost::lexical_cast<std::string>(minval);
- std::string expected_maxval = boost::lexical_cast<std::string>(maxval);
-
- // create a correct generator type from the given integer type
- typedef typename
- boost::mpl::if_<
- boost::mpl::bool_<std::numeric_limits<T>::is_signed>,
- karma::int_generator<T>,
- karma::uint_generator<T>
- >::type
- int_generator_type;
-
- int_generator_type const gen = int_generator_type();
-
- BOOST_TEST(test(expected_maxval, gen, maxval));
- BOOST_TEST(test(expected_minval, gen, minval));
- BOOST_TEST(test(expected_maxval, gen(maxval)));
- BOOST_TEST(test(expected_minval, gen(minval)));
- BOOST_TEST(test(expected_maxval, gen(maxval), maxval));
- BOOST_TEST(test(expected_minval, gen(minval), minval));
- BOOST_TEST(!test("", gen(maxval), maxval-1));
- BOOST_TEST(!test("", gen(minval), minval+1));
- BOOST_TEST(test(expected_maxval, lit(maxval)));
- BOOST_TEST(test(expected_minval, lit(minval)));
-
- BOOST_TEST(test_delimited(expected_maxval + " ", gen, maxval, char(' ')));
- BOOST_TEST(test_delimited(expected_minval + " ", gen, minval, char(' ')));
- BOOST_TEST(test_delimited(expected_maxval + " ", gen(maxval), char(' ')));
- BOOST_TEST(test_delimited(expected_minval + " ", gen(minval), char(' ')));
- BOOST_TEST(test_delimited(expected_maxval + " ", gen(maxval), maxval, char(' ')));
- BOOST_TEST(test_delimited(expected_minval + " ", gen(minval), minval, char(' ')));
- BOOST_TEST(!test_delimited("", gen(maxval), maxval-1, char(' ')));
- BOOST_TEST(!test_delimited("", gen(minval), minval+1, char(' ')));
- BOOST_TEST(test_delimited(expected_maxval + " ", lit(maxval), char(' ')));
- BOOST_TEST(test_delimited(expected_minval + " ", lit(minval), char(' ')));
-
- // action tests
- BOOST_TEST(test(expected_maxval, gen[_1 = val(maxval)]));
- BOOST_TEST(test(expected_minval, gen[_1 = val(minval)]));
-
- // optional tests
- boost::optional<T> optmin, optmax(maxval);
-
- BOOST_TEST(!test("", gen, optmin));
- BOOST_TEST(!test("", gen(minval), optmin));
-
- optmin = minval;
- BOOST_TEST(test(expected_minval, gen, optmin));
- BOOST_TEST(test(expected_maxval, gen, optmax));
- BOOST_TEST(test(expected_minval, gen(minval), optmin));
- BOOST_TEST(test(expected_maxval, gen(maxval), optmax));
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- // Phoenix expression tests (only supported while including
- // karma_phoenix_attributes.hpp
- namespace phoenix = boost::phoenix;
-
- BOOST_TEST(test("1", gen, phoenix::val(1)));
-
- T val = 1;
- BOOST_TEST(test("1", gen, phoenix::ref(val)));
- BOOST_TEST(test("2", gen, ++phoenix::ref(val)));
-#endif
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
 int
 main()
 {
@@ -118,9 +39,9 @@
 
         ///////////////////////////////////////////////////////////////////////
         // this is currently ambiguous with character literals
-// BOOST_TEST(test("0", 0));
-// BOOST_TEST(test("123", 123));
-// BOOST_TEST(test("-123", -123));
+ BOOST_TEST(test("0", 0));
+ BOOST_TEST(test("123", 123));
+ BOOST_TEST(test("-123", -123));
 
         BOOST_TEST(test("0", int_, 0));
         BOOST_TEST(test("123", int_, 123));
@@ -204,135 +125,10 @@
         BOOST_TEST(test("123", int_(ref(i2))));
         BOOST_TEST(test("-123", int_(ref(i3))));
     }
-
- {
- using namespace boost::spirit::ascii;
-
- karma::int_generator<int, 10, true> const signed_int =
- karma::int_generator<int, 10, true>();
-
- ///////////////////////////////////////////////////////////////////////
- BOOST_TEST(test(" 0", signed_int, 0));
- BOOST_TEST(test("+123", signed_int, 123));
- BOOST_TEST(test("-123", signed_int, -123));
-
- BOOST_TEST(test_delimited(" 0 ", signed_int, 0, char_(' ')));
- BOOST_TEST(test_delimited("+123 ", signed_int, 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", signed_int, -123, char_(' ')));
-
- BOOST_TEST(test(" 0", lower[signed_int], 0));
- BOOST_TEST(test("+123", lower[signed_int], 123));
- BOOST_TEST(test("-123", lower[signed_int], -123));
-
- BOOST_TEST(test_delimited(" 0 ", lower[signed_int], 0, char_(' ')));
- BOOST_TEST(test_delimited("+123 ", lower[signed_int], 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", lower[signed_int], -123, char_(' ')));
-
- BOOST_TEST(test(" 0", upper[signed_int], 0));
- BOOST_TEST(test("+123", upper[signed_int], 123));
- BOOST_TEST(test("-123", upper[signed_int], -123));
-
- BOOST_TEST(test_delimited(" 0 ", upper[signed_int], 0, char_(' ')));
- BOOST_TEST(test_delimited("+123 ", upper[signed_int], 123, char_(' ')));
- BOOST_TEST(test_delimited("-123 ", upper[signed_int], -123, char_(' ')));
-
- ///////////////////////////////////////////////////////////////////////
- BOOST_TEST(test(" 0", signed_int(0)));
- BOOST_TEST(test("+123", signed_int(123)));
- BOOST_TEST(test("-123", signed_int(-123)));
-
- BOOST_TEST(test_delimited(" 0 ", signed_int(0), char_(' ')));
- BOOST_TEST(test_delimited("+123 ", signed_int(123), char_(' ')));
- BOOST_TEST(test_delimited("-123 ", signed_int(-123), char_(' ')));
-
- BOOST_TEST(test(" 0", lower[signed_int(0)]));
- BOOST_TEST(test("+123", lower[signed_int(123)]));
- BOOST_TEST(test("-123", lower[signed_int(-123)]));
-
- BOOST_TEST(test_delimited(" 0 ", lower[signed_int(0)], char_(' ')));
- BOOST_TEST(test_delimited("+123 ", lower[signed_int(123)], char_(' ')));
- BOOST_TEST(test_delimited("-123 ", lower[signed_int(-123)], char_(' ')));
-
- BOOST_TEST(test(" 0", upper[signed_int(0)]));
- BOOST_TEST(test("+123", upper[signed_int(123)]));
- BOOST_TEST(test("-123", upper[signed_int(-123)]));
-
- BOOST_TEST(test_delimited(" 0 ", upper[signed_int(0)], char_(' ')));
- BOOST_TEST(test_delimited("+123 ", upper[signed_int(123)], char_(' ')));
- BOOST_TEST(test_delimited("-123 ", upper[signed_int(-123)], char_(' ')));
-
- using namespace boost::phoenix;
-
- BOOST_TEST(test(" 0", signed_int(val(0))));
- BOOST_TEST(test("+123", signed_int(val(123))));
- BOOST_TEST(test("-123", signed_int(val(-123))));
-
- int i1 = 0, i2 = 123, i3 = -123;
- BOOST_TEST(test(" 0", signed_int(ref(i1))));
- BOOST_TEST(test("+123", signed_int(ref(i2))));
- BOOST_TEST(test("-123", signed_int(ref(i3))));
- }
-
+
     {
         ///////////////////////////////////////////////////////////////////////
         using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("1234", uint_, 1234));
- BOOST_TEST(test("ff", hex, 0xff));
- BOOST_TEST(test("1234", oct, 01234));
- BOOST_TEST(test("11110000", bin, 0xf0));
-
- BOOST_TEST(test_delimited("1234 ", uint_, 1234, char_(' ')));
- BOOST_TEST(test_delimited("ff ", hex, 0xff, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", oct, 01234, char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", bin, 0xf0, char_(' ')));
-
- // test unsigned generator with signed integral value
- BOOST_TEST(test("ff", hex, (char)0xff));
- BOOST_TEST(test_delimited("ff ", hex, (char)0xff, char_(' ')));
-
- BOOST_TEST(test("1234", lower[uint_], 1234));
- BOOST_TEST(test("ff", lower[hex], 0xff));
- BOOST_TEST(test("1234", lower[oct], 01234));
- BOOST_TEST(test("11110000", lower[bin], 0xf0));
-
- BOOST_TEST(test_delimited("1234 ", lower[uint_], 1234, char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[hex], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", lower[oct], 01234, char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", lower[bin], 0xf0, char_(' ')));
-
- BOOST_TEST(test("1234", upper[uint_], 1234));
- BOOST_TEST(test("FF", upper[hex], 0xff));
- BOOST_TEST(test("1234", upper[oct], 01234));
- BOOST_TEST(test("11110000", upper[bin], 0xf0));
-
- BOOST_TEST(test_delimited("1234 ", upper[uint_], 1234, char_(' ')));
- BOOST_TEST(test_delimited("FF ", upper[hex], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", upper[oct], 01234, char_(' ')));
- BOOST_TEST(test_delimited("11110000 ", upper[bin], 0xf0, char_(' ')));
-
- // no generator transformation should occur for uint_'s
- BOOST_TEST(test("1234", upper[upper[uint_]], 1234));
- BOOST_TEST(test("1234", upper[lower[uint_]], 1234));
- BOOST_TEST(test("1234", lower[upper[uint_]], 1234));
- BOOST_TEST(test("1234", lower[lower[uint_]], 1234));
-
- BOOST_TEST(test_delimited("1234 ", upper[upper[uint_]], 1234, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", upper[lower[uint_]], 1234, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", lower[upper[uint_]], 1234, char_(' ')));
- BOOST_TEST(test_delimited("1234 ", lower[lower[uint_]], 1234, char_(' ')));
-
- BOOST_TEST(test("FF", upper[upper[hex]], 0xff));
- BOOST_TEST(test("FF", upper[lower[hex]], 0xff));
- BOOST_TEST(test("ff", lower[upper[hex]], 0xff));
- BOOST_TEST(test("ff", lower[lower[hex]], 0xff));
-
- BOOST_TEST(test_delimited("FF ", upper[upper[hex]], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("FF ", upper[lower[hex]], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[upper[hex]], 0xff, char_(' ')));
- BOOST_TEST(test_delimited("ff ", lower[lower[hex]], 0xff, char_(' ')));
-
- ///////////////////////////////////////////////////////////////////////
         BOOST_TEST(test("1234", uint_(1234)));
         BOOST_TEST(test("ff", hex(0xff)));
         BOOST_TEST(test("1234", oct(01234)));
@@ -374,17 +170,6 @@
         BOOST_TEST(test_delimited("ff ", lower[lower[hex(0xff)]], char_(' ')));
     }
 
-// test boundary values
- typedef boost::mpl::vector<
-#ifdef BOOST_HAS_LONG_LONG
- boost::long_long_type, boost::ulong_long_type,
-#endif
- short, unsigned short,
- int, unsigned int,
- long, unsigned long
- > integer_types;
- boost::mpl::for_each<integer_types>(test_minmax());
-
     return boost::report_errors();
 }
 

Added: trunk/libs/spirit/test/karma/int_numerics2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/int_numerics2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,168 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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)
+
+//#define KARMA_FAIL_COMPILATION
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/for_each.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/bool.hpp>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_numeric.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_action.hpp>
+#include <boost/spirit/include/karma_phoenix_attributes.hpp>
+
+#include <limits>
+#include "test.hpp"
+
+using namespace spirit_test;
+
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+
+ {
+ using namespace boost::spirit::ascii;
+
+ karma::int_generator<int, 10, true> const signed_int =
+ karma::int_generator<int, 10, true>();
+
+ ///////////////////////////////////////////////////////////////////////
+ BOOST_TEST(test(" 0", signed_int, 0));
+ BOOST_TEST(test("+123", signed_int, 123));
+ BOOST_TEST(test("-123", signed_int, -123));
+
+ BOOST_TEST(test_delimited(" 0 ", signed_int, 0, char_(' ')));
+ BOOST_TEST(test_delimited("+123 ", signed_int, 123, char_(' ')));
+ BOOST_TEST(test_delimited("-123 ", signed_int, -123, char_(' ')));
+
+ BOOST_TEST(test(" 0", lower[signed_int], 0));
+ BOOST_TEST(test("+123", lower[signed_int], 123));
+ BOOST_TEST(test("-123", lower[signed_int], -123));
+
+ BOOST_TEST(test_delimited(" 0 ", lower[signed_int], 0, char_(' ')));
+ BOOST_TEST(test_delimited("+123 ", lower[signed_int], 123, char_(' ')));
+ BOOST_TEST(test_delimited("-123 ", lower[signed_int], -123, char_(' ')));
+
+ BOOST_TEST(test(" 0", upper[signed_int], 0));
+ BOOST_TEST(test("+123", upper[signed_int], 123));
+ BOOST_TEST(test("-123", upper[signed_int], -123));
+
+ BOOST_TEST(test_delimited(" 0 ", upper[signed_int], 0, char_(' ')));
+ BOOST_TEST(test_delimited("+123 ", upper[signed_int], 123, char_(' ')));
+ BOOST_TEST(test_delimited("-123 ", upper[signed_int], -123, char_(' ')));
+
+ ///////////////////////////////////////////////////////////////////////
+ BOOST_TEST(test(" 0", signed_int(0)));
+ BOOST_TEST(test("+123", signed_int(123)));
+ BOOST_TEST(test("-123", signed_int(-123)));
+
+ BOOST_TEST(test_delimited(" 0 ", signed_int(0), char_(' ')));
+ BOOST_TEST(test_delimited("+123 ", signed_int(123), char_(' ')));
+ BOOST_TEST(test_delimited("-123 ", signed_int(-123), char_(' ')));
+
+ BOOST_TEST(test(" 0", lower[signed_int(0)]));
+ BOOST_TEST(test("+123", lower[signed_int(123)]));
+ BOOST_TEST(test("-123", lower[signed_int(-123)]));
+
+ BOOST_TEST(test_delimited(" 0 ", lower[signed_int(0)], char_(' ')));
+ BOOST_TEST(test_delimited("+123 ", lower[signed_int(123)], char_(' ')));
+ BOOST_TEST(test_delimited("-123 ", lower[signed_int(-123)], char_(' ')));
+
+ BOOST_TEST(test(" 0", upper[signed_int(0)]));
+ BOOST_TEST(test("+123", upper[signed_int(123)]));
+ BOOST_TEST(test("-123", upper[signed_int(-123)]));
+
+ BOOST_TEST(test_delimited(" 0 ", upper[signed_int(0)], char_(' ')));
+ BOOST_TEST(test_delimited("+123 ", upper[signed_int(123)], char_(' ')));
+ BOOST_TEST(test_delimited("-123 ", upper[signed_int(-123)], char_(' ')));
+
+ using namespace boost::phoenix;
+
+ BOOST_TEST(test(" 0", signed_int(val(0))));
+ BOOST_TEST(test("+123", signed_int(val(123))));
+ BOOST_TEST(test("-123", signed_int(val(-123))));
+
+ int i1 = 0, i2 = 123, i3 = -123;
+ BOOST_TEST(test(" 0", signed_int(ref(i1))));
+ BOOST_TEST(test("+123", signed_int(ref(i2))));
+ BOOST_TEST(test("-123", signed_int(ref(i3))));
+ }
+
+ {
+ ///////////////////////////////////////////////////////////////////////
+ using namespace boost::spirit::ascii;
+
+ BOOST_TEST(test("1234", uint_, 1234));
+ BOOST_TEST(test("ff", hex, 0xff));
+ BOOST_TEST(test("1234", oct, 01234));
+ BOOST_TEST(test("11110000", bin, 0xf0));
+
+ BOOST_TEST(test_delimited("1234 ", uint_, 1234, char_(' ')));
+ BOOST_TEST(test_delimited("ff ", hex, 0xff, char_(' ')));
+ BOOST_TEST(test_delimited("1234 ", oct, 01234, char_(' ')));
+ BOOST_TEST(test_delimited("11110000 ", bin, 0xf0, char_(' ')));
+
+ // test unsigned generator with signed integral value
+ BOOST_TEST(test("ff", hex, (char)0xff));
+ BOOST_TEST(test_delimited("ff ", hex, (char)0xff, char_(' ')));
+
+ BOOST_TEST(test("1234", lower[uint_], 1234));
+ BOOST_TEST(test("ff", lower[hex], 0xff));
+ BOOST_TEST(test("1234", lower[oct], 01234));
+ BOOST_TEST(test("11110000", lower[bin], 0xf0));
+
+ BOOST_TEST(test_delimited("1234 ", lower[uint_], 1234, char_(' ')));
+ BOOST_TEST(test_delimited("ff ", lower[hex], 0xff, char_(' ')));
+ BOOST_TEST(test_delimited("1234 ", lower[oct], 01234, char_(' ')));
+ BOOST_TEST(test_delimited("11110000 ", lower[bin], 0xf0, char_(' ')));
+
+ BOOST_TEST(test("1234", upper[uint_], 1234));
+ BOOST_TEST(test("FF", upper[hex], 0xff));
+ BOOST_TEST(test("1234", upper[oct], 01234));
+ BOOST_TEST(test("11110000", upper[bin], 0xf0));
+
+ BOOST_TEST(test_delimited("1234 ", upper[uint_], 1234, char_(' ')));
+ BOOST_TEST(test_delimited("FF ", upper[hex], 0xff, char_(' ')));
+ BOOST_TEST(test_delimited("1234 ", upper[oct], 01234, char_(' ')));
+ BOOST_TEST(test_delimited("11110000 ", upper[bin], 0xf0, char_(' ')));
+
+ // no generator transformation should occur for uint_'s
+ BOOST_TEST(test("1234", upper[upper[uint_]], 1234));
+ BOOST_TEST(test("1234", upper[lower[uint_]], 1234));
+ BOOST_TEST(test("1234", lower[upper[uint_]], 1234));
+ BOOST_TEST(test("1234", lower[lower[uint_]], 1234));
+
+ BOOST_TEST(test_delimited("1234 ", upper[upper[uint_]], 1234, char_(' ')));
+ BOOST_TEST(test_delimited("1234 ", upper[lower[uint_]], 1234, char_(' ')));
+ BOOST_TEST(test_delimited("1234 ", lower[upper[uint_]], 1234, char_(' ')));
+ BOOST_TEST(test_delimited("1234 ", lower[lower[uint_]], 1234, char_(' ')));
+
+ BOOST_TEST(test("FF", upper[upper[hex]], 0xff));
+ BOOST_TEST(test("FF", upper[lower[hex]], 0xff));
+ BOOST_TEST(test("ff", lower[upper[hex]], 0xff));
+ BOOST_TEST(test("ff", lower[lower[hex]], 0xff));
+
+ BOOST_TEST(test_delimited("FF ", upper[upper[hex]], 0xff, char_(' ')));
+ BOOST_TEST(test_delimited("FF ", upper[lower[hex]], 0xff, char_(' ')));
+ BOOST_TEST(test_delimited("ff ", lower[upper[hex]], 0xff, char_(' ')));
+ BOOST_TEST(test_delimited("ff ", lower[lower[hex]], 0xff, char_(' ')));
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/spirit/test/karma/int_numerics3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/int_numerics3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,129 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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)
+
+//#define KARMA_FAIL_COMPILATION
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/for_each.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/bool.hpp>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_numeric.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_action.hpp>
+#include <boost/spirit/include/karma_phoenix_attributes.hpp>
+
+#include <limits>
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+struct test_minmax
+{
+ template <typename T>
+ void operator()(T) const
+ {
+ using namespace boost::spirit;
+ using namespace boost::phoenix;
+
+ T minval = (std::numeric_limits<T>::min)();
+ T maxval = (std::numeric_limits<T>::max)();
+
+ std::string expected_minval = boost::lexical_cast<std::string>(minval);
+ std::string expected_maxval = boost::lexical_cast<std::string>(maxval);
+
+ // create a correct generator type from the given integer type
+ typedef typename
+ boost::mpl::if_<
+ boost::mpl::bool_<std::numeric_limits<T>::is_signed>,
+ karma::int_generator<T>,
+ karma::uint_generator<T>
+ >::type
+ int_generator_type;
+
+ int_generator_type const gen = int_generator_type();
+
+ BOOST_TEST(test(expected_maxval, gen, maxval));
+ BOOST_TEST(test(expected_minval, gen, minval));
+ BOOST_TEST(test(expected_maxval, gen(maxval)));
+ BOOST_TEST(test(expected_minval, gen(minval)));
+ BOOST_TEST(test(expected_maxval, gen(maxval), maxval));
+ BOOST_TEST(test(expected_minval, gen(minval), minval));
+ BOOST_TEST(!test("", gen(maxval), maxval-1));
+ BOOST_TEST(!test("", gen(minval), minval+1));
+ BOOST_TEST(test(expected_maxval, lit(maxval)));
+ BOOST_TEST(test(expected_minval, lit(minval)));
+
+ BOOST_TEST(test_delimited(expected_maxval + " ", gen, maxval, char(' ')));
+ BOOST_TEST(test_delimited(expected_minval + " ", gen, minval, char(' ')));
+ BOOST_TEST(test_delimited(expected_maxval + " ", gen(maxval), char(' ')));
+ BOOST_TEST(test_delimited(expected_minval + " ", gen(minval), char(' ')));
+ BOOST_TEST(test_delimited(expected_maxval + " ", gen(maxval), maxval, char(' ')));
+ BOOST_TEST(test_delimited(expected_minval + " ", gen(minval), minval, char(' ')));
+ BOOST_TEST(!test_delimited("", gen(maxval), maxval-1, char(' ')));
+ BOOST_TEST(!test_delimited("", gen(minval), minval+1, char(' ')));
+ BOOST_TEST(test_delimited(expected_maxval + " ", lit(maxval), char(' ')));
+ BOOST_TEST(test_delimited(expected_minval + " ", lit(minval), char(' ')));
+
+ // action tests
+ BOOST_TEST(test(expected_maxval, gen[_1 = val(maxval)]));
+ BOOST_TEST(test(expected_minval, gen[_1 = val(minval)]));
+
+ // optional tests
+ boost::optional<T> optmin, optmax(maxval);
+
+ BOOST_TEST(!test("", gen, optmin));
+ BOOST_TEST(!test("", gen(minval), optmin));
+
+ optmin = minval;
+ BOOST_TEST(test(expected_minval, gen, optmin));
+ BOOST_TEST(test(expected_maxval, gen, optmax));
+ BOOST_TEST(test(expected_minval, gen(minval), optmin));
+ BOOST_TEST(test(expected_maxval, gen(maxval), optmax));
+
+// we support Phoenix attributes only starting with V2.2
+#if SPIRIT_VERSION >= 0x2020
+ // Phoenix expression tests (only supported while including
+ // karma_phoenix_attributes.hpp
+ namespace phoenix = boost::phoenix;
+
+ BOOST_TEST(test("1", gen, phoenix::val(1)));
+
+ T val = 1;
+ BOOST_TEST(test("1", gen, phoenix::ref(val)));
+ BOOST_TEST(test("2", gen, ++phoenix::ref(val)));
+#endif
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+
+// test boundary values
+ typedef boost::mpl::vector<
+#ifdef BOOST_HAS_LONG_LONG
+ boost::long_long_type, boost::ulong_long_type,
+#endif
+ short, unsigned short,
+ int, unsigned int,
+ long, unsigned long
+ > integer_types;
+ boost::mpl::for_each<integer_types>(test_minmax());
+
+ return boost::report_errors();
+}
+

Deleted: trunk/libs/spirit/test/karma/karma_optional_double.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/karma_optional_double.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,52 +0,0 @@
-// Copyright (c) 2010 Olaf Peter
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/spirit/include/karma.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-namespace client
-{
- namespace karma = boost::spirit::karma;
-
- template <typename OutputIterator>
- struct grammar
- : karma::grammar<OutputIterator, boost::optional<double>()>
- {
- grammar()
- : grammar::base_type(start)
- {
- using karma::double_;
-
- u = double_ << "U";
- start = ( !double_ << "NA" ) | u;
-
- start.name("start");
- u.name("u");
- }
-
- karma::rule<OutputIterator, double()> u;
- karma::rule<OutputIterator, boost::optional<double>()> start;
- };
-}
-
-int main()
-{
- namespace karma = boost::spirit::karma;
-
- typedef std::back_insert_iterator<std::string> sink_type;
-
- boost::optional<double> d1, d2;
- d2 = 1.0;
-
- std::string generated1, generated2;
- client::grammar<sink_type> g;
-
- BOOST_TEST(karma::generate(sink_type(generated1), g, d1) && generated1 == "NA");
- BOOST_TEST(karma::generate(sink_type(generated2), g, d2) && generated2 == "1.0U");
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/karma/pattern.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/pattern.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,215 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/karma_operator.hpp>
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_auxiliary.hpp>
-#include <boost/spirit/include/karma_string.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_nonterminal.hpp>
-#include <boost/spirit/include/karma_action.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-#include <boost/spirit/include/phoenix_fusion.hpp>
-
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-int main()
-{
- using namespace boost;
- using namespace boost::spirit;
- using namespace boost::spirit::ascii;
-
- typedef spirit_test::output_iterator<char>::type outiter_type;
-
- // test rule parameter propagation
- {
- using boost::phoenix::at_c;
-
- karma::rule<outiter_type, fusion::vector<char, int, double>()> start;
- fusion::vector<char, int, double> vec('a', 10, 12.4);
-
- start %= char_ << int_ << double_;
- BOOST_TEST(test("a1012.4", start, vec));
-
- karma::rule<outiter_type, char()> a;
- karma::rule<outiter_type, int()> b;
- karma::rule<outiter_type, double()> c;
-
- a %= char_ << eps;
- b %= int_;
- c %= double_;
- start = a[_1 = at_c<0>(_r0)] << b[_1 = at_c<1>(_r0)] << c[_1 = at_c<2>(_r0)];
- BOOST_TEST(test("a1012.4", start, vec));
-
- start = (a << b << c)[_1 = at_c<0>(_r0), _2 = at_c<1>(_r0), _3 = at_c<2>(_r0)];
- BOOST_TEST(test("a1012.4", start, vec));
-
- start = a << b << c;
- BOOST_TEST(test("a1012.4", start, vec));
-
- start %= a << b << c;
- BOOST_TEST(test("a1012.4", start, vec));
- }
-
- {
- using boost::phoenix::at_c;
-
- karma::rule<outiter_type, space_type, fusion::vector<char, int, double>()> start;
- fusion::vector<char, int, double> vec('a', 10, 12.4);
-
- start %= char_ << int_ << double_;
- BOOST_TEST(test_delimited("a 10 12.4 ", start, vec, space));
-
- karma::rule<outiter_type, space_type, char()> a;
- karma::rule<outiter_type, space_type, int()> b;
- karma::rule<outiter_type, space_type, double()> c;
-
- a %= char_ << eps;
- b %= int_;
- c %= double_;
- start = a[_1 = at_c<0>(_r0)] << b[_1 = at_c<1>(_r0)] << c[_1 = at_c<2>(_r0)];
- BOOST_TEST(test_delimited("a 10 12.4 ", start, vec, space));
-
- start = (a << b << c)[_1 = at_c<0>(_r0), _2 = at_c<1>(_r0), _3 = at_c<2>(_r0)];
- BOOST_TEST(test_delimited("a 10 12.4 ", start, vec, space));
-
- start = a << b << c;
- BOOST_TEST(test_delimited("a 10 12.4 ", start, vec, space));
-
- start %= a << b << c;
- BOOST_TEST(test_delimited("a 10 12.4 ", start, vec, space));
- }
-
- // test direct initalization
- {
- using boost::phoenix::at_c;
-
- fusion::vector<char, int, double> vec('a', 10, 12.4);
- karma::rule<outiter_type, space_type, fusion::vector<char, int, double>()>
- start = char_ << int_ << double_;;
-
- BOOST_TEST(test_delimited("a 10 12.4 ", start, vec, space));
-
- karma::rule<outiter_type, space_type, char()> a = char_ << eps;
- karma::rule<outiter_type, space_type, int()> b = int_;
- karma::rule<outiter_type, space_type, double()> c = double_;
-
- start = a[_1 = at_c<0>(_r0)] << b[_1 = at_c<1>(_r0)] << c[_1 = at_c<2>(_r0)];
- BOOST_TEST(test_delimited("a 10 12.4 ", start, vec, space));
- }
-
- // locals test
- {
- karma::rule<outiter_type, locals<std::string> > start;
-
- start = string[_1 = "abc", _a = _1] << int_[_1 = 10] << string[_1 = _a];
- BOOST_TEST(test("abc10abc", start));
- }
-
- {
- karma::rule<outiter_type, space_type, locals<std::string> > start;
-
- start = string[_1 = "abc", _a = _1] << int_[_1 = 10] << string[_1 = _a];
- BOOST_TEST(test_delimited("abc 10 abc ", start, space));
- }
-
- // alias tests
- {
- typedef variant<char, int, double> var_type;
-
- karma::rule<outiter_type, var_type()> d, start;
-
- d = start.alias(); // d will always track start
-
- start = (char_ | int_ | double_)[_1 = _val];
-
- var_type v ('a');
- BOOST_TEST(test("a", d, v));
- v = 10;
- BOOST_TEST(test("10", d, v));
- v = 12.4;
- BOOST_TEST(test("12.4", d, v));
- }
-
- {
- typedef variant<char, int, double> var_type;
-
- karma::rule<outiter_type, space_type, var_type()> d, start;
-
- d = start.alias(); // d will always track start
-
- start = (char_ | int_ | double_)[_1 = _val];
-
- var_type v ('a');
- BOOST_TEST(test_delimited("a ", d, v, space));
- v = 10;
- BOOST_TEST(test_delimited("10 ", d, v, space));
- v = 12.4;
- BOOST_TEST(test_delimited("12.4 ", d, v, space));
- }
-
- {
- typedef variant<char, int, double> var_type;
-
- karma::rule<outiter_type, var_type()> d, start;
-
- d = start.alias(); // d will always track start
-
- start %= char_ | int_ | double_;
-
- var_type v ('a');
- BOOST_TEST(test("a", d, v));
- v = 10;
- BOOST_TEST(test("10", d, v));
- v = 12.4;
- BOOST_TEST(test("12.4", d, v));
-
- start = char_ | int_ | double_;
-
- v = 'a';
- BOOST_TEST(test("a", d, v));
- v = 10;
- BOOST_TEST(test("10", d, v));
- v = 12.4;
- BOOST_TEST(test("12.4", d, v));
- }
-
- {
- typedef variant<char, int, double> var_type;
-
- karma::rule<outiter_type, space_type, var_type()> d, start;
-
- d = start.alias(); // d will always track start
-
- start %= char_ | int_ | double_;
-
- var_type v ('a');
- BOOST_TEST(test_delimited("a ", d, v, space));
- v = 10;
- BOOST_TEST(test_delimited("10 ", d, v, space));
- v = 12.4;
- BOOST_TEST(test_delimited("12.4 ", d, v, space));
-
- start = char_ | int_ | double_;
-
- v = 'a';
- BOOST_TEST(test_delimited("a ", d, v, space));
- v = 10;
- BOOST_TEST(test_delimited("10 ", d, v, space));
- v = 12.4;
- BOOST_TEST(test_delimited("12.4 ", d, v, space));
- }
-
- return boost::report_errors();
-}
-

Copied: trunk/libs/spirit/test/karma/pattern1.cpp (from r67483, /trunk/libs/spirit/test/karma/pattern.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/pattern.cpp (original)
+++ trunk/libs/spirit/test/karma/pattern1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -108,108 +108,6 @@
         BOOST_TEST(test_delimited("a 10 12.4 ", start, vec, space));
     }
 
- // locals test
- {
- karma::rule<outiter_type, locals<std::string> > start;
-
- start = string[_1 = "abc", _a = _1] << int_[_1 = 10] << string[_1 = _a];
- BOOST_TEST(test("abc10abc", start));
- }
-
- {
- karma::rule<outiter_type, space_type, locals<std::string> > start;
-
- start = string[_1 = "abc", _a = _1] << int_[_1 = 10] << string[_1 = _a];
- BOOST_TEST(test_delimited("abc 10 abc ", start, space));
- }
-
- // alias tests
- {
- typedef variant<char, int, double> var_type;
-
- karma::rule<outiter_type, var_type()> d, start;
-
- d = start.alias(); // d will always track start
-
- start = (char_ | int_ | double_)[_1 = _val];
-
- var_type v ('a');
- BOOST_TEST(test("a", d, v));
- v = 10;
- BOOST_TEST(test("10", d, v));
- v = 12.4;
- BOOST_TEST(test("12.4", d, v));
- }
-
- {
- typedef variant<char, int, double> var_type;
-
- karma::rule<outiter_type, space_type, var_type()> d, start;
-
- d = start.alias(); // d will always track start
-
- start = (char_ | int_ | double_)[_1 = _val];
-
- var_type v ('a');
- BOOST_TEST(test_delimited("a ", d, v, space));
- v = 10;
- BOOST_TEST(test_delimited("10 ", d, v, space));
- v = 12.4;
- BOOST_TEST(test_delimited("12.4 ", d, v, space));
- }
-
- {
- typedef variant<char, int, double> var_type;
-
- karma::rule<outiter_type, var_type()> d, start;
-
- d = start.alias(); // d will always track start
-
- start %= char_ | int_ | double_;
-
- var_type v ('a');
- BOOST_TEST(test("a", d, v));
- v = 10;
- BOOST_TEST(test("10", d, v));
- v = 12.4;
- BOOST_TEST(test("12.4", d, v));
-
- start = char_ | int_ | double_;
-
- v = 'a';
- BOOST_TEST(test("a", d, v));
- v = 10;
- BOOST_TEST(test("10", d, v));
- v = 12.4;
- BOOST_TEST(test("12.4", d, v));
- }
-
- {
- typedef variant<char, int, double> var_type;
-
- karma::rule<outiter_type, space_type, var_type()> d, start;
-
- d = start.alias(); // d will always track start
-
- start %= char_ | int_ | double_;
-
- var_type v ('a');
- BOOST_TEST(test_delimited("a ", d, v, space));
- v = 10;
- BOOST_TEST(test_delimited("10 ", d, v, space));
- v = 12.4;
- BOOST_TEST(test_delimited("12.4 ", d, v, space));
-
- start = char_ | int_ | double_;
-
- v = 'a';
- BOOST_TEST(test_delimited("a ", d, v, space));
- v = 10;
- BOOST_TEST(test_delimited("10 ", d, v, space));
- v = 12.4;
- BOOST_TEST(test_delimited("12.4 ", d, v, space));
- }
-
     return boost::report_errors();
 }
 

Added: trunk/libs/spirit/test/karma/pattern2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/pattern2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,138 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_operator.hpp>
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_auxiliary.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_numeric.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
+#include <boost/spirit/include/karma_action.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+#include <boost/spirit/include/phoenix_fusion.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int main()
+{
+ using namespace boost;
+ using namespace boost::spirit;
+ using namespace boost::spirit::ascii;
+
+ typedef spirit_test::output_iterator<char>::type outiter_type;
+
+ // locals test
+ {
+ karma::rule<outiter_type, locals<std::string> > start;
+
+ start = string[_1 = "abc", _a = _1] << int_[_1 = 10] << string[_1 = _a];
+ BOOST_TEST(test("abc10abc", start));
+ }
+
+ {
+ karma::rule<outiter_type, space_type, locals<std::string> > start;
+
+ start = string[_1 = "abc", _a = _1] << int_[_1 = 10] << string[_1 = _a];
+ BOOST_TEST(test_delimited("abc 10 abc ", start, space));
+ }
+
+ // alias tests
+ {
+ typedef variant<char, int, double> var_type;
+
+ karma::rule<outiter_type, var_type()> d, start;
+
+ d = start.alias(); // d will always track start
+
+ start = (char_ | int_ | double_)[_1 = _val];
+
+ var_type v ('a');
+ BOOST_TEST(test("a", d, v));
+ v = 10;
+ BOOST_TEST(test("10", d, v));
+ v = 12.4;
+ BOOST_TEST(test("12.4", d, v));
+ }
+
+ {
+ typedef variant<char, int, double> var_type;
+
+ karma::rule<outiter_type, space_type, var_type()> d, start;
+
+ d = start.alias(); // d will always track start
+
+ start = (char_ | int_ | double_)[_1 = _val];
+
+ var_type v ('a');
+ BOOST_TEST(test_delimited("a ", d, v, space));
+ v = 10;
+ BOOST_TEST(test_delimited("10 ", d, v, space));
+ v = 12.4;
+ BOOST_TEST(test_delimited("12.4 ", d, v, space));
+ }
+
+ {
+ typedef variant<char, int, double> var_type;
+
+ karma::rule<outiter_type, var_type()> d, start;
+
+ d = start.alias(); // d will always track start
+
+ start %= char_ | int_ | double_;
+
+ var_type v ('a');
+ BOOST_TEST(test("a", d, v));
+ v = 10;
+ BOOST_TEST(test("10", d, v));
+ v = 12.4;
+ BOOST_TEST(test("12.4", d, v));
+
+ start = char_ | int_ | double_;
+
+ v = 'a';
+ BOOST_TEST(test("a", d, v));
+ v = 10;
+ BOOST_TEST(test("10", d, v));
+ v = 12.4;
+ BOOST_TEST(test("12.4", d, v));
+ }
+
+ {
+ typedef variant<char, int, double> var_type;
+
+ karma::rule<outiter_type, space_type, var_type()> d, start;
+
+ d = start.alias(); // d will always track start
+
+ start %= char_ | int_ | double_;
+
+ var_type v ('a');
+ BOOST_TEST(test_delimited("a ", d, v, space));
+ v = 10;
+ BOOST_TEST(test_delimited("10 ", d, v, space));
+ v = 12.4;
+ BOOST_TEST(test_delimited("12.4 ", d, v, space));
+
+ start = char_ | int_ | double_;
+
+ v = 'a';
+ BOOST_TEST(test_delimited("a ", d, v, space));
+ v = 10;
+ BOOST_TEST(test_delimited("10 ", d, v, space));
+ v = 12.4;
+ BOOST_TEST(test_delimited("12.4 ", d, v, space));
+ }
+
+ return boost::report_errors();
+}
+

Deleted: trunk/libs/spirit/test/karma/real_numerics.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/real_numerics.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,560 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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)
-
-//#define KARMA_FAIL_COMPILATION
-
-#include <boost/version.hpp>
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/math/concepts/real_concept.hpp>
-
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_generate.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_phoenix_attributes.hpp>
-
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-
-#include <limits>
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces the scientific notation
-template <typename T>
-struct scientific_policy : boost::spirit::karma::real_policies<T>
-{
- // we want the numbers always to be in scientific format
- typedef boost::spirit::karma::real_policies<T> base_type;
- static int floatfield(T) { return base_type::fmtflags::scientific; }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces the fixed notation
-template <typename T>
-struct fixed_policy : boost::spirit::karma::real_policies<T>
-{
- typedef boost::spirit::karma::real_policies<T> base_type;
-
- // we want the numbers always to be in scientific format
- static int floatfield(T) { return base_type::fmtflags::fixed; }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces to output trailing zeros in the
-// fractional part
-template <typename T>
-struct trailing_zeros_policy : boost::spirit::karma::real_policies<T> // 4 digits
-{
- // we want the numbers always to contain trailing zeros up to 4 digits in
- // the fractional part
- static bool trailing_zeros(T) { return true; }
-
- // we want to generate up to 4 fractional digits
- static unsigned int precision(T) { return 4; }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces the sign to be generated
-template <typename T>
-struct signed_policy : boost::spirit::karma::real_policies<T>
-{
- // we want to always have a sign generated
- static bool force_sign(T)
- {
- return true;
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces to output trailing zeros in the
-// fractional part
-template <typename T>
-struct bordercase_policy : boost::spirit::karma::real_policies<T>
-{
- // we want to generate up to the maximum significant amount of fractional
- // digits
- static unsigned int precision(T)
- {
- return std::numeric_limits<T>::digits10 + 1;
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces to output trailing zeros in the
-// fractional part
-template <typename T>
-struct statefull_policy : boost::spirit::karma::real_policies<T>
-{
- statefull_policy(int precision = 4, bool trailingzeros = false)
- : precision_(precision), trailingzeros_(trailingzeros)
- {}
-
- // we want to generate up to the maximum significant amount of fractional
- // digits
- unsigned int precision(T) const
- {
- return precision_;
- }
-
- bool trailing_zeros(T) const
- {
- return trailingzeros_;
- }
-
- int precision_;
- bool trailingzeros_;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-int main()
-{
- using namespace boost::spirit;
-
- {
- ///////////////////////////////////////////////////////////////////////
- // use the default real_policies
- BOOST_TEST(test("0.0", double_, 0.0));
- BOOST_TEST(test("1.0", double_, 1.0));
- BOOST_TEST(test("1.0", double_, 1.0001));
- BOOST_TEST(test("1.001", double_, 1.001));
- BOOST_TEST(test("1.01", double_, 1.010));
- BOOST_TEST(test("1.1", double_, 1.100));
-
- BOOST_TEST(test("1.234e-04", double_, 0.00012345));
- BOOST_TEST(test("0.001", double_, 0.0012345));
- BOOST_TEST(test("0.012", double_, 0.012345));
- BOOST_TEST(test("0.123", double_, 0.12345));
- BOOST_TEST(test("1.234", double_, 1.2345));
- BOOST_TEST(test("12.346", double_, 12.346));
- BOOST_TEST(test("123.46", double_, 123.46));
- BOOST_TEST(test("1234.5", double_, 1234.5));
- BOOST_TEST(test("12342.0", double_, 12342.));
- BOOST_TEST(test("1.234e05", double_, 123420.));
-
- BOOST_TEST(test("-1.0", double_, -1.0));
- BOOST_TEST(test("-1.234", double_, -1.2345));
- BOOST_TEST(test("-1.235", double_, -1.2346));
- BOOST_TEST(test("-1234.2", double_, -1234.2));
-
- BOOST_TEST(test("1.0", double_(1.0)));
- BOOST_TEST(test("1.0", double_(1.0001)));
- BOOST_TEST(test("1.001", double_(1.001)));
- BOOST_TEST(test("1.01", double_(1.010)));
- BOOST_TEST(test("1.1", double_(1.100)));
-
- BOOST_TEST(test("1.234e-04", double_(0.00012345)));
- BOOST_TEST(test("0.001", double_(0.0012345)));
- BOOST_TEST(test("0.012", double_(0.012345)));
- BOOST_TEST(test("0.123", double_(0.12345)));
- BOOST_TEST(test("1.234", double_(1.2345)));
- BOOST_TEST(test("12.346", double_(12.346)));
- BOOST_TEST(test("123.46", double_(123.46)));
- BOOST_TEST(test("1234.5", double_(1234.5)));
- BOOST_TEST(test("12342.0", double_(12342.)));
- BOOST_TEST(test("1.234e05", double_(123420.)));
- }
-
- {
- ///////////////////////////////////////////////////////////////////////
- // test NaN and Inf
- BOOST_TEST(test("nan", double_, std::numeric_limits<double>::quiet_NaN()));
- BOOST_TEST(test("-nan", double_, -std::numeric_limits<double>::quiet_NaN()));
- BOOST_TEST(test("inf", double_, std::numeric_limits<double>::infinity()));
- BOOST_TEST(test("-inf", double_, -std::numeric_limits<double>::infinity()));
-
- typedef karma::real_generator<double, signed_policy<double> > signed_type;
- signed_type const signed_ = signed_type();
-
- BOOST_TEST(test("+nan", signed_, std::numeric_limits<double>::quiet_NaN()));
- BOOST_TEST(test("-nan", signed_, -std::numeric_limits<double>::quiet_NaN()));
- BOOST_TEST(test("+inf", signed_, std::numeric_limits<double>::infinity()));
- BOOST_TEST(test("-inf", signed_, -std::numeric_limits<double>::infinity()));
- BOOST_TEST(test(" 0.0", signed_, 0.0));
-
- BOOST_TEST(test("+nan", signed_(std::numeric_limits<double>::quiet_NaN())));
- BOOST_TEST(test("-nan", signed_(-std::numeric_limits<double>::quiet_NaN())));
- BOOST_TEST(test("+inf", signed_(std::numeric_limits<double>::infinity())));
- BOOST_TEST(test("-inf", signed_(-std::numeric_limits<double>::infinity())));
- BOOST_TEST(test(" 0.0", signed_(0.0)));
- }
-
- {
- ///////////////////////////////////////////////////////////////////////
- typedef karma::real_generator<double, statefull_policy<double> >
- statefull_type;
-
- statefull_policy<double> policy(5, true);
- statefull_type const statefull = statefull_type(policy);
-
- BOOST_TEST(test("0.00000", statefull, 0.0));
- BOOST_TEST(test("0.00000", statefull(0.0)));
-
- using namespace boost::phoenix;
- BOOST_TEST(test("0.00000", statefull(val(0.0))));
- }
-
- {
- ///////////////////////////////////////////////////////////////////////
- typedef karma::real_generator<double, trailing_zeros_policy<double> >
- trailing_zeros_type;
- trailing_zeros_type const trail_zeros = trailing_zeros_type();
-
- BOOST_TEST(test("0.0000", trail_zeros, 0.0));
- BOOST_TEST(test("1.0000", trail_zeros, 1.0));
- BOOST_TEST(test("1.0001", trail_zeros, 1.0001));
- BOOST_TEST(test("1.0010", trail_zeros, 1.001));
- BOOST_TEST(test("1.0100", trail_zeros, 1.010));
- BOOST_TEST(test("1.1000", trail_zeros, 1.100));
-
- BOOST_TEST(test("1.2345e-04", trail_zeros, 0.00012345));
- BOOST_TEST(test("0.0012", trail_zeros, 0.0012345));
- BOOST_TEST(test("0.0123", trail_zeros, 0.012345));
- BOOST_TEST(test("0.1235", trail_zeros, 0.12345));
- BOOST_TEST(test("1.2345", trail_zeros, 1.2345));
- BOOST_TEST(test("12.3460", trail_zeros, 12.346));
- BOOST_TEST(test("123.4600", trail_zeros, 123.46));
- BOOST_TEST(test("1234.5000", trail_zeros, 1234.5));
- BOOST_TEST(test("12342.0000", trail_zeros, 12342.));
- BOOST_TEST(test("1.2342e05", trail_zeros, 123420.));
-
- BOOST_TEST(test("-1.0000", trail_zeros, -1.0));
- BOOST_TEST(test("-1.2345", trail_zeros, -1.2345));
- BOOST_TEST(test("-1.2346", trail_zeros, -1.2346));
- BOOST_TEST(test("-1234.2000", trail_zeros, -1234.2));
-
- BOOST_TEST(test("1.0000", trail_zeros(1.0)));
- BOOST_TEST(test("1.0001", trail_zeros(1.0001)));
- BOOST_TEST(test("1.0010", trail_zeros(1.001)));
- BOOST_TEST(test("1.0100", trail_zeros(1.010)));
- BOOST_TEST(test("1.1000", trail_zeros(1.100)));
-
- BOOST_TEST(test("1.2345e-04", trail_zeros(0.00012345)));
- BOOST_TEST(test("0.0012", trail_zeros(0.0012345)));
- BOOST_TEST(test("0.0123", trail_zeros(0.012345)));
- BOOST_TEST(test("0.1235", trail_zeros(0.12345)));
- BOOST_TEST(test("1.2345", trail_zeros(1.2345)));
- BOOST_TEST(test("12.3460", trail_zeros(12.346)));
- BOOST_TEST(test("123.4600", trail_zeros(123.46)));
- BOOST_TEST(test("1234.5000", trail_zeros(1234.5)));
- BOOST_TEST(test("12342.0000", trail_zeros(12342.)));
- BOOST_TEST(test("1.2342e05", trail_zeros(123420.)));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- BOOST_TEST(test_delimited("0.0 ", double_, 0.0, char_(' ')));
- BOOST_TEST(test_delimited("1.0 ", double_, 1.0, char_(' ')));
- BOOST_TEST(test_delimited("1.0 ", double_, 1.0001, char_(' ')));
- BOOST_TEST(test_delimited("1.001 ", double_, 1.001, char_(' ')));
- BOOST_TEST(test_delimited("1.01 ", double_, 1.010, char_(' ')));
- BOOST_TEST(test_delimited("1.1 ", double_, 1.100, char_(' ')));
-
- BOOST_TEST(test_delimited("1.234e-04 ", double_, 0.00012345, char_(' ')));
- BOOST_TEST(test_delimited("0.001 ", double_, 0.0012345, char_(' ')));
- BOOST_TEST(test_delimited("0.012 ", double_, 0.012345, char_(' ')));
- BOOST_TEST(test_delimited("0.123 ", double_, 0.12345, char_(' ')));
- BOOST_TEST(test_delimited("1.234 ", double_, 1.2345, char_(' ')));
- BOOST_TEST(test_delimited("12.346 ", double_, 12.346, char_(' ')));
- BOOST_TEST(test_delimited("123.46 ", double_, 123.46, char_(' ')));
- BOOST_TEST(test_delimited("1234.5 ", double_, 1234.5, char_(' ')));
- BOOST_TEST(test_delimited("12342.0 ", double_, 12342., char_(' ')));
- BOOST_TEST(test_delimited("1.234e05 ", double_, 123420., char_(' ')));
-
- BOOST_TEST(test_delimited("-1.0 ", double_, -1.0, char_(' ')));
- BOOST_TEST(test_delimited("-1.234 ", double_, -1.2345, char_(' ')));
- BOOST_TEST(test_delimited("-1.235 ", double_, -1.2346, char_(' ')));
- BOOST_TEST(test_delimited("-1234.2 ", double_, -1234.2, char_(' ')));
-
- BOOST_TEST(test_delimited("1.0 ", double_(1.0), char_(' ')));
- BOOST_TEST(test_delimited("1.0 ", double_(1.0001), char_(' ')));
- BOOST_TEST(test_delimited("1.001 ", double_(1.001), char_(' ')));
- BOOST_TEST(test_delimited("1.01 ", double_(1.010), char_(' ')));
- BOOST_TEST(test_delimited("1.1 ", double_(1.100), char_(' ')));
-
- BOOST_TEST(test_delimited("1.234e-04 ", double_(0.00012345), char_(' ')));
- BOOST_TEST(test_delimited("0.001 ", double_(0.0012345), char_(' ')));
- BOOST_TEST(test_delimited("0.012 ", double_(0.012345), char_(' ')));
- BOOST_TEST(test_delimited("0.123 ", double_(0.12345), char_(' ')));
- BOOST_TEST(test_delimited("1.234 ", double_(1.2345), char_(' ')));
- BOOST_TEST(test_delimited("12.346 ", double_(12.346), char_(' ')));
- BOOST_TEST(test_delimited("123.46 ", double_(123.46), char_(' ')));
- BOOST_TEST(test_delimited("1234.5 ", double_(1234.5), char_(' ')));
- BOOST_TEST(test_delimited("12342.0 ", double_(12342.), char_(' ')));
- BOOST_TEST(test_delimited("1.234e05 ", double_(123420.), char_(' ')));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- // test NaN and Inf
- BOOST_TEST(test_delimited("nan ", double_,
- std::numeric_limits<double>::quiet_NaN(), char_(' ')));
- BOOST_TEST(test_delimited("-nan ", double_,
- -std::numeric_limits<double>::quiet_NaN(), char_(' ')));
- BOOST_TEST(test_delimited("inf ", double_,
- std::numeric_limits<double>::infinity(), char_(' ')));
- BOOST_TEST(test_delimited("-inf ", double_,
- -std::numeric_limits<double>::infinity(), char_(' ')));
-
- typedef karma::real_generator<double, signed_policy<double> > signed_type;
- signed_type const signed_ = signed_type();
-
- BOOST_TEST(test_delimited("+nan ", signed_,
- std::numeric_limits<double>::quiet_NaN(), char_(' ')));
- BOOST_TEST(test_delimited("-nan ", signed_,
- -std::numeric_limits<double>::quiet_NaN(), char_(' ')));
- BOOST_TEST(test_delimited("+inf ", signed_,
- std::numeric_limits<double>::infinity(), char_(' ')));
- BOOST_TEST(test_delimited("-inf ", signed_,
- -std::numeric_limits<double>::infinity(), char_(' ')));
- BOOST_TEST(test_delimited(" 0.0 ", signed_, 0.0, char_(' ')));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- typedef karma::real_generator<double, scientific_policy<double> >
- science_type;
- science_type const science = science_type();
-
- BOOST_TEST(test("0.0e00", science, 0.0));
- BOOST_TEST(test("1.0e00", science, 1.0));
-
- BOOST_TEST(test("1.234e-05", science, 0.000012345));
- BOOST_TEST(test("1.234e-04", science, 0.00012345));
- BOOST_TEST(test("1.234e-03", science, 0.0012345));
- BOOST_TEST(test("1.234e-02", science, 0.012345));
- BOOST_TEST(test("1.235e-01", science, 0.12345)); // note the rounding error!
- BOOST_TEST(test("1.234e00", science, 1.2345));
- BOOST_TEST(test("1.235e01", science, 12.346));
- BOOST_TEST(test("1.235e02", science, 123.46));
- BOOST_TEST(test("1.234e03", science, 1234.5));
- BOOST_TEST(test("1.234e04", science, 12342.));
- BOOST_TEST(test("1.234e05", science, 123420.));
-
- BOOST_TEST(test("-1.234e-05", science, -0.000012345));
- BOOST_TEST(test("-1.234e-04", science, -0.00012345));
- BOOST_TEST(test("-1.234e-03", science, -0.0012345));
- BOOST_TEST(test("-1.234e-02", science, -0.012345));
- BOOST_TEST(test("-1.235e-01", science, -0.12345)); // note the rounding error!
- BOOST_TEST(test("-1.234e00", science, -1.2345));
- BOOST_TEST(test("-1.235e01", science, -12.346));
- BOOST_TEST(test("-1.235e02", science, -123.46));
- BOOST_TEST(test("-1.234e03", science, -1234.5));
- BOOST_TEST(test("-1.234e04", science, -12342.));
- BOOST_TEST(test("-1.234e05", science, -123420.));
-
- BOOST_TEST(test("1.234E-05", upper[science], 0.000012345));
- BOOST_TEST(test("1.234E-04", upper[science], 0.00012345));
- BOOST_TEST(test("1.234E-03", upper[science], 0.0012345));
- BOOST_TEST(test("1.234E-02", upper[science], 0.012345));
- BOOST_TEST(test("1.235E-01", upper[science], 0.12345)); // note the rounding error!
- BOOST_TEST(test("1.234E00", upper[science], 1.2345));
- BOOST_TEST(test("1.235E01", upper[science], 12.346));
- BOOST_TEST(test("1.235E02", upper[science], 123.46));
- BOOST_TEST(test("1.234E03", upper[science], 1234.5));
- BOOST_TEST(test("1.234E04", upper[science], 12342.));
- BOOST_TEST(test("1.234E05", upper[science], 123420.));
-
- BOOST_TEST(test("-1.234E-05", upper[science], -0.000012345));
- BOOST_TEST(test("-1.234E-04", upper[science], -0.00012345));
- BOOST_TEST(test("-1.234E-03", upper[science], -0.0012345));
- BOOST_TEST(test("-1.234E-02", upper[science], -0.012345));
- BOOST_TEST(test("-1.235E-01", upper[science], -0.12345)); // note the rounding error!
- BOOST_TEST(test("-1.234E00", upper[science], -1.2345));
- BOOST_TEST(test("-1.235E01", upper[science], -12.346));
- BOOST_TEST(test("-1.235E02", upper[science], -123.46));
- BOOST_TEST(test("-1.234E03", upper[science], -1234.5));
- BOOST_TEST(test("-1.234E04", upper[science], -12342.));
- BOOST_TEST(test("-1.234E05", upper[science], -123420.));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- typedef karma::real_generator<double, fixed_policy<double> > fixed_type;
- fixed_type const fixed = fixed_type();
-
- BOOST_TEST(test("0.0", fixed, 0.0));
- BOOST_TEST(test("1.0", fixed, 1.0));
-
- BOOST_TEST(test("0.0", fixed, 0.000012345));
- BOOST_TEST(test("0.0", fixed, 0.00012345));
- BOOST_TEST(test("0.001", fixed, 0.0012345));
- BOOST_TEST(test("0.012", fixed, 0.012345));
- BOOST_TEST(test("0.123", fixed, 0.12345));
- BOOST_TEST(test("1.234", fixed, 1.2345));
- BOOST_TEST(test("12.345", fixed, 12.345));
- BOOST_TEST(test("123.45", fixed, 123.45));
- BOOST_TEST(test("1234.5", fixed, 1234.5));
- BOOST_TEST(test("12342.0", fixed, 12342.));
- BOOST_TEST(test("123420.0", fixed, 123420.));
- BOOST_TEST(test("123420000000000000000.0", fixed, 1.23420e20));
-
- BOOST_TEST(test("0.0", fixed, -0.000012345));
- BOOST_TEST(test("0.0", fixed, -0.00012345));
- BOOST_TEST(test("-0.001", fixed, -0.0012345));
- BOOST_TEST(test("-0.012", fixed, -0.012345));
- BOOST_TEST(test("-0.123", fixed, -0.12345));
- BOOST_TEST(test("-1.234", fixed, -1.2345));
- BOOST_TEST(test("-12.346", fixed, -12.346));
- BOOST_TEST(test("-123.46", fixed, -123.46));
- BOOST_TEST(test("-1234.5", fixed, -1234.5));
- BOOST_TEST(test("-12342.0", fixed, -12342.));
- BOOST_TEST(test("-123420.0", fixed, -123420.));
- BOOST_TEST(test("-123420000000000000000.0", fixed, -1.23420e20));
- }
-
- {
- BOOST_TEST(test("1.0", lit(1.0)));
- BOOST_TEST(test("1.0", lit(1.0f)));
- BOOST_TEST(test("1.0", lit(1.0l)));
-
- BOOST_TEST(test("1.0", double_(1.0), 1.0));
- BOOST_TEST(test("1.0", float_(1.0), 1.0f));
- BOOST_TEST(test("1.0", long_double(1.0), 1.0l));
- BOOST_TEST(!test("", double_(1.0), 2.0));
- BOOST_TEST(!test("", float_(1.0), 2.0f));
- BOOST_TEST(!test("", long_double(1.0), 2.0l));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- // test NaN and Inf
- BOOST_TEST(test("NAN", upper[double_],
- std::numeric_limits<double>::quiet_NaN()));
- BOOST_TEST(test("-NAN", upper[double_],
- -std::numeric_limits<double>::quiet_NaN()));
- BOOST_TEST(test("INF", upper[double_],
- std::numeric_limits<double>::infinity()));
- BOOST_TEST(test("-INF", upper[double_],
- -std::numeric_limits<double>::infinity()));
-
- typedef karma::real_generator<double, signed_policy<double> > signed_type;
- signed_type const signed_ = signed_type();
-
- BOOST_TEST(test("+NAN", upper[signed_],
- std::numeric_limits<double>::quiet_NaN()));
- BOOST_TEST(test("-NAN", upper[signed_],
- -std::numeric_limits<double>::quiet_NaN()));
- BOOST_TEST(test("+INF", upper[signed_],
- std::numeric_limits<double>::infinity()));
- BOOST_TEST(test("-INF", upper[signed_],
- -std::numeric_limits<double>::infinity()));
- BOOST_TEST(test(" 0.0", upper[signed_], 0.0));
- }
-
-// support for using real_concept with a Karma generator has been implemented
-// in Boost versions > 1.36 only, additionally real_concept is available only
-// if BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is not defined
-#if BOOST_VERSION > 103600 && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
- {
- using boost::math::concepts::real_concept;
- typedef karma::real_generator<real_concept> custom_type;
- custom_type const custom = custom_type();
-
- BOOST_TEST(test("0.0", custom, real_concept(0.0)));
- BOOST_TEST(test("1.0", custom, real_concept(1.0)));
- BOOST_TEST(test("1.0", custom, real_concept(1.0001)));
- BOOST_TEST(test("1.001", custom, real_concept(1.001)));
- BOOST_TEST(test("1.01", custom, real_concept(1.010)));
- BOOST_TEST(test("1.1", custom, real_concept(1.100)));
-
- BOOST_TEST(test("1.234e-04", custom, real_concept(0.00012345)));
- BOOST_TEST(test("0.001", custom, real_concept(0.0012345)));
- BOOST_TEST(test("0.012", custom, real_concept(0.012345)));
- BOOST_TEST(test("0.123", custom, real_concept(0.12345)));
- BOOST_TEST(test("1.234", custom, real_concept(1.2345)));
- BOOST_TEST(test("12.346", custom, real_concept(12.346)));
- BOOST_TEST(test("123.46", custom, real_concept(123.46)));
- BOOST_TEST(test("1234.5", custom, real_concept(1234.5)));
- BOOST_TEST(test("12342.0", custom, real_concept(12342.)));
- BOOST_TEST(test("1.234e05", custom, real_concept(123420.)));
-
- BOOST_TEST(test("-1.0", custom, real_concept(-1.0)));
- BOOST_TEST(test("-1.234", custom, real_concept(-1.2345)));
- BOOST_TEST(test("-1.235", custom, real_concept(-1.2346)));
- BOOST_TEST(test("-1234.2", custom, real_concept(-1234.2)));
-
- BOOST_TEST(test("1.0", custom(real_concept(1.0))));
- BOOST_TEST(test("1.0", custom(real_concept(1.0001))));
- BOOST_TEST(test("1.001", custom(real_concept(1.001))));
- BOOST_TEST(test("1.01", custom(real_concept(1.010))));
- BOOST_TEST(test("1.1", custom(real_concept(1.100))));
-
- BOOST_TEST(test("1.234e-04", custom(real_concept(0.00012345))));
- BOOST_TEST(test("0.001", custom(real_concept(0.0012345))));
- BOOST_TEST(test("0.012", custom(real_concept(0.012345))));
- BOOST_TEST(test("0.123", custom(real_concept(0.12345))));
- BOOST_TEST(test("1.234", custom(real_concept(1.2345))));
- BOOST_TEST(test("12.346", custom(real_concept(12.346))));
- BOOST_TEST(test("123.46", custom(real_concept(123.46))));
- BOOST_TEST(test("1234.5", custom(real_concept(1234.5))));
- BOOST_TEST(test("12342.0", custom(real_concept(12342.))));
- BOOST_TEST(test("1.234e05", custom(real_concept(123420.))));
- }
-#endif
-
-// this appears to be broken on Apple Tiger x86 with gcc4.0.1
-#if (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ != 40001) || \
- !defined(__APPLE__)
- {
- ///////////////////////////////////////////////////////////////////////
- typedef karma::real_generator<double, bordercase_policy<double> >
- bordercase_type;
- bordercase_type const bordercase = bordercase_type();
-
-// BOOST_TEST(test("-5.7222349715140557e307",
-// bordercase(-5.7222349715140557e307)));
-
- BOOST_TEST(test("1.7976931348623158e308",
- bordercase(1.7976931348623158e308))); // DBL_MAX
- BOOST_TEST(test("-1.7976931348623158e308",
- bordercase(-1.7976931348623158e308))); // -DBL_MAX
- BOOST_TEST(test("2.2250738585072014e-308",
- bordercase(2.2250738585072014e-308))); // DBL_MIN
- BOOST_TEST(test("-2.2250738585072014e-308",
- bordercase(-2.2250738585072014e-308))); // -DBL_MIN
- }
-#endif
-
- {
- boost::optional<double> v;
- BOOST_TEST(!test("", double_, v));
- BOOST_TEST(!test("", double_(1.0), v));
-
- v = 1.0;
- BOOST_TEST(test("1.0", double_, v));
- BOOST_TEST(test("1.0", double_(1.0), v));
- }
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- { // Phoenix expression tests (requires to include
- // karma_phoenix_attributes.hpp)
- namespace phoenix = boost::phoenix;
-
- BOOST_TEST(test("1.0", double_, phoenix::val(1.0)));
-
- double d = 1.2;
- BOOST_TEST(test("1.2", double_, phoenix::ref(d)));
- BOOST_TEST(test("2.2", double_, ++phoenix::ref(d)));
- }
-#endif
-
- return boost::report_errors();
-}

Added: trunk/libs/spirit/test/karma/real_numerics.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/real_numerics.hpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,120 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Hartmut Kaiser
+ Copyright (c) 2010 Bryce Lelbach
+
+ Distributed under 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)
+==============================================================================*/
+
+#if !defined(BOOST_SPIRIT_TEST_REAL_NUMERICS_HPP)
+#define BOOST_SPIRIT_TEST_REAL_NUMERICS_HPP
+
+#include <boost/version.hpp>
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/math/concepts/real_concept.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_numeric.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_phoenix_attributes.hpp>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include <limits>
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+// policy for real_generator, which forces the scientific notation
+template <typename T>
+struct scientific_policy : boost::spirit::karma::real_policies<T>
+{
+ // we want the numbers always to be in scientific format
+ typedef boost::spirit::karma::real_policies<T> base_type;
+ static int floatfield(T) { return base_type::fmtflags::scientific; }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// policy for real_generator, which forces the fixed notation
+template <typename T>
+struct fixed_policy : boost::spirit::karma::real_policies<T>
+{
+ typedef boost::spirit::karma::real_policies<T> base_type;
+
+ // we want the numbers always to be in scientific format
+ static int floatfield(T) { return base_type::fmtflags::fixed; }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// policy for real_generator, which forces to output trailing zeros in the
+// fractional part
+template <typename T>
+struct trailing_zeros_policy : boost::spirit::karma::real_policies<T> // 4 digits
+{
+ // we want the numbers always to contain trailing zeros up to 4 digits in
+ // the fractional part
+ static bool trailing_zeros(T) { return true; }
+
+ // we want to generate up to 4 fractional digits
+ static unsigned int precision(T) { return 4; }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// policy for real_generator, which forces the sign to be generated
+template <typename T>
+struct signed_policy : boost::spirit::karma::real_policies<T>
+{
+ // we want to always have a sign generated
+ static bool force_sign(T)
+ {
+ return true;
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// policy for real_generator, which forces to output trailing zeros in the
+// fractional part
+template <typename T>
+struct bordercase_policy : boost::spirit::karma::real_policies<T>
+{
+ // we want to generate up to the maximum significant amount of fractional
+ // digits
+ static unsigned int precision(T)
+ {
+ return std::numeric_limits<T>::digits10 + 1;
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// policy for real_generator, which forces to output trailing zeros in the
+// fractional part
+template <typename T>
+struct statefull_policy : boost::spirit::karma::real_policies<T>
+{
+ statefull_policy(int precision = 4, bool trailingzeros = false)
+ : precision_(precision), trailingzeros_(trailingzeros)
+ {}
+
+ // we want to generate up to the maximum significant amount of fractional
+ // digits
+ unsigned int precision(T) const
+ {
+ return precision_;
+ }
+
+ bool trailing_zeros(T) const
+ {
+ return trailingzeros_;
+ }
+
+ int precision_;
+ bool trailingzeros_;
+};
+
+#endif // BOOST_SPIRIT_TEST_REAL_NUMERICS_HPP
+

Copied: trunk/libs/spirit/test/karma/real_numerics1.cpp (from r67483, /trunk/libs/spirit/test/karma/real_numerics.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/real_numerics.cpp (original)
+++ trunk/libs/spirit/test/karma/real_numerics1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -1,116 +1,12 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2011 Hartmut Kaiser
+// Copyright (c) 2011 Bryce Lelbach
 //
 // Distributed under 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)
 
 //#define KARMA_FAIL_COMPILATION
 
-#include <boost/version.hpp>
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/math/concepts/real_concept.hpp>
-
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_generate.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_phoenix_attributes.hpp>
-
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-
-#include <limits>
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces the scientific notation
-template <typename T>
-struct scientific_policy : boost::spirit::karma::real_policies<T>
-{
- // we want the numbers always to be in scientific format
- typedef boost::spirit::karma::real_policies<T> base_type;
- static int floatfield(T) { return base_type::fmtflags::scientific; }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces the fixed notation
-template <typename T>
-struct fixed_policy : boost::spirit::karma::real_policies<T>
-{
- typedef boost::spirit::karma::real_policies<T> base_type;
-
- // we want the numbers always to be in scientific format
- static int floatfield(T) { return base_type::fmtflags::fixed; }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces to output trailing zeros in the
-// fractional part
-template <typename T>
-struct trailing_zeros_policy : boost::spirit::karma::real_policies<T> // 4 digits
-{
- // we want the numbers always to contain trailing zeros up to 4 digits in
- // the fractional part
- static bool trailing_zeros(T) { return true; }
-
- // we want to generate up to 4 fractional digits
- static unsigned int precision(T) { return 4; }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces the sign to be generated
-template <typename T>
-struct signed_policy : boost::spirit::karma::real_policies<T>
-{
- // we want to always have a sign generated
- static bool force_sign(T)
- {
- return true;
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces to output trailing zeros in the
-// fractional part
-template <typename T>
-struct bordercase_policy : boost::spirit::karma::real_policies<T>
-{
- // we want to generate up to the maximum significant amount of fractional
- // digits
- static unsigned int precision(T)
- {
- return std::numeric_limits<T>::digits10 + 1;
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// policy for real_generator, which forces to output trailing zeros in the
-// fractional part
-template <typename T>
-struct statefull_policy : boost::spirit::karma::real_policies<T>
-{
- statefull_policy(int precision = 4, bool trailingzeros = false)
- : precision_(precision), trailingzeros_(trailingzeros)
- {}
-
- // we want to generate up to the maximum significant amount of fractional
- // digits
- unsigned int precision(T) const
- {
- return precision_;
- }
-
- bool trailing_zeros(T) const
- {
- return trailingzeros_;
- }
-
- int precision_;
- bool trailingzeros_;
-};
+#include "real_numerics.hpp"
 
 ///////////////////////////////////////////////////////////////////////////////
 int main()
@@ -246,190 +142,7 @@
         BOOST_TEST(test("12342.0000", trail_zeros(12342.)));
         BOOST_TEST(test("1.2342e05", trail_zeros(123420.)));
     }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- BOOST_TEST(test_delimited("0.0 ", double_, 0.0, char_(' ')));
- BOOST_TEST(test_delimited("1.0 ", double_, 1.0, char_(' ')));
- BOOST_TEST(test_delimited("1.0 ", double_, 1.0001, char_(' ')));
- BOOST_TEST(test_delimited("1.001 ", double_, 1.001, char_(' ')));
- BOOST_TEST(test_delimited("1.01 ", double_, 1.010, char_(' ')));
- BOOST_TEST(test_delimited("1.1 ", double_, 1.100, char_(' ')));
-
- BOOST_TEST(test_delimited("1.234e-04 ", double_, 0.00012345, char_(' ')));
- BOOST_TEST(test_delimited("0.001 ", double_, 0.0012345, char_(' ')));
- BOOST_TEST(test_delimited("0.012 ", double_, 0.012345, char_(' ')));
- BOOST_TEST(test_delimited("0.123 ", double_, 0.12345, char_(' ')));
- BOOST_TEST(test_delimited("1.234 ", double_, 1.2345, char_(' ')));
- BOOST_TEST(test_delimited("12.346 ", double_, 12.346, char_(' ')));
- BOOST_TEST(test_delimited("123.46 ", double_, 123.46, char_(' ')));
- BOOST_TEST(test_delimited("1234.5 ", double_, 1234.5, char_(' ')));
- BOOST_TEST(test_delimited("12342.0 ", double_, 12342., char_(' ')));
- BOOST_TEST(test_delimited("1.234e05 ", double_, 123420., char_(' ')));
-
- BOOST_TEST(test_delimited("-1.0 ", double_, -1.0, char_(' ')));
- BOOST_TEST(test_delimited("-1.234 ", double_, -1.2345, char_(' ')));
- BOOST_TEST(test_delimited("-1.235 ", double_, -1.2346, char_(' ')));
- BOOST_TEST(test_delimited("-1234.2 ", double_, -1234.2, char_(' ')));
-
- BOOST_TEST(test_delimited("1.0 ", double_(1.0), char_(' ')));
- BOOST_TEST(test_delimited("1.0 ", double_(1.0001), char_(' ')));
- BOOST_TEST(test_delimited("1.001 ", double_(1.001), char_(' ')));
- BOOST_TEST(test_delimited("1.01 ", double_(1.010), char_(' ')));
- BOOST_TEST(test_delimited("1.1 ", double_(1.100), char_(' ')));
-
- BOOST_TEST(test_delimited("1.234e-04 ", double_(0.00012345), char_(' ')));
- BOOST_TEST(test_delimited("0.001 ", double_(0.0012345), char_(' ')));
- BOOST_TEST(test_delimited("0.012 ", double_(0.012345), char_(' ')));
- BOOST_TEST(test_delimited("0.123 ", double_(0.12345), char_(' ')));
- BOOST_TEST(test_delimited("1.234 ", double_(1.2345), char_(' ')));
- BOOST_TEST(test_delimited("12.346 ", double_(12.346), char_(' ')));
- BOOST_TEST(test_delimited("123.46 ", double_(123.46), char_(' ')));
- BOOST_TEST(test_delimited("1234.5 ", double_(1234.5), char_(' ')));
- BOOST_TEST(test_delimited("12342.0 ", double_(12342.), char_(' ')));
- BOOST_TEST(test_delimited("1.234e05 ", double_(123420.), char_(' ')));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- // test NaN and Inf
- BOOST_TEST(test_delimited("nan ", double_,
- std::numeric_limits<double>::quiet_NaN(), char_(' ')));
- BOOST_TEST(test_delimited("-nan ", double_,
- -std::numeric_limits<double>::quiet_NaN(), char_(' ')));
- BOOST_TEST(test_delimited("inf ", double_,
- std::numeric_limits<double>::infinity(), char_(' ')));
- BOOST_TEST(test_delimited("-inf ", double_,
- -std::numeric_limits<double>::infinity(), char_(' ')));
-
- typedef karma::real_generator<double, signed_policy<double> > signed_type;
- signed_type const signed_ = signed_type();
-
- BOOST_TEST(test_delimited("+nan ", signed_,
- std::numeric_limits<double>::quiet_NaN(), char_(' ')));
- BOOST_TEST(test_delimited("-nan ", signed_,
- -std::numeric_limits<double>::quiet_NaN(), char_(' ')));
- BOOST_TEST(test_delimited("+inf ", signed_,
- std::numeric_limits<double>::infinity(), char_(' ')));
- BOOST_TEST(test_delimited("-inf ", signed_,
- -std::numeric_limits<double>::infinity(), char_(' ')));
- BOOST_TEST(test_delimited(" 0.0 ", signed_, 0.0, char_(' ')));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- typedef karma::real_generator<double, scientific_policy<double> >
- science_type;
- science_type const science = science_type();
-
- BOOST_TEST(test("0.0e00", science, 0.0));
- BOOST_TEST(test("1.0e00", science, 1.0));
-
- BOOST_TEST(test("1.234e-05", science, 0.000012345));
- BOOST_TEST(test("1.234e-04", science, 0.00012345));
- BOOST_TEST(test("1.234e-03", science, 0.0012345));
- BOOST_TEST(test("1.234e-02", science, 0.012345));
- BOOST_TEST(test("1.235e-01", science, 0.12345)); // note the rounding error!
- BOOST_TEST(test("1.234e00", science, 1.2345));
- BOOST_TEST(test("1.235e01", science, 12.346));
- BOOST_TEST(test("1.235e02", science, 123.46));
- BOOST_TEST(test("1.234e03", science, 1234.5));
- BOOST_TEST(test("1.234e04", science, 12342.));
- BOOST_TEST(test("1.234e05", science, 123420.));
-
- BOOST_TEST(test("-1.234e-05", science, -0.000012345));
- BOOST_TEST(test("-1.234e-04", science, -0.00012345));
- BOOST_TEST(test("-1.234e-03", science, -0.0012345));
- BOOST_TEST(test("-1.234e-02", science, -0.012345));
- BOOST_TEST(test("-1.235e-01", science, -0.12345)); // note the rounding error!
- BOOST_TEST(test("-1.234e00", science, -1.2345));
- BOOST_TEST(test("-1.235e01", science, -12.346));
- BOOST_TEST(test("-1.235e02", science, -123.46));
- BOOST_TEST(test("-1.234e03", science, -1234.5));
- BOOST_TEST(test("-1.234e04", science, -12342.));
- BOOST_TEST(test("-1.234e05", science, -123420.));
-
- BOOST_TEST(test("1.234E-05", upper[science], 0.000012345));
- BOOST_TEST(test("1.234E-04", upper[science], 0.00012345));
- BOOST_TEST(test("1.234E-03", upper[science], 0.0012345));
- BOOST_TEST(test("1.234E-02", upper[science], 0.012345));
- BOOST_TEST(test("1.235E-01", upper[science], 0.12345)); // note the rounding error!
- BOOST_TEST(test("1.234E00", upper[science], 1.2345));
- BOOST_TEST(test("1.235E01", upper[science], 12.346));
- BOOST_TEST(test("1.235E02", upper[science], 123.46));
- BOOST_TEST(test("1.234E03", upper[science], 1234.5));
- BOOST_TEST(test("1.234E04", upper[science], 12342.));
- BOOST_TEST(test("1.234E05", upper[science], 123420.));
-
- BOOST_TEST(test("-1.234E-05", upper[science], -0.000012345));
- BOOST_TEST(test("-1.234E-04", upper[science], -0.00012345));
- BOOST_TEST(test("-1.234E-03", upper[science], -0.0012345));
- BOOST_TEST(test("-1.234E-02", upper[science], -0.012345));
- BOOST_TEST(test("-1.235E-01", upper[science], -0.12345)); // note the rounding error!
- BOOST_TEST(test("-1.234E00", upper[science], -1.2345));
- BOOST_TEST(test("-1.235E01", upper[science], -12.346));
- BOOST_TEST(test("-1.235E02", upper[science], -123.46));
- BOOST_TEST(test("-1.234E03", upper[science], -1234.5));
- BOOST_TEST(test("-1.234E04", upper[science], -12342.));
- BOOST_TEST(test("-1.234E05", upper[science], -123420.));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- ///////////////////////////////////////////////////////////////////////
- typedef karma::real_generator<double, fixed_policy<double> > fixed_type;
- fixed_type const fixed = fixed_type();
-
- BOOST_TEST(test("0.0", fixed, 0.0));
- BOOST_TEST(test("1.0", fixed, 1.0));
-
- BOOST_TEST(test("0.0", fixed, 0.000012345));
- BOOST_TEST(test("0.0", fixed, 0.00012345));
- BOOST_TEST(test("0.001", fixed, 0.0012345));
- BOOST_TEST(test("0.012", fixed, 0.012345));
- BOOST_TEST(test("0.123", fixed, 0.12345));
- BOOST_TEST(test("1.234", fixed, 1.2345));
- BOOST_TEST(test("12.345", fixed, 12.345));
- BOOST_TEST(test("123.45", fixed, 123.45));
- BOOST_TEST(test("1234.5", fixed, 1234.5));
- BOOST_TEST(test("12342.0", fixed, 12342.));
- BOOST_TEST(test("123420.0", fixed, 123420.));
- BOOST_TEST(test("123420000000000000000.0", fixed, 1.23420e20));
-
- BOOST_TEST(test("0.0", fixed, -0.000012345));
- BOOST_TEST(test("0.0", fixed, -0.00012345));
- BOOST_TEST(test("-0.001", fixed, -0.0012345));
- BOOST_TEST(test("-0.012", fixed, -0.012345));
- BOOST_TEST(test("-0.123", fixed, -0.12345));
- BOOST_TEST(test("-1.234", fixed, -1.2345));
- BOOST_TEST(test("-12.346", fixed, -12.346));
- BOOST_TEST(test("-123.46", fixed, -123.46));
- BOOST_TEST(test("-1234.5", fixed, -1234.5));
- BOOST_TEST(test("-12342.0", fixed, -12342.));
- BOOST_TEST(test("-123420.0", fixed, -123420.));
- BOOST_TEST(test("-123420000000000000000.0", fixed, -1.23420e20));
- }
-
- {
- BOOST_TEST(test("1.0", lit(1.0)));
- BOOST_TEST(test("1.0", lit(1.0f)));
- BOOST_TEST(test("1.0", lit(1.0l)));
-
- BOOST_TEST(test("1.0", double_(1.0), 1.0));
- BOOST_TEST(test("1.0", float_(1.0), 1.0f));
- BOOST_TEST(test("1.0", long_double(1.0), 1.0l));
- BOOST_TEST(!test("", double_(1.0), 2.0));
- BOOST_TEST(!test("", float_(1.0), 2.0f));
- BOOST_TEST(!test("", long_double(1.0), 2.0l));
- }
-
+
     {
         using namespace boost::spirit::ascii;
 
@@ -458,103 +171,7 @@
         BOOST_TEST(test(" 0.0", upper[signed_], 0.0));
     }
 
-// support for using real_concept with a Karma generator has been implemented
-// in Boost versions > 1.36 only, additionally real_concept is available only
-// if BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is not defined
-#if BOOST_VERSION > 103600 && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
- {
- using boost::math::concepts::real_concept;
- typedef karma::real_generator<real_concept> custom_type;
- custom_type const custom = custom_type();
-
- BOOST_TEST(test("0.0", custom, real_concept(0.0)));
- BOOST_TEST(test("1.0", custom, real_concept(1.0)));
- BOOST_TEST(test("1.0", custom, real_concept(1.0001)));
- BOOST_TEST(test("1.001", custom, real_concept(1.001)));
- BOOST_TEST(test("1.01", custom, real_concept(1.010)));
- BOOST_TEST(test("1.1", custom, real_concept(1.100)));
-
- BOOST_TEST(test("1.234e-04", custom, real_concept(0.00012345)));
- BOOST_TEST(test("0.001", custom, real_concept(0.0012345)));
- BOOST_TEST(test("0.012", custom, real_concept(0.012345)));
- BOOST_TEST(test("0.123", custom, real_concept(0.12345)));
- BOOST_TEST(test("1.234", custom, real_concept(1.2345)));
- BOOST_TEST(test("12.346", custom, real_concept(12.346)));
- BOOST_TEST(test("123.46", custom, real_concept(123.46)));
- BOOST_TEST(test("1234.5", custom, real_concept(1234.5)));
- BOOST_TEST(test("12342.0", custom, real_concept(12342.)));
- BOOST_TEST(test("1.234e05", custom, real_concept(123420.)));
-
- BOOST_TEST(test("-1.0", custom, real_concept(-1.0)));
- BOOST_TEST(test("-1.234", custom, real_concept(-1.2345)));
- BOOST_TEST(test("-1.235", custom, real_concept(-1.2346)));
- BOOST_TEST(test("-1234.2", custom, real_concept(-1234.2)));
-
- BOOST_TEST(test("1.0", custom(real_concept(1.0))));
- BOOST_TEST(test("1.0", custom(real_concept(1.0001))));
- BOOST_TEST(test("1.001", custom(real_concept(1.001))));
- BOOST_TEST(test("1.01", custom(real_concept(1.010))));
- BOOST_TEST(test("1.1", custom(real_concept(1.100))));
-
- BOOST_TEST(test("1.234e-04", custom(real_concept(0.00012345))));
- BOOST_TEST(test("0.001", custom(real_concept(0.0012345))));
- BOOST_TEST(test("0.012", custom(real_concept(0.012345))));
- BOOST_TEST(test("0.123", custom(real_concept(0.12345))));
- BOOST_TEST(test("1.234", custom(real_concept(1.2345))));
- BOOST_TEST(test("12.346", custom(real_concept(12.346))));
- BOOST_TEST(test("123.46", custom(real_concept(123.46))));
- BOOST_TEST(test("1234.5", custom(real_concept(1234.5))));
- BOOST_TEST(test("12342.0", custom(real_concept(12342.))));
- BOOST_TEST(test("1.234e05", custom(real_concept(123420.))));
- }
-#endif
-
-// this appears to be broken on Apple Tiger x86 with gcc4.0.1
-#if (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ != 40001) || \
- !defined(__APPLE__)
- {
- ///////////////////////////////////////////////////////////////////////
- typedef karma::real_generator<double, bordercase_policy<double> >
- bordercase_type;
- bordercase_type const bordercase = bordercase_type();
-
-// BOOST_TEST(test("-5.7222349715140557e307",
-// bordercase(-5.7222349715140557e307)));
-
- BOOST_TEST(test("1.7976931348623158e308",
- bordercase(1.7976931348623158e308))); // DBL_MAX
- BOOST_TEST(test("-1.7976931348623158e308",
- bordercase(-1.7976931348623158e308))); // -DBL_MAX
- BOOST_TEST(test("2.2250738585072014e-308",
- bordercase(2.2250738585072014e-308))); // DBL_MIN
- BOOST_TEST(test("-2.2250738585072014e-308",
- bordercase(-2.2250738585072014e-308))); // -DBL_MIN
- }
-#endif
-
- {
- boost::optional<double> v;
- BOOST_TEST(!test("", double_, v));
- BOOST_TEST(!test("", double_(1.0), v));
-
- v = 1.0;
- BOOST_TEST(test("1.0", double_, v));
- BOOST_TEST(test("1.0", double_(1.0), v));
- }
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- { // Phoenix expression tests (requires to include
- // karma_phoenix_attributes.hpp)
- namespace phoenix = boost::phoenix;
-
- BOOST_TEST(test("1.0", double_, phoenix::val(1.0)));
-
- double d = 1.2;
- BOOST_TEST(test("1.2", double_, phoenix::ref(d)));
- BOOST_TEST(test("2.2", double_, ++phoenix::ref(d)));
- }
-#endif
 
     return boost::report_errors();
 }
+

Added: trunk/libs/spirit/test/karma/real_numerics2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/real_numerics2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,164 @@
+// Copyright (c) 2001-2011 Hartmut Kaiser
+// Copyright (c) 2011 Bryce Lelbach
+//
+// Distributed under 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)
+
+//#define KARMA_FAIL_COMPILATION
+
+#include "real_numerics.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+int main()
+{
+ using namespace boost::spirit;
+
+ {
+ using namespace boost::spirit::ascii;
+
+ ///////////////////////////////////////////////////////////////////////
+ BOOST_TEST(test_delimited("0.0 ", double_, 0.0, char_(' ')));
+ BOOST_TEST(test_delimited("1.0 ", double_, 1.0, char_(' ')));
+ BOOST_TEST(test_delimited("1.0 ", double_, 1.0001, char_(' ')));
+ BOOST_TEST(test_delimited("1.001 ", double_, 1.001, char_(' ')));
+ BOOST_TEST(test_delimited("1.01 ", double_, 1.010, char_(' ')));
+ BOOST_TEST(test_delimited("1.1 ", double_, 1.100, char_(' ')));
+
+ BOOST_TEST(test_delimited("1.234e-04 ", double_, 0.00012345, char_(' ')));
+ BOOST_TEST(test_delimited("0.001 ", double_, 0.0012345, char_(' ')));
+ BOOST_TEST(test_delimited("0.012 ", double_, 0.012345, char_(' ')));
+ BOOST_TEST(test_delimited("0.123 ", double_, 0.12345, char_(' ')));
+ BOOST_TEST(test_delimited("1.234 ", double_, 1.2345, char_(' ')));
+ BOOST_TEST(test_delimited("12.346 ", double_, 12.346, char_(' ')));
+ BOOST_TEST(test_delimited("123.46 ", double_, 123.46, char_(' ')));
+ BOOST_TEST(test_delimited("1234.5 ", double_, 1234.5, char_(' ')));
+ BOOST_TEST(test_delimited("12342.0 ", double_, 12342., char_(' ')));
+ BOOST_TEST(test_delimited("1.234e05 ", double_, 123420., char_(' ')));
+
+ BOOST_TEST(test_delimited("-1.0 ", double_, -1.0, char_(' ')));
+ BOOST_TEST(test_delimited("-1.234 ", double_, -1.2345, char_(' ')));
+ BOOST_TEST(test_delimited("-1.235 ", double_, -1.2346, char_(' ')));
+ BOOST_TEST(test_delimited("-1234.2 ", double_, -1234.2, char_(' ')));
+
+ BOOST_TEST(test_delimited("1.0 ", double_(1.0), char_(' ')));
+ BOOST_TEST(test_delimited("1.0 ", double_(1.0001), char_(' ')));
+ BOOST_TEST(test_delimited("1.001 ", double_(1.001), char_(' ')));
+ BOOST_TEST(test_delimited("1.01 ", double_(1.010), char_(' ')));
+ BOOST_TEST(test_delimited("1.1 ", double_(1.100), char_(' ')));
+
+ BOOST_TEST(test_delimited("1.234e-04 ", double_(0.00012345), char_(' ')));
+ BOOST_TEST(test_delimited("0.001 ", double_(0.0012345), char_(' ')));
+ BOOST_TEST(test_delimited("0.012 ", double_(0.012345), char_(' ')));
+ BOOST_TEST(test_delimited("0.123 ", double_(0.12345), char_(' ')));
+ BOOST_TEST(test_delimited("1.234 ", double_(1.2345), char_(' ')));
+ BOOST_TEST(test_delimited("12.346 ", double_(12.346), char_(' ')));
+ BOOST_TEST(test_delimited("123.46 ", double_(123.46), char_(' ')));
+ BOOST_TEST(test_delimited("1234.5 ", double_(1234.5), char_(' ')));
+ BOOST_TEST(test_delimited("12342.0 ", double_(12342.), char_(' ')));
+ BOOST_TEST(test_delimited("1.234e05 ", double_(123420.), char_(' ')));
+ }
+
+ {
+ using namespace boost::spirit::ascii;
+
+ ///////////////////////////////////////////////////////////////////////
+ // test NaN and Inf
+ BOOST_TEST(test_delimited("nan ", double_,
+ std::numeric_limits<double>::quiet_NaN(), char_(' ')));
+ BOOST_TEST(test_delimited("-nan ", double_,
+ -std::numeric_limits<double>::quiet_NaN(), char_(' ')));
+ BOOST_TEST(test_delimited("inf ", double_,
+ std::numeric_limits<double>::infinity(), char_(' ')));
+ BOOST_TEST(test_delimited("-inf ", double_,
+ -std::numeric_limits<double>::infinity(), char_(' ')));
+
+ typedef karma::real_generator<double, signed_policy<double> > signed_type;
+ signed_type const signed_ = signed_type();
+
+ BOOST_TEST(test_delimited("+nan ", signed_,
+ std::numeric_limits<double>::quiet_NaN(), char_(' ')));
+ BOOST_TEST(test_delimited("-nan ", signed_,
+ -std::numeric_limits<double>::quiet_NaN(), char_(' ')));
+ BOOST_TEST(test_delimited("+inf ", signed_,
+ std::numeric_limits<double>::infinity(), char_(' ')));
+ BOOST_TEST(test_delimited("-inf ", signed_,
+ -std::numeric_limits<double>::infinity(), char_(' ')));
+ BOOST_TEST(test_delimited(" 0.0 ", signed_, 0.0, char_(' ')));
+ }
+
+ {
+ using namespace boost::spirit::ascii;
+
+ ///////////////////////////////////////////////////////////////////////
+ typedef karma::real_generator<double, scientific_policy<double> >
+ science_type;
+ science_type const science = science_type();
+
+ BOOST_TEST(test("0.0e00", science, 0.0));
+ BOOST_TEST(test("1.0e00", science, 1.0));
+
+ BOOST_TEST(test("1.234e-05", science, 0.000012345));
+ BOOST_TEST(test("1.234e-04", science, 0.00012345));
+ BOOST_TEST(test("1.234e-03", science, 0.0012345));
+ BOOST_TEST(test("1.234e-02", science, 0.012345));
+ BOOST_TEST(test("1.235e-01", science, 0.12345)); // note the rounding error!
+ BOOST_TEST(test("1.234e00", science, 1.2345));
+ BOOST_TEST(test("1.235e01", science, 12.346));
+ BOOST_TEST(test("1.235e02", science, 123.46));
+ BOOST_TEST(test("1.234e03", science, 1234.5));
+ BOOST_TEST(test("1.234e04", science, 12342.));
+ BOOST_TEST(test("1.234e05", science, 123420.));
+
+ BOOST_TEST(test("-1.234e-05", science, -0.000012345));
+ BOOST_TEST(test("-1.234e-04", science, -0.00012345));
+ BOOST_TEST(test("-1.234e-03", science, -0.0012345));
+ BOOST_TEST(test("-1.234e-02", science, -0.012345));
+ BOOST_TEST(test("-1.235e-01", science, -0.12345)); // note the rounding error!
+ BOOST_TEST(test("-1.234e00", science, -1.2345));
+ BOOST_TEST(test("-1.235e01", science, -12.346));
+ BOOST_TEST(test("-1.235e02", science, -123.46));
+ BOOST_TEST(test("-1.234e03", science, -1234.5));
+ BOOST_TEST(test("-1.234e04", science, -12342.));
+ BOOST_TEST(test("-1.234e05", science, -123420.));
+
+ BOOST_TEST(test("1.234E-05", upper[science], 0.000012345));
+ BOOST_TEST(test("1.234E-04", upper[science], 0.00012345));
+ BOOST_TEST(test("1.234E-03", upper[science], 0.0012345));
+ BOOST_TEST(test("1.234E-02", upper[science], 0.012345));
+ BOOST_TEST(test("1.235E-01", upper[science], 0.12345)); // note the rounding error!
+ BOOST_TEST(test("1.234E00", upper[science], 1.2345));
+ BOOST_TEST(test("1.235E01", upper[science], 12.346));
+ BOOST_TEST(test("1.235E02", upper[science], 123.46));
+ BOOST_TEST(test("1.234E03", upper[science], 1234.5));
+ BOOST_TEST(test("1.234E04", upper[science], 12342.));
+ BOOST_TEST(test("1.234E05", upper[science], 123420.));
+
+ BOOST_TEST(test("-1.234E-05", upper[science], -0.000012345));
+ BOOST_TEST(test("-1.234E-04", upper[science], -0.00012345));
+ BOOST_TEST(test("-1.234E-03", upper[science], -0.0012345));
+ BOOST_TEST(test("-1.234E-02", upper[science], -0.012345));
+ BOOST_TEST(test("-1.235E-01", upper[science], -0.12345)); // note the rounding error!
+ BOOST_TEST(test("-1.234E00", upper[science], -1.2345));
+ BOOST_TEST(test("-1.235E01", upper[science], -12.346));
+ BOOST_TEST(test("-1.235E02", upper[science], -123.46));
+ BOOST_TEST(test("-1.234E03", upper[science], -1234.5));
+ BOOST_TEST(test("-1.234E04", upper[science], -12342.));
+ BOOST_TEST(test("-1.234E05", upper[science], -123420.));
+ }
+
+ {
+ BOOST_TEST(test("1.0", lit(1.0)));
+ BOOST_TEST(test("1.0", lit(1.0f)));
+ BOOST_TEST(test("1.0", lit(1.0l)));
+
+ BOOST_TEST(test("1.0", double_(1.0), 1.0));
+ BOOST_TEST(test("1.0", float_(1.0), 1.0f));
+ BOOST_TEST(test("1.0", long_double(1.0), 1.0l));
+ BOOST_TEST(!test("", double_(1.0), 2.0));
+ BOOST_TEST(!test("", float_(1.0), 2.0f));
+ BOOST_TEST(!test("", long_double(1.0), 2.0l));
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/spirit/test/karma/real_numerics3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/real_numerics3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,154 @@
+// Copyright (c) 2001-2011 Hartmut Kaiser
+// Copyright (c) 2011 Bryce Lelbach
+//
+// Distributed under 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)
+
+//#define KARMA_FAIL_COMPILATION
+
+#include "real_numerics.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+int main()
+{
+ using namespace boost::spirit;
+
+ {
+ using namespace boost::spirit::ascii;
+
+ ///////////////////////////////////////////////////////////////////////
+ typedef karma::real_generator<double, fixed_policy<double> > fixed_type;
+ fixed_type const fixed = fixed_type();
+
+ BOOST_TEST(test("0.0", fixed, 0.0));
+ BOOST_TEST(test("1.0", fixed, 1.0));
+
+ BOOST_TEST(test("0.0", fixed, 0.000012345));
+ BOOST_TEST(test("0.0", fixed, 0.00012345));
+ BOOST_TEST(test("0.001", fixed, 0.0012345));
+ BOOST_TEST(test("0.012", fixed, 0.012345));
+ BOOST_TEST(test("0.123", fixed, 0.12345));
+ BOOST_TEST(test("1.234", fixed, 1.2345));
+ BOOST_TEST(test("12.345", fixed, 12.345));
+ BOOST_TEST(test("123.45", fixed, 123.45));
+ BOOST_TEST(test("1234.5", fixed, 1234.5));
+ BOOST_TEST(test("12342.0", fixed, 12342.));
+ BOOST_TEST(test("123420.0", fixed, 123420.));
+ BOOST_TEST(test("123420000000000000000.0", fixed, 1.23420e20));
+
+ BOOST_TEST(test("0.0", fixed, -0.000012345));
+ BOOST_TEST(test("0.0", fixed, -0.00012345));
+ BOOST_TEST(test("-0.001", fixed, -0.0012345));
+ BOOST_TEST(test("-0.012", fixed, -0.012345));
+ BOOST_TEST(test("-0.123", fixed, -0.12345));
+ BOOST_TEST(test("-1.234", fixed, -1.2345));
+ BOOST_TEST(test("-12.346", fixed, -12.346));
+ BOOST_TEST(test("-123.46", fixed, -123.46));
+ BOOST_TEST(test("-1234.5", fixed, -1234.5));
+ BOOST_TEST(test("-12342.0", fixed, -12342.));
+ BOOST_TEST(test("-123420.0", fixed, -123420.));
+ BOOST_TEST(test("-123420000000000000000.0", fixed, -1.23420e20));
+ }
+
+
+// support for using real_concept with a Karma generator has been implemented
+// in Boost versions > 1.36 only, additionally real_concept is available only
+// if BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is not defined
+#if BOOST_VERSION > 103600 && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
+ {
+ using boost::math::concepts::real_concept;
+ typedef karma::real_generator<real_concept> custom_type;
+ custom_type const custom = custom_type();
+
+ BOOST_TEST(test("0.0", custom, real_concept(0.0)));
+ BOOST_TEST(test("1.0", custom, real_concept(1.0)));
+ BOOST_TEST(test("1.0", custom, real_concept(1.0001)));
+ BOOST_TEST(test("1.001", custom, real_concept(1.001)));
+ BOOST_TEST(test("1.01", custom, real_concept(1.010)));
+ BOOST_TEST(test("1.1", custom, real_concept(1.100)));
+
+ BOOST_TEST(test("1.234e-04", custom, real_concept(0.00012345)));
+ BOOST_TEST(test("0.001", custom, real_concept(0.0012345)));
+ BOOST_TEST(test("0.012", custom, real_concept(0.012345)));
+ BOOST_TEST(test("0.123", custom, real_concept(0.12345)));
+ BOOST_TEST(test("1.234", custom, real_concept(1.2345)));
+ BOOST_TEST(test("12.346", custom, real_concept(12.346)));
+ BOOST_TEST(test("123.46", custom, real_concept(123.46)));
+ BOOST_TEST(test("1234.5", custom, real_concept(1234.5)));
+ BOOST_TEST(test("12342.0", custom, real_concept(12342.)));
+ BOOST_TEST(test("1.234e05", custom, real_concept(123420.)));
+
+ BOOST_TEST(test("-1.0", custom, real_concept(-1.0)));
+ BOOST_TEST(test("-1.234", custom, real_concept(-1.2345)));
+ BOOST_TEST(test("-1.235", custom, real_concept(-1.2346)));
+ BOOST_TEST(test("-1234.2", custom, real_concept(-1234.2)));
+
+ BOOST_TEST(test("1.0", custom(real_concept(1.0))));
+ BOOST_TEST(test("1.0", custom(real_concept(1.0001))));
+ BOOST_TEST(test("1.001", custom(real_concept(1.001))));
+ BOOST_TEST(test("1.01", custom(real_concept(1.010))));
+ BOOST_TEST(test("1.1", custom(real_concept(1.100))));
+
+ BOOST_TEST(test("1.234e-04", custom(real_concept(0.00012345))));
+ BOOST_TEST(test("0.001", custom(real_concept(0.0012345))));
+ BOOST_TEST(test("0.012", custom(real_concept(0.012345))));
+ BOOST_TEST(test("0.123", custom(real_concept(0.12345))));
+ BOOST_TEST(test("1.234", custom(real_concept(1.2345))));
+ BOOST_TEST(test("12.346", custom(real_concept(12.346))));
+ BOOST_TEST(test("123.46", custom(real_concept(123.46))));
+ BOOST_TEST(test("1234.5", custom(real_concept(1234.5))));
+ BOOST_TEST(test("12342.0", custom(real_concept(12342.))));
+ BOOST_TEST(test("1.234e05", custom(real_concept(123420.))));
+ }
+#endif
+
+// this appears to be broken on Apple Tiger x86 with gcc4.0.1
+#if (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ != 40001) || \
+ !defined(__APPLE__)
+ {
+ ///////////////////////////////////////////////////////////////////////
+ typedef karma::real_generator<double, bordercase_policy<double> >
+ bordercase_type;
+ bordercase_type const bordercase = bordercase_type();
+
+// BOOST_TEST(test("-5.7222349715140557e307",
+// bordercase(-5.7222349715140557e307)));
+
+ BOOST_TEST(test("1.7976931348623158e308",
+ bordercase(1.7976931348623158e308))); // DBL_MAX
+ BOOST_TEST(test("-1.7976931348623158e308",
+ bordercase(-1.7976931348623158e308))); // -DBL_MAX
+ BOOST_TEST(test("2.2250738585072014e-308",
+ bordercase(2.2250738585072014e-308))); // DBL_MIN
+ BOOST_TEST(test("-2.2250738585072014e-308",
+ bordercase(-2.2250738585072014e-308))); // -DBL_MIN
+ }
+#endif
+
+ {
+ boost::optional<double> v;
+ BOOST_TEST(!test("", double_, v));
+ BOOST_TEST(!test("", double_(1.0), v));
+
+ v = 1.0;
+ BOOST_TEST(test("1.0", double_, v));
+ BOOST_TEST(test("1.0", double_(1.0), v));
+ }
+
+// we support Phoenix attributes only starting with V2.2
+#if SPIRIT_VERSION >= 0x2020
+ { // Phoenix expression tests (requires to include
+ // karma_phoenix_attributes.hpp)
+ namespace phoenix = boost::phoenix;
+
+ BOOST_TEST(test("1.0", double_, phoenix::val(1.0)));
+
+ double d = 1.2;
+ BOOST_TEST(test("1.2", double_, phoenix::ref(d)));
+ BOOST_TEST(test("2.2", double_, ++phoenix::ref(d)));
+ }
+#endif
+
+ return boost::report_errors();
+}
+

Deleted: trunk/libs/spirit/test/karma/real_scientific.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/real_scientific.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,40 +0,0 @@
-// Copyright (c) 2010 Lars Kielhorn
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/karma.hpp>
-
-#include <iostream>
-#include <string>
-#include <iterator>
-
-namespace karma = boost::spirit::karma;
-
-// define a new real number formatting policy
-template <typename Num>
-struct scientific_policy : karma::real_policies<Num>
-{
- // we want the numbers always to be in scientific format
- static int floatfield(Num n) { return std::ios_base::scientific; }
-};
-
-int main()
-{
- // define a new generator type based on the new policy
- typedef karma::real_generator<double, scientific_policy<double> >
- science_type;
- science_type const scientific = science_type();
-
- std::string output;
- typedef std::back_insert_iterator<std::string> output_iterator;
- output_iterator sink(output);
-
- // should output: 1.0e-01, but will output: 10.0e-02
- BOOST_TEST(karma::generate(sink, scientific, 0.1) && output == "1.0e-01");
-
- return boost::report_errors();
-};

Deleted: trunk/libs/spirit/test/karma/repeat.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/repeat.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,240 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/assign/std/vector.hpp>
-
-#include <boost/spirit/include/karma_operator.hpp>
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_string.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_operator.hpp>
-#include <boost/spirit/include/karma_action.hpp>
-#include <boost/spirit/include/karma_nonterminal.hpp>
-#include <boost/spirit/include/karma_auxiliary.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_phoenix_attributes.hpp>
-#include <boost/spirit/include/support_argument.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-#include <boost/fusion/include/std_pair.hpp>
-
-#include <string>
-#include <iostream>
-#include <vector>
-
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-struct action
-{
- action (std::vector<char>& vec)
- : vec(vec), it(vec.begin())
- {}
-
- void operator()(unsigned& value, boost::spirit::unused_type, bool& pass) const
- {
- pass = (it != vec.end());
- if (pass)
- value = *it++;
- }
-
- std::vector<char>& vec;
- mutable std::vector<char>::iterator it;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-int main()
-{
- using namespace boost::spirit::ascii;
- using boost::spirit::karma::repeat;
- using boost::spirit::karma::inf;
- using boost::spirit::karma::int_;
- using boost::spirit::karma::hex;
- using boost::spirit::karma::_1;
-
- {
- std::string str8("aaaaaaaa");
- BOOST_TEST(test("aaaaaaaa", repeat[char_], str8)); // kleene synonym
- BOOST_TEST(test("aaaaaaaa", repeat(8)[char_], str8));
- BOOST_TEST(test("aaa", repeat(3)[char_], str8));
- BOOST_TEST(!test("aaaaaaaa", repeat(9)[char_], str8));
-
- std::string str3("aaa");
- BOOST_TEST(test("aaaaa", repeat(3, 5)[char_], str8));
- BOOST_TEST(test("aaa", repeat(3, 5)[char_], str3));
- BOOST_TEST(!test("aaa", repeat(4, 5)[char_], str3));
-
- BOOST_TEST(test("aaa", repeat(3, inf)[char_], str3));
- BOOST_TEST(test("aaaaaaaa", repeat(3, inf)[char_], str8));
- BOOST_TEST(!test("aaa", repeat(4, inf)[char_], str3));
- }
-
- {
- std::string str8("aaaaaaaa");
- BOOST_TEST(test_delimited("a a a a a a a a ", repeat[char_], str8, space));
- BOOST_TEST(test_delimited("a a a a a a a a ", repeat(8)[char_], str8, space));
- BOOST_TEST(test_delimited("a a a ", repeat(3)[char_], str8, space));
- BOOST_TEST(!test_delimited("a a a a a a a a ", repeat(9)[char_], str8, space));
-
- std::string str3("aaa");
- BOOST_TEST(test_delimited("a a a a a ", repeat(3, 5)[char_], str8, space));
- BOOST_TEST(test_delimited("a a a ", repeat(3, 5)[char_], str3, space));
- BOOST_TEST(!test_delimited("a a a ", repeat(4, 5)[char_], str3, space));
-
- BOOST_TEST(test_delimited("a a a ", repeat(3, inf)[char_], str3, space));
- BOOST_TEST(test_delimited("a a a a a a a a ", repeat(3, inf)[char_], str8, space));
- BOOST_TEST(!test_delimited("a a a ", repeat(4, inf)[char_], str3, space));
- }
-
- { // lazy repeats
- using boost::phoenix::val;
-
- std::string str8("aaaaaaaa");
- BOOST_TEST(test("aaaaaaaa", repeat[char_], str8)); // kleene synonym
- BOOST_TEST(test("aaaaaaaa", repeat(val(8))[char_], str8));
- BOOST_TEST(test("aaa", repeat(val(3))[char_], str8));
- BOOST_TEST(!test("aaaaaaaa", repeat(val(9))[char_], str8));
-
- std::string str3("aaa");
- BOOST_TEST(test("aaaaa", repeat(val(3), val(5))[char_], str8));
- BOOST_TEST(test("aaa", repeat(val(3), val(5))[char_], str3));
- BOOST_TEST(!test("aaa", repeat(val(4), val(5))[char_], str3));
-
- BOOST_TEST(test("aaa", repeat(val(3), val(inf))[char_], str3));
- BOOST_TEST(test("aaaaaaaa", repeat(val(3), val(inf))[char_], str8));
- BOOST_TEST(!test("aaa", repeat(val(4), val(inf))[char_], str3));
- }
-
- {
- std::string str("aBcdeFGH");
- BOOST_TEST(test("abcdefgh", lower[repeat(8)[char_]], str));
- BOOST_TEST(test_delimited("A B C D E F G H ", upper[repeat(8)[char_]], str, space));
- }
-
- { // actions
- namespace phx = boost::phoenix;
-
- std::vector<char> v;
- v.push_back('a');
- v.push_back('a');
- v.push_back('a');
- v.push_back('a');
- BOOST_TEST(test("aaaa", repeat(4)[char_][_1 = phx::ref(v)]));
- }
-
- { // more actions
- namespace phx = boost::phoenix;
-
- std::vector<int> v;
- v.push_back(123);
- v.push_back(456);
- v.push_back(789);
- BOOST_TEST(test_delimited("123 456 789 ", repeat(3)[int_][_1 = phx::ref(v)], space));
- }
-
- // failing sub-generators
- {
- using boost::spirit::karma::strict;
- using boost::spirit::karma::relaxed;
-
- using namespace boost::assign;
- namespace karma = boost::spirit::karma;
-
- typedef std::pair<char, char> data;
- std::vector<data> v2, v3;
- v2 += std::make_pair('a', 'a'),
- std::make_pair('b', 'b'),
- std::make_pair('c', 'c'),
- std::make_pair('d', 'd'),
- std::make_pair('e', 'e'),
- std::make_pair('f', 'f'),
- std::make_pair('g', 'g');
- v3 += std::make_pair('a', 'a'),
- std::make_pair('b', 'b'),
- std::make_pair('c', 'c'),
- std::make_pair('d', 'd');
-
- karma::rule<spirit_test::output_iterator<char>::type, data()> r;
-
- r = &char_('d') << char_;
- BOOST_TEST(test("d", repeat[r], v2));
- BOOST_TEST(test("d", relaxed[repeat[r]], v2));
- BOOST_TEST(test("", strict[repeat[r]], v2));
-
- r = !char_('d') << char_;
- BOOST_TEST(test("abcefg", repeat(6)[r], v2));
- BOOST_TEST(!test("", repeat(5)[r], v2));
- BOOST_TEST(test("abcefg", relaxed[repeat(6)[r]], v2));
- BOOST_TEST(!test("", relaxed[repeat(5)[r]], v2));
- BOOST_TEST(!test("", strict[repeat(6)[r]], v2));
- BOOST_TEST(!test("", strict[repeat(5)[r]], v2));
-
- r = !char_('c') << char_;
- BOOST_TEST(test("abd", repeat(3)[r], v2));
- BOOST_TEST(test("abd", relaxed[repeat(3)[r]], v2));
- BOOST_TEST(!test("", strict[repeat(3)[r]], v2));
-
- r = !char_('a') << char_;
- BOOST_TEST(test("bcdef", repeat(3, 5)[r], v2));
- BOOST_TEST(test("bcd", repeat(3, 5)[r], v3));
- BOOST_TEST(!test("", repeat(4, 5)[r], v3));
- BOOST_TEST(test("bcdef", relaxed[repeat(3, 5)[r]], v2));
- BOOST_TEST(test("bcd", relaxed[repeat(3, 5)[r]], v3));
- BOOST_TEST(!test("", relaxed[repeat(4, 5)[r]], v3));
- BOOST_TEST(!test("", strict[repeat(3, 5)[r]], v2));
- BOOST_TEST(!test("", strict[repeat(3, 5)[r]], v3));
- BOOST_TEST(!test("", strict[repeat(4, 5)[r]], v3));
-
- BOOST_TEST(test("bcd", repeat(3, inf)[r], v3));
- BOOST_TEST(test("bcdefg", repeat(3, inf)[r], v2));
- BOOST_TEST(!test("", repeat(4, inf)[r], v3));
-
- r = !char_('g') << char_;
- BOOST_TEST(test("abcde", repeat(3, 5)[r], v2));
- BOOST_TEST(test("abcd", repeat(3, 5)[r], v3));
- BOOST_TEST(!test("", repeat(4, 5)[r], v3));
- BOOST_TEST(test("abcde", relaxed[repeat(3, 5)[r]], v2));
- BOOST_TEST(test("abcd", relaxed[repeat(3, 5)[r]], v3));
- BOOST_TEST(!test("", relaxed[repeat(4, 5)[r]], v3));
- BOOST_TEST(test("abcde", strict[repeat(3, 5)[r]], v2));
- BOOST_TEST(test("abcd", strict[repeat(3, 5)[r]], v3));
- BOOST_TEST(!test("", strict[repeat(5)[r]], v3));
- }
-
- {
- // make sure user defined end condition is applied if no attribute
- // is passed in
- using namespace boost::assign;
-
- std::vector<char> v;
- v += 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h';
- BOOST_TEST(test("[6162636465666768]",
- '[' << repeat[hex[action(v)]] << ']'));
- }
-
-// we support Phoenix attributes only starting with V2.2
-#if SPIRIT_VERSION >= 0x2020
- {
- namespace ascii = boost::spirit::ascii;
- namespace phoenix = boost::phoenix;
-
- char c = 'a';
- BOOST_TEST(test("bcd", repeat(3)[ascii::char_[_1 = ++phoenix::ref(c)]]));
-
- c = 'a';
- BOOST_TEST(test("bcd", repeat(3)[ascii::char_], ++phoenix::ref(c)));
- }
-#endif
-
- return boost::report_errors();
-}
-

Copied: trunk/libs/spirit/test/karma/repeat1.cpp (from r67483, /trunk/libs/spirit/test/karma/repeat.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/repeat.cpp (original)
+++ trunk/libs/spirit/test/karma/repeat1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -60,6 +60,26 @@
     using boost::spirit::karma::int_;
     using boost::spirit::karma::hex;
     using boost::spirit::karma::_1;
+
+ { // lazy repeats
+ using boost::phoenix::val;
+
+ std::string str8("aaaaaaaa");
+ BOOST_TEST(test("aaaaaaaa", repeat[char_], str8)); // kleene synonym
+ BOOST_TEST(test("aaaaaaaa", repeat(val(8))[char_], str8));
+ BOOST_TEST(test("aaa", repeat(val(3))[char_], str8));
+ BOOST_TEST(!test("aaaaaaaa", repeat(val(9))[char_], str8));
+
+ std::string str3("aaa");
+ BOOST_TEST(test("aaaaa", repeat(val(3), val(5))[char_], str8));
+ BOOST_TEST(test("aaa", repeat(val(3), val(5))[char_], str3));
+ BOOST_TEST(!test("aaa", repeat(val(4), val(5))[char_], str3));
+
+ BOOST_TEST(test("aaa", repeat(val(3), val(inf))[char_], str3));
+ BOOST_TEST(test("aaaaaaaa", repeat(val(3), val(inf))[char_], str8));
+ BOOST_TEST(!test("aaa", repeat(val(4), val(inf))[char_], str3));
+ }
+
 
     {
         std::string str8("aaaaaaaa");
@@ -95,121 +115,6 @@
         BOOST_TEST(!test_delimited("a a a ", repeat(4, inf)[char_], str3, space));
     }
 
- { // lazy repeats
- using boost::phoenix::val;
-
- std::string str8("aaaaaaaa");
- BOOST_TEST(test("aaaaaaaa", repeat[char_], str8)); // kleene synonym
- BOOST_TEST(test("aaaaaaaa", repeat(val(8))[char_], str8));
- BOOST_TEST(test("aaa", repeat(val(3))[char_], str8));
- BOOST_TEST(!test("aaaaaaaa", repeat(val(9))[char_], str8));
-
- std::string str3("aaa");
- BOOST_TEST(test("aaaaa", repeat(val(3), val(5))[char_], str8));
- BOOST_TEST(test("aaa", repeat(val(3), val(5))[char_], str3));
- BOOST_TEST(!test("aaa", repeat(val(4), val(5))[char_], str3));
-
- BOOST_TEST(test("aaa", repeat(val(3), val(inf))[char_], str3));
- BOOST_TEST(test("aaaaaaaa", repeat(val(3), val(inf))[char_], str8));
- BOOST_TEST(!test("aaa", repeat(val(4), val(inf))[char_], str3));
- }
-
- {
- std::string str("aBcdeFGH");
- BOOST_TEST(test("abcdefgh", lower[repeat(8)[char_]], str));
- BOOST_TEST(test_delimited("A B C D E F G H ", upper[repeat(8)[char_]], str, space));
- }
-
- { // actions
- namespace phx = boost::phoenix;
-
- std::vector<char> v;
- v.push_back('a');
- v.push_back('a');
- v.push_back('a');
- v.push_back('a');
- BOOST_TEST(test("aaaa", repeat(4)[char_][_1 = phx::ref(v)]));
- }
-
- { // more actions
- namespace phx = boost::phoenix;
-
- std::vector<int> v;
- v.push_back(123);
- v.push_back(456);
- v.push_back(789);
- BOOST_TEST(test_delimited("123 456 789 ", repeat(3)[int_][_1 = phx::ref(v)], space));
- }
-
- // failing sub-generators
- {
- using boost::spirit::karma::strict;
- using boost::spirit::karma::relaxed;
-
- using namespace boost::assign;
- namespace karma = boost::spirit::karma;
-
- typedef std::pair<char, char> data;
- std::vector<data> v2, v3;
- v2 += std::make_pair('a', 'a'),
- std::make_pair('b', 'b'),
- std::make_pair('c', 'c'),
- std::make_pair('d', 'd'),
- std::make_pair('e', 'e'),
- std::make_pair('f', 'f'),
- std::make_pair('g', 'g');
- v3 += std::make_pair('a', 'a'),
- std::make_pair('b', 'b'),
- std::make_pair('c', 'c'),
- std::make_pair('d', 'd');
-
- karma::rule<spirit_test::output_iterator<char>::type, data()> r;
-
- r = &char_('d') << char_;
- BOOST_TEST(test("d", repeat[r], v2));
- BOOST_TEST(test("d", relaxed[repeat[r]], v2));
- BOOST_TEST(test("", strict[repeat[r]], v2));
-
- r = !char_('d') << char_;
- BOOST_TEST(test("abcefg", repeat(6)[r], v2));
- BOOST_TEST(!test("", repeat(5)[r], v2));
- BOOST_TEST(test("abcefg", relaxed[repeat(6)[r]], v2));
- BOOST_TEST(!test("", relaxed[repeat(5)[r]], v2));
- BOOST_TEST(!test("", strict[repeat(6)[r]], v2));
- BOOST_TEST(!test("", strict[repeat(5)[r]], v2));
-
- r = !char_('c') << char_;
- BOOST_TEST(test("abd", repeat(3)[r], v2));
- BOOST_TEST(test("abd", relaxed[repeat(3)[r]], v2));
- BOOST_TEST(!test("", strict[repeat(3)[r]], v2));
-
- r = !char_('a') << char_;
- BOOST_TEST(test("bcdef", repeat(3, 5)[r], v2));
- BOOST_TEST(test("bcd", repeat(3, 5)[r], v3));
- BOOST_TEST(!test("", repeat(4, 5)[r], v3));
- BOOST_TEST(test("bcdef", relaxed[repeat(3, 5)[r]], v2));
- BOOST_TEST(test("bcd", relaxed[repeat(3, 5)[r]], v3));
- BOOST_TEST(!test("", relaxed[repeat(4, 5)[r]], v3));
- BOOST_TEST(!test("", strict[repeat(3, 5)[r]], v2));
- BOOST_TEST(!test("", strict[repeat(3, 5)[r]], v3));
- BOOST_TEST(!test("", strict[repeat(4, 5)[r]], v3));
-
- BOOST_TEST(test("bcd", repeat(3, inf)[r], v3));
- BOOST_TEST(test("bcdefg", repeat(3, inf)[r], v2));
- BOOST_TEST(!test("", repeat(4, inf)[r], v3));
-
- r = !char_('g') << char_;
- BOOST_TEST(test("abcde", repeat(3, 5)[r], v2));
- BOOST_TEST(test("abcd", repeat(3, 5)[r], v3));
- BOOST_TEST(!test("", repeat(4, 5)[r], v3));
- BOOST_TEST(test("abcde", relaxed[repeat(3, 5)[r]], v2));
- BOOST_TEST(test("abcd", relaxed[repeat(3, 5)[r]], v3));
- BOOST_TEST(!test("", relaxed[repeat(4, 5)[r]], v3));
- BOOST_TEST(test("abcde", strict[repeat(3, 5)[r]], v2));
- BOOST_TEST(test("abcd", strict[repeat(3, 5)[r]], v3));
- BOOST_TEST(!test("", strict[repeat(5)[r]], v3));
- }
-
     {
         // make sure user defined end condition is applied if no attribute
         // is passed in

Added: trunk/libs/spirit/test/karma/repeat2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/repeat2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,144 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/assign/std/vector.hpp>
+
+#include <boost/spirit/include/karma_operator.hpp>
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_numeric.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_operator.hpp>
+#include <boost/spirit/include/karma_action.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
+#include <boost/spirit/include/karma_auxiliary.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_phoenix_attributes.hpp>
+#include <boost/spirit/include/support_argument.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+#include <boost/fusion/include/std_pair.hpp>
+
+#include <string>
+#include <iostream>
+#include <vector>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int main()
+{
+ using namespace boost::spirit::ascii;
+ using boost::spirit::karma::repeat;
+ using boost::spirit::karma::inf;
+ using boost::spirit::karma::int_;
+ using boost::spirit::karma::hex;
+ using boost::spirit::karma::_1;
+
+ {
+ std::string str("aBcdeFGH");
+ BOOST_TEST(test("abcdefgh", lower[repeat(8)[char_]], str));
+ BOOST_TEST(test_delimited("A B C D E F G H ", upper[repeat(8)[char_]], str, space));
+ }
+
+ { // actions
+ namespace phx = boost::phoenix;
+
+ std::vector<char> v;
+ v.push_back('a');
+ v.push_back('a');
+ v.push_back('a');
+ v.push_back('a');
+ BOOST_TEST(test("aaaa", repeat(4)[char_][_1 = phx::ref(v)]));
+ }
+
+ { // more actions
+ namespace phx = boost::phoenix;
+
+ std::vector<int> v;
+ v.push_back(123);
+ v.push_back(456);
+ v.push_back(789);
+ BOOST_TEST(test_delimited("123 456 789 ", repeat(3)[int_][_1 = phx::ref(v)], space));
+ }
+
+ // failing sub-generators
+ {
+ using boost::spirit::karma::strict;
+ using boost::spirit::karma::relaxed;
+
+ using namespace boost::assign;
+ namespace karma = boost::spirit::karma;
+
+ typedef std::pair<char, char> data;
+ std::vector<data> v2, v3;
+ v2 += std::make_pair('a', 'a'),
+ std::make_pair('b', 'b'),
+ std::make_pair('c', 'c'),
+ std::make_pair('d', 'd'),
+ std::make_pair('e', 'e'),
+ std::make_pair('f', 'f'),
+ std::make_pair('g', 'g');
+ v3 += std::make_pair('a', 'a'),
+ std::make_pair('b', 'b'),
+ std::make_pair('c', 'c'),
+ std::make_pair('d', 'd');
+
+ karma::rule<spirit_test::output_iterator<char>::type, data()> r;
+
+ r = &char_('d') << char_;
+ BOOST_TEST(test("d", repeat[r], v2));
+ BOOST_TEST(test("d", relaxed[repeat[r]], v2));
+ BOOST_TEST(test("", strict[repeat[r]], v2));
+
+ r = !char_('d') << char_;
+ BOOST_TEST(test("abcefg", repeat(6)[r], v2));
+ BOOST_TEST(!test("", repeat(5)[r], v2));
+ BOOST_TEST(test("abcefg", relaxed[repeat(6)[r]], v2));
+ BOOST_TEST(!test("", relaxed[repeat(5)[r]], v2));
+ BOOST_TEST(!test("", strict[repeat(6)[r]], v2));
+ BOOST_TEST(!test("", strict[repeat(5)[r]], v2));
+
+ r = !char_('c') << char_;
+ BOOST_TEST(test("abd", repeat(3)[r], v2));
+ BOOST_TEST(test("abd", relaxed[repeat(3)[r]], v2));
+ BOOST_TEST(!test("", strict[repeat(3)[r]], v2));
+
+ r = !char_('a') << char_;
+ BOOST_TEST(test("bcdef", repeat(3, 5)[r], v2));
+ BOOST_TEST(test("bcd", repeat(3, 5)[r], v3));
+ BOOST_TEST(!test("", repeat(4, 5)[r], v3));
+ BOOST_TEST(test("bcdef", relaxed[repeat(3, 5)[r]], v2));
+ BOOST_TEST(test("bcd", relaxed[repeat(3, 5)[r]], v3));
+ BOOST_TEST(!test("", relaxed[repeat(4, 5)[r]], v3));
+ BOOST_TEST(!test("", strict[repeat(3, 5)[r]], v2));
+ BOOST_TEST(!test("", strict[repeat(3, 5)[r]], v3));
+ BOOST_TEST(!test("", strict[repeat(4, 5)[r]], v3));
+
+ BOOST_TEST(test("bcd", repeat(3, inf)[r], v3));
+ BOOST_TEST(test("bcdefg", repeat(3, inf)[r], v2));
+ BOOST_TEST(!test("", repeat(4, inf)[r], v3));
+
+ r = !char_('g') << char_;
+ BOOST_TEST(test("abcde", repeat(3, 5)[r], v2));
+ BOOST_TEST(test("abcd", repeat(3, 5)[r], v3));
+ BOOST_TEST(!test("", repeat(4, 5)[r], v3));
+ BOOST_TEST(test("abcde", relaxed[repeat(3, 5)[r]], v2));
+ BOOST_TEST(test("abcd", relaxed[repeat(3, 5)[r]], v3));
+ BOOST_TEST(!test("", relaxed[repeat(4, 5)[r]], v3));
+ BOOST_TEST(test("abcde", strict[repeat(3, 5)[r]], v2));
+ BOOST_TEST(test("abcd", strict[repeat(3, 5)[r]], v3));
+ BOOST_TEST(!test("", strict[repeat(5)[r]], v3));
+ }
+
+ return boost::report_errors();
+}
+

Deleted: trunk/libs/spirit/test/karma/semantic_action_attribute.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/semantic_action_attribute.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,35 +0,0 @@
-// Copyright (c) 2010 Michael Caisse
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <string>
-#include <vector>
-#include <boost/spirit/include/karma.hpp>
-#include <boost/spirit/include/phoenix.hpp>
-
-#include "test.hpp"
-
-using namespace spirit_test;
-
-namespace karma = boost::spirit::karma;
-namespace phx = boost::phoenix;
-
-int main()
-{
- using karma::int_;
- using karma::_1;
-
- BOOST_TEST(test("16909060", int_[ _1 = phx::val(0x01020304) ]));
-
- // make sure the passed attribute type does not enforce the attribute type
- // for the semantic action
- unsigned char char_value = 8;
- BOOST_TEST(test("16909060", int_[ _1 = phx::val(0x01020304) ], char_value));
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/karma/sequence.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/sequence.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,289 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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)
-
-// #define KARMA_TEST_COMPILE_FAIL
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_string.hpp>
-#include <boost/spirit/include/karma_numeric.hpp>
-#include <boost/spirit/include/karma_generate.hpp>
-#include <boost/spirit/include/karma_operator.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_action.hpp>
-#include <boost/spirit/include/karma_nonterminal.hpp>
-#include <boost/spirit/include/karma_auxiliary.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/support_unused.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-#include <boost/spirit/include/phoenix_stl.hpp>
-#include <boost/fusion/include/vector.hpp>
-
-#include "test.hpp"
-
-using namespace spirit_test;
-
-///////////////////////////////////////////////////////////////////////////////
-// lazy version of fusion::size
-struct seqsize_impl
-{
- template <typename Sequence>
- struct result
- : boost::fusion::result_of::size<Sequence>
- {};
-
- template <typename Sequence>
- typename result<Sequence>::type
- operator()(Sequence const& seq) const
- {
- return boost::fusion::size(seq);
- }
-};
-
-boost::phoenix::function<seqsize_impl> const seqsize = seqsize_impl();
-
-///////////////////////////////////////////////////////////////////////////////
-int main()
-{
- using namespace boost::spirit;
- using namespace boost::spirit::ascii;
- namespace fusion = boost::fusion;
-
- {
- {
- BOOST_TEST(test("xi", char_('x') << char_('i')));
- BOOST_TEST(!test("xi", char_('x') << char_('o')));
- }
-
- {
- BOOST_TEST(test_delimited("x i ", char_('x') << 'i', char(' ')));
- BOOST_TEST(!test_delimited("x i ",
- char_('x') << char_('o'), char(' ')));
- }
-
- {
- BOOST_TEST(test_delimited("Hello , World ",
- lit("Hello") << ',' << "World", char(' ')));
- }
-
- {
- // a single element
- char attr = 'a';
- BOOST_TEST((test("ab", char_ << 'b', attr)));
- }
-
- {
- // a single element fusion sequence
- fusion::vector<char> attr('a');
- BOOST_TEST((test("ab", char_ << 'b', attr)));
- }
-
- {
- fusion::vector<char, char, std::string> p ('a', 'b', "cdefg");
- BOOST_TEST(test("abcdefg", char_ << char_ << string, p));
- BOOST_TEST(test_delimited("a b cdefg ",
- char_ << char_ << string, p, char(' ')));
- }
-
- {
- fusion::vector<char, int, char> p ('a', 12, 'c');
- BOOST_TEST(test("a12c", char_ << int_ << char_, p));
- BOOST_TEST(test_delimited("a 12 c ",
- char_ << int_ << char_, p, char(' ')));
- }
-
- {
- // element sequence can be shorter and longer than the attribute
- // sequence
- using boost::spirit::karma::strict;
- using boost::spirit::karma::relaxed;
-
- fusion::vector<char, int, char> p ('a', 12, 'c');
- BOOST_TEST(test("a12", char_ << int_, p));
- BOOST_TEST(test_delimited("a 12 ", char_ << int_, p, char(' ')));
-
- BOOST_TEST(test("a12", relaxed[char_ << int_], p));
- BOOST_TEST(test_delimited("a 12 ", relaxed[char_ << int_], p, char(' ')));
-
- BOOST_TEST(!test("", strict[char_ << int_], p));
- BOOST_TEST(!test_delimited("", strict[char_ << int_], p, char(' ')));
-
- fusion::vector<char, int> p1 ('a', 12);
- BOOST_TEST(test("a12c", char_ << int_ << char_('c'), p1));
- BOOST_TEST(test_delimited("a 12 c ", char_ << int_ << char_('c'),
- p1, char(' ')));
-
- BOOST_TEST(test("a12c", relaxed[char_ << int_ << char_('c')], p1));
- BOOST_TEST(test_delimited("a 12 c ",
- relaxed[char_ << int_ << char_('c')], p1, char(' ')));
-
- BOOST_TEST(!test("", strict[char_ << int_ << char_('c')], p1));
- BOOST_TEST(!test_delimited("", strict[char_ << int_ << char_('c')],
- p1, char(' ')));
-
- BOOST_TEST(test("a12", strict[char_ << int_], p1));
- BOOST_TEST(test_delimited("a 12 ", strict[char_ << int_], p1, char(' ')));
-
- std::string value("foo ' bar");
- BOOST_TEST(test("\"foo ' bar\"", '"' << strict[*(~char_('*'))] << '"', value));
- BOOST_TEST(test("\"foo ' bar\"", strict['"' << *(~char_('*')) << '"'], value));
- }
-
- {
- // if all elements of a sequence have unused parameters, the whole
- // sequence has an unused parameter as well
- fusion::vector<char, char> p ('a', 'e');
- BOOST_TEST(test("abcde",
- char_ << (lit('b') << 'c' << 'd') << char_, p));
- BOOST_TEST(test_delimited("a b c d e ",
- char_ << (lit('b') << 'c' << 'd') << char_, p, char(' ')));
- }
-
- {
- // literal generators do not need an attribute
- fusion::vector<char, char> p('a', 'c');
- BOOST_TEST(test("abc", char_ << 'b' << char_, p));
- BOOST_TEST(test_delimited("a b c ",
- char_ << 'b' << char_, p, char(' ')));
- }
-
- {
- // literal generators do not need an attribute, not even at the end
- fusion::vector<char, char> p('a', 'c');
- BOOST_TEST(test("acb", char_ << char_ << 'b', p));
- BOOST_TEST(test_delimited("a c b ",
- char_ << char_ << 'b', p, char(' ')));
- }
-
- {
- std::list<int> v;
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- BOOST_TEST(test("123", int_ << int_ << int_, v));
-// BOOST_TEST(test_delimited("1 2 3 ", int_ << int_ << int_, v, ' '));
-// BOOST_TEST(test("1,2,3", int_ << ',' << int_ << ',' << int_, v));
-// BOOST_TEST(test_delimited("1 , 2 , 3 ",
-// int_ << ',' << int_ << ',' << int_, v, ' '));
- }
-
- {
- BOOST_TEST(test("aa", lower[char_('A') << 'a']));
- BOOST_TEST(test_delimited("BEGIN END ",
- upper[lit("begin") << "end"], char(' ')));
- BOOST_TEST(!test_delimited("BEGIN END ",
- upper[lit("begin") << "nend"], char(' ')));
-
- BOOST_TEST(test("Aa ", left_align[char_('A') << 'a']));
- BOOST_TEST(test(" Aa ", center[char_('A') << 'a']));
- BOOST_TEST(test(" Aa", right_align[char_('A') << 'a']));
- }
-
- {
- // make sure single element tuples get passed through if the rhs
- // has a single element tuple as its attribute
- typedef spirit_test::output_iterator<char>::type iterator_type;
- fusion::vector<double, int> fv(2.0, 1);
- karma::rule<iterator_type, fusion::vector<double, int>()> r;
- r %= double_ << ',' << int_;
- BOOST_TEST(test("test:2.0,1", "test:" << r, fv));
- }
-
- // action tests
- {
- using namespace boost::phoenix;
-
- BOOST_TEST(test("abcdefg",
- (char_ << char_ << string)[_1 = 'a', _2 = 'b', _3 = "cdefg"]));
- BOOST_TEST(test_delimited("a b cdefg ",
- (char_ << char_ << string)[_1 = 'a', _2 = 'b', _3 = "cdefg"],
- char(' ')));
-
- BOOST_TEST(test_delimited("a 12 c ",
- (char_ << lit(12) << char_)[_1 = 'a', _2 = 'c'], char(' ')));
-
- char c = 'c';
- BOOST_TEST(test("abc",
- (char_[_1 = 'a'] << 'b' << char_)[_1 = 'x', _2 = ref(c)]));
- BOOST_TEST(test_delimited("a b c ",
- (char_[_1 = 'a'] << 'b' << char_)[_2 = ref(c)], char(' ')));
-
- BOOST_TEST(test("aa", lower[char_ << 'A'][_1 = 'A']));
- BOOST_TEST(test("AA", upper[char_ << 'a'][_1 = 'a']));
-
- BOOST_TEST(test("Aa ", left_align[char_ << 'a'][_1 = 'A']));
- BOOST_TEST(test(" Aa ", center[char_ << 'a'][_1 = 'A']));
- BOOST_TEST(test(" Aa", right_align[char_ << 'a'][_1 = 'A']));
- }
- }
-
- // test special case where sequence has a one element vector attribute
- // sequence and this element is a rule (attribute has to be passed through
- // without change)
- {
- typedef spirit_test::output_iterator<char>::type outiter_type;
- namespace karma = boost::spirit::karma;
-
- karma::rule<outiter_type, std::vector<int>()> r = -(int_ % ',');
- std::vector<int> v;
- BOOST_TEST(test(">", '>' << r, v));
-
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- v.push_back(4);
- BOOST_TEST(test(">1,2,3,4", '>' << r, v));
- }
-
- {
- namespace karma = boost::spirit::karma;
- typedef spirit_test::output_iterator<char>::type outiter_type;
-
- karma::rule<outiter_type, std::string()> e = karma::string;
- karma::rule<outiter_type, std::vector<std::string>()> l = e << *(',' << e);
-
- std::vector<std::string> v;
- v.push_back("abc1");
- v.push_back("abc2");
- v.push_back("abc3");
- BOOST_TEST(test("abc1,abc2,abc3", l, v));
- }
-
- {
- namespace karma = boost::spirit::karma;
- namespace phoenix = boost::phoenix;
-
- typedef spirit_test::output_iterator<char>::type outiter_type;
- typedef fusion::vector<char, char, char> vector_type;
-
- vector_type p ('a', 'b', 'c');
- BOOST_TEST(test("ab", char_ << char_, p));
-
- karma::rule<outiter_type, vector_type()> r;
- r %= char_ << char_ << &karma::eps[seqsize(_val) == 3];
- BOOST_TEST(!test("", r, p));
-
- r %= char_ << char_ << char_ << &karma::eps[seqsize(_val) == 3];
- BOOST_TEST(test("abc", r, p));
- }
-
- {
- std::list<int> v;
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- v.push_back(4);
-
- BOOST_TEST(test("1234", repeat(2)[int_] << *int_, v));
- BOOST_TEST(test_delimited("1 2 3 4 ", repeat(2)[int_] << *int_, v, char(' ')));
- }
-
- return boost::report_errors();
-}
-

Copied: trunk/libs/spirit/test/karma/sequence1.cpp (from r67483, /trunk/libs/spirit/test/karma/sequence.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/sequence.cpp (original)
+++ trunk/libs/spirit/test/karma/sequence1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -30,259 +30,117 @@
 using namespace spirit_test;
 
 ///////////////////////////////////////////////////////////////////////////////
-// lazy version of fusion::size
-struct seqsize_impl
+int main()
 {
- template <typename Sequence>
- struct result
- : boost::fusion::result_of::size<Sequence>
- {};
+ using namespace boost::spirit;
+ using namespace boost::spirit::ascii;
+ namespace fusion = boost::fusion;
 
- template <typename Sequence>
- typename result<Sequence>::type
- operator()(Sequence const& seq) const
     {
- return boost::fusion::size(seq);
+ BOOST_TEST(test("xi", char_('x') << char_('i')));
+ BOOST_TEST(!test("xi", char_('x') << char_('o')));
     }
-};
 
-boost::phoenix::function<seqsize_impl> const seqsize = seqsize_impl();
+ {
+ BOOST_TEST(test_delimited("x i ", char_('x') << 'i', char(' ')));
+ BOOST_TEST(!test_delimited("x i ",
+ char_('x') << char_('o'), char(' ')));
+ }
 
-///////////////////////////////////////////////////////////////////////////////
-int main()
-{
- using namespace boost::spirit;
- using namespace boost::spirit::ascii;
- namespace fusion = boost::fusion;
+ {
+ BOOST_TEST(test_delimited("Hello , World ",
+ lit("Hello") << ',' << "World", char(' ')));
+ }
+
+ {
+ // a single element
+ char attr = 'a';
+ BOOST_TEST((test("ab", char_ << 'b', attr)));
+ }
+
+ {
+ // a single element fusion sequence
+ fusion::vector<char> attr('a');
+ BOOST_TEST((test("ab", char_ << 'b', attr)));
+ }
+
+ {
+ fusion::vector<char, char, std::string> p ('a', 'b', "cdefg");
+ BOOST_TEST(test("abcdefg", char_ << char_ << string, p));
+ BOOST_TEST(test_delimited("a b cdefg ",
+ char_ << char_ << string, p, char(' ')));
+ }
+
+ {
+ fusion::vector<char, int, char> p ('a', 12, 'c');
+ BOOST_TEST(test("a12c", char_ << int_ << char_, p));
+ BOOST_TEST(test_delimited("a 12 c ",
+ char_ << int_ << char_, p, char(' ')));
+ }
 
     {
- {
- BOOST_TEST(test("xi", char_('x') << char_('i')));
- BOOST_TEST(!test("xi", char_('x') << char_('o')));
- }
-
- {
- BOOST_TEST(test_delimited("x i ", char_('x') << 'i', char(' ')));
- BOOST_TEST(!test_delimited("x i ",
- char_('x') << char_('o'), char(' ')));
- }
-
- {
- BOOST_TEST(test_delimited("Hello , World ",
- lit("Hello") << ',' << "World", char(' ')));
- }
-
- {
- // a single element
- char attr = 'a';
- BOOST_TEST((test("ab", char_ << 'b', attr)));
- }
-
- {
- // a single element fusion sequence
- fusion::vector<char> attr('a');
- BOOST_TEST((test("ab", char_ << 'b', attr)));
- }
-
- {
- fusion::vector<char, char, std::string> p ('a', 'b', "cdefg");
- BOOST_TEST(test("abcdefg", char_ << char_ << string, p));
- BOOST_TEST(test_delimited("a b cdefg ",
- char_ << char_ << string, p, char(' ')));
- }
-
- {
- fusion::vector<char, int, char> p ('a', 12, 'c');
- BOOST_TEST(test("a12c", char_ << int_ << char_, p));
- BOOST_TEST(test_delimited("a 12 c ",
- char_ << int_ << char_, p, char(' ')));
- }
-
- {
- // element sequence can be shorter and longer than the attribute
- // sequence
- using boost::spirit::karma::strict;
- using boost::spirit::karma::relaxed;
-
- fusion::vector<char, int, char> p ('a', 12, 'c');
- BOOST_TEST(test("a12", char_ << int_, p));
- BOOST_TEST(test_delimited("a 12 ", char_ << int_, p, char(' ')));
-
- BOOST_TEST(test("a12", relaxed[char_ << int_], p));
- BOOST_TEST(test_delimited("a 12 ", relaxed[char_ << int_], p, char(' ')));
-
- BOOST_TEST(!test("", strict[char_ << int_], p));
- BOOST_TEST(!test_delimited("", strict[char_ << int_], p, char(' ')));
-
- fusion::vector<char, int> p1 ('a', 12);
- BOOST_TEST(test("a12c", char_ << int_ << char_('c'), p1));
- BOOST_TEST(test_delimited("a 12 c ", char_ << int_ << char_('c'),
- p1, char(' ')));
-
- BOOST_TEST(test("a12c", relaxed[char_ << int_ << char_('c')], p1));
- BOOST_TEST(test_delimited("a 12 c ",
- relaxed[char_ << int_ << char_('c')], p1, char(' ')));
-
- BOOST_TEST(!test("", strict[char_ << int_ << char_('c')], p1));
- BOOST_TEST(!test_delimited("", strict[char_ << int_ << char_('c')],
- p1, char(' ')));
-
- BOOST_TEST(test("a12", strict[char_ << int_], p1));
- BOOST_TEST(test_delimited("a 12 ", strict[char_ << int_], p1, char(' ')));
-
- std::string value("foo ' bar");
- BOOST_TEST(test("\"foo ' bar\"", '"' << strict[*(~char_('*'))] << '"', value));
- BOOST_TEST(test("\"foo ' bar\"", strict['"' << *(~char_('*')) << '"'], value));
- }
-
- {
- // if all elements of a sequence have unused parameters, the whole
- // sequence has an unused parameter as well
- fusion::vector<char, char> p ('a', 'e');
- BOOST_TEST(test("abcde",
- char_ << (lit('b') << 'c' << 'd') << char_, p));
- BOOST_TEST(test_delimited("a b c d e ",
- char_ << (lit('b') << 'c' << 'd') << char_, p, char(' ')));
- }
-
- {
- // literal generators do not need an attribute
- fusion::vector<char, char> p('a', 'c');
- BOOST_TEST(test("abc", char_ << 'b' << char_, p));
- BOOST_TEST(test_delimited("a b c ",
- char_ << 'b' << char_, p, char(' ')));
- }
-
- {
- // literal generators do not need an attribute, not even at the end
- fusion::vector<char, char> p('a', 'c');
- BOOST_TEST(test("acb", char_ << char_ << 'b', p));
- BOOST_TEST(test_delimited("a c b ",
- char_ << char_ << 'b', p, char(' ')));
- }
-
- {
- std::list<int> v;
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- BOOST_TEST(test("123", int_ << int_ << int_, v));
-// BOOST_TEST(test_delimited("1 2 3 ", int_ << int_ << int_, v, ' '));
-// BOOST_TEST(test("1,2,3", int_ << ',' << int_ << ',' << int_, v));
-// BOOST_TEST(test_delimited("1 , 2 , 3 ",
-// int_ << ',' << int_ << ',' << int_, v, ' '));
- }
-
- {
- BOOST_TEST(test("aa", lower[char_('A') << 'a']));
- BOOST_TEST(test_delimited("BEGIN END ",
- upper[lit("begin") << "end"], char(' ')));
- BOOST_TEST(!test_delimited("BEGIN END ",
- upper[lit("begin") << "nend"], char(' ')));
-
- BOOST_TEST(test("Aa ", left_align[char_('A') << 'a']));
- BOOST_TEST(test(" Aa ", center[char_('A') << 'a']));
- BOOST_TEST(test(" Aa", right_align[char_('A') << 'a']));
- }
-
- {
- // make sure single element tuples get passed through if the rhs
- // has a single element tuple as its attribute
- typedef spirit_test::output_iterator<char>::type iterator_type;
- fusion::vector<double, int> fv(2.0, 1);
- karma::rule<iterator_type, fusion::vector<double, int>()> r;
- r %= double_ << ',' << int_;
- BOOST_TEST(test("test:2.0,1", "test:" << r, fv));
- }
-
- // action tests
- {
- using namespace boost::phoenix;
-
- BOOST_TEST(test("abcdefg",
- (char_ << char_ << string)[_1 = 'a', _2 = 'b', _3 = "cdefg"]));
- BOOST_TEST(test_delimited("a b cdefg ",
- (char_ << char_ << string)[_1 = 'a', _2 = 'b', _3 = "cdefg"],
- char(' ')));
-
- BOOST_TEST(test_delimited("a 12 c ",
- (char_ << lit(12) << char_)[_1 = 'a', _2 = 'c'], char(' ')));
-
- char c = 'c';
- BOOST_TEST(test("abc",
- (char_[_1 = 'a'] << 'b' << char_)[_1 = 'x', _2 = ref(c)]));
- BOOST_TEST(test_delimited("a b c ",
- (char_[_1 = 'a'] << 'b' << char_)[_2 = ref(c)], char(' ')));
-
- BOOST_TEST(test("aa", lower[char_ << 'A'][_1 = 'A']));
- BOOST_TEST(test("AA", upper[char_ << 'a'][_1 = 'a']));
-
- BOOST_TEST(test("Aa ", left_align[char_ << 'a'][_1 = 'A']));
- BOOST_TEST(test(" Aa ", center[char_ << 'a'][_1 = 'A']));
- BOOST_TEST(test(" Aa", right_align[char_ << 'a'][_1 = 'A']));
- }
- }
-
- // test special case where sequence has a one element vector attribute
- // sequence and this element is a rule (attribute has to be passed through
- // without change)
- {
- typedef spirit_test::output_iterator<char>::type outiter_type;
- namespace karma = boost::spirit::karma;
-
- karma::rule<outiter_type, std::vector<int>()> r = -(int_ % ',');
- std::vector<int> v;
- BOOST_TEST(test(">", '>' << r, v));
-
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- v.push_back(4);
- BOOST_TEST(test(">1,2,3,4", '>' << r, v));
- }
-
- {
- namespace karma = boost::spirit::karma;
- typedef spirit_test::output_iterator<char>::type outiter_type;
-
- karma::rule<outiter_type, std::string()> e = karma::string;
- karma::rule<outiter_type, std::vector<std::string>()> l = e << *(',' << e);
-
- std::vector<std::string> v;
- v.push_back("abc1");
- v.push_back("abc2");
- v.push_back("abc3");
- BOOST_TEST(test("abc1,abc2,abc3", l, v));
- }
-
- {
- namespace karma = boost::spirit::karma;
- namespace phoenix = boost::phoenix;
-
- typedef spirit_test::output_iterator<char>::type outiter_type;
- typedef fusion::vector<char, char, char> vector_type;
-
- vector_type p ('a', 'b', 'c');
- BOOST_TEST(test("ab", char_ << char_, p));
-
- karma::rule<outiter_type, vector_type()> r;
- r %= char_ << char_ << &karma::eps[seqsize(_val) == 3];
- BOOST_TEST(!test("", r, p));
-
- r %= char_ << char_ << char_ << &karma::eps[seqsize(_val) == 3];
- BOOST_TEST(test("abc", r, p));
- }
-
- {
- std::list<int> v;
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- v.push_back(4);
+ // element sequence can be shorter and longer than the attribute
+ // sequence
+ using boost::spirit::karma::strict;
+ using boost::spirit::karma::relaxed;
+
+ fusion::vector<char, int, char> p ('a', 12, 'c');
+ BOOST_TEST(test("a12", char_ << int_, p));
+ BOOST_TEST(test_delimited("a 12 ", char_ << int_, p, char(' ')));
+
+ BOOST_TEST(test("a12", relaxed[char_ << int_], p));
+ BOOST_TEST(test_delimited("a 12 ", relaxed[char_ << int_], p, char(' ')));
+
+ BOOST_TEST(!test("", strict[char_ << int_], p));
+ BOOST_TEST(!test_delimited("", strict[char_ << int_], p, char(' ')));
+
+ fusion::vector<char, int> p1 ('a', 12);
+ BOOST_TEST(test("a12c", char_ << int_ << char_('c'), p1));
+ BOOST_TEST(test_delimited("a 12 c ", char_ << int_ << char_('c'),
+ p1, char(' ')));
+
+ BOOST_TEST(test("a12c", relaxed[char_ << int_ << char_('c')], p1));
+ BOOST_TEST(test_delimited("a 12 c ",
+ relaxed[char_ << int_ << char_('c')], p1, char(' ')));
+
+ BOOST_TEST(!test("", strict[char_ << int_ << char_('c')], p1));
+ BOOST_TEST(!test_delimited("", strict[char_ << int_ << char_('c')],
+ p1, char(' ')));
 
- BOOST_TEST(test("1234", repeat(2)[int_] << *int_, v));
- BOOST_TEST(test_delimited("1 2 3 4 ", repeat(2)[int_] << *int_, v, char(' ')));
+ BOOST_TEST(test("a12", strict[char_ << int_], p1));
+ BOOST_TEST(test_delimited("a 12 ", strict[char_ << int_], p1, char(' ')));
+
+ std::string value("foo ' bar");
+ BOOST_TEST(test("\"foo ' bar\"", '"' << strict[*(~char_('*'))] << '"', value));
+ BOOST_TEST(test("\"foo ' bar\"", strict['"' << *(~char_('*')) << '"'], value));
+ }
+
+ {
+ // if all elements of a sequence have unused parameters, the whole
+ // sequence has an unused parameter as well
+ fusion::vector<char, char> p ('a', 'e');
+ BOOST_TEST(test("abcde",
+ char_ << (lit('b') << 'c' << 'd') << char_, p));
+ BOOST_TEST(test_delimited("a b c d e ",
+ char_ << (lit('b') << 'c' << 'd') << char_, p, char(' ')));
+ }
+
+ {
+ // literal generators do not need an attribute
+ fusion::vector<char, char> p('a', 'c');
+ BOOST_TEST(test("abc", char_ << 'b' << char_, p));
+ BOOST_TEST(test_delimited("a b c ",
+ char_ << 'b' << char_, p, char(' ')));
     }
+
+ {
+ // literal generators do not need an attribute, not even at the end
+ fusion::vector<char, char> p('a', 'c');
+ BOOST_TEST(test("acb", char_ << char_ << 'b', p));
+ BOOST_TEST(test_delimited("a c b ",
+ char_ << char_ << 'b', p, char(' ')));
+ }
+
 
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/karma/sequence2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/sequence2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,182 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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)
+
+// #define KARMA_TEST_COMPILE_FAIL
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_numeric.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_operator.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_action.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
+#include <boost/spirit/include/karma_auxiliary.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/support_unused.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+#include <boost/spirit/include/phoenix_stl.hpp>
+#include <boost/fusion/include/vector.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+// lazy version of fusion::size
+struct seqsize_impl
+{
+ template <typename Sequence>
+ struct result
+ : boost::fusion::result_of::size<Sequence>
+ {};
+
+ template <typename Sequence>
+ typename result<Sequence>::type
+ operator()(Sequence const& seq) const
+ {
+ return boost::fusion::size(seq);
+ }
+};
+
+boost::phoenix::function<seqsize_impl> const seqsize = seqsize_impl();
+
+///////////////////////////////////////////////////////////////////////////////
+int main()
+{
+ using namespace boost::spirit;
+ using namespace boost::spirit::ascii;
+ namespace fusion = boost::fusion;
+
+
+ {
+ std::list<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ v.push_back(3);
+ BOOST_TEST(test("123", int_ << int_ << int_, v));
+ BOOST_TEST(test_delimited("1 2 3 ", int_ << int_ << int_, v, ' '));
+ BOOST_TEST(test("1,2,3", int_ << ',' << int_ << ',' << int_, v));
+ BOOST_TEST(test_delimited("1 , 2 , 3 ", int_ << ',' << int_ << ',' << int_, v, ' '));
+ }
+
+ {
+ BOOST_TEST(test("aa", lower[char_('A') << 'a']));
+ BOOST_TEST(test_delimited("BEGIN END ",
+ upper[lit("begin") << "end"], char(' ')));
+ BOOST_TEST(!test_delimited("BEGIN END ",
+ upper[lit("begin") << "nend"], char(' ')));
+
+ BOOST_TEST(test("Aa ", left_align[char_('A') << 'a']));
+ BOOST_TEST(test(" Aa ", center[char_('A') << 'a']));
+ BOOST_TEST(test(" Aa", right_align[char_('A') << 'a']));
+ }
+
+ {
+ // make sure single element tuples get passed through if the rhs
+ // has a single element tuple as its attribute
+ typedef spirit_test::output_iterator<char>::type iterator_type;
+ fusion::vector<double, int> fv(2.0, 1);
+ karma::rule<iterator_type, fusion::vector<double, int>()> r;
+ r %= double_ << ',' << int_;
+ BOOST_TEST(test("test:2.0,1", "test:" << r, fv));
+ }
+
+ // action tests
+ {
+ using namespace boost::phoenix;
+
+ BOOST_TEST(test("abcdefg",
+ (char_ << char_ << string)[_1 = 'a', _2 = 'b', _3 = "cdefg"]));
+ BOOST_TEST(test_delimited("a b cdefg ",
+ (char_ << char_ << string)[_1 = 'a', _2 = 'b', _3 = "cdefg"],
+ char(' ')));
+
+ BOOST_TEST(test_delimited("a 12 c ",
+ (char_ << lit(12) << char_)[_1 = 'a', _2 = 'c'], char(' ')));
+
+ char c = 'c';
+ BOOST_TEST(test("abc",
+ (char_[_1 = 'a'] << 'b' << char_)[_1 = 'x', _2 = ref(c)]));
+ BOOST_TEST(test_delimited("a b c ",
+ (char_[_1 = 'a'] << 'b' << char_)[_2 = ref(c)], char(' ')));
+
+ BOOST_TEST(test("aa", lower[char_ << 'A'][_1 = 'A']));
+ BOOST_TEST(test("AA", upper[char_ << 'a'][_1 = 'a']));
+
+ BOOST_TEST(test("Aa ", left_align[char_ << 'a'][_1 = 'A']));
+ BOOST_TEST(test(" Aa ", center[char_ << 'a'][_1 = 'A']));
+ BOOST_TEST(test(" Aa", right_align[char_ << 'a'][_1 = 'A']));
+ }
+
+ // test special case where sequence has a one element vector attribute
+ // sequence and this element is a rule (attribute has to be passed through
+ // without change)
+ {
+ typedef spirit_test::output_iterator<char>::type outiter_type;
+ namespace karma = boost::spirit::karma;
+
+ karma::rule<outiter_type, std::vector<int>()> r = -(int_ % ',');
+ std::vector<int> v;
+ BOOST_TEST(test(">", '>' << r, v));
+
+ v.push_back(1);
+ v.push_back(2);
+ v.push_back(3);
+ v.push_back(4);
+ BOOST_TEST(test(">1,2,3,4", '>' << r, v));
+ }
+
+ {
+ namespace karma = boost::spirit::karma;
+ typedef spirit_test::output_iterator<char>::type outiter_type;
+
+ karma::rule<outiter_type, std::string()> e = karma::string;
+ karma::rule<outiter_type, std::vector<std::string>()> l = e << *(',' << e);
+
+ std::vector<std::string> v;
+ v.push_back("abc1");
+ v.push_back("abc2");
+ v.push_back("abc3");
+ BOOST_TEST(test("abc1,abc2,abc3", l, v));
+ }
+
+ {
+ namespace karma = boost::spirit::karma;
+ namespace phoenix = boost::phoenix;
+
+ typedef spirit_test::output_iterator<char>::type outiter_type;
+ typedef fusion::vector<char, char, char> vector_type;
+
+ vector_type p ('a', 'b', 'c');
+ BOOST_TEST(test("ab", char_ << char_, p));
+
+ karma::rule<outiter_type, vector_type()> r;
+ r %= char_ << char_ << &karma::eps[seqsize(_val) == 3];
+ BOOST_TEST(!test("", r, p));
+
+ r %= char_ << char_ << char_ << &karma::eps[seqsize(_val) == 3];
+ BOOST_TEST(test("abc", r, p));
+ }
+
+ {
+ std::list<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ v.push_back(3);
+ v.push_back(4);
+
+ BOOST_TEST(test("1234", repeat(2)[int_] << *int_, v));
+ BOOST_TEST(test_delimited("1 2 3 4 ", repeat(2)[int_] << *int_, v, char(' ')));
+ }
+
+ return boost::report_errors();
+}
+

Modified: trunk/libs/spirit/test/karma/stream.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/stream.cpp (original)
+++ trunk/libs/spirit/test/karma/stream.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -3,6 +3,9 @@
 // Distributed under 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 <stdint.h>
+#include <cwchar>
+#include <streambuf>
 #include <iostream>
 
 #include <boost/config/warning_disable.hpp>
@@ -51,13 +54,6 @@
         BOOST_TEST(test("1", stream, 1));
         BOOST_TEST(test("1.1", stream, 1.1));
         BOOST_TEST(test("{1.2,2.4}", stream, complex(1.2, 2.4)));
-
- BOOST_TEST(test(L"x", wstream, L'x'));
- BOOST_TEST(test(L"xyz", wstream, L"xyz"));
- BOOST_TEST(test(L"xyz", wstream, std::basic_string<wchar_t>(L"xyz")));
- BOOST_TEST(test(L"1", wstream, 1));
- BOOST_TEST(test(L"1.1", wstream, 1.1));
- BOOST_TEST(test(L"{1.2,2.4}", wstream, complex(1.2, 2.4)));
     }
 
     {
@@ -67,13 +63,6 @@
         BOOST_TEST(test("1", stream(1)));
         BOOST_TEST(test("1.1", stream(1.1)));
         BOOST_TEST(test("{1.2,2.4}", stream(complex(1.2, 2.4))));
-
- BOOST_TEST(test(L"x", wstream(L'x')));
- BOOST_TEST(test(L"xyz", wstream(L"xyz")));
- BOOST_TEST(test(L"xyz", wstream(std::basic_string<wchar_t>(L"xyz"))));
- BOOST_TEST(test(L"1", wstream(1)));
- BOOST_TEST(test(L"1.1", wstream(1.1)));
- BOOST_TEST(test(L"{1.2,2.4}", wstream(complex(1.2, 2.4))));
     }
 
     {
@@ -85,13 +74,6 @@
         BOOST_TEST(test("X", upper[stream], 'x'));
         BOOST_TEST(test("XYZ", upper[stream], "xyz"));
         BOOST_TEST(test("XYZ", upper[stream], std::string("xyz")));
-
- BOOST_TEST(test(L"x", lower[wstream], L'X'));
- BOOST_TEST(test(L"xyz", lower[wstream], L"XYZ"));
- BOOST_TEST(test(L"xyz", lower[wstream], std::basic_string<wchar_t>(L"XYZ")));
- BOOST_TEST(test(L"X", upper[wstream], L'x'));
- BOOST_TEST(test(L"XYZ", upper[wstream], L"xyz"));
- BOOST_TEST(test(L"XYZ", upper[wstream], std::basic_string<wchar_t>(L"xyz")));
     }
 
     {
@@ -101,13 +83,6 @@
         BOOST_TEST(test_delimited("1 ", stream, 1, ' '));
         BOOST_TEST(test_delimited("1.1 ", stream, 1.1, ' '));
         BOOST_TEST(test_delimited("{1.2,2.4} ", stream, complex(1.2, 2.4), ' '));
-
- BOOST_TEST(test_delimited(L"x ", wstream, L'x', L' '));
- BOOST_TEST(test_delimited(L"xyz ", wstream, L"xyz", L' '));
- BOOST_TEST(test_delimited(L"xyz ", wstream, std::basic_string<wchar_t>(L"xyz"), L' '));
- BOOST_TEST(test_delimited(L"1 ", wstream, 1, ' '));
- BOOST_TEST(test_delimited(L"1.1 ", wstream, 1.1, ' '));
- BOOST_TEST(test_delimited(L"{1.2,2.4} ", wstream, complex(1.2, 2.4), ' '));
     }
 
     {
@@ -138,13 +113,6 @@
         BOOST_TEST(test_delimited("X ", upper[stream], 'x', ' '));
         BOOST_TEST(test_delimited("XYZ ", upper[stream], "xyz", ' '));
         BOOST_TEST(test_delimited("XYZ ", upper[stream], std::string("xyz"), ' '));
-
- BOOST_TEST(test_delimited(L"x ", lower[wstream], L'X', L' '));
- BOOST_TEST(test_delimited(L"xyz ", lower[wstream], L"XYZ", L' '));
- BOOST_TEST(test_delimited(L"xyz ", lower[wstream], std::basic_string<wchar_t>(L"XYZ"), L' '));
- BOOST_TEST(test_delimited(L"X ", upper[wstream], L'x', L' '));
- BOOST_TEST(test_delimited(L"XYZ ", upper[wstream], L"xyz", ' '));
- BOOST_TEST(test_delimited(L"XYZ ", upper[wstream], std::basic_string<wchar_t>(L"xyz"), L' '));
     }
 
     { // lazy streams
@@ -153,10 +121,6 @@
         std::basic_string<char> s("abc");
         BOOST_TEST((test("abc", stream(phx::val(s)))));
         BOOST_TEST((test("abc", stream(phx::ref(s)))));
-
- std::basic_string<wchar_t> ws(L"abc");
- BOOST_TEST((test(L"abc", wstream(phx::val(ws)))));
- BOOST_TEST((test(L"abc", wstream(phx::ref(ws)))));
     }
 
     {

Deleted: trunk/libs/spirit/test/karma/symbols.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/symbols.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,314 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/karma_auxiliary.hpp>
-#include <boost/spirit/include/karma_char.hpp>
-#include <boost/spirit/include/karma_string.hpp>
-#include <boost/spirit/include/karma_operator.hpp>
-#include <boost/spirit/include/karma_directive.hpp>
-#include <boost/spirit/include/karma_generate.hpp>
-#include <boost/spirit/include/karma_nonterminal.hpp>
-
-#include "test.hpp"
-
-namespace fusion = boost::fusion;
-
-template <typename T>
-inline std::vector<T>
-make_vector(T const& t1, T const& t2)
-{
- std::vector<T> v;
- v.push_back(t1);
- v.push_back(t2);
- return v;
-}
-
-int main()
-{
- using spirit_test::test;
- using boost::spirit::karma::symbols;
-
- { // basics
- symbols<char, std::string> sym;
-
- sym.add
- ('j', "Joel")
- ('h', "Hartmut")
- ('t', "Tom")
- ('k', "Kim")
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, std::string> >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("Joel", sym, 'j')));
- BOOST_TEST((test("Hartmut", sym, 'h')));
- BOOST_TEST((test("Tom", sym, 't')));
- BOOST_TEST((test("Kim", sym, 'k')));
- BOOST_TEST((!test("", sym, 'x')));
-
- // test copy
- symbols<char, std::string> sym2;
- sym2 = sym;
- BOOST_TEST((test("Joel", sym2, 'j')));
- BOOST_TEST((test("Hartmut", sym2, 'h')));
- BOOST_TEST((test("Tom", sym2, 't')));
- BOOST_TEST((test("Kim", sym2, 'k')));
- BOOST_TEST((!test("", sym2, 'x')));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Joelyo", sym << "yo", 'j')));
-
- sym.remove
- ('j')
- ('h')
- ;
-
- BOOST_TEST((!test("", sym, 'j')));
- BOOST_TEST((!test("", sym, 'h')));
- }
-
- { // advanced
- using boost::spirit::karma::rule;
- using boost::spirit::karma::lit;
-
- typedef spirit_test::output_iterator<char>::type output_iterator_type;
-
- symbols<char, rule<output_iterator_type> > sym;
-
- rule<output_iterator_type> r1 = lit("Joel");
- rule<output_iterator_type> r2 = lit("Hartmut");
- rule<output_iterator_type> r3 = lit("Tom");
- rule<output_iterator_type> r4 = lit("Kim");
-
- sym.add
- ('j', r1.alias())
- ('h', r2.alias())
- ('t', r3.alias())
- ('k', r4.alias())
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, rule<output_iterator_type> > >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("Joel", sym, 'j')));
- BOOST_TEST((test("Hartmut", sym, 'h')));
- BOOST_TEST((test("Tom", sym, 't')));
- BOOST_TEST((test("Kim", sym, 'k')));
- BOOST_TEST((!test("", sym, 'x')));
-
- // test copy
- symbols<char, rule<output_iterator_type> > sym2;
- sym2 = sym;
- BOOST_TEST((test("Joel", sym2, 'j')));
- BOOST_TEST((test("Hartmut", sym2, 'h')));
- BOOST_TEST((test("Tom", sym2, 't')));
- BOOST_TEST((test("Kim", sym2, 'k')));
- BOOST_TEST((!test("", sym2, 'x')));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Joelyo", sym << "yo", 'j')));
-
- sym.remove
- ('j')
- ('h')
- ;
-
- BOOST_TEST((!test("", sym, 'j')));
- BOOST_TEST((!test("", sym, 'h')));
- }
-
- { // more advanced
- using boost::spirit::karma::rule;
- using boost::spirit::karma::lit;
- using boost::spirit::karma::string;
-
- typedef spirit_test::output_iterator<char>::type output_iterator_type;
-
- symbols<char, rule<output_iterator_type, std::string()> > sym;
- rule<output_iterator_type, std::string()> r1 = string;
-
- sym.add
- ('j', r1.alias())
- ('h', r1.alias())
- ('t', r1.alias())
- ('k', r1.alias())
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, std::string> >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("Joel", sym, fusion::make_vector('j', "Joel"))));
- BOOST_TEST((test("Hartmut", sym, fusion::make_vector('h', "Hartmut"))));
- BOOST_TEST((test("Tom", sym, fusion::make_vector('t', "Tom"))));
- BOOST_TEST((test("Kim", sym, fusion::make_vector('k', "Kim"))));
- BOOST_TEST((!test("", sym, 'x')));
-
- // test copy
- symbols<char, rule<output_iterator_type, std::string()> > sym2;
- sym2 = sym;
- BOOST_TEST((test("Joel", sym2, fusion::make_vector('j', "Joel"))));
- BOOST_TEST((test("Hartmut", sym2, fusion::make_vector('h', "Hartmut"))));
- BOOST_TEST((test("Tom", sym2, fusion::make_vector('t', "Tom"))));
- BOOST_TEST((test("Kim", sym2, fusion::make_vector('k', "Kim"))));
- BOOST_TEST((!test("", sym2, 'x')));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Joelyo", sym << "yo", fusion::make_vector('j', "Joel"))));
-
- sym.remove
- ('j')
- ('h')
- ;
-
- BOOST_TEST((!test("", sym, 'j')));
- BOOST_TEST((!test("", sym, 'h')));
- }
-
- { // more advanced
- using boost::spirit::karma::rule;
- using boost::spirit::karma::lit;
- using boost::spirit::karma::char_;
-
- typedef spirit_test::output_iterator<char>::type output_iterator_type;
-
- symbols<char, rule<output_iterator_type, char()> > sym;
- rule<output_iterator_type, char()> r1 = char_;
-
- sym.add
- ('j', r1.alias())
- ('h', r1.alias())
- ('t', r1.alias())
- ('k', r1.alias())
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, rule<output_iterator_type, char()> > >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("J", sym, make_vector('j', 'J'))));
- BOOST_TEST((test("H", sym, make_vector('h', 'H'))));
- BOOST_TEST((test("T", sym, make_vector('t', 'T'))));
- BOOST_TEST((test("K", sym, make_vector('k', 'K'))));
- BOOST_TEST((!test("", sym, 'x')));
-
- // test copy
- symbols<char, rule<output_iterator_type, char()> > sym2;
- sym2 = sym;
- BOOST_TEST((test("J", sym2, make_vector('j', 'J'))));
- BOOST_TEST((test("H", sym2, make_vector('h', 'H'))));
- BOOST_TEST((test("T", sym2, make_vector('t', 'T'))));
- BOOST_TEST((test("K", sym2, make_vector('k', 'K'))));
- BOOST_TEST((!test("", sym2, 'x')));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Jyo", sym << "yo", make_vector('j', 'J'))));
-
- sym.remove
- ('j')
- ('h')
- ;
-
- BOOST_TEST((!test("", sym, 'j')));
- BOOST_TEST((!test("", sym, 'h')));
- }
-
- { // basics
- symbols<std::string> sym;
-
- sym.add
- ("Joel")
- ("Hartmut")
- ("Tom")
- ("Kim")
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, std::string> >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("Joel", sym, "Joel")));
- BOOST_TEST((test("Hartmut", sym, "Hartmut")));
- BOOST_TEST((test("Tom", sym, "Tom")));
- BOOST_TEST((test("Kim", sym, "Kim")));
- BOOST_TEST((!test("", sym, "X")));
-
- // test copy
- symbols<std::string> sym2;
- sym2 = sym;
- BOOST_TEST((test("Joel", sym2, "Joel")));
- BOOST_TEST((test("Hartmut", sym2, "Hartmut")));
- BOOST_TEST((test("Tom", sym2, "Tom")));
- BOOST_TEST((test("Kim", sym2, "Kim")));
- BOOST_TEST((!test("", sym2, "X")));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Joelyo", sym << "yo", "Joel")));
-
- sym.remove
- ("Joel")
- ("Hartmut")
- ;
-
- BOOST_TEST((!test("", sym, "Joel")));
- BOOST_TEST((!test("", sym, "Hartmut")));
- }
-
- { // lower/upper handling
- using namespace boost::spirit::ascii;
- using boost::spirit::karma::lower;
- using boost::spirit::karma::upper;
-
- symbols<char, std::string> sym;
- sym.add
- ('j', "Joel")
- ('h', "Hartmut")
- ('t', "Tom")
- ('k', "Kim")
- ;
-
- BOOST_TEST((test("joel", lower[sym], 'j')));
- BOOST_TEST((test("hartmut", lower[sym], 'h')));
- BOOST_TEST((test("tom", lower[sym], 't')));
- BOOST_TEST((test("kim", lower[sym], 'k')));
-
- BOOST_TEST((test("JOEL", upper[sym], 'j')));
- BOOST_TEST((test("HARTMUT", upper[sym], 'h')));
- BOOST_TEST((test("TOM", upper[sym], 't')));
- BOOST_TEST((test("KIM", upper[sym], 'k')));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("joelyo", lower[sym] << "yo", 'j')));
- BOOST_TEST((test("JOELyo", upper[sym] << "yo", 'j')));
- }
-
- return boost::report_errors();
-}

Copied: trunk/libs/spirit/test/karma/symbols1.cpp (from r67483, /trunk/libs/spirit/test/karma/symbols.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/symbols.cpp (original)
+++ trunk/libs/spirit/test/karma/symbols1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -78,210 +78,6 @@
         BOOST_TEST((!test("", sym, 'h')));
     }
 
- { // advanced
- using boost::spirit::karma::rule;
- using boost::spirit::karma::lit;
-
- typedef spirit_test::output_iterator<char>::type output_iterator_type;
-
- symbols<char, rule<output_iterator_type> > sym;
-
- rule<output_iterator_type> r1 = lit("Joel");
- rule<output_iterator_type> r2 = lit("Hartmut");
- rule<output_iterator_type> r3 = lit("Tom");
- rule<output_iterator_type> r4 = lit("Kim");
-
- sym.add
- ('j', r1.alias())
- ('h', r2.alias())
- ('t', r3.alias())
- ('k', r4.alias())
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, rule<output_iterator_type> > >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("Joel", sym, 'j')));
- BOOST_TEST((test("Hartmut", sym, 'h')));
- BOOST_TEST((test("Tom", sym, 't')));
- BOOST_TEST((test("Kim", sym, 'k')));
- BOOST_TEST((!test("", sym, 'x')));
-
- // test copy
- symbols<char, rule<output_iterator_type> > sym2;
- sym2 = sym;
- BOOST_TEST((test("Joel", sym2, 'j')));
- BOOST_TEST((test("Hartmut", sym2, 'h')));
- BOOST_TEST((test("Tom", sym2, 't')));
- BOOST_TEST((test("Kim", sym2, 'k')));
- BOOST_TEST((!test("", sym2, 'x')));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Joelyo", sym << "yo", 'j')));
-
- sym.remove
- ('j')
- ('h')
- ;
-
- BOOST_TEST((!test("", sym, 'j')));
- BOOST_TEST((!test("", sym, 'h')));
- }
-
- { // more advanced
- using boost::spirit::karma::rule;
- using boost::spirit::karma::lit;
- using boost::spirit::karma::string;
-
- typedef spirit_test::output_iterator<char>::type output_iterator_type;
-
- symbols<char, rule<output_iterator_type, std::string()> > sym;
- rule<output_iterator_type, std::string()> r1 = string;
-
- sym.add
- ('j', r1.alias())
- ('h', r1.alias())
- ('t', r1.alias())
- ('k', r1.alias())
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, std::string> >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("Joel", sym, fusion::make_vector('j', "Joel"))));
- BOOST_TEST((test("Hartmut", sym, fusion::make_vector('h', "Hartmut"))));
- BOOST_TEST((test("Tom", sym, fusion::make_vector('t', "Tom"))));
- BOOST_TEST((test("Kim", sym, fusion::make_vector('k', "Kim"))));
- BOOST_TEST((!test("", sym, 'x')));
-
- // test copy
- symbols<char, rule<output_iterator_type, std::string()> > sym2;
- sym2 = sym;
- BOOST_TEST((test("Joel", sym2, fusion::make_vector('j', "Joel"))));
- BOOST_TEST((test("Hartmut", sym2, fusion::make_vector('h', "Hartmut"))));
- BOOST_TEST((test("Tom", sym2, fusion::make_vector('t', "Tom"))));
- BOOST_TEST((test("Kim", sym2, fusion::make_vector('k', "Kim"))));
- BOOST_TEST((!test("", sym2, 'x')));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Joelyo", sym << "yo", fusion::make_vector('j', "Joel"))));
-
- sym.remove
- ('j')
- ('h')
- ;
-
- BOOST_TEST((!test("", sym, 'j')));
- BOOST_TEST((!test("", sym, 'h')));
- }
-
- { // more advanced
- using boost::spirit::karma::rule;
- using boost::spirit::karma::lit;
- using boost::spirit::karma::char_;
-
- typedef spirit_test::output_iterator<char>::type output_iterator_type;
-
- symbols<char, rule<output_iterator_type, char()> > sym;
- rule<output_iterator_type, char()> r1 = char_;
-
- sym.add
- ('j', r1.alias())
- ('h', r1.alias())
- ('t', r1.alias())
- ('k', r1.alias())
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, rule<output_iterator_type, char()> > >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("J", sym, make_vector('j', 'J'))));
- BOOST_TEST((test("H", sym, make_vector('h', 'H'))));
- BOOST_TEST((test("T", sym, make_vector('t', 'T'))));
- BOOST_TEST((test("K", sym, make_vector('k', 'K'))));
- BOOST_TEST((!test("", sym, 'x')));
-
- // test copy
- symbols<char, rule<output_iterator_type, char()> > sym2;
- sym2 = sym;
- BOOST_TEST((test("J", sym2, make_vector('j', 'J'))));
- BOOST_TEST((test("H", sym2, make_vector('h', 'H'))));
- BOOST_TEST((test("T", sym2, make_vector('t', 'T'))));
- BOOST_TEST((test("K", sym2, make_vector('k', 'K'))));
- BOOST_TEST((!test("", sym2, 'x')));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Jyo", sym << "yo", make_vector('j', 'J'))));
-
- sym.remove
- ('j')
- ('h')
- ;
-
- BOOST_TEST((!test("", sym, 'j')));
- BOOST_TEST((!test("", sym, 'h')));
- }
-
- { // basics
- symbols<std::string> sym;
-
- sym.add
- ("Joel")
- ("Hartmut")
- ("Tom")
- ("Kim")
- ;
-
- boost::mpl::true_ f =
- boost::mpl::bool_<boost::spirit::traits::is_generator<
- symbols<char, std::string> >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("Joel", sym, "Joel")));
- BOOST_TEST((test("Hartmut", sym, "Hartmut")));
- BOOST_TEST((test("Tom", sym, "Tom")));
- BOOST_TEST((test("Kim", sym, "Kim")));
- BOOST_TEST((!test("", sym, "X")));
-
- // test copy
- symbols<std::string> sym2;
- sym2 = sym;
- BOOST_TEST((test("Joel", sym2, "Joel")));
- BOOST_TEST((test("Hartmut", sym2, "Hartmut")));
- BOOST_TEST((test("Tom", sym2, "Tom")));
- BOOST_TEST((test("Kim", sym2, "Kim")));
- BOOST_TEST((!test("", sym2, "X")));
-
- // make sure it plays well with other generators
- BOOST_TEST((test("Joelyo", sym << "yo", "Joel")));
-
- sym.remove
- ("Joel")
- ("Hartmut")
- ;
-
- BOOST_TEST((!test("", sym, "Joel")));
- BOOST_TEST((!test("", sym, "Hartmut")));
- }
-
     { // lower/upper handling
         using namespace boost::spirit::ascii;
         using boost::spirit::karma::lower;

Added: trunk/libs/spirit/test/karma/symbols2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/symbols2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,144 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_auxiliary.hpp>
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_operator.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
+
+#include "test.hpp"
+
+namespace fusion = boost::fusion;
+
+template <typename T>
+inline std::vector<T>
+make_vector(T const& t1, T const& t2)
+{
+ std::vector<T> v;
+ v.push_back(t1);
+ v.push_back(t2);
+ return v;
+}
+
+int main()
+{
+ using spirit_test::test;
+ using boost::spirit::karma::symbols;
+
+ { // advanced
+ using boost::spirit::karma::rule;
+ using boost::spirit::karma::lit;
+
+ typedef spirit_test::output_iterator<char>::type output_iterator_type;
+
+ symbols<char, rule<output_iterator_type> > sym;
+
+ rule<output_iterator_type> r1 = lit("Joel");
+ rule<output_iterator_type> r2 = lit("Hartmut");
+ rule<output_iterator_type> r3 = lit("Tom");
+ rule<output_iterator_type> r4 = lit("Kim");
+
+ sym.add
+ ('j', r1.alias())
+ ('h', r2.alias())
+ ('t', r3.alias())
+ ('k', r4.alias())
+ ;
+
+ boost::mpl::true_ f =
+ boost::mpl::bool_<boost::spirit::traits::is_generator<
+ symbols<char, rule<output_iterator_type> > >::value>();
+
+ // silence stupid compiler warnings
+ // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
+ BOOST_TEST((f.value));
+
+ BOOST_TEST((test("Joel", sym, 'j')));
+ BOOST_TEST((test("Hartmut", sym, 'h')));
+ BOOST_TEST((test("Tom", sym, 't')));
+ BOOST_TEST((test("Kim", sym, 'k')));
+ BOOST_TEST((!test("", sym, 'x')));
+
+ // test copy
+ symbols<char, rule<output_iterator_type> > sym2;
+ sym2 = sym;
+ BOOST_TEST((test("Joel", sym2, 'j')));
+ BOOST_TEST((test("Hartmut", sym2, 'h')));
+ BOOST_TEST((test("Tom", sym2, 't')));
+ BOOST_TEST((test("Kim", sym2, 'k')));
+ BOOST_TEST((!test("", sym2, 'x')));
+
+ // make sure it plays well with other generators
+ BOOST_TEST((test("Joelyo", sym << "yo", 'j')));
+
+ sym.remove
+ ('j')
+ ('h')
+ ;
+
+ BOOST_TEST((!test("", sym, 'j')));
+ BOOST_TEST((!test("", sym, 'h')));
+ }
+
+ { // more advanced
+ using boost::spirit::karma::rule;
+ using boost::spirit::karma::lit;
+ using boost::spirit::karma::string;
+
+ typedef spirit_test::output_iterator<char>::type output_iterator_type;
+
+ symbols<char, rule<output_iterator_type, std::string()> > sym;
+ rule<output_iterator_type, std::string()> r1 = string;
+
+ sym.add
+ ('j', r1.alias())
+ ('h', r1.alias())
+ ('t', r1.alias())
+ ('k', r1.alias())
+ ;
+
+ boost::mpl::true_ f =
+ boost::mpl::bool_<boost::spirit::traits::is_generator<
+ symbols<char, std::string> >::value>();
+
+ // silence stupid compiler warnings
+ // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
+ BOOST_TEST((f.value));
+
+ BOOST_TEST((test("Joel", sym, fusion::make_vector('j', "Joel"))));
+ BOOST_TEST((test("Hartmut", sym, fusion::make_vector('h', "Hartmut"))));
+ BOOST_TEST((test("Tom", sym, fusion::make_vector('t', "Tom"))));
+ BOOST_TEST((test("Kim", sym, fusion::make_vector('k', "Kim"))));
+ BOOST_TEST((!test("", sym, 'x')));
+
+ // test copy
+ symbols<char, rule<output_iterator_type, std::string()> > sym2;
+ sym2 = sym;
+ BOOST_TEST((test("Joel", sym2, fusion::make_vector('j', "Joel"))));
+ BOOST_TEST((test("Hartmut", sym2, fusion::make_vector('h', "Hartmut"))));
+ BOOST_TEST((test("Tom", sym2, fusion::make_vector('t', "Tom"))));
+ BOOST_TEST((test("Kim", sym2, fusion::make_vector('k', "Kim"))));
+ BOOST_TEST((!test("", sym2, 'x')));
+
+ // make sure it plays well with other generators
+ BOOST_TEST((test("Joelyo", sym << "yo", fusion::make_vector('j', "Joel"))));
+
+ sym.remove
+ ('j')
+ ('h')
+ ;
+
+ BOOST_TEST((!test("", sym, 'j')));
+ BOOST_TEST((!test("", sym, 'h')));
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/karma/symbols3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/symbols3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,134 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_auxiliary.hpp>
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_operator.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
+
+#include "test.hpp"
+
+namespace fusion = boost::fusion;
+
+template <typename T>
+inline std::vector<T>
+make_vector(T const& t1, T const& t2)
+{
+ std::vector<T> v;
+ v.push_back(t1);
+ v.push_back(t2);
+ return v;
+}
+
+int main()
+{
+ using spirit_test::test;
+ using boost::spirit::karma::symbols;
+
+ { // more advanced
+ using boost::spirit::karma::rule;
+ using boost::spirit::karma::lit;
+ using boost::spirit::karma::char_;
+
+ typedef spirit_test::output_iterator<char>::type output_iterator_type;
+
+ symbols<char, rule<output_iterator_type, char()> > sym;
+ rule<output_iterator_type, char()> r1 = char_;
+
+ sym.add
+ ('j', r1.alias())
+ ('h', r1.alias())
+ ('t', r1.alias())
+ ('k', r1.alias())
+ ;
+
+ boost::mpl::true_ f =
+ boost::mpl::bool_<boost::spirit::traits::is_generator<
+ symbols<char, rule<output_iterator_type, char()> > >::value>();
+
+ // silence stupid compiler warnings
+ // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
+ BOOST_TEST((f.value));
+
+ BOOST_TEST((test("J", sym, make_vector('j', 'J'))));
+ BOOST_TEST((test("H", sym, make_vector('h', 'H'))));
+ BOOST_TEST((test("T", sym, make_vector('t', 'T'))));
+ BOOST_TEST((test("K", sym, make_vector('k', 'K'))));
+ BOOST_TEST((!test("", sym, 'x')));
+
+ // test copy
+ symbols<char, rule<output_iterator_type, char()> > sym2;
+ sym2 = sym;
+ BOOST_TEST((test("J", sym2, make_vector('j', 'J'))));
+ BOOST_TEST((test("H", sym2, make_vector('h', 'H'))));
+ BOOST_TEST((test("T", sym2, make_vector('t', 'T'))));
+ BOOST_TEST((test("K", sym2, make_vector('k', 'K'))));
+ BOOST_TEST((!test("", sym2, 'x')));
+
+ // make sure it plays well with other generators
+ BOOST_TEST((test("Jyo", sym << "yo", make_vector('j', 'J'))));
+
+ sym.remove
+ ('j')
+ ('h')
+ ;
+
+ BOOST_TEST((!test("", sym, 'j')));
+ BOOST_TEST((!test("", sym, 'h')));
+ }
+
+ { // basics
+ symbols<std::string> sym;
+
+ sym.add
+ ("Joel")
+ ("Hartmut")
+ ("Tom")
+ ("Kim")
+ ;
+
+ boost::mpl::true_ f =
+ boost::mpl::bool_<boost::spirit::traits::is_generator<
+ symbols<char, std::string> >::value>();
+
+ // silence stupid compiler warnings
+ // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
+ BOOST_TEST((f.value));
+
+ BOOST_TEST((test("Joel", sym, "Joel")));
+ BOOST_TEST((test("Hartmut", sym, "Hartmut")));
+ BOOST_TEST((test("Tom", sym, "Tom")));
+ BOOST_TEST((test("Kim", sym, "Kim")));
+ BOOST_TEST((!test("", sym, "X")));
+
+ // test copy
+ symbols<std::string> sym2;
+ sym2 = sym;
+ BOOST_TEST((test("Joel", sym2, "Joel")));
+ BOOST_TEST((test("Hartmut", sym2, "Hartmut")));
+ BOOST_TEST((test("Tom", sym2, "Tom")));
+ BOOST_TEST((test("Kim", sym2, "Kim")));
+ BOOST_TEST((!test("", sym2, "X")));
+
+ // make sure it plays well with other generators
+ BOOST_TEST((test("Joelyo", sym << "yo", "Joel")));
+
+ sym.remove
+ ("Joel")
+ ("Hartmut")
+ ;
+
+ BOOST_TEST((!test("", sym, "Joel")));
+ BOOST_TEST((!test("", sym, "Hartmut")));
+ }
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/karma/utree.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/utree.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,335 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2001-2010 Joel de Guzman
-// Copyright (c) 2010 Bryce Lelbach
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/mpl/print.hpp>
-
-#include <boost/spirit/include/support_utree.hpp>
-#include <boost/spirit/include/karma.hpp>
-
-#include <sstream>
-
-#include "test.hpp"
-
-int main()
-{
- using spirit_test::test;
- using spirit_test::test_delimited;
- using boost::spirit::utree;
- using boost::spirit::utree_type;
- using boost::spirit::utf8_string_range_type;
- using boost::spirit::utf8_string_type;
- using boost::spirit::utf8_symbol_type;
-
- using boost::spirit::karma::char_;
- using boost::spirit::karma::bool_;
- using boost::spirit::karma::int_;
- using boost::spirit::karma::double_;
- using boost::spirit::karma::string;
- using boost::spirit::karma::space;
- using boost::spirit::karma::rule;
-
- typedef spirit_test::output_iterator<char>::type output_iterator;
-
- // primitive data types
- {
- utree ut('x');
- BOOST_TEST(test("x", char_, ut));
-
- ut = false;
- BOOST_TEST(test("false", bool_, ut));
-
- ut = 123;
- BOOST_TEST(test("123", int_, ut));
-
- ut = 123.45;
- BOOST_TEST(test("123.45", double_, ut));
-
- ut = "abc";
- BOOST_TEST(test("abc", string, ut));
-
- ut = utf8_symbol_type("xyz");
- BOOST_TEST(test("xyz", string, ut));
- }
-
- // sequences
- {
- using boost::spirit::karma::digit;
- using boost::spirit::karma::repeat;
-
- utree ut;
- ut.push_back('x');
- ut.push_back('y');
- BOOST_TEST(test("xy", char_ << char_, ut));
-
- ut.clear();
- ut.push_back(123);
- ut.push_back(456);
- BOOST_TEST(test_delimited("123 456 ", int_ << int_, ut, space));
-
- ut.clear();
- ut.push_back(1.23);
- ut.push_back(4.56);
- BOOST_TEST(test_delimited("1.23 4.56 ", double_ << double_, ut, space));
-
- ut.clear();
- ut.push_back(1.23);
- ut.push_back("ab");
- BOOST_TEST(test("1.23ab", double_ << string, ut));
-
- ut.clear();
-
- rule<output_iterator, double()> r1 = double_;
- rule<output_iterator, utree()> r2 = double_;
-
- // ( 1.23 "a" "b" )
- ut.push_back(1.23);
- ut.push_back('a');
- ut.push_back('b');
- BOOST_TEST(test("1.23ab", double_ << *char_, ut));
- BOOST_TEST(test("1.23ab", r1 << *char_, ut));
- BOOST_TEST(test("1.23ab", r2 << *char_, ut));
-
- // ( ( 1.23 ) "a" "b" )
- ut.clear();
- utree ut1;
- ut1.push_back(1.23);
- ut.push_back(ut1);
- ut.push_back('a');
- ut.push_back('b');
- BOOST_TEST(test("1.23ab", r1 << *char_, ut));
- BOOST_TEST(test("1.23ab", r2 << *char_, ut));
-
- // ( "a" "b" 1.23 )
- ut.clear();
- ut.push_back('a');
- ut.push_back('b');
- ut.push_back(1.23);
- BOOST_TEST(test("ab1.23", repeat(2)[~digit] << double_, ut));
- BOOST_TEST(test("ab1.23", repeat(2)[~digit] << r1, ut));
- BOOST_TEST(test("ab1.23", repeat(2)[~digit] << r2, ut));
-
- // ( "a" "b" ( 1.23 ) )
- ut.clear();
- ut.push_back('a');
- ut.push_back('b');
- ut.push_back(ut1);
- BOOST_TEST(test("ab1.23", repeat(2)[~digit] << r1, ut));
- BOOST_TEST(test("ab1.23", repeat(2)[~digit] << r2, ut));
- }
-
- // kleene star
- {
- utree ut;
- ut.push_back('a');
- ut.push_back('b');
- BOOST_TEST(test("ab", *char_, ut));
-
- ut.clear();
- ut.push_back(123);
- ut.push_back(456);
- BOOST_TEST(test_delimited("123 456 ", *int_, ut, space));
-
- ut.clear();
- ut.push_back(1.23);
- ut.push_back(4.56);
- BOOST_TEST(test_delimited("1.23 4.56 ", *double_, ut, space));
- }
-
- // lists
- {
- rule<output_iterator, utree()> r1, r1ref;
- rule<output_iterator, utf8_string_range_type()> r1str;
- rule<output_iterator, utree::const_range()> r1list;
-
- r1 = double_ | int_ | r1str | r1list | r1ref;
-
- r1ref = r1;
-
- r1str = string;
-
- r1list = '(' << -(r1 % ',') << ')';
-
- // ( "abc" "def" )
- utree ut;
- ut.push_back("abc");
- ut.push_back("def");
- BOOST_TEST(test("abc,def", string % ',', ut));
- BOOST_TEST(test("(abc,def)", r1, ut));
-
- // ( ( "abc" "def" ) )
- utree ut1;
- ut1.push_back(ut);
- BOOST_TEST(test("((abc,def))", r1, ut1));
-
-// rule<output_iterator, std::vector<char>()> r2 = char_ % ',';
-// BOOST_TEST(test("abc,def", r2, ut));
-// BOOST_TEST(test("abc,def", r2, ut1));
-
- // ( ( "abc" "def" ) ( "abc" "def" ) )
- ut1.push_back(ut);
- BOOST_TEST(test("(abc,def) (abc,def)", r1 << ' ' << r1, ut1));
-
- // ( 123 456 )
- ut.clear();
- ut.push_back(123);
- ut.push_back(456);
- BOOST_TEST(test("123,456", int_ % ',', ut));
- BOOST_TEST(test("(123,456)", r1, ut));
-
- // ( ( 123 456 ) )
- ut1.clear();
- ut1.push_back(ut);
- BOOST_TEST(test("((123,456))", r1, ut1));
-
-// rule<output_iterator, std::vector<int>()> r4 = int_ % ',';
-// BOOST_TEST(test("123,456", r4, ut));
-// BOOST_TEST(test("123,456", r4, ut1));
-
- // ( ( 123 456 ) ( 123 456 ) )
- ut1.push_back(ut);
- BOOST_TEST(test("(123,456) (123,456)", r1 << ' ' << r1, ut1));
-
- // ( 1.23 4.56 )
- ut.clear();
- ut.push_back(1.23);
- ut.push_back(4.56);
- BOOST_TEST(test("1.23,4.56", double_ % ',', ut));
- BOOST_TEST(test("(1.23,4.56)", r1, ut));
-
- // ( ( 1.23 4.56 ) )
- ut1.clear();
- ut1.push_back(ut);
- BOOST_TEST(test("((1.23,4.56))", r1, ut1));
-
-// rule<output_iterator, std::vector<double>()> r6 = double_ % ',';
-// BOOST_TEST(test("1.23,4.56", r6, ut));
-// BOOST_TEST(test("1.23,4.56", r6, ut1));
-
- // ( ( 1.23 4.56 ) ( 1.23 4.56 ) )
- ut1.push_back(ut);
- BOOST_TEST(test("(1.23,4.56) (1.23,4.56)", r1 <<' ' << r1, ut1));
- }
-
- // alternatives
- {
- rule<output_iterator, utree()> r1 = int_ | double_;
- utree ut(10);
- BOOST_TEST(test("10", int_ | double_, ut));
- BOOST_TEST(test("10", r1, ut));
-
- ut = 10.2;
- BOOST_TEST(test("10.2", int_ | double_, ut));
- BOOST_TEST(test("10.2", r1, ut));
- }
-
- // optionals
- {
- utree ut('x');
- BOOST_TEST(test("x", -char_, ut));
-
- ut.clear();
- BOOST_TEST(test("", -char_, ut));
- }
-
- // as_string
- {
- using boost::spirit::karma::digit;
- using boost::spirit::karma::as_string;
-
- utree ut("xy");
- BOOST_TEST(test("xy", string, ut));
- BOOST_TEST(test("xy", as_string[*char_], ut));
- BOOST_TEST(test("x,y", as_string[char_ << ',' << char_], ut));
-
- ut.clear();
- ut.push_back("ab");
- ut.push_back(1.2);
- BOOST_TEST(test("ab1.2", as_string[*~digit] << double_, ut));
- BOOST_TEST(test("a,b1.2", as_string[~digit % ','] << double_, ut));
- }
-
- // as
- {
- using boost::spirit::karma::digit;
- using boost::spirit::karma::as;
-
- typedef as<std::string> as_string_type;
- as_string_type const as_string = as_string_type();
-
- typedef as<utf8_symbol_type> as_symbol_type;
- as_symbol_type const as_symbol = as_symbol_type();
-
- utree ut("xy");
- BOOST_TEST(test("xy", string, ut));
- BOOST_TEST(test("xy", as_string[*char_], ut));
- BOOST_TEST(test("x,y", as_string[char_ << ',' << char_], ut));
-
- ut.clear();
- ut.push_back("ab");
- ut.push_back(1.2);
- BOOST_TEST(test("ab1.2", as_string[*~digit] << double_, ut));
- BOOST_TEST(test("a,b1.2", as_string[~digit % ','] << double_, ut));
-
- ut = utf8_symbol_type("xy");
- BOOST_TEST(test("xy", string, ut));
- BOOST_TEST(test("xy", as_symbol[*char_], ut));
- BOOST_TEST(test("x,y", as_symbol[char_ << ',' << char_], ut));
-
- ut.clear();
- ut.push_back(utf8_symbol_type("ab"));
- ut.push_back(1.2);
- BOOST_TEST(test("ab1.2", as_symbol[*~digit] << double_, ut));
- BOOST_TEST(test("a,b1.2", as_symbol[~digit % ','] << double_, ut));
- }
-
- // typed basic_string rules
- {
- utree ut("buzz");
-
- rule<output_iterator, utf8_string_type()> r1 = string;
- rule<output_iterator, utf8_symbol_type()> r2 = string;
-
- BOOST_TEST(test("buzz", r1, ut));
-
- ut = utf8_symbol_type("bar");
- BOOST_TEST(test("bar", r2, ut));
- }
-
- // parameterized karma::string
- {
- utree ut("foo");
-
- rule<output_iterator, utf8_string_type()> r1 = string("foo");
- BOOST_TEST(test("foo", string("foo"), ut));
- BOOST_TEST(test("foo", r1, ut));
- }
-
- {
- using boost::spirit::karma::verbatim;
- using boost::spirit::karma::repeat;
- using boost::spirit::karma::space;
- using boost::spirit::karma::digit;
-
- utree ut;
- ut.push_back('x');
- ut.push_back('y');
- ut.push_back('c');
- BOOST_TEST(test_delimited("xy c ", verbatim[repeat(2)[char_]] << char_, ut, space));
- BOOST_TEST(test_delimited("x yc ", char_ << verbatim[*char_], ut, space));
-
- ut.clear();
- ut.push_back('a');
- ut.push_back('b');
- ut.push_back(1.2);
- BOOST_TEST(test_delimited("ab 1.2 ", verbatim[repeat(2)[~digit]] << double_, ut, space));
- }
-
- return boost::report_errors();
-}

Copied: trunk/libs/spirit/test/karma/utree1.cpp (from r67483, /trunk/libs/spirit/test/karma/utree.cpp)
==============================================================================
--- /trunk/libs/spirit/test/karma/utree.cpp (original)
+++ trunk/libs/spirit/test/karma/utree1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -124,212 +124,5 @@
         BOOST_TEST(test("ab1.23", repeat(2)[~digit] << r2, ut));
     }
 
- // kleene star
- {
- utree ut;
- ut.push_back('a');
- ut.push_back('b');
- BOOST_TEST(test("ab", *char_, ut));
-
- ut.clear();
- ut.push_back(123);
- ut.push_back(456);
- BOOST_TEST(test_delimited("123 456 ", *int_, ut, space));
-
- ut.clear();
- ut.push_back(1.23);
- ut.push_back(4.56);
- BOOST_TEST(test_delimited("1.23 4.56 ", *double_, ut, space));
- }
-
- // lists
- {
- rule<output_iterator, utree()> r1, r1ref;
- rule<output_iterator, utf8_string_range_type()> r1str;
- rule<output_iterator, utree::const_range()> r1list;
-
- r1 = double_ | int_ | r1str | r1list | r1ref;
-
- r1ref = r1;
-
- r1str = string;
-
- r1list = '(' << -(r1 % ',') << ')';
-
- // ( "abc" "def" )
- utree ut;
- ut.push_back("abc");
- ut.push_back("def");
- BOOST_TEST(test("abc,def", string % ',', ut));
- BOOST_TEST(test("(abc,def)", r1, ut));
-
- // ( ( "abc" "def" ) )
- utree ut1;
- ut1.push_back(ut);
- BOOST_TEST(test("((abc,def))", r1, ut1));
-
-// rule<output_iterator, std::vector<char>()> r2 = char_ % ',';
-// BOOST_TEST(test("abc,def", r2, ut));
-// BOOST_TEST(test("abc,def", r2, ut1));
-
- // ( ( "abc" "def" ) ( "abc" "def" ) )
- ut1.push_back(ut);
- BOOST_TEST(test("(abc,def) (abc,def)", r1 << ' ' << r1, ut1));
-
- // ( 123 456 )
- ut.clear();
- ut.push_back(123);
- ut.push_back(456);
- BOOST_TEST(test("123,456", int_ % ',', ut));
- BOOST_TEST(test("(123,456)", r1, ut));
-
- // ( ( 123 456 ) )
- ut1.clear();
- ut1.push_back(ut);
- BOOST_TEST(test("((123,456))", r1, ut1));
-
-// rule<output_iterator, std::vector<int>()> r4 = int_ % ',';
-// BOOST_TEST(test("123,456", r4, ut));
-// BOOST_TEST(test("123,456", r4, ut1));
-
- // ( ( 123 456 ) ( 123 456 ) )
- ut1.push_back(ut);
- BOOST_TEST(test("(123,456) (123,456)", r1 << ' ' << r1, ut1));
-
- // ( 1.23 4.56 )
- ut.clear();
- ut.push_back(1.23);
- ut.push_back(4.56);
- BOOST_TEST(test("1.23,4.56", double_ % ',', ut));
- BOOST_TEST(test("(1.23,4.56)", r1, ut));
-
- // ( ( 1.23 4.56 ) )
- ut1.clear();
- ut1.push_back(ut);
- BOOST_TEST(test("((1.23,4.56))", r1, ut1));
-
-// rule<output_iterator, std::vector<double>()> r6 = double_ % ',';
-// BOOST_TEST(test("1.23,4.56", r6, ut));
-// BOOST_TEST(test("1.23,4.56", r6, ut1));
-
- // ( ( 1.23 4.56 ) ( 1.23 4.56 ) )
- ut1.push_back(ut);
- BOOST_TEST(test("(1.23,4.56) (1.23,4.56)", r1 <<' ' << r1, ut1));
- }
-
- // alternatives
- {
- rule<output_iterator, utree()> r1 = int_ | double_;
- utree ut(10);
- BOOST_TEST(test("10", int_ | double_, ut));
- BOOST_TEST(test("10", r1, ut));
-
- ut = 10.2;
- BOOST_TEST(test("10.2", int_ | double_, ut));
- BOOST_TEST(test("10.2", r1, ut));
- }
-
- // optionals
- {
- utree ut('x');
- BOOST_TEST(test("x", -char_, ut));
-
- ut.clear();
- BOOST_TEST(test("", -char_, ut));
- }
-
- // as_string
- {
- using boost::spirit::karma::digit;
- using boost::spirit::karma::as_string;
-
- utree ut("xy");
- BOOST_TEST(test("xy", string, ut));
- BOOST_TEST(test("xy", as_string[*char_], ut));
- BOOST_TEST(test("x,y", as_string[char_ << ',' << char_], ut));
-
- ut.clear();
- ut.push_back("ab");
- ut.push_back(1.2);
- BOOST_TEST(test("ab1.2", as_string[*~digit] << double_, ut));
- BOOST_TEST(test("a,b1.2", as_string[~digit % ','] << double_, ut));
- }
-
- // as
- {
- using boost::spirit::karma::digit;
- using boost::spirit::karma::as;
-
- typedef as<std::string> as_string_type;
- as_string_type const as_string = as_string_type();
-
- typedef as<utf8_symbol_type> as_symbol_type;
- as_symbol_type const as_symbol = as_symbol_type();
-
- utree ut("xy");
- BOOST_TEST(test("xy", string, ut));
- BOOST_TEST(test("xy", as_string[*char_], ut));
- BOOST_TEST(test("x,y", as_string[char_ << ',' << char_], ut));
-
- ut.clear();
- ut.push_back("ab");
- ut.push_back(1.2);
- BOOST_TEST(test("ab1.2", as_string[*~digit] << double_, ut));
- BOOST_TEST(test("a,b1.2", as_string[~digit % ','] << double_, ut));
-
- ut = utf8_symbol_type("xy");
- BOOST_TEST(test("xy", string, ut));
- BOOST_TEST(test("xy", as_symbol[*char_], ut));
- BOOST_TEST(test("x,y", as_symbol[char_ << ',' << char_], ut));
-
- ut.clear();
- ut.push_back(utf8_symbol_type("ab"));
- ut.push_back(1.2);
- BOOST_TEST(test("ab1.2", as_symbol[*~digit] << double_, ut));
- BOOST_TEST(test("a,b1.2", as_symbol[~digit % ','] << double_, ut));
- }
-
- // typed basic_string rules
- {
- utree ut("buzz");
-
- rule<output_iterator, utf8_string_type()> r1 = string;
- rule<output_iterator, utf8_symbol_type()> r2 = string;
-
- BOOST_TEST(test("buzz", r1, ut));
-
- ut = utf8_symbol_type("bar");
- BOOST_TEST(test("bar", r2, ut));
- }
-
- // parameterized karma::string
- {
- utree ut("foo");
-
- rule<output_iterator, utf8_string_type()> r1 = string("foo");
- BOOST_TEST(test("foo", string("foo"), ut));
- BOOST_TEST(test("foo", r1, ut));
- }
-
- {
- using boost::spirit::karma::verbatim;
- using boost::spirit::karma::repeat;
- using boost::spirit::karma::space;
- using boost::spirit::karma::digit;
-
- utree ut;
- ut.push_back('x');
- ut.push_back('y');
- ut.push_back('c');
- BOOST_TEST(test_delimited("xy c ", verbatim[repeat(2)[char_]] << char_, ut, space));
- BOOST_TEST(test_delimited("x yc ", char_ << verbatim[*char_], ut, space));
-
- ut.clear();
- ut.push_back('a');
- ut.push_back('b');
- ut.push_back(1.2);
- BOOST_TEST(test_delimited("ab 1.2 ", verbatim[repeat(2)[~digit]] << double_, ut, space));
- }
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/karma/utree2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/utree2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,155 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2010 Joel de Guzman
+// Copyright (c) 2010 Bryce Lelbach
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/mpl/print.hpp>
+
+#include <boost/spirit/include/support_utree.hpp>
+#include <boost/spirit/include/karma.hpp>
+
+#include <sstream>
+
+#include "test.hpp"
+
+int main()
+{
+ using spirit_test::test;
+ using spirit_test::test_delimited;
+ using boost::spirit::utree;
+ using boost::spirit::utree_type;
+ using boost::spirit::utf8_string_range_type;
+ using boost::spirit::utf8_string_type;
+ using boost::spirit::utf8_symbol_type;
+
+ using boost::spirit::karma::char_;
+ using boost::spirit::karma::bool_;
+ using boost::spirit::karma::int_;
+ using boost::spirit::karma::double_;
+ using boost::spirit::karma::string;
+ using boost::spirit::karma::space;
+ using boost::spirit::karma::rule;
+
+ typedef spirit_test::output_iterator<char>::type output_iterator;
+
+ // kleene star
+ {
+ utree ut;
+ ut.push_back('a');
+ ut.push_back('b');
+ BOOST_TEST(test("ab", *char_, ut));
+
+ ut.clear();
+ ut.push_back(123);
+ ut.push_back(456);
+ BOOST_TEST(test_delimited("123 456 ", *int_, ut, space));
+
+ ut.clear();
+ ut.push_back(1.23);
+ ut.push_back(4.56);
+ BOOST_TEST(test_delimited("1.23 4.56 ", *double_, ut, space));
+ }
+
+ // lists
+ {
+ rule<output_iterator, utree()> r1, r1ref;
+ rule<output_iterator, utf8_string_range_type()> r1str;
+ rule<output_iterator, utree::const_range()> r1list;
+
+ r1 = double_ | int_ | r1str | r1list | r1ref;
+
+ r1ref = r1;
+
+ r1str = string;
+
+ r1list = '(' << -(r1 % ',') << ')';
+
+ // ( "abc" "def" )
+ utree ut;
+ ut.push_back("abc");
+ ut.push_back("def");
+ BOOST_TEST(test("abc,def", string % ',', ut));
+ BOOST_TEST(test("(abc,def)", r1, ut));
+
+ // ( ( "abc" "def" ) )
+ utree ut1;
+ ut1.push_back(ut);
+ BOOST_TEST(test("((abc,def))", r1, ut1));
+
+// rule<output_iterator, std::vector<char>()> r2 = char_ % ',';
+// BOOST_TEST(test("abc,def", r2, ut));
+// BOOST_TEST(test("abc,def", r2, ut1));
+
+ // ( ( "abc" "def" ) ( "abc" "def" ) )
+ ut1.push_back(ut);
+ BOOST_TEST(test("(abc,def) (abc,def)", r1 << ' ' << r1, ut1));
+
+ // ( 123 456 )
+ ut.clear();
+ ut.push_back(123);
+ ut.push_back(456);
+ BOOST_TEST(test("123,456", int_ % ',', ut));
+ BOOST_TEST(test("(123,456)", r1, ut));
+
+ // ( ( 123 456 ) )
+ ut1.clear();
+ ut1.push_back(ut);
+ BOOST_TEST(test("((123,456))", r1, ut1));
+
+// rule<output_iterator, std::vector<int>()> r4 = int_ % ',';
+// BOOST_TEST(test("123,456", r4, ut));
+// BOOST_TEST(test("123,456", r4, ut1));
+
+ // ( ( 123 456 ) ( 123 456 ) )
+ ut1.push_back(ut);
+ BOOST_TEST(test("(123,456) (123,456)", r1 << ' ' << r1, ut1));
+
+ // ( 1.23 4.56 )
+ ut.clear();
+ ut.push_back(1.23);
+ ut.push_back(4.56);
+ BOOST_TEST(test("1.23,4.56", double_ % ',', ut));
+ BOOST_TEST(test("(1.23,4.56)", r1, ut));
+
+ // ( ( 1.23 4.56 ) )
+ ut1.clear();
+ ut1.push_back(ut);
+ BOOST_TEST(test("((1.23,4.56))", r1, ut1));
+
+// rule<output_iterator, std::vector<double>()> r6 = double_ % ',';
+// BOOST_TEST(test("1.23,4.56", r6, ut));
+// BOOST_TEST(test("1.23,4.56", r6, ut1));
+
+ // ( ( 1.23 4.56 ) ( 1.23 4.56 ) )
+ ut1.push_back(ut);
+ BOOST_TEST(test("(1.23,4.56) (1.23,4.56)", r1 <<' ' << r1, ut1));
+ }
+
+ // alternatives
+ {
+ rule<output_iterator, utree()> r1 = int_ | double_;
+ utree ut(10);
+ BOOST_TEST(test("10", int_ | double_, ut));
+ BOOST_TEST(test("10", r1, ut));
+
+ ut = 10.2;
+ BOOST_TEST(test("10.2", int_ | double_, ut));
+ BOOST_TEST(test("10.2", r1, ut));
+ }
+
+ // optionals
+ {
+ utree ut('x');
+ BOOST_TEST(test("x", -char_, ut));
+
+ ut.clear();
+ BOOST_TEST(test("", -char_, ut));
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/karma/utree3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/utree3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,134 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2010 Joel de Guzman
+// Copyright (c) 2010 Bryce Lelbach
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/mpl/print.hpp>
+
+#include <boost/spirit/include/support_utree.hpp>
+#include <boost/spirit/include/karma.hpp>
+
+#include <sstream>
+
+#include "test.hpp"
+
+int main()
+{
+ using spirit_test::test;
+ using spirit_test::test_delimited;
+ using boost::spirit::utree;
+ using boost::spirit::utree_type;
+ using boost::spirit::utf8_string_range_type;
+ using boost::spirit::utf8_string_type;
+ using boost::spirit::utf8_symbol_type;
+
+ using boost::spirit::karma::char_;
+ using boost::spirit::karma::bool_;
+ using boost::spirit::karma::int_;
+ using boost::spirit::karma::double_;
+ using boost::spirit::karma::string;
+ using boost::spirit::karma::space;
+ using boost::spirit::karma::rule;
+
+ typedef spirit_test::output_iterator<char>::type output_iterator;
+
+ // as_string
+ {
+ using boost::spirit::karma::digit;
+ using boost::spirit::karma::as_string;
+
+ utree ut("xy");
+ BOOST_TEST(test("xy", string, ut));
+ BOOST_TEST(test("xy", as_string[*char_], ut));
+ BOOST_TEST(test("x,y", as_string[char_ << ',' << char_], ut));
+
+ ut.clear();
+ ut.push_back("ab");
+ ut.push_back(1.2);
+ BOOST_TEST(test("ab1.2", as_string[*~digit] << double_, ut));
+ BOOST_TEST(test("a,b1.2", as_string[~digit % ','] << double_, ut));
+ }
+
+ // as
+ {
+ using boost::spirit::karma::digit;
+ using boost::spirit::karma::as;
+
+ typedef as<std::string> as_string_type;
+ as_string_type const as_string = as_string_type();
+
+ typedef as<utf8_symbol_type> as_symbol_type;
+ as_symbol_type const as_symbol = as_symbol_type();
+
+ utree ut("xy");
+ BOOST_TEST(test("xy", string, ut));
+ BOOST_TEST(test("xy", as_string[*char_], ut));
+ BOOST_TEST(test("x,y", as_string[char_ << ',' << char_], ut));
+
+ ut.clear();
+ ut.push_back("ab");
+ ut.push_back(1.2);
+ BOOST_TEST(test("ab1.2", as_string[*~digit] << double_, ut));
+ BOOST_TEST(test("a,b1.2", as_string[~digit % ','] << double_, ut));
+
+ ut = utf8_symbol_type("xy");
+ BOOST_TEST(test("xy", string, ut));
+ BOOST_TEST(test("xy", as_symbol[*char_], ut));
+ BOOST_TEST(test("x,y", as_symbol[char_ << ',' << char_], ut));
+
+ ut.clear();
+ ut.push_back(utf8_symbol_type("ab"));
+ ut.push_back(1.2);
+ BOOST_TEST(test("ab1.2", as_symbol[*~digit] << double_, ut));
+ BOOST_TEST(test("a,b1.2", as_symbol[~digit % ','] << double_, ut));
+ }
+
+ // typed basic_string rules
+ {
+ utree ut("buzz");
+
+ rule<output_iterator, utf8_string_type()> r1 = string;
+ rule<output_iterator, utf8_symbol_type()> r2 = string;
+
+ BOOST_TEST(test("buzz", r1, ut));
+
+ ut = utf8_symbol_type("bar");
+ BOOST_TEST(test("bar", r2, ut));
+ }
+
+ // parameterized karma::string
+ {
+ utree ut("foo");
+
+ rule<output_iterator, utf8_string_type()> r1 = string("foo");
+ BOOST_TEST(test("foo", string("foo"), ut));
+ BOOST_TEST(test("foo", r1, ut));
+ }
+
+ {
+ using boost::spirit::karma::verbatim;
+ using boost::spirit::karma::repeat;
+ using boost::spirit::karma::space;
+ using boost::spirit::karma::digit;
+
+ utree ut;
+ ut.push_back('x');
+ ut.push_back('y');
+ ut.push_back('c');
+ BOOST_TEST(test_delimited("xy c ", verbatim[repeat(2)[char_]] << char_, ut, space));
+ BOOST_TEST(test_delimited("x yc ", char_ << verbatim[*char_], ut, space));
+
+ ut.clear();
+ ut.push_back('a');
+ ut.push_back('b');
+ ut.push_back(1.2);
+ BOOST_TEST(test_delimited("ab 1.2 ", verbatim[repeat(2)[~digit]] << double_, ut, space));
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/karma/wstream.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/wstream.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,115 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+//
+// Distributed under 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 <stdint.h>
+#include <cwchar>
+#include <streambuf>
+#include <iostream>
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_string.hpp>
+#include <boost/spirit/include/karma_stream.hpp>
+#include <boost/spirit/include/karma_directive.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+// a simple complex number representation z = a + bi
+struct complex
+{
+ complex (double a, double b)
+ : a(a), b(b)
+ {}
+
+ double a;
+ double b;
+
+ template <typename Char>
+ friend std::basic_ostream<Char>&
+ operator<< (std::basic_ostream<Char>& os, complex z)
+ {
+ os << "{" << z.a << "," << z.b << "}";
+ return os;
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+
+ {
+ BOOST_TEST(test(L"x", wstream, L'x'));
+ BOOST_TEST(test(L"xyz", wstream, L"xyz"));
+ BOOST_TEST(test(L"xyz", wstream, std::basic_string<wchar_t>(L"xyz")));
+ BOOST_TEST(test(L"1", wstream, 1));
+ BOOST_TEST(test(L"1.1", wstream, 1.1));
+ BOOST_TEST(test(L"{1.2,2.4}", wstream, complex(1.2, 2.4)));
+ }
+
+ {
+ BOOST_TEST(test(L"x", wstream(L'x')));
+ BOOST_TEST(test(L"xyz", wstream(L"xyz")));
+ BOOST_TEST(test(L"xyz", wstream(std::basic_string<wchar_t>(L"xyz"))));
+ BOOST_TEST(test(L"1", wstream(1)));
+ BOOST_TEST(test(L"1.1", wstream(1.1)));
+ BOOST_TEST(test(L"{1.2,2.4}", wstream(complex(1.2, 2.4))));
+ }
+
+ {
+ using namespace boost::spirit::ascii;
+
+ BOOST_TEST(test(L"x", lower[wstream], L'X'));
+ BOOST_TEST(test(L"xyz", lower[wstream], L"XYZ"));
+ BOOST_TEST(test(L"xyz", lower[wstream], std::basic_string<wchar_t>(L"XYZ")));
+ BOOST_TEST(test(L"X", upper[wstream], L'x'));
+ BOOST_TEST(test(L"XYZ", upper[wstream], L"xyz"));
+ BOOST_TEST(test(L"XYZ", upper[wstream], std::basic_string<wchar_t>(L"xyz")));
+ }
+
+ {
+ BOOST_TEST(test_delimited(L"x ", wstream, L'x', L' '));
+ BOOST_TEST(test_delimited(L"xyz ", wstream, L"xyz", L' '));
+ BOOST_TEST(test_delimited(L"xyz ", wstream, std::basic_string<wchar_t>(L"xyz"), L' '));
+ BOOST_TEST(test_delimited(L"1 ", wstream, 1, ' '));
+ BOOST_TEST(test_delimited(L"1.1 ", wstream, 1.1, ' '));
+ BOOST_TEST(test_delimited(L"{1.2,2.4} ", wstream, complex(1.2, 2.4), ' '));
+ }
+
+ {
+ using namespace boost::spirit::ascii;
+
+ BOOST_TEST(test_delimited(L"x ", lower[wstream], L'X', L' '));
+ BOOST_TEST(test_delimited(L"xyz ", lower[wstream], L"XYZ", L' '));
+ BOOST_TEST(test_delimited(L"xyz ", lower[wstream], std::basic_string<wchar_t>(L"XYZ"), L' '));
+ BOOST_TEST(test_delimited(L"X ", upper[wstream], L'x', L' '));
+ BOOST_TEST(test_delimited(L"XYZ ", upper[wstream], L"xyz", ' '));
+ BOOST_TEST(test_delimited(L"XYZ ", upper[wstream], std::basic_string<wchar_t>(L"xyz"), L' '));
+ }
+
+ { // lazy streams
+ namespace phx = boost::phoenix;
+
+ std::basic_string<wchar_t> ws(L"abc");
+ BOOST_TEST((test(L"abc", wstream(phx::val(ws)))));
+ BOOST_TEST((test(L"abc", wstream(phx::ref(ws)))));
+ }
+
+ {
+ boost::optional<wchar_t> c;
+ BOOST_TEST(!test(L"", wstream, c));
+ c = L'x';
+ BOOST_TEST(test(L"x", wstream, c));
+ }
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/lex/regression001.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression001.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,64 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2009 Pavel Baranov
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-
-#include <iostream>
-#include <string>
-
-using namespace boost::spirit;
-using namespace boost::spirit::lex;
-
-typedef const char * base_iterator;
-
-///////////////////////////////////////////////////////////////////////////////
-// Token definition
-///////////////////////////////////////////////////////////////////////////////
-template <typename Lexer>
-struct position_helper_tokens : lexer<Lexer>
-{
- position_helper_tokens()
- {
- // define tokens and associate them with the lexer
- eol = "\n";
- any = "[^\n]+";
-
- // associate tokens with the lexer
- this->self
- = eol
- | any
- ;
- }
-
- token_def<> any, eol;
-};
-
-int main()
-{
- // read input from the given file
- std::string str ("test");
-
- // token type
- typedef lexertl::token<base_iterator, lex::omit, boost::mpl::false_> token_type;
-
- // lexer type
- typedef lexertl::actor_lexer<token_type> lexer_type;
-
- // create the lexer object instance needed to invoke the lexical analysis
- position_helper_tokens<lexer_type> position_helper_lexer;
-
- // tokenize the given string, all generated tokens are discarded
- base_iterator first = str.c_str();
- base_iterator last = &first[str.size()];
-
- for(lexer_type::iterator_type i = position_helper_lexer.begin(first, last);
- i != position_helper_lexer.end() && (*i).is_valid(); i++ )
- {
- }
- return boost::report_errors();
-}
-

Deleted: trunk/libs/spirit/test/lex/regression002.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression002.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,44 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2009 Carl Barron
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include <iostream>
-#include <algorithm>
-#include "matlib.h"
-
-void test_matrix(std::vector<std::vector<double> > const& x)
-{
- BOOST_TEST(x.size() == 3);
- BOOST_TEST(x[0].size() == 2 && x[0][0] == 1 && x[0][1] == 2);
- BOOST_TEST(x[1].size() == 1 && x[1][0] == 3);
- BOOST_TEST(x[2].size() == 3 && x[2][0] == 4 && x[2][1] == 5 && x[2][2] == 6);
-}
-
-int main ()
-{
- std::string input("[[1,2][3][4,5,6]]");
-
- std::vector<std::vector<double> > results;
- typedef std::string::iterator iter;
- typedef boost::spirit::lex::lexertl::actor_lexer<
- boost::spirit::lex::lexertl::token<iter>
- > lexer_type;
-
- typedef matlib_tokens<lexer_type> matlib_type;
- matlib_type matrix(results);
- iter first = input.begin();
-
- try {
- BOOST_TEST(boost::spirit::lex::tokenize(first, input.end(), matrix));
- test_matrix(results);
- }
- catch (std::runtime_error const& e) {
- std::cerr << "caught exception: " << e.what() << std::endl;
- BOOST_TEST(false);
- }
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/regression003.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression003.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,50 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2009 Carl Barron
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/lex_static_lexertl.hpp>
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <exception>
-
-#include "matlib_static.h"
-#include "matlib.h"
-
-void test_matrix(std::vector<std::vector<double> > const& x)
-{
- BOOST_TEST(x.size() == 3);
- BOOST_TEST(x[0].size() == 2 && x[0][0] == 1 && x[0][1] == 2);
- BOOST_TEST(x[1].size() == 1 && x[1][0] == 3);
- BOOST_TEST(x[2].size() == 3 && x[2][0] == 4 && x[2][1] == 5 && x[2][2] == 6);
-}
-
-int main()
-{
- std::string input("[[1,2][3][4,5,6]]");
- std::vector<std::vector<double> > results;
-
- typedef std::string::iterator iter;
- typedef boost::spirit::lex::lexertl::static_actor_lexer<
- boost::spirit::lex::lexertl::token<iter>,
- boost::spirit::lex::lexertl::static_::lexer_matlib
- > lexer_type;
-
- typedef matlib_tokens<lexer_type> matlib_type;
- matlib_type matrix(results);
- iter first = input.begin();
-
- try {
- BOOST_TEST(boost::spirit::lex::tokenize(first, input.end(), matrix));
- test_matrix(results);
- }
- catch (std::runtime_error const& e) {
- std::cerr << e.what() << '\n';
- BOOST_TEST(false);
- }
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/regression003_generate.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression003_generate.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,32 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2009 Carl Barron
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include <boost/spirit/include/lex_generate_static_lexertl.hpp>
-
-#include <fstream>
-#include <vector>
-
-#include "matlib.h"
-
-int main(int argc, char* argv[])
-{
- std::vector<std::vector<double> > results;
-
- typedef std::string::iterator iter;
- typedef boost::spirit::lex::lexertl::actor_lexer<
- boost::spirit::lex::lexertl::token<iter>
- > lexer_type;
-
- typedef matlib_tokens<lexer_type> matlib_type;
- matlib_type matrix(results);
-
- std::ofstream out(argc < 2 ? "matlib_static.h" : argv[1]);
- BOOST_TEST(boost::spirit::lex::lexertl::generate_static_dfa(matrix, out, "matlib"));
- return boost::report_errors();
-}
-

Deleted: trunk/libs/spirit/test/lex/regression003_generate_switch.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression003_generate_switch.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,33 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2009 Carl Barron
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include <boost/spirit/include/lex_generate_static_lexertl.hpp>
-
-#include <fstream>
-#include <vector>
-
-#include "matlib.h"
-
-int main(int argc, char* argv[])
-{
- std::vector<std::vector<double> > results;
-
- typedef std::string::iterator iter;
- typedef boost::spirit::lex::lexertl::actor_lexer<
- boost::spirit::lex::lexertl::token<iter>
- > lexer_type;
-
- typedef matlib_tokens<lexer_type> matlib_type;
- matlib_type matrix(results);
-
- std::ofstream out(argc < 2 ? "matlib_static_switch.h" : argv[1]);
- BOOST_TEST(boost::spirit::lex::lexertl::generate_static_switch(
- matrix, out, "matlib_switch"));
- return boost::report_errors();
-}
-

Deleted: trunk/libs/spirit/test/lex/regression003_switch.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression003_switch.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,50 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2009 Carl Barron
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/lex_static_lexertl.hpp>
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <exception>
-
-#include "matlib_static_switch.h"
-#include "matlib.h"
-
-void test_matrix(std::vector<std::vector<double> > const& x)
-{
- BOOST_TEST(x.size() == 3);
- BOOST_TEST(x[0].size() == 2 && x[0][0] == 1 && x[0][1] == 2);
- BOOST_TEST(x[1].size() == 1 && x[1][0] == 3);
- BOOST_TEST(x[2].size() == 3 && x[2][0] == 4 && x[2][1] == 5 && x[2][2] == 6);
-}
-
-int main()
-{
- std::string input("[[1,2][3][4,5,6]]");
- std::vector<std::vector<double> > results;
-
- typedef std::string::iterator iter;
- typedef boost::spirit::lex::lexertl::static_actor_lexer<
- boost::spirit::lex::lexertl::token<iter>,
- boost::spirit::lex::lexertl::static_::lexer_matlib_switch
- > lexer_type;
-
- typedef matlib_tokens<lexer_type> matlib_type;
- matlib_type matrix(results);
- iter first = input.begin();
-
- try {
- BOOST_TEST(boost::spirit::lex::tokenize(first, input.end(), matrix));
- test_matrix(results);
- }
- catch (std::runtime_error const& e) {
- std::cerr << e.what() << '\n';
- BOOST_TEST(false);
- }
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/regression004.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression004.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,90 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2009 Tor Brede Vekterli
-//
-// Distributed under 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)
-
-// #define BOOST_SPIRIT_LEXERTL_DEBUG
-#define BOOST_VARIANT_MINIMIZE_SIZE
-
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/config/warning_disable.hpp>
-
-#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-#include <boost/spirit/include/phoenix_container.hpp>
-
-#include <iostream>
-#include <string>
-
-namespace qi = boost::spirit::qi;
-namespace lex = boost::spirit::lex;
-
-enum tokenids
-{
- IDANY = lex::min_token_id + 10 // Lower 8 bits is 0x0a, same as '\n'
-};
-
-template <typename Lexer>
-struct word_count_tokens : lex::lexer<Lexer>
-{
- word_count_tokens()
- {
- this->self.add_pattern
- ("TEST", "A")
- ;
- word = "{TEST}";
- this->self.add
- (word)
- ('\n')
- (".", IDANY)
- ;
- }
- lex::token_def<std::string> word;
-};
-
-template <typename Iterator>
-struct word_count_grammar : qi::grammar<Iterator>
-{
- template <typename TokenDef>
- word_count_grammar(TokenDef const& tok)
- : word_count_grammar::base_type(start)
- , c(0), w(0), l(0)
- {
- using boost::phoenix::ref;
- using qi::lit;
- using qi::token;
-
- start = *( tok.word [++ref(w)]
- | lit('\n') [++ref(l)]
- | token(IDANY) [++ref(c)]
- )
- ;
- }
- std::size_t c, w, l;
- qi::rule<Iterator> start;
-};
-
-
-int main()
-{
- typedef lex::lexertl::token<
- const char*, boost::mpl::vector<std::string>
- > token_type;
-
- typedef lex::lexertl::lexer<token_type> lexer_type;
- typedef word_count_tokens<lexer_type>::iterator_type iterator_type;
- word_count_tokens<lexer_type> word_count; // Our lexer
- word_count_grammar<iterator_type> g (word_count); // Our parser
-
- std::string str ("A\nBCDEFGHI");
- char const* first = str.c_str();
- char const* last = &first[str.size()];
-
- BOOST_TEST(lex::tokenize_and_parse(first, last, word_count, g));
- BOOST_TEST(g.l == 1 && g.w == 1 && g.c == 8);
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/regression005.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression005.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,92 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2009 Jean-Francois Ostiguy
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/config/warning_disable.hpp>
-
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include <boost/spirit/include/qi.hpp>
-
-#include <string>
-#include <iostream>
-#include <sstream>
-
-namespace lex = boost::spirit::lex;
-namespace qi = boost::spirit::qi;
-namespace mpl = boost::mpl;
-
-template <typename Lexer>
-struct my_lexer : lex::lexer<Lexer>
-{
- my_lexer()
- {
- delimiter = "BEGIN|END";
- identifier = "[a-zA-Z][_\\.a-zA-Z0-9]*";
- ws = "[ \\t\\n]+";
- real = "([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)|([-+]?[1-9]+\\.?([eE][-+]?[0-9]+))";
- integer = "[0-9]+";
-
- this->self += ws[lex::_pass = lex::pass_flags::pass_ignore];
- this->self += delimiter;
- this->self += identifier;
- this->self += real;
- this->self += integer;
- this->self += '=';
- this->self += ';';
- }
-
- lex::token_def<> ws;
- lex::token_def<std::string> identifier;
- lex::token_def<int> integer;
- lex::token_def<double> real;
- lex::token_def<> delimiter;
-};
-
-template <typename Iterator>
-struct my_grammar : qi::grammar<Iterator>
-{
- template <typename TokenDef>
- my_grammar( TokenDef const& tok )
- : my_grammar::base_type(statement)
- {
- statement
- = qi::eoi
- | *(delimiter | declaration)
- ;
-
- delimiter = tok.delimiter >> tok.identifier;
- declaration = tok.identifier >> option >> ';';
- option = *(tok.identifier >> '=' >> (tok.real | tok.integer));
- }
-
- qi::rule<Iterator> statement, delimiter, declaration, option;
-};
-
-typedef lex::lexertl::token<char const*
- , mpl::vector<std::string, double, int> > token_type;
-typedef lex::lexertl::actor_lexer<token_type> lexer_type;
-typedef my_lexer<lexer_type>::iterator_type iterator_type;
-
-int main()
-{
- std::string test_string ("BEGIN section\n");
- // we introduce a syntax error: ";;" instead of ";" as a terminator.
- test_string += "Identity;;\n"; // this will make the parser fail
- test_string += "END section\n" ;
-
- char const* first = &test_string[0];
- char const* last = &first[test_string.size()];
-
- my_lexer<lexer_type> lexer;
- my_grammar<iterator_type> grammar(lexer);
-
- BOOST_TEST(lex::tokenize_and_parse(first, last, lexer, grammar));
- BOOST_TEST(first != last);
-
- return boost::report_errors();
-}
-
-

Deleted: trunk/libs/spirit/test/lex/regression006.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression006.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,132 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2010 Sergey "GooRoo" Olendarenko
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/config/warning_disable.hpp>
-
-#include <cstdlib>
-#include <iostream>
-#include <locale>
-#include <string>
-
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include <boost/spirit/include/phoenix_object.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-#include <boost/spirit/include/phoenix_container.hpp>
-
-namespace lex = boost::spirit::lex;
-namespace phoenix = boost::phoenix;
-
-typedef std::basic_string<wchar_t> wstring_type;
-
-///////////////////////////////////////////////////////////////////////////////
-enum tokenids
-{
- ID_IDENT = 1,
- ID_CONSTANT,
- ID_OPERATION,
- ID_BRACKET
-};
-
-///////////////////////////////////////////////////////////////////////////////
-struct test_data
-{
- int tokenid;
- wstring_type value;
-};
-
-// alpha+x1*(2.836-x2[i])
-test_data data[] =
-{
- { ID_IDENT, L"alpha" },
- { ID_OPERATION, L"+" },
- { ID_IDENT, L"x1" },
- { ID_OPERATION, L"*" },
- { ID_BRACKET, L"(" },
- { ID_CONSTANT, L"2.836" },
- { ID_OPERATION, L"-" },
- { ID_IDENT, L"x2" },
- { ID_BRACKET, L"[" },
- { ID_IDENT, L"i" },
- { ID_BRACKET, L"]" },
- { ID_BRACKET, L")" }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-struct test_impl
-{
- template <typename TokenId, typename Value>
- struct result { typedef void type; };
-
- template <typename TokenId, typename Value>
- void operator()(TokenId const& tokenid, Value const& val) const
- {
- BOOST_TEST(sequence_counter < sizeof(data)/sizeof(data[0]));
- BOOST_TEST(data[sequence_counter].tokenid == tokenid);
- BOOST_TEST(0 == val.which());
-
- typedef boost::iterator_range<wstring_type::iterator> iterator_range;
- iterator_range r = boost::get<iterator_range>(val);
- BOOST_TEST(data[sequence_counter].value ==
- wstring_type(r.begin(), r.end()));
-
- ++sequence_counter;
- }
-
- static int sequence_counter;
-};
-int test_impl::sequence_counter = 0;
-
-phoenix::function<test_impl> const test = test_impl();
-
-///////////////////////////////////////////////////////////////////////////////
-template <typename Lexer>
-struct mega_tokens : lex::lexer<Lexer>
-{
- mega_tokens()
- : identifier(L"[a-zA-Z_][a-zA-Z0-9_]*", ID_IDENT)
- , constant (L"[0-9]+(\\.[0-9]+)?", ID_CONSTANT)
- , operation (L"[\\+\\-\\*/]", ID_OPERATION)
- , bracket (L"[\\(\\)\\[\\]]", ID_BRACKET)
- {
- using lex::_tokenid;
- using lex::_val;
-
- this->self
- = operation [ test(_tokenid, _val) ]
- | identifier [ test(_tokenid, _val) ]
- | constant [ test(_tokenid, _val) ]
- | bracket [ test(_tokenid, _val) ]
- ;
- }
-
- lex::token_def<wchar_t, wchar_t> operation;
- lex::token_def<wstring_type, wchar_t> identifier;
- lex::token_def<double, wchar_t> constant;
- lex::token_def<wchar_t, wchar_t> bracket;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-int main()
-{
- typedef wstring_type::iterator base_iterator;
- typedef lex::lexertl::token<
- base_iterator, boost::mpl::vector<wchar_t, wstring_type, double>
- > token_type;
- typedef lex::lexertl::actor_lexer<token_type> lexer_type;
- typedef mega_tokens<lexer_type>::iterator_type iterator_type;
-
- mega_tokens<lexer_type> mega_lexer;
-
- wstring_type exampleStr = L"alpha+x1*(2.836-x2[i])";
- base_iterator first = exampleStr.begin();
-
- BOOST_TEST(lex::tokenize(first, exampleStr.end(), mega_lexer));
- BOOST_TEST(test_impl::sequence_counter == sizeof(data)/sizeof(data[0]));
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/regression007.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression007.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,108 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2010 Mathias Gaunard
-//
-// Distributed under 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)
-
-// #define BOOST_SPIRIT_LEXERTL_DEBUG
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/support_multi_pass.hpp>
-#include <boost/spirit/include/classic_position_iterator.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-
-#include <boost/spirit/home/phoenix/core.hpp>
-#include <boost/spirit/home/phoenix/operator.hpp>
-#include <boost/spirit/home/phoenix/statement.hpp>
-#include <boost/spirit/home/phoenix/object.hpp>
-#include <boost/spirit/home/phoenix/stl.hpp>
-
-namespace spirit = boost::spirit;
-namespace lex = spirit::lex;
-namespace phoenix = boost::phoenix;
-
-typedef spirit::classic::position_iterator2<
- spirit::multi_pass<std::istreambuf_iterator<char> >
-> file_iterator;
-
-typedef boost::iterator_range<file_iterator> file_range;
-
-inline file_iterator
-make_file_iterator(std::istream& input, const std::string& filename)
-{
- return file_iterator(
- spirit::make_default_multi_pass(
- std::istreambuf_iterator<char>(input)),
- spirit::multi_pass<std::istreambuf_iterator<char> >(),
- filename);
-}
-
-struct identifier
-{
- identifier(file_iterator begin, file_iterator end)
- {
- }
-};
-
-struct string_literal
-{
- string_literal(file_iterator begin, file_iterator end)
- {
- }
-};
-
-typedef lex::lexertl::token<
- file_iterator, boost::mpl::vector<identifier, string_literal>
-> token_type;
-
-struct lexer
- : lex::lexer<lex::lexertl::actor_lexer<token_type> >
-{
- lexer()
- : id("[a-zA-Z0-9]+", 1)
- , st("'[^'\\n]*'", 2)
- {
- self("ST") =
- st [ lex::_state = "INITIAL" ]
- ;
-
- self("*") =
- id [ lex::_state = "ST" ]
- | lex::token_def<>(".", 3) [ lex::_state = "ST" ]
- ;
- }
-
- lex::token_def<identifier> id;
- lex::token_def<string_literal> st;
-};
-
-typedef lexer::iterator_type token_iterator;
-
-int main()
-{
- std::stringstream ss;
- ss << "foo 'bar'";
-
- file_iterator begin = make_file_iterator(ss, "SS");
- file_iterator end;
-
- lexer l;
- token_iterator begin2 = l.begin(begin, end, "ST");
- token_iterator end2 = l.end();
-
- std::size_t test_data[] = { 1, 3, 2 };
- std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
-
- token_iterator it = begin2;
- std::size_t i = 0;
- for (/**/; it != end2 && i < test_data_size; ++it, ++i)
- {
- BOOST_TEST(it->id() == test_data[i]);
- }
- BOOST_TEST(it == end2);
- BOOST_TEST(i == test_data_size);
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/regression008.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression008.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,115 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2010 Mathias Gaunard
-//
-// Distributed under 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)
-
-// #define BOOST_SPIRIT_LEXERTL_DEBUG 1
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/support_multi_pass.hpp>
-#include <boost/spirit/include/classic_position_iterator.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-
-#include <boost/spirit/home/phoenix/core.hpp>
-#include <boost/spirit/home/phoenix/operator.hpp>
-#include <boost/spirit/home/phoenix/statement.hpp>
-#include <boost/spirit/home/phoenix/object.hpp>
-#include <boost/spirit/home/phoenix/stl.hpp>
-
-namespace spirit = boost::spirit;
-namespace lex = spirit::lex;
-namespace phoenix = boost::phoenix;
-
-typedef spirit::classic::position_iterator2<
- spirit::multi_pass<std::istreambuf_iterator<char> >
-> file_iterator;
-
-inline file_iterator
-make_file_iterator(std::istream& input, const std::string& filename)
-{
- return file_iterator(
- spirit::make_default_multi_pass(
- std::istreambuf_iterator<char>(input)),
- spirit::multi_pass<std::istreambuf_iterator<char> >(),
- filename);
-}
-
-struct identifier
-{
- identifier(file_iterator begin, file_iterator end)
- {
- }
-};
-
-struct string_literal
-{
- string_literal(file_iterator begin, file_iterator end)
- {
- }
-};
-
-typedef lex::lexertl::token<
- file_iterator, boost::mpl::vector<identifier, string_literal>
-> token_type;
-
-struct lexer
- : lex::lexer<lex::lexertl::actor_lexer<token_type> >
-{
- lexer()
- : id("[a-zA-Z0-9]+", 1)
- , st("'[^'\\n]*'", 2)
- {
- self = id [
- lex::_state = "ST"
- ]
- | lex::token_def<>(".", 3) [
- lex::_state = "ST"
- ]
- ;
-
- self("ST") =
- st [
- lex::_state = "INITIAL"
- ]
- | lex::token_def<>(".", 4) [
- lex::_state = "INITIAL"
- , lex::_pass = lex::pass_flags::pass_fail
- ]
- ;
- }
-
- lex::token_def<identifier> id;
- lex::token_def<string_literal> st;
-};
-
-typedef lexer::iterator_type token_iterator;
-
-int main()
-{
- std::stringstream ss;
- ss << "foo 'bar'";
-
- file_iterator begin = make_file_iterator(ss, "SS");
- file_iterator end;
-
- lexer l;
- token_iterator begin2 = l.begin(begin, end, "ST");
- token_iterator end2 = l.end();
-
- std::size_t test_data[] = { 1, 3, 2 };
- std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
-
- token_iterator it = begin2;
- std::size_t i = 0;
- for (/**/; it != end2 && i < test_data_size; ++it, ++i)
- {
- BOOST_TEST(it->id() == test_data[i]);
- }
- BOOST_TEST(it == end2);
- BOOST_TEST(i == test_data_size);
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/regression009.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression009.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,103 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2010 Mathias Gaunard
-//
-// Distributed under 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)
-
-#define BOOST_SPIRIT_DEBUG 1 // required for token streaming
-// #define BOOST_SPIRIT_LEXERTL_DEBUG 1
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/support_multi_pass.hpp>
-#include <boost/spirit/include/classic_position_iterator.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-
-#include <boost/spirit/home/phoenix/core.hpp>
-#include <boost/spirit/home/phoenix/operator.hpp>
-#include <boost/spirit/home/phoenix/statement.hpp>
-#include <boost/spirit/home/phoenix/object.hpp>
-
-#include <sstream>
-
-namespace spirit = boost::spirit;
-namespace lex = spirit::lex;
-namespace phoenix = boost::phoenix;
-
-typedef spirit::classic::position_iterator2<
- spirit::multi_pass<std::istreambuf_iterator<char> >
-> file_iterator;
-
-typedef boost::iterator_range<file_iterator> file_range;
-
-inline file_iterator
-make_file_iterator(std::istream& input, const std::string& filename)
-{
- return file_iterator(
- spirit::make_default_multi_pass(
- std::istreambuf_iterator<char>(input)),
- spirit::multi_pass<std::istreambuf_iterator<char> >(),
- filename);
-}
-
-struct string_literal
-{
- string_literal(file_iterator begin, file_iterator end)
- {
- }
-};
-
-typedef lex::lexertl::token<
- file_iterator, boost::mpl::vector<string_literal>
-> token_type;
-
-struct lexer
- : lex::lexer<lex::lexertl::actor_lexer<token_type> >
-{
- lexer() : st("'[^'\\n]*'", 1)
- {
- lex::token_def<> string_lookahead('\'');
- self("LA") = string_lookahead;
-
- // make sure lookahead is implicitly evaluated using the lexer state
- // the token_def has been associated with
- self = st [
- phoenix::if_(lex::lookahead(string_lookahead)) [ lex::more() ]
- ]
- ;
- }
-
- lex::token_def<string_literal> st;
-};
-
-typedef lexer::iterator_type token_iterator;
-
-int main()
-{
- std::stringstream ss;
- ss << "'foo''bar'";
-
- file_iterator begin = make_file_iterator(ss, "SS");
- file_iterator end;
-
- lexer l;
- token_iterator begin2 = l.begin(begin, end);
- token_iterator end2 = l.end();
-
- char const* test_data[] = { "1,'foo'", "1,'foo''bar'" };
- std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
-
- token_iterator it = begin2;
- std::size_t i = 0;
- for (/**/; it != end2 && i < test_data_size; ++it, ++i)
- {
- std::stringstream ss;
- ss << it->id() << "," << *it;
- BOOST_TEST(ss.str() == test_data[i]);
- }
- BOOST_TEST(it == end2);
- BOOST_TEST(i == test_data_size);
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/regression010.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/regression010.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,100 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2010 Mathias Gaunard
-//
-// Distributed under 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)
-
-// This test makes sure that the BOL state (begin of line) is properly reset
-// if a token matched at the beginning of a line is discarded using
-// lex::pass_fail.
-
-// #define BOOST_SPIRIT_LEXERTL_DEBUG 1
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/support_multi_pass.hpp>
-#include <boost/spirit/include/classic_position_iterator.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-
-#include <boost/spirit/home/phoenix/core.hpp>
-#include <boost/spirit/home/phoenix/operator.hpp>
-#include <boost/spirit/home/phoenix/statement.hpp>
-#include <boost/spirit/home/phoenix/object.hpp>
-
-namespace spirit = boost::spirit;
-namespace lex = spirit::lex;
-namespace phoenix = boost::phoenix;
-
-typedef spirit::classic::position_iterator2<
- spirit::multi_pass<std::istreambuf_iterator<char> >
-> file_iterator;
-
-inline file_iterator
-make_file_iterator(std::istream& input, const std::string& filename)
-{
- return file_iterator(
- spirit::make_default_multi_pass(
- std::istreambuf_iterator<char>(input)),
- spirit::multi_pass<std::istreambuf_iterator<char> >(),
- filename);
-}
-
-typedef lex::lexertl::token<file_iterator> token_type;
-
-struct lexer
- : lex::lexer<lex::lexertl::actor_lexer<token_type> >
-{
- lexer() : word("^[a-zA-Z0-9]+$", 1)
- {
- self = word [
- lex::_state = "O"
- ]
- | lex::token_def<>("!.*$") [
- lex::_state = "O"
- , lex::_pass = lex::pass_flags::pass_ignore
- ]
- | lex::token_def<>('\n', 2) [
- lex::_state = "O"
- ]
- ;
-
- self("O") =
- lex::token_def<>(".") [
- lex::_state = "INITIAL"
- , lex::_pass = lex::pass_flags::pass_fail
- ]
- ;
- }
-
- lex::token_def<> word;
-};
-
-typedef lexer::iterator_type token_iterator;
-
-int main()
-{
- std::stringstream ss;
- ss << "!foo\nbar\n!baz";
-
- file_iterator begin = make_file_iterator(ss, "SS");
- file_iterator end;
-
- lexer l;
- token_iterator begin2 = l.begin(begin, end);
- token_iterator end2 = l.end();
-
- std::size_t test_data[] = { 2, 1, 2 };
- std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
-
- token_iterator it = begin2;
- std::size_t i = 0;
- for (/**/; it != end2 && i < test_data_size; ++it, ++i)
- {
- BOOST_TEST(it->id() == test_data[i]);
- }
- BOOST_TEST(it == end2);
- BOOST_TEST(i == test_data_size);
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/lex/state_switcher_test.cpp
==============================================================================
--- trunk/libs/spirit/test/lex/state_switcher_test.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,90 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/include/lex_lexertl.hpp>
-#include "test_parser.hpp"
-
-///////////////////////////////////////////////////////////////////////////////
-// Token definition
-///////////////////////////////////////////////////////////////////////////////
-template <typename Lexer>
-struct switch_state_tokens : boost::spirit::lex::lexer<Lexer>
-{
- switch_state_tokens()
- {
- // define tokens and associate them with the lexer
- identifier = "[a-zA-Z_][a-zA-Z0-9_]*";
- this->self = identifier;
-
- // any token definition to be used as the skip parser during parsing
- // has to be associated with a separate lexer state (here 'WS')
- white_space = "[ \\t\\n]+";
- this->self("WS") = white_space;
-
- separators = "[,;]";
- this->self("SEP") = separators;
- }
-
- boost::spirit::lex::token_def<> identifier, white_space, separators;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-int main()
-{
- using namespace boost::spirit;
- using namespace boost::spirit::qi;
- using namespace spirit_test;
-
- typedef std::string::iterator base_iterator_type;
- typedef boost::spirit::lex::lexertl::token<base_iterator_type> token_type;
- typedef boost::spirit::lex::lexertl::lexer<token_type> lexer_type;
-
- {
- // the tokens class will be initialized inside the test_parser function
- switch_state_tokens<lexer_type> lex;
-
- BOOST_TEST(test_parser("ident", lex.identifier, lex));
- BOOST_TEST(!test_parser("ident", set_state("WS") >> lex.identifier, lex));
- BOOST_TEST(!test_parser("ident", in_state("WS")[lex.identifier], lex));
-
- BOOST_TEST(test_parser("\t \n", set_state("WS") >> lex.white_space, lex));
- BOOST_TEST(test_parser("\t \n", in_state("WS")[lex.white_space], lex));
- BOOST_TEST(!test_parser("\t \n", lex.white_space, lex));
- }
-
- {
- // the tokens class will be initialized inside the test_parser function
- switch_state_tokens<lexer_type> lex;
-
- BOOST_TEST(test_parser(",ident", lex.identifier, lex,
- in_state("SEP")[lex.separators]));
- BOOST_TEST(!test_parser(";ident", set_state("WS") >> lex.identifier,
- lex, in_state("SEP")[lex.separators]));
- BOOST_TEST(!test_parser(",ident", in_state("WS")[lex.identifier],
- lex, in_state("SEP")[lex.separators]));
-
- BOOST_TEST(test_parser(",\t \n", set_state("WS") >> lex.white_space,
- lex, in_state("SEP")[lex.separators]));
- BOOST_TEST(test_parser(";\t \n", in_state("WS")[lex.white_space],
- lex, in_state("SEP")[lex.separators]));
- BOOST_TEST(!test_parser(",\t \n", lex.white_space, lex,
- in_state("SEP")[lex.separators]));
- }
-
- {
- // the tokens class will be initialized inside the test_parser function
- switch_state_tokens<lexer_type> lex;
-
- BOOST_TEST(test_parser("ident\t \n",
- lex.identifier >> set_state("WS") >> lex.white_space, lex));
- BOOST_TEST(test_parser("\t \nident",
- in_state("WS")[lex.white_space] >> lex.identifier, lex));
- }
-
- return boost::report_errors();
-}
-

Deleted: trunk/libs/spirit/test/qi/attr_with_action.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/attr_with_action.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,27 +0,0 @@
-// Copyright (c) 2010 Daniel James
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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)
-
-// this is a compile only regression test
-
-#include <boost/config/warning_disable.hpp>
-#include <boost/spirit/include/qi.hpp>
-
-namespace qi = boost::spirit::qi;
-
-struct source_mode {};
-
-struct process_type
-{
- template <typename A, typename B, typename C>
- void operator()(A&, B&, C&) const {}
-};
-
-int main()
-{
- process_type process;
- qi::rule<char const*> x = qi::attr(source_mode()) [process];
- return 0;
-}
\ No newline at end of file

Deleted: trunk/libs/spirit/test/qi/attribute.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/attribute.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,267 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Hartmut Kaiser
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/fusion/include/struct.hpp>
-#include <boost/fusion/include/nview.hpp>
-
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_string.hpp>
-#include <boost/spirit/include/qi_numeric.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/spirit/include/qi_nonterminal.hpp>
-#include <boost/spirit/include/qi_auxiliary.hpp>
-
-#include <iostream>
-#include <vector>
-#include <string>
-#include "test.hpp"
-
-///////////////////////////////////////////////////////////////////////////////
-struct test_data
-{
- std::string s1;
- std::string s2;
- int i1;
- double d1;
- std::string s3;
-};
-
-BOOST_FUSION_ADAPT_STRUCT(
- test_data,
- (int, i1)
- (std::string, s1)
- (std::string, s2)
- (std::string, s3)
- (double, d1)
-)
-
-///////////////////////////////////////////////////////////////////////////////
-struct test_int_data1
-{
- int i;
-};
-
-// we provide a custom attribute transformation taking copy of the actual
-// attribute value, simulating more complex type transformations
-namespace boost { namespace spirit { namespace traits
-{
- template <>
- struct transform_attribute<test_int_data1, int, qi::domain>
- {
- typedef int type;
- static int pre(test_int_data1& d) { return d.i; }
- static void post(test_int_data1& d, int i) { d.i = i; }
- static void fail(test_int_data1&) {}
- };
-}}}
-
-///////////////////////////////////////////////////////////////////////////////
-struct test_int_data2
-{
- int i;
-};
-
-// we provide a simple custom attribute transformation utilizing passing the
-// actual attribute by reference
-namespace boost { namespace spirit { namespace traits
-{
- template <>
- struct transform_attribute<test_int_data2, int, qi::domain>
- {
- typedef int& type;
- static int& pre(test_int_data2& d) { return d.i; }
- static void post(test_int_data2&, int const&) {}
- static void fail(test_int_data2&) {}
- };
-}}}
-
-///////////////////////////////////////////////////////////////////////////////
-int
-main()
-{
- using spirit_test::test_attr;
- namespace qi = boost::spirit::qi;
- namespace fusion = boost::fusion;
-
- // testing attribute reordering in a fusion sequence as explicit attribute
- {
- typedef fusion::result_of::as_nview<test_data, 1, 0, 4>::type
- test_view;
-
- test_data d1 = { "", "", 0, 0.0, "" };
- test_view v1 = fusion::as_nview<1, 0, 4>(d1);
- BOOST_TEST(test_attr("s1,2,1.5",
- *(qi::char_ - ',') >> ',' >> qi::int_ >> ',' >> qi::double_, v1));
- BOOST_TEST(d1.i1 == 2 && d1.s1 == "s1" && d1.d1 == 1.5);
-
- test_data d2 = { "", "", 0, 0.0, "" };
- test_view v2 = fusion::as_nview<1, 0, 4>(d2);
- BOOST_TEST(test_attr("s1, 2, 1.5 ",
- *(qi::char_ - ',') >> ',' >> qi::int_ >> ',' >> qi::double_,
- v2, qi::space));
- BOOST_TEST(d2.i1 == 2 && d2.s1 == "s1" && d2.d1 == 1.5);
- }
-
- {
- // this won't work without the second template argument as *digit
- // exposes a vector<char> as its attribute
- std::string str;
- BOOST_TEST(test_attr("123"
- , qi::attr_cast<std::string, std::string>(*qi::digit), str));
- BOOST_TEST(str == "123");
- }
-
- // testing attribute reordering in a fusion sequence involving a rule
- {
- typedef fusion::result_of::as_nview<test_data, 1, 0, 4>::type
- test_view;
- std::vector<test_data> v;
-
- qi::rule<char const*, test_view()> r1 =
- *(qi::char_ - ',') >> ',' >> qi::int_ >> ',' >> qi::double_;
-
- BOOST_TEST(test_attr("s1,2,1.5\ns2,4,3.5", r1 % qi::eol, v));
- BOOST_TEST(v.size() == 2 &&
- v[0].i1 == 2 && v[0].s1 == "s1" && v[0].d1 == 1.5 &&
- v[1].i1 == 4 && v[1].s1 == "s2" && v[1].d1 == 3.5);
-
- qi::rule<char const*, test_view(), qi::blank_type> r2 =
- *(qi::char_ - ',') >> ',' >> qi::int_ >> ',' >> qi::double_;
-
- v.clear();
- BOOST_TEST(test_attr("s1, 2, 1.5 \n s2, 4, 3.5", r2 % qi::eol, v, qi::blank));
- BOOST_TEST(v.size() == 2 &&
- v[0].i1 == 2 && v[0].s1 == "s1" && v[0].d1 == 1.5 &&
- v[1].i1 == 4 && v[1].s1 == "s2" && v[1].d1 == 3.5);
- }
-
- // testing explicit transformation if attribute needs to be copied
- {
- test_int_data1 d = { 0 };
- BOOST_TEST(test_attr("1", qi::attr_cast(qi::int_), d));
- BOOST_TEST(d.i == 1);
- BOOST_TEST(test_attr("2", qi::attr_cast<test_int_data1>(qi::int_), d));
- BOOST_TEST(d.i == 2);
- BOOST_TEST(test_attr("3", qi::attr_cast<test_int_data1, int>(qi::int_), d));
- BOOST_TEST(d.i == 3);
- }
-
- {
- std::vector<test_int_data1> v;
-
- BOOST_TEST(test_attr("1,2", qi::attr_cast(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- v.clear();
- BOOST_TEST(test_attr("1,2"
- , qi::attr_cast<test_int_data1>(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- v.clear();
- BOOST_TEST(test_attr("1,2"
- , qi::attr_cast<test_int_data1, int>(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- {
- std::vector<test_int_data1> v;
- qi::rule<char const*, int()> r = qi::int_;
-
- BOOST_TEST(test_attr("1,2", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- {
- std::vector<double> v;
- qi::rule<char const*, int()> r = qi::int_;
-
- BOOST_TEST(test_attr("1,2", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0] == 1.0 && v[1] == 2.0);
- }
-
- {
- std::vector<test_int_data1> v;
-
-// this won't compile as there is no defined transformation for
-// test_int_data1 and double
-// BOOST_TEST(test_attr("1.0,2.2", qi::attr_cast(qi::double_) % ',', v));
-// BOOST_TEST(test_attr("1.0,2.2"
-// , qi::attr_cast<test_int_data1>(qi::double_) % ',', v));
-
- BOOST_TEST(test_attr("1.0,2.2"
- , qi::attr_cast<test_int_data1, int>(qi::double_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- qi::rule<char const*, int()> r = qi::double_;
-
- v.clear();
- BOOST_TEST(test_attr("1.0,2.0", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- // testing explicit transformation if attribute is taken by reference
- {
- test_int_data2 d = { 0 };
- BOOST_TEST(test_attr("1", qi::attr_cast(qi::int_), d));
- BOOST_TEST(d.i == 1);
- BOOST_TEST(test_attr("2", qi::attr_cast<test_int_data2>(qi::int_), d));
- BOOST_TEST(d.i == 2);
- BOOST_TEST(test_attr("3", qi::attr_cast<test_int_data2, int>(qi::int_), d));
- BOOST_TEST(d.i == 3);
- }
-
- {
- std::vector<test_int_data2> v;
-
- BOOST_TEST(test_attr("1,2", qi::attr_cast(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- v.clear();
- BOOST_TEST(test_attr("1,2"
- , qi::attr_cast<test_int_data2>(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- v.clear();
- BOOST_TEST(test_attr("1,2"
- , qi::attr_cast<test_int_data2, int>(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- {
- std::vector<test_int_data2> v;
- qi::rule<char const*, int()> r = qi::int_;
-
- BOOST_TEST(test_attr("1,2", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- {
- std::vector<test_int_data2> v;
-
-// this won't compile as there is no defined transformation for
-// test_int_data2 and double
-// BOOST_TEST(test_attr("1.0,2.2", qi::attr_cast(qi::double_) % ',', v));
-// BOOST_TEST(test_attr("1.0,2.2"
-// , qi::attr_cast<test_int_data2>(qi::double_) % ',', v));
-
- BOOST_TEST(test_attr("1.0,2.2"
- , qi::attr_cast<test_int_data2, int>(qi::double_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- qi::rule<char const*, int()> r = qi::double_;
-
- v.clear();
- BOOST_TEST(test_attr("1.0,2.0", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- return boost::report_errors();
-}

Copied: trunk/libs/spirit/test/qi/attribute1.cpp (from r67483, /trunk/libs/spirit/test/qi/attribute.cpp)
==============================================================================
--- /trunk/libs/spirit/test/qi/attribute.cpp (original)
+++ trunk/libs/spirit/test/qi/attribute1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -171,97 +171,5 @@
         BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
     }
 
- {
- std::vector<test_int_data1> v;
- qi::rule<char const*, int()> r = qi::int_;
-
- BOOST_TEST(test_attr("1,2", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- {
- std::vector<double> v;
- qi::rule<char const*, int()> r = qi::int_;
-
- BOOST_TEST(test_attr("1,2", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0] == 1.0 && v[1] == 2.0);
- }
-
- {
- std::vector<test_int_data1> v;
-
-// this won't compile as there is no defined transformation for
-// test_int_data1 and double
-// BOOST_TEST(test_attr("1.0,2.2", qi::attr_cast(qi::double_) % ',', v));
-// BOOST_TEST(test_attr("1.0,2.2"
-// , qi::attr_cast<test_int_data1>(qi::double_) % ',', v));
-
- BOOST_TEST(test_attr("1.0,2.2"
- , qi::attr_cast<test_int_data1, int>(qi::double_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- qi::rule<char const*, int()> r = qi::double_;
-
- v.clear();
- BOOST_TEST(test_attr("1.0,2.0", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- // testing explicit transformation if attribute is taken by reference
- {
- test_int_data2 d = { 0 };
- BOOST_TEST(test_attr("1", qi::attr_cast(qi::int_), d));
- BOOST_TEST(d.i == 1);
- BOOST_TEST(test_attr("2", qi::attr_cast<test_int_data2>(qi::int_), d));
- BOOST_TEST(d.i == 2);
- BOOST_TEST(test_attr("3", qi::attr_cast<test_int_data2, int>(qi::int_), d));
- BOOST_TEST(d.i == 3);
- }
-
- {
- std::vector<test_int_data2> v;
-
- BOOST_TEST(test_attr("1,2", qi::attr_cast(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- v.clear();
- BOOST_TEST(test_attr("1,2"
- , qi::attr_cast<test_int_data2>(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- v.clear();
- BOOST_TEST(test_attr("1,2"
- , qi::attr_cast<test_int_data2, int>(qi::int_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- {
- std::vector<test_int_data2> v;
- qi::rule<char const*, int()> r = qi::int_;
-
- BOOST_TEST(test_attr("1,2", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
- {
- std::vector<test_int_data2> v;
-
-// this won't compile as there is no defined transformation for
-// test_int_data2 and double
-// BOOST_TEST(test_attr("1.0,2.2", qi::attr_cast(qi::double_) % ',', v));
-// BOOST_TEST(test_attr("1.0,2.2"
-// , qi::attr_cast<test_int_data2>(qi::double_) % ',', v));
-
- BOOST_TEST(test_attr("1.0,2.2"
- , qi::attr_cast<test_int_data2, int>(qi::double_) % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
-
- qi::rule<char const*, int()> r = qi::double_;
-
- v.clear();
- BOOST_TEST(test_attr("1.0,2.0", r % ',', v));
- BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
- }
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/qi/attribute2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/attribute2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,187 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Hartmut Kaiser
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/fusion/include/struct.hpp>
+#include <boost/fusion/include/nview.hpp>
+
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_nonterminal.hpp>
+#include <boost/spirit/include/qi_auxiliary.hpp>
+
+#include <iostream>
+#include <vector>
+#include <string>
+#include "test.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+struct test_data
+{
+ std::string s1;
+ std::string s2;
+ int i1;
+ double d1;
+ std::string s3;
+};
+
+BOOST_FUSION_ADAPT_STRUCT(
+ test_data,
+ (int, i1)
+ (std::string, s1)
+ (std::string, s2)
+ (std::string, s3)
+ (double, d1)
+)
+
+///////////////////////////////////////////////////////////////////////////////
+struct test_int_data1
+{
+ int i;
+};
+
+// we provide a custom attribute transformation taking copy of the actual
+// attribute value, simulating more complex type transformations
+namespace boost { namespace spirit { namespace traits
+{
+ template <>
+ struct transform_attribute<test_int_data1, int, qi::domain>
+ {
+ typedef int type;
+ static int pre(test_int_data1& d) { return d.i; }
+ static void post(test_int_data1& d, int i) { d.i = i; }
+ static void fail(test_int_data1&) {}
+ };
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
+struct test_int_data2
+{
+ int i;
+};
+
+// we provide a simple custom attribute transformation utilizing passing the
+// actual attribute by reference
+namespace boost { namespace spirit { namespace traits
+{
+ template <>
+ struct transform_attribute<test_int_data2, int, qi::domain>
+ {
+ typedef int& type;
+ static int& pre(test_int_data2& d) { return d.i; }
+ static void post(test_int_data2&, int const&) {}
+ static void fail(test_int_data2&) {}
+ };
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using spirit_test::test_attr;
+ namespace qi = boost::spirit::qi;
+ namespace fusion = boost::fusion;
+
+ {
+ std::vector<test_int_data1> v;
+ qi::rule<char const*, int()> r = qi::int_;
+
+ BOOST_TEST(test_attr("1,2", r % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+ }
+
+ {
+ std::vector<double> v;
+ qi::rule<char const*, int()> r = qi::int_;
+
+ BOOST_TEST(test_attr("1,2", r % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0] == 1.0 && v[1] == 2.0);
+ }
+
+ {
+ std::vector<test_int_data1> v;
+
+// this won't compile as there is no defined transformation for
+// test_int_data1 and double
+// BOOST_TEST(test_attr("1.0,2.2", qi::attr_cast(qi::double_) % ',', v));
+// BOOST_TEST(test_attr("1.0,2.2"
+// , qi::attr_cast<test_int_data1>(qi::double_) % ',', v));
+
+ BOOST_TEST(test_attr("1.0,2.2"
+ , qi::attr_cast<test_int_data1, int>(qi::double_) % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+
+ qi::rule<char const*, int()> r = qi::double_;
+
+ v.clear();
+ BOOST_TEST(test_attr("1.0,2.0", r % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+ }
+
+ // testing explicit transformation if attribute is taken by reference
+ {
+ test_int_data2 d = { 0 };
+ BOOST_TEST(test_attr("1", qi::attr_cast(qi::int_), d));
+ BOOST_TEST(d.i == 1);
+ BOOST_TEST(test_attr("2", qi::attr_cast<test_int_data2>(qi::int_), d));
+ BOOST_TEST(d.i == 2);
+ BOOST_TEST(test_attr("3", qi::attr_cast<test_int_data2, int>(qi::int_), d));
+ BOOST_TEST(d.i == 3);
+ }
+
+ {
+ std::vector<test_int_data2> v;
+
+ BOOST_TEST(test_attr("1,2", qi::attr_cast(qi::int_) % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+
+ v.clear();
+ BOOST_TEST(test_attr("1,2"
+ , qi::attr_cast<test_int_data2>(qi::int_) % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+
+ v.clear();
+ BOOST_TEST(test_attr("1,2"
+ , qi::attr_cast<test_int_data2, int>(qi::int_) % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+ }
+
+ {
+ std::vector<test_int_data2> v;
+ qi::rule<char const*, int()> r = qi::int_;
+
+ BOOST_TEST(test_attr("1,2", r % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+ }
+
+ {
+ std::vector<test_int_data2> v;
+
+// this won't compile as there is no defined transformation for
+// test_int_data2 and double
+// BOOST_TEST(test_attr("1.0,2.2", qi::attr_cast(qi::double_) % ',', v));
+// BOOST_TEST(test_attr("1.0,2.2"
+// , qi::attr_cast<test_int_data2>(qi::double_) % ',', v));
+
+ BOOST_TEST(test_attr("1.0,2.2"
+ , qi::attr_cast<test_int_data2, int>(qi::double_) % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+
+ qi::rule<char const*, int()> r = qi::double_;
+
+ v.clear();
+ BOOST_TEST(test_attr("1.0,2.0", r % ',', v));
+ BOOST_TEST(v.size() == 2 && v[0].i == 1 && v[1].i == 2);
+ }
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/qi/clear_test.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/clear_test.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,38 +0,0 @@
-// Copyright (c) 2010 Daniel James
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/qi.hpp>
-#include <vector>
-
-int main()
-{
- typedef char const* Iterator;
- namespace qi = boost::spirit::qi;
-
- qi::rule<Iterator, std::vector<boost::iterator_range<Iterator> >()> list;
- list = *qi::raw[qi::char_]; // This fails to compile
-
- char const* test = "abcdef";
- int test_length = 6;
- char const* test_begin = test;
- char const* test_end = test + test_length;
- std::vector<boost::iterator_range<Iterator> > result;
- bool r = qi::parse(test_begin, test_end, list, result);
-
- BOOST_TEST(r);
- BOOST_TEST(test_begin == test_end);
- BOOST_TEST(result.size() == test_length);
-
- for(int i = 0; i < test_length; ++i) {
- BOOST_TEST(result[i].begin() == test + i);
- BOOST_TEST(result[i].end() == test + i + 1);
- }
-
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/qi/debug_optional.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/debug_optional.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,24 +0,0 @@
-// Copyright (c) 2010 Carl Philipp Reh
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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)
-
-// make sure optionals play well with debug output
-
-#define BOOST_SPIRIT_DEBUG
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/home/support/attributes.hpp>
-#include <boost/optional.hpp>
-
-int main()
-{
- boost::spirit::qi::rule<
- char const *,
- boost::optional<int>()
- > foo;
-
- BOOST_SPIRIT_DEBUG_NODE(foo);
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/qi/match_manip.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/match_manip.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,328 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Hartmut Kaiser
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under 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 <boost/config/warning_disable.hpp>
-
-#include <boost/spirit/include/support_argument.hpp>
-#include <boost/spirit/include/qi_action.hpp>
-#include <boost/spirit/include/qi_numeric.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/spirit/include/qi_stream.hpp>
-#include <boost/spirit/include/qi_match.hpp>
-#include <boost/spirit/include/qi_match_auto.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-
-#include <string>
-#include <sstream>
-#include <vector>
-#include <list>
-
-#include <boost/detail/lightweight_test.hpp>
-
-///////////////////////////////////////////////////////////////////////////////
-template <typename Char, typename Expr>
-bool test(Char const *toparse, Expr const& expr)
-{
- namespace spirit = boost::spirit;
- BOOST_SPIRIT_ASSERT_MATCH(spirit::qi::domain, Expr);
-
- std::istringstream istrm(toparse);
- istrm.unsetf(std::ios::skipws);
- istrm >> spirit::qi::compile<spirit::qi::domain>(expr);
- return istrm.good() || istrm.eof();
-}
-
-template <typename Char, typename Expr, typename CopyExpr, typename CopyAttr
- , typename Skipper, typename Attribute>
-bool test(Char const *toparse,
- boost::spirit::qi::detail::match_manip<
- Expr, CopyExpr, CopyAttr, Skipper, Attribute> const& mm)
-{
- std::istringstream istrm(toparse);
- istrm.unsetf(std::ios::skipws);
- istrm >> mm;
- return istrm.good() || istrm.eof();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-bool is_list_ok(std::list<char> const& l)
-{
- std::list<char>::const_iterator cit = l.begin();
- if (cit == l.end() || *cit != 'a')
- return false;
- if (++cit == l.end() || *cit != 'b')
- return false;
-
- return ++cit != l.end() && *cit == 'c';
-}
-
-///////////////////////////////////////////////////////////////////////////////
-int
-main()
-{
- using boost::spirit::qi::_1;
- using boost::spirit::qi::_2;
- using boost::spirit::qi::match;
- using boost::spirit::qi::phrase_match;
- using boost::spirit::qi::typed_stream;
- using boost::spirit::qi::stream;
- using boost::spirit::qi::int_;
-
- using namespace boost::spirit::ascii;
- namespace fusion = boost::fusion;
- namespace phx = boost::phoenix;
-
- {
- char c = '\0';
- BOOST_TEST(test( "a",
- char_[phx::ref(c) = _1]
- ) && c == 'a');
-
- c = '\0';
- BOOST_TEST(test( "a",
- match(char_[phx::ref(c) = _1])
- ) && c == 'a');
-
- c = '\0';
- BOOST_TEST(test( " a",
- phrase_match(char_[phx::ref(c) = _1], space)
- ) && c == 'a');
-
- c = '\0';
- BOOST_TEST(test( "a",
- match(char_, c)
- ) && c == 'a');
-
- c = '\0';
- BOOST_TEST(test( " a",
- phrase_match(char_, space, c)
- ) && c == 'a');
- }
-
- {
- ///////////////////////////////////////////////////////////////////////
- typedef typed_stream<char> char_stream_type;
- char_stream_type const char_stream = char_stream_type();
-
- typedef typed_stream<int> int_stream_type;
- int_stream_type const int_stream = int_stream_type();
-
- ///////////////////////////////////////////////////////////////////////
- char c = '\0';
- BOOST_TEST(test( "a",
- char_stream[phx::ref(c) = _1]
- ) && c == 'a');
-
- c = '\0';
- BOOST_TEST(test( "a",
- match(char_stream[phx::ref(c) = _1])
- ) && c == 'a');
-
- c = '\0';
- BOOST_TEST(test( " a",
- phrase_match(char_stream[phx::ref(c) = _1], space)
- ) && c == 'a');
-
- int i = 0;
- BOOST_TEST(test( "42",
- int_stream[phx::ref(i) = _1]
- ) && i == 42);
-
- i = 0;
- BOOST_TEST(test( "42",
- match(int_stream[phx::ref(i) = _1])
- ) && i == 42);
-
- i = 0;
- BOOST_TEST(test( " 42",
- phrase_match(int_stream[phx::ref(i) = _1], space)
- ) && i == 42);
-
- ///////////////////////////////////////////////////////////////////////
- c = '\0';
- BOOST_TEST(test( "a",
- match(stream, c)
- ) && c == 'a');
-
- c = '\0';
- BOOST_TEST(test( " a",
- phrase_match(stream, space, c)
- ) && c == 'a');
-
- i = 0;
- BOOST_TEST(test( "42",
- match(stream, i)
- ) && i == 42);
-
- i = 0;
- BOOST_TEST(test( " 42",
- phrase_match(stream, space, i)
- ) && i == 42);
- }
-
- {
- char a = '\0', b = '\0';
- BOOST_TEST(test( "ab",
- char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1]
- ) && a == 'a' && b == 'b');
-
- a = '\0', b = '\0';
- BOOST_TEST(test( "ab",
- match(char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1])
- ) && a == 'a' && b == 'b');
-
- a = '\0', b = '\0';
- BOOST_TEST(test( " a b",
- phrase_match(char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1], space)
- ) && a == 'a' && b == 'b');
-
- fusion::vector<char, char> t;
- BOOST_TEST(test( "ab",
- match(char_ >> char_, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b');
-
- t = fusion::vector<char, char>();
- BOOST_TEST(test( " a b",
- phrase_match(char_ >> char_, space, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b');
- }
-
- {
- char a = '\0', b = '\0', c = '\0';
- BOOST_TEST(test( "abc",
- char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1] >> char_[phx::ref(c) = _1]
- ) && a == 'a' && b == 'b' && c == 'c');
-
- BOOST_TEST(test( "abc",
- match(char_('a') >> char_('b') >> char_('c'))
- ));
-
- BOOST_TEST(test( " a b c",
- phrase_match(char_('a') >> char_('b') >> char_('c'), space)
- ));
-
- BOOST_TEST(!test( "abc",
- match(char_('a') >> char_('b') >> char_('d'))
- ));
-
- BOOST_TEST(!test( " a b c",
- phrase_match(char_('a') >> char_('b') >> char_('d'), space)
- ));
-
- fusion::vector<char, char, char> t;
- BOOST_TEST(test( "abc",
- match(char_ >> char_ >> char_, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
-
- t = fusion::vector<char, char, char>();
- BOOST_TEST(test( " a b c",
- phrase_match(char_ >> char_ >> char_, space, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
-
- t = fusion::vector<char, char, char>();
- BOOST_TEST(test( "abc",
- match(t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
-
- t = fusion::vector<char, char, char>();
- BOOST_TEST(test( " a b c",
- phrase_match(t, space)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
- }
-
- {
- char a = '\0';
- int i = 0;
- BOOST_TEST(test( "a2",
- (char_ >> int_)[phx::ref(a) = _1, phx::ref(i) = _2]
- ) && a == 'a' && i == 2);
-
- fusion::vector<char, int> t;
- BOOST_TEST(test( "a2",
- match(char_ >> int_, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 2);
-
- t = fusion::vector<char, int>();
- BOOST_TEST(test( " a 2",
- phrase_match(char_ >> int_, space, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 2);
-
- BOOST_TEST(!test( "a2",
- match(char_ >> alpha, t)
- ));
- BOOST_TEST(!test( " a 2",
- phrase_match(char_ >> alpha, space, t)
- ));
- }
-
- {
- // parse elements of a vector
- std::vector<char> v;
- BOOST_TEST(test( "abc",
- (*char_)[phx::ref(v) = _1]
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( "abc",
- match(*char_, v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( " a b c",
- phrase_match(*char_, space, v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( "abc",
- match(v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( " a b c",
- phrase_match(v, space)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- // parse a comma separated list of vector elements
- v.clear();
- BOOST_TEST(test( "a,b,c",
- match(char_ % ',', v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( " a , b , c",
- phrase_match(char_ % ',', space, v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- // output all elements of a list
- std::list<char> l;
- BOOST_TEST(test( "abc",
- match(*char_, l)
- ) && 3 == l.size() && is_list_ok(l));
-
- l.clear();
- BOOST_TEST(test( " a b c",
- phrase_match(*char_, space, l)
- ) && 3 == l.size() && is_list_ok(l));
-
- l.clear();
- BOOST_TEST(test( "abc",
- match(l)
- ) && 3 == l.size() && is_list_ok(l));
-
- l.clear();
- BOOST_TEST(test( " a b c",
- phrase_match(l, space)
- ) && 3 == l.size() && is_list_ok(l));
- }
-
- return boost::report_errors();
-}
-

Added: trunk/libs/spirit/test/qi/match_manip.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/match_manip.hpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,70 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Hartmut Kaiser
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ Distributed under 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)
+=============================================================================*/
+#if !defined(BOOST_SPIRIT_TEST_MATCH_MANIP_HPP)
+#define BOOST_SPIRIT_TEST_MATCH_MANIP_HPP
+
+#include <boost/config/warning_disable.hpp>
+
+#include <boost/spirit/include/support_argument.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_stream.hpp>
+#include <boost/spirit/include/qi_match.hpp>
+#include <boost/spirit/include/qi_match_auto.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include <string>
+#include <sstream>
+#include <vector>
+#include <list>
+
+#include <boost/detail/lightweight_test.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+template <typename Char, typename Expr>
+bool test(Char const *toparse, Expr const& expr)
+{
+ namespace spirit = boost::spirit;
+ BOOST_SPIRIT_ASSERT_MATCH(spirit::qi::domain, Expr);
+
+ std::istringstream istrm(toparse);
+ istrm.unsetf(std::ios::skipws);
+ istrm >> spirit::qi::compile<spirit::qi::domain>(expr);
+ return istrm.good() || istrm.eof();
+}
+
+template <typename Char, typename Expr, typename CopyExpr, typename CopyAttr
+ , typename Skipper, typename Attribute>
+bool test(Char const *toparse,
+ boost::spirit::qi::detail::match_manip<
+ Expr, CopyExpr, CopyAttr, Skipper, Attribute> const& mm)
+{
+ std::istringstream istrm(toparse);
+ istrm.unsetf(std::ios::skipws);
+ istrm >> mm;
+ return istrm.good() || istrm.eof();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+bool is_list_ok(std::list<char> const& l)
+{
+ std::list<char>::const_iterator cit = l.begin();
+ if (cit == l.end() || *cit != 'a')
+ return false;
+ if (++cit == l.end() || *cit != 'b')
+ return false;
+
+ return ++cit != l.end() && *cit == 'c';
+}
+
+#endif

Copied: trunk/libs/spirit/test/qi/match_manip1.cpp (from r67483, /trunk/libs/spirit/test/qi/match_manip.cpp)
==============================================================================
--- /trunk/libs/spirit/test/qi/match_manip.cpp (original)
+++ trunk/libs/spirit/test/qi/match_manip1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -5,66 +5,9 @@
     Distributed under 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 <boost/config/warning_disable.hpp>
 
-#include <boost/spirit/include/support_argument.hpp>
-#include <boost/spirit/include/qi_action.hpp>
-#include <boost/spirit/include/qi_numeric.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/spirit/include/qi_stream.hpp>
-#include <boost/spirit/include/qi_match.hpp>
-#include <boost/spirit/include/qi_match_auto.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_statement.hpp>
-
-#include <string>
-#include <sstream>
-#include <vector>
-#include <list>
-
-#include <boost/detail/lightweight_test.hpp>
-
-///////////////////////////////////////////////////////////////////////////////
-template <typename Char, typename Expr>
-bool test(Char const *toparse, Expr const& expr)
-{
- namespace spirit = boost::spirit;
- BOOST_SPIRIT_ASSERT_MATCH(spirit::qi::domain, Expr);
-
- std::istringstream istrm(toparse);
- istrm.unsetf(std::ios::skipws);
- istrm >> spirit::qi::compile<spirit::qi::domain>(expr);
- return istrm.good() || istrm.eof();
-}
-
-template <typename Char, typename Expr, typename CopyExpr, typename CopyAttr
- , typename Skipper, typename Attribute>
-bool test(Char const *toparse,
- boost::spirit::qi::detail::match_manip<
- Expr, CopyExpr, CopyAttr, Skipper, Attribute> const& mm)
-{
- std::istringstream istrm(toparse);
- istrm.unsetf(std::ios::skipws);
- istrm >> mm;
- return istrm.good() || istrm.eof();
-}
+#include "match_manip.hpp"
 
-///////////////////////////////////////////////////////////////////////////////
-bool is_list_ok(std::list<char> const& l)
-{
- std::list<char>::const_iterator cit = l.begin();
- if (cit == l.end() || *cit != 'a')
- return false;
- if (++cit == l.end() || *cit != 'b')
- return false;
-
- return ++cit != l.end() && *cit == 'c';
-}
-
-///////////////////////////////////////////////////////////////////////////////
 int
 main()
 {
@@ -168,161 +111,6 @@
         ) && i == 42);
     }
 
- {
- char a = '\0', b = '\0';
- BOOST_TEST(test( "ab",
- char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1]
- ) && a == 'a' && b == 'b');
-
- a = '\0', b = '\0';
- BOOST_TEST(test( "ab",
- match(char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1])
- ) && a == 'a' && b == 'b');
-
- a = '\0', b = '\0';
- BOOST_TEST(test( " a b",
- phrase_match(char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1], space)
- ) && a == 'a' && b == 'b');
-
- fusion::vector<char, char> t;
- BOOST_TEST(test( "ab",
- match(char_ >> char_, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b');
-
- t = fusion::vector<char, char>();
- BOOST_TEST(test( " a b",
- phrase_match(char_ >> char_, space, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b');
- }
-
- {
- char a = '\0', b = '\0', c = '\0';
- BOOST_TEST(test( "abc",
- char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1] >> char_[phx::ref(c) = _1]
- ) && a == 'a' && b == 'b' && c == 'c');
-
- BOOST_TEST(test( "abc",
- match(char_('a') >> char_('b') >> char_('c'))
- ));
-
- BOOST_TEST(test( " a b c",
- phrase_match(char_('a') >> char_('b') >> char_('c'), space)
- ));
-
- BOOST_TEST(!test( "abc",
- match(char_('a') >> char_('b') >> char_('d'))
- ));
-
- BOOST_TEST(!test( " a b c",
- phrase_match(char_('a') >> char_('b') >> char_('d'), space)
- ));
-
- fusion::vector<char, char, char> t;
- BOOST_TEST(test( "abc",
- match(char_ >> char_ >> char_, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
-
- t = fusion::vector<char, char, char>();
- BOOST_TEST(test( " a b c",
- phrase_match(char_ >> char_ >> char_, space, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
-
- t = fusion::vector<char, char, char>();
- BOOST_TEST(test( "abc",
- match(t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
-
- t = fusion::vector<char, char, char>();
- BOOST_TEST(test( " a b c",
- phrase_match(t, space)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
- }
-
- {
- char a = '\0';
- int i = 0;
- BOOST_TEST(test( "a2",
- (char_ >> int_)[phx::ref(a) = _1, phx::ref(i) = _2]
- ) && a == 'a' && i == 2);
-
- fusion::vector<char, int> t;
- BOOST_TEST(test( "a2",
- match(char_ >> int_, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 2);
-
- t = fusion::vector<char, int>();
- BOOST_TEST(test( " a 2",
- phrase_match(char_ >> int_, space, t)
- ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 2);
-
- BOOST_TEST(!test( "a2",
- match(char_ >> alpha, t)
- ));
- BOOST_TEST(!test( " a 2",
- phrase_match(char_ >> alpha, space, t)
- ));
- }
-
- {
- // parse elements of a vector
- std::vector<char> v;
- BOOST_TEST(test( "abc",
- (*char_)[phx::ref(v) = _1]
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( "abc",
- match(*char_, v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( " a b c",
- phrase_match(*char_, space, v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( "abc",
- match(v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( " a b c",
- phrase_match(v, space)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- // parse a comma separated list of vector elements
- v.clear();
- BOOST_TEST(test( "a,b,c",
- match(char_ % ',', v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- v.clear();
- BOOST_TEST(test( " a , b , c",
- phrase_match(char_ % ',', space, v)
- ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
-
- // output all elements of a list
- std::list<char> l;
- BOOST_TEST(test( "abc",
- match(*char_, l)
- ) && 3 == l.size() && is_list_ok(l));
-
- l.clear();
- BOOST_TEST(test( " a b c",
- phrase_match(*char_, space, l)
- ) && 3 == l.size() && is_list_ok(l));
-
- l.clear();
- BOOST_TEST(test( "abc",
- match(l)
- ) && 3 == l.size() && is_list_ok(l));
-
- l.clear();
- BOOST_TEST(test( " a b c",
- phrase_match(l, space)
- ) && 3 == l.size() && is_list_ok(l));
- }
-
     return boost::report_errors();
 }
 

Added: trunk/libs/spirit/test/qi/match_manip2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/match_manip2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,98 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Hartmut Kaiser
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ Distributed under 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 "match_manip.hpp"
+
+int
+main()
+{
+ using boost::spirit::qi::_1;
+ using boost::spirit::qi::_2;
+ using boost::spirit::qi::match;
+ using boost::spirit::qi::phrase_match;
+ using boost::spirit::qi::typed_stream;
+ using boost::spirit::qi::stream;
+ using boost::spirit::qi::int_;
+
+ using namespace boost::spirit::ascii;
+ namespace fusion = boost::fusion;
+ namespace phx = boost::phoenix;
+
+ {
+ char a = '\0', b = '\0';
+ BOOST_TEST(test( "ab",
+ char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1]
+ ) && a == 'a' && b == 'b');
+
+ a = '\0', b = '\0';
+ BOOST_TEST(test( "ab",
+ match(char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1])
+ ) && a == 'a' && b == 'b');
+
+ a = '\0', b = '\0';
+ BOOST_TEST(test( " a b",
+ phrase_match(char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1], space)
+ ) && a == 'a' && b == 'b');
+
+ fusion::vector<char, char> t;
+ BOOST_TEST(test( "ab",
+ match(char_ >> char_, t)
+ ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b');
+
+ t = fusion::vector<char, char>();
+ BOOST_TEST(test( " a b",
+ phrase_match(char_ >> char_, space, t)
+ ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b');
+ }
+
+ {
+ char a = '\0', b = '\0', c = '\0';
+ BOOST_TEST(test( "abc",
+ char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1] >> char_[phx::ref(c) = _1]
+ ) && a == 'a' && b == 'b' && c == 'c');
+
+ BOOST_TEST(test( "abc",
+ match(char_('a') >> char_('b') >> char_('c'))
+ ));
+
+ BOOST_TEST(test( " a b c",
+ phrase_match(char_('a') >> char_('b') >> char_('c'), space)
+ ));
+
+ BOOST_TEST(!test( "abc",
+ match(char_('a') >> char_('b') >> char_('d'))
+ ));
+
+ BOOST_TEST(!test( " a b c",
+ phrase_match(char_('a') >> char_('b') >> char_('d'), space)
+ ));
+
+ fusion::vector<char, char, char> t;
+ BOOST_TEST(test( "abc",
+ match(char_ >> char_ >> char_, t)
+ ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
+
+ t = fusion::vector<char, char, char>();
+ BOOST_TEST(test( " a b c",
+ phrase_match(char_ >> char_ >> char_, space, t)
+ ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
+
+ t = fusion::vector<char, char, char>();
+ BOOST_TEST(test( "abc",
+ match(t)
+ ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
+
+ t = fusion::vector<char, char, char>();
+ BOOST_TEST(test( " a b c",
+ phrase_match(t, space)
+ ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/spirit/test/qi/match_manip3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/match_manip3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,113 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Hartmut Kaiser
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ Distributed under 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 "match_manip.hpp"
+
+int
+main()
+{
+ using boost::spirit::qi::_1;
+ using boost::spirit::qi::_2;
+ using boost::spirit::qi::match;
+ using boost::spirit::qi::phrase_match;
+ using boost::spirit::qi::typed_stream;
+ using boost::spirit::qi::stream;
+ using boost::spirit::qi::int_;
+
+ using namespace boost::spirit::ascii;
+ namespace fusion = boost::fusion;
+ namespace phx = boost::phoenix;
+
+ {
+ char a = '\0';
+ int i = 0;
+ BOOST_TEST(test( "a2",
+ (char_ >> int_)[phx::ref(a) = _1, phx::ref(i) = _2]
+ ) && a == 'a' && i == 2);
+
+ fusion::vector<char, int> t;
+ BOOST_TEST(test( "a2",
+ match(char_ >> int_, t)
+ ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 2);
+
+ t = fusion::vector<char, int>();
+ BOOST_TEST(test( " a 2",
+ phrase_match(char_ >> int_, space, t)
+ ) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 2);
+
+ BOOST_TEST(!test( "a2",
+ match(char_ >> alpha, t)
+ ));
+ BOOST_TEST(!test( " a 2",
+ phrase_match(char_ >> alpha, space, t)
+ ));
+ }
+
+ {
+ // parse elements of a vector
+ std::vector<char> v;
+ BOOST_TEST(test( "abc",
+ (*char_)[phx::ref(v) = _1]
+ ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
+
+ v.clear();
+ BOOST_TEST(test( "abc",
+ match(*char_, v)
+ ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
+
+ v.clear();
+ BOOST_TEST(test( " a b c",
+ phrase_match(*char_, space, v)
+ ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
+
+ v.clear();
+ BOOST_TEST(test( "abc",
+ match(v)
+ ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
+
+ v.clear();
+ BOOST_TEST(test( " a b c",
+ phrase_match(v, space)
+ ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
+
+ // parse a comma separated list of vector elements
+ v.clear();
+ BOOST_TEST(test( "a,b,c",
+ match(char_ % ',', v)
+ ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
+
+ v.clear();
+ BOOST_TEST(test( " a , b , c",
+ phrase_match(char_ % ',', space, v)
+ ) && 3 == v.size() && v[0] == 'a' && v[1] == 'b' && v[2] == 'c');
+
+ // output all elements of a list
+ std::list<char> l;
+ BOOST_TEST(test( "abc",
+ match(*char_, l)
+ ) && 3 == l.size() && is_list_ok(l));
+
+ l.clear();
+ BOOST_TEST(test( " a b c",
+ phrase_match(*char_, space, l)
+ ) && 3 == l.size() && is_list_ok(l));
+
+ l.clear();
+ BOOST_TEST(test( "abc",
+ match(l)
+ ) && 3 == l.size() && is_list_ok(l));
+
+ l.clear();
+ BOOST_TEST(test( " a b c",
+ phrase_match(l, space)
+ ) && 3 == l.size() && is_list_ok(l));
+ }
+
+ return boost::report_errors();
+}
+

Deleted: trunk/libs/spirit/test/qi/one_element_fusion_sequence.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/one_element_fusion_sequence.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,27 +0,0 @@
-// Copyright (c) 2001-2011 Hartmut Kaiser
-// Copyright (c) 2010 Daniel James
-//
-// Distributed under 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)
-
-// This compilation test fails if proto expressions are not properly
-// distinguished from 'normal' Fusion sequences.
-
-#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/include/phoenix.hpp>
-#include <string>
-
-int main()
-{
- namespace qi = boost::spirit::qi;
- typedef std::string::const_iterator iterator;
-
- qi::symbols<char, qi::rule<iterator> > phrase_keyword_rules;
- qi::rule<iterator, qi::locals<qi::rule<iterator> > > phrase_markup_impl;
-
- phrase_markup_impl
- = (phrase_keyword_rules >> !qi::alnum) [qi::_a = qi::_1]
- ;
-
- return 0;
-}

Deleted: trunk/libs/spirit/test/qi/real.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/real.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,425 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
- Copyright (c) 2001-2010 Hartmut Kaiser
-
- 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 <climits>
-#include <boost/math/concepts/real_concept.hpp>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_numeric.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/math/special_functions/fpclassify.hpp>
-#include <boost/math/special_functions/sign.hpp>
-
-#include "test.hpp"
-
-///////////////////////////////////////////////////////////////////////////////
-// These policies can be used to parse thousand separated
-// numbers with at most 2 decimal digits after the decimal
-// point. e.g. 123,456,789.01
-///////////////////////////////////////////////////////////////////////////////
-template <typename T>
-struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
-{
- // 2 decimal places Max
- template <typename Iterator, typename Attribute>
- static bool
- parse_frac_n(Iterator& first, Iterator const& last, Attribute& attr)
- {
- namespace qi = boost::spirit::qi;
- return qi::extract_uint<T, 10, 1, 2, true>::call(first, last, attr);
- }
-
- // No exponent
- template <typename Iterator>
- static bool
- parse_exp(Iterator&, Iterator const&)
- {
- return false;
- }
-
- // No exponent
- template <typename Iterator, typename Attribute>
- static bool
- parse_exp_n(Iterator&, Iterator const&, Attribute&)
- {
- return false;
- }
-
- // Thousands separated numbers
- template <typename Iterator, typename Attribute>
- static bool
- parse_n(Iterator& first, Iterator const& last, Attribute& attr)
- {
- using boost::spirit::qi::uint_parser;
- namespace qi = boost::spirit::qi;
-
- uint_parser<unsigned, 10, 1, 3> uint3;
- uint_parser<unsigned, 10, 3, 3> uint3_3;
-
- T result = 0;
- if (parse(first, last, uint3, result))
- {
- bool hit = false;
- T n;
- Iterator save = first;
-
- while (qi::parse(first, last, ',') && qi::parse(first, last, uint3_3, n))
- {
- result = result * 1000 + n;
- save = first;
- hit = true;
- }
-
- first = save;
- if (hit)
- attr = result;
- return hit;
- }
- return false;
- }
-};
-
-template <typename T>
-struct no_trailing_dot_policy : boost::spirit::qi::real_policies<T>
-{
- static bool const allow_trailing_dot = false;
-};
-
-template <typename T>
-struct no_leading_dot_policy : boost::spirit::qi::real_policies<T>
-{
- static bool const allow_leading_dot = false;
-};
-
-template <typename T>
-bool
-compare(T n, double expected)
-{
- T const eps = std::pow(10.0, -std::numeric_limits<T>::digits10);
- T delta = n - expected;
- return (delta >= -eps) && (delta <= eps);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// A custom real type
-struct custom_real
-{
- double n;
- custom_real() : n(0) {}
- custom_real(double n_) : n(n_) {}
- friend custom_real operator*(custom_real a, custom_real b)
- { return custom_real(a.n * b.n); }
- friend custom_real operator+(custom_real a, custom_real b)
- { return custom_real(a.n + b.n); }
- friend custom_real operator-(custom_real a, custom_real b)
- { return custom_real(a.n - b.n); }
-};
-
-int
-main()
-{
- using spirit_test::test;
- using spirit_test::test_attr;
-
- ///////////////////////////////////////////////////////////////////////////////
- // thousand separated numbers
- ///////////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::uint_parser;
- using boost::spirit::qi::parse;
-
- uint_parser<unsigned, 10, 1, 3> uint3;
- uint_parser<unsigned, 10, 3, 3> uint3_3;
-
- #define r (uint3 >> *(',' >> uint3_3))
-
- BOOST_TEST(test("1,234,567,890", r));
- BOOST_TEST(test("12,345,678,900", r));
- BOOST_TEST(test("123,456,789,000", r));
- BOOST_TEST(!test("1000,234,567,890", r));
- BOOST_TEST(!test("1,234,56,890", r));
- BOOST_TEST(!test("1,66", r));
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // unsigned real number tests
- ///////////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::real_parser;
- using boost::spirit::qi::parse;
- using boost::spirit::qi::ureal_policies;
-
- real_parser<double, ureal_policies<double> > udouble;
- double d;
-
- BOOST_TEST(test("1234", udouble));
- BOOST_TEST(test_attr("1234", udouble, d) && compare(d, 1234));
-
- BOOST_TEST(test("1.2e3", udouble));
- BOOST_TEST(test_attr("1.2e3", udouble, d) && compare(d, 1.2e3));
-
- BOOST_TEST(test("1.2e-3", udouble));
- BOOST_TEST(test_attr("1.2e-3", udouble, d) && compare(d, 1.2e-3));
-
- BOOST_TEST(test("1.e2", udouble));
- BOOST_TEST(test_attr("1.e2", udouble, d) && compare(d, 1.e2));
-
- BOOST_TEST(test("1.", udouble));
- BOOST_TEST(test_attr("1.", udouble, d) && compare(d, 1.));
-
- BOOST_TEST(test(".2e3", udouble));
- BOOST_TEST(test_attr(".2e3", udouble, d) && compare(d, .2e3));
-
- BOOST_TEST(test("2e3", udouble));
- BOOST_TEST(test_attr("2e3", udouble, d) && compare(d, 2e3));
-
- BOOST_TEST(test("2", udouble));
- BOOST_TEST(test_attr("2", udouble, d) && compare(d, 2));
-
- using boost::math::fpclassify;
- BOOST_TEST(test("inf", udouble));
- BOOST_TEST(test("infinity", udouble));
- BOOST_TEST(test("INF", udouble));
- BOOST_TEST(test("INFINITY", udouble));
- BOOST_TEST(test_attr("inf", udouble, d) && FP_INFINITE == fpclassify(d));
- BOOST_TEST(test_attr("INF", udouble, d) && FP_INFINITE == fpclassify(d));
- BOOST_TEST(test_attr("infinity", udouble, d) && FP_INFINITE == fpclassify(d));
- BOOST_TEST(test_attr("INFINITY", udouble, d) && FP_INFINITE == fpclassify(d));
-
- BOOST_TEST(test("nan", udouble));
- BOOST_TEST(test_attr("nan", udouble, d) && FP_NAN == fpclassify(d));
- BOOST_TEST(test("NAN", udouble));
- BOOST_TEST(test_attr("NAN", udouble, d) && FP_NAN == fpclassify(d));
-
- BOOST_TEST(test("nan(...)", udouble));
- BOOST_TEST(test_attr("nan(...)", udouble, d) && FP_NAN == fpclassify(d));
- BOOST_TEST(test("NAN(...)", udouble));
- BOOST_TEST(test_attr("NAN(...)", udouble, d) && FP_NAN == fpclassify(d));
-
- BOOST_TEST(!test("e3", udouble));
- BOOST_TEST(!test_attr("e3", udouble, d));
-
- BOOST_TEST(!test("-1.2e3", udouble));
- BOOST_TEST(!test_attr("-1.2e3", udouble, d));
-
- BOOST_TEST(!test("+1.2e3", udouble));
- BOOST_TEST(!test_attr("+1.2e3", udouble, d));
-
- BOOST_TEST(!test("1.2e", udouble));
- BOOST_TEST(!test_attr("1.2e", udouble, d));
-
- BOOST_TEST(!test("-.3", udouble));
- BOOST_TEST(!test_attr("-.3", udouble, d));
- }
-
-///////////////////////////////////////////////////////////////////////////////
-// signed real number tests
-///////////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::double_;
- using boost::spirit::qi::parse;
- double d;
-
- BOOST_TEST(test("-1234", double_));
- BOOST_TEST(test_attr("-1234", double_, d) && compare(d, -1234));
-
- BOOST_TEST(test("-1.2e3", double_));
- BOOST_TEST(test_attr("-1.2e3", double_, d) && compare(d, -1.2e3));
-
- BOOST_TEST(test("+1.2e3", double_));
- BOOST_TEST(test_attr("+1.2e3", double_, d) && compare(d, 1.2e3));
-
- BOOST_TEST(test("-0.1", double_));
- BOOST_TEST(test_attr("-0.1", double_, d) && compare(d, -0.1));
-
- BOOST_TEST(test("-1.2e-3", double_));
- BOOST_TEST(test_attr("-1.2e-3", double_, d) && compare(d, -1.2e-3));
-
- BOOST_TEST(test("-1.e2", double_));
- BOOST_TEST(test_attr("-1.e2", double_, d) && compare(d, -1.e2));
-
- BOOST_TEST(test("-.2e3", double_));
- BOOST_TEST(test_attr("-.2e3", double_, d) && compare(d, -.2e3));
-
- BOOST_TEST(test("-2e3", double_));
- BOOST_TEST(test_attr("-2e3", double_, d) && compare(d, -2e3));
-
- BOOST_TEST(!test("-e3", double_));
- BOOST_TEST(!test_attr("-e3", double_, d));
-
- BOOST_TEST(!test("-1.2e", double_));
- BOOST_TEST(!test_attr("-1.2e", double_, d));
-
-#if defined(BOOST_SPIRIT_TEST_REAL_PRECISION)
- BOOST_TEST(test_attr("-5.7222349715140557e+307", double_, d));
- BOOST_TEST(d == -5.7222349715140557e+307); // exact!
-
- BOOST_TEST(test_attr("2.0332938517515416e-308", double_, d));
- BOOST_TEST(d == 2.0332938517515416e-308); // exact!
-
- BOOST_TEST(test_attr("20332938517515416e291", double_, d));
- BOOST_TEST(d == 20332938517515416e291); // exact!
-
- BOOST_TEST(test_attr("2.0332938517515416e307", double_, d));
- BOOST_TEST(d == 2.0332938517515416e307); // exact!
-#endif
-
- using boost::math::fpclassify;
- using boost::spirit::detail::signbit; // Boost version is broken
-
- BOOST_TEST(test("-inf", double_));
- BOOST_TEST(test("-infinity", double_));
- BOOST_TEST(test_attr("-inf", double_, d) &&
- FP_INFINITE == fpclassify(d) && signbit(d));
- BOOST_TEST(test_attr("-infinity", double_, d) &&
- FP_INFINITE == fpclassify(d) && signbit(d));
- BOOST_TEST(test("-INF", double_));
- BOOST_TEST(test("-INFINITY", double_));
- BOOST_TEST(test_attr("-INF", double_, d) &&
- FP_INFINITE == fpclassify(d) && signbit(d));
- BOOST_TEST(test_attr("-INFINITY", double_, d) &&
- FP_INFINITE == fpclassify(d) && signbit(d));
-
- BOOST_TEST(test("-nan", double_));
- BOOST_TEST(test_attr("-nan", double_, d) &&
- FP_NAN == fpclassify(d) && signbit(d));
- BOOST_TEST(test("-NAN", double_));
- BOOST_TEST(test_attr("-NAN", double_, d) &&
- FP_NAN == fpclassify(d) && signbit(d));
-
- BOOST_TEST(test("-nan(...)", double_));
- BOOST_TEST(test_attr("-nan(...)", double_, d) &&
- FP_NAN == fpclassify(d) && signbit(d));
- BOOST_TEST(test("-NAN(...)", double_));
- BOOST_TEST(test_attr("-NAN(...)", double_, d) &&
- FP_NAN == fpclassify(d) && signbit(d));
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // strict real number tests
- ///////////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::real_parser;
- using boost::spirit::qi::parse;
- using boost::spirit::qi::strict_ureal_policies;
- using boost::spirit::qi::strict_real_policies;
-
- real_parser<double, strict_ureal_policies<double> > strict_udouble;
- real_parser<double, strict_real_policies<double> > strict_double;
- double d;
-
- BOOST_TEST(!test("1234", strict_udouble));
- BOOST_TEST(!test_attr("1234", strict_udouble, d));
-
- BOOST_TEST(test("1.2", strict_udouble));
- BOOST_TEST(test_attr("1.2", strict_udouble, d) && compare(d, 1.2));
-
- BOOST_TEST(!test("-1234", strict_double));
- BOOST_TEST(!test_attr("-1234", strict_double, d));
-
- BOOST_TEST(test("123.", strict_double));
- BOOST_TEST(test_attr("123.", strict_double, d) && compare(d, 123));
-
- BOOST_TEST(test("3.E6", strict_double));
- BOOST_TEST(test_attr("3.E6", strict_double, d) && compare(d, 3e6));
-
- real_parser<double, no_trailing_dot_policy<double> > notrdot_real;
- real_parser<double, no_leading_dot_policy<double> > nolddot_real;
-
- BOOST_TEST(!test("1234.", notrdot_real)); // Bad trailing dot
- BOOST_TEST(!test(".1234", nolddot_real)); // Bad leading dot
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Special thousands separated numbers
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::real_parser;
- using boost::spirit::qi::parse;
- real_parser<double, ts_real_policies<double> > ts_real;
- double d;
-
- BOOST_TEST(test("123,456,789.01", ts_real));
- BOOST_TEST(test_attr("123,456,789.01", ts_real, d) && compare(d, 123456789.01));
-
- BOOST_TEST(test("12,345,678.90", ts_real));
- BOOST_TEST(test_attr("12,345,678.90", ts_real, d) && compare(d, 12345678.90));
-
- BOOST_TEST(test("1,234,567.89", ts_real));
- BOOST_TEST(test_attr("1,234,567.89", ts_real, d) && compare(d, 1234567.89));
-
- BOOST_TEST(!test("1234,567,890", ts_real));
- BOOST_TEST(!test("1,234,5678,9", ts_real));
- BOOST_TEST(!test("1,234,567.89e6", ts_real));
- BOOST_TEST(!test("1,66", ts_real));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Custom data type
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::math::concepts::real_concept;
- using boost::spirit::qi::real_parser;
- using boost::spirit::qi::real_policies;
- using boost::spirit::qi::parse;
-
- real_parser<real_concept, real_policies<real_concept> > custom_real;
- real_concept d;
-
- BOOST_TEST(test("-1234", custom_real));
- BOOST_TEST(test_attr("-1234", custom_real, d) && compare(d, -1234));
-
- BOOST_TEST(test("-1.2e3", custom_real));
- BOOST_TEST(test_attr("-1.2e3", custom_real, d) && compare(d, -1.2e3));
-
- BOOST_TEST(test("+1.2e3", custom_real));
- BOOST_TEST(test_attr("+1.2e3", custom_real, d) && compare(d, 1.2e3));
-
- BOOST_TEST(test("-0.1", custom_real));
- BOOST_TEST(test_attr("-0.1", custom_real, d) && compare(d, -0.1));
-
- BOOST_TEST(test("-1.2e-3", custom_real));
- BOOST_TEST(test_attr("-1.2e-3", custom_real, d) && compare(d, -1.2e-3));
-
- BOOST_TEST(test("-1.e2", custom_real));
- BOOST_TEST(test_attr("-1.e2", custom_real, d) && compare(d, -1.e2));
-
- BOOST_TEST(test("-.2e3", custom_real));
- BOOST_TEST(test_attr("-.2e3", custom_real, d) && compare(d, -.2e3));
-
- BOOST_TEST(test("-2e3", custom_real));
- BOOST_TEST(test_attr("-2e3", custom_real, d) && compare(d, -2e3));
-
- BOOST_TEST(!test("-e3", custom_real));
- BOOST_TEST(!test_attr("-e3", custom_real, d));
-
- BOOST_TEST(!test("-1.2e", custom_real));
- BOOST_TEST(!test_attr("-1.2e", custom_real, d));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // custom real tests
- ///////////////////////////////////////////////////////////////////////////
- //~ {
- //~ using boost::spirit::qi::double_;
- //~ custom_real n;
-
- //~ BOOST_TEST(test_attr("-123456e6", double_, n));
- //~ }
-
- // this should pass, but currently doesn't because of the way the real
- // parser handles the fractional part of a number
- {
- using boost::spirit::qi::float_;
-
- float f;
- BOOST_TEST(test_attr("123233.4124", float_, f) && f == 123233.4140625f);
- }
-
- return boost::report_errors();
-}

Added: trunk/libs/spirit/test/qi/real.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/real.hpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,126 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2010 Hartmut Kaiser
+
+ 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)
+=============================================================================*/
+#if !defined(BOOST_SPIRIT_TEST_QI_REAL_HPP)
+#define BOOST_SPIRIT_TEST_QI_REAL_HPP
+
+#include <climits>
+#include <boost/math/concepts/real_concept.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/math/special_functions/fpclassify.hpp>
+#include <boost/math/special_functions/sign.hpp>
+
+#include "test.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+// These policies can be used to parse thousand separated
+// numbers with at most 2 decimal digits after the decimal
+// point. e.g. 123,456,789.01
+///////////////////////////////////////////////////////////////////////////////
+template <typename T>
+struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
+{
+ // 2 decimal places Max
+ template <typename Iterator, typename Attribute>
+ static bool
+ parse_frac_n(Iterator& first, Iterator const& last, Attribute& attr)
+ {
+ namespace qi = boost::spirit::qi;
+ return qi::extract_uint<T, 10, 1, 2, true>::call(first, last, attr);
+ }
+
+ // No exponent
+ template <typename Iterator>
+ static bool
+ parse_exp(Iterator&, Iterator const&)
+ {
+ return false;
+ }
+
+ // No exponent
+ template <typename Iterator, typename Attribute>
+ static bool
+ parse_exp_n(Iterator&, Iterator const&, Attribute&)
+ {
+ return false;
+ }
+
+ // Thousands separated numbers
+ template <typename Iterator, typename Attribute>
+ static bool
+ parse_n(Iterator& first, Iterator const& last, Attribute& attr)
+ {
+ using boost::spirit::qi::uint_parser;
+ namespace qi = boost::spirit::qi;
+
+ uint_parser<unsigned, 10, 1, 3> uint3;
+ uint_parser<unsigned, 10, 3, 3> uint3_3;
+
+ T result = 0;
+ if (parse(first, last, uint3, result))
+ {
+ bool hit = false;
+ T n;
+ Iterator save = first;
+
+ while (qi::parse(first, last, ',') && qi::parse(first, last, uint3_3, n))
+ {
+ result = result * 1000 + n;
+ save = first;
+ hit = true;
+ }
+
+ first = save;
+ if (hit)
+ attr = result;
+ return hit;
+ }
+ return false;
+ }
+};
+
+template <typename T>
+struct no_trailing_dot_policy : boost::spirit::qi::real_policies<T>
+{
+ static bool const allow_trailing_dot = false;
+};
+
+template <typename T>
+struct no_leading_dot_policy : boost::spirit::qi::real_policies<T>
+{
+ static bool const allow_leading_dot = false;
+};
+
+template <typename T>
+bool
+compare(T n, double expected)
+{
+ T const eps = std::pow(10.0, -std::numeric_limits<T>::digits10);
+ T delta = n - expected;
+ return (delta >= -eps) && (delta <= eps);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// A custom real type
+struct custom_real
+{
+ double n;
+ custom_real() : n(0) {}
+ custom_real(double n_) : n(n_) {}
+ friend custom_real operator*(custom_real a, custom_real b)
+ { return custom_real(a.n * b.n); }
+ friend custom_real operator+(custom_real a, custom_real b)
+ { return custom_real(a.n + b.n); }
+ friend custom_real operator-(custom_real a, custom_real b)
+ { return custom_real(a.n - b.n); }
+};
+
+#endif

Copied: trunk/libs/spirit/test/qi/real1.cpp (from r67483, /trunk/libs/spirit/test/qi/real.cpp)
==============================================================================
--- /trunk/libs/spirit/test/qi/real.cpp (original)
+++ trunk/libs/spirit/test/qi/real1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -6,119 +6,8 @@
     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
-#include <climits>
-#include <boost/math/concepts/real_concept.hpp>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_numeric.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/math/special_functions/fpclassify.hpp>
-#include <boost/math/special_functions/sign.hpp>
-
-#include "test.hpp"
-
-///////////////////////////////////////////////////////////////////////////////
-// These policies can be used to parse thousand separated
-// numbers with at most 2 decimal digits after the decimal
-// point. e.g. 123,456,789.01
-///////////////////////////////////////////////////////////////////////////////
-template <typename T>
-struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
-{
- // 2 decimal places Max
- template <typename Iterator, typename Attribute>
- static bool
- parse_frac_n(Iterator& first, Iterator const& last, Attribute& attr)
- {
- namespace qi = boost::spirit::qi;
- return qi::extract_uint<T, 10, 1, 2, true>::call(first, last, attr);
- }
-
- // No exponent
- template <typename Iterator>
- static bool
- parse_exp(Iterator&, Iterator const&)
- {
- return false;
- }
-
- // No exponent
- template <typename Iterator, typename Attribute>
- static bool
- parse_exp_n(Iterator&, Iterator const&, Attribute&)
- {
- return false;
- }
-
- // Thousands separated numbers
- template <typename Iterator, typename Attribute>
- static bool
- parse_n(Iterator& first, Iterator const& last, Attribute& attr)
- {
- using boost::spirit::qi::uint_parser;
- namespace qi = boost::spirit::qi;
 
- uint_parser<unsigned, 10, 1, 3> uint3;
- uint_parser<unsigned, 10, 3, 3> uint3_3;
-
- T result = 0;
- if (parse(first, last, uint3, result))
- {
- bool hit = false;
- T n;
- Iterator save = first;
-
- while (qi::parse(first, last, ',') && qi::parse(first, last, uint3_3, n))
- {
- result = result * 1000 + n;
- save = first;
- hit = true;
- }
-
- first = save;
- if (hit)
- attr = result;
- return hit;
- }
- return false;
- }
-};
-
-template <typename T>
-struct no_trailing_dot_policy : boost::spirit::qi::real_policies<T>
-{
- static bool const allow_trailing_dot = false;
-};
-
-template <typename T>
-struct no_leading_dot_policy : boost::spirit::qi::real_policies<T>
-{
- static bool const allow_leading_dot = false;
-};
-
-template <typename T>
-bool
-compare(T n, double expected)
-{
- T const eps = std::pow(10.0, -std::numeric_limits<T>::digits10);
- T delta = n - expected;
- return (delta >= -eps) && (delta <= eps);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// A custom real type
-struct custom_real
-{
- double n;
- custom_real() : n(0) {}
- custom_real(double n_) : n(n_) {}
- friend custom_real operator*(custom_real a, custom_real b)
- { return custom_real(a.n * b.n); }
- friend custom_real operator+(custom_real a, custom_real b)
- { return custom_real(a.n + b.n); }
- friend custom_real operator-(custom_real a, custom_real b)
- { return custom_real(a.n - b.n); }
-};
+#include "real.hpp"
 
 int
 main()
@@ -217,209 +106,5 @@
         BOOST_TEST(!test_attr("-.3", udouble, d));
     }
 
-///////////////////////////////////////////////////////////////////////////////
-// signed real number tests
-///////////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::double_;
- using boost::spirit::qi::parse;
- double d;
-
- BOOST_TEST(test("-1234", double_));
- BOOST_TEST(test_attr("-1234", double_, d) && compare(d, -1234));
-
- BOOST_TEST(test("-1.2e3", double_));
- BOOST_TEST(test_attr("-1.2e3", double_, d) && compare(d, -1.2e3));
-
- BOOST_TEST(test("+1.2e3", double_));
- BOOST_TEST(test_attr("+1.2e3", double_, d) && compare(d, 1.2e3));
-
- BOOST_TEST(test("-0.1", double_));
- BOOST_TEST(test_attr("-0.1", double_, d) && compare(d, -0.1));
-
- BOOST_TEST(test("-1.2e-3", double_));
- BOOST_TEST(test_attr("-1.2e-3", double_, d) && compare(d, -1.2e-3));
-
- BOOST_TEST(test("-1.e2", double_));
- BOOST_TEST(test_attr("-1.e2", double_, d) && compare(d, -1.e2));
-
- BOOST_TEST(test("-.2e3", double_));
- BOOST_TEST(test_attr("-.2e3", double_, d) && compare(d, -.2e3));
-
- BOOST_TEST(test("-2e3", double_));
- BOOST_TEST(test_attr("-2e3", double_, d) && compare(d, -2e3));
-
- BOOST_TEST(!test("-e3", double_));
- BOOST_TEST(!test_attr("-e3", double_, d));
-
- BOOST_TEST(!test("-1.2e", double_));
- BOOST_TEST(!test_attr("-1.2e", double_, d));
-
-#if defined(BOOST_SPIRIT_TEST_REAL_PRECISION)
- BOOST_TEST(test_attr("-5.7222349715140557e+307", double_, d));
- BOOST_TEST(d == -5.7222349715140557e+307); // exact!
-
- BOOST_TEST(test_attr("2.0332938517515416e-308", double_, d));
- BOOST_TEST(d == 2.0332938517515416e-308); // exact!
-
- BOOST_TEST(test_attr("20332938517515416e291", double_, d));
- BOOST_TEST(d == 20332938517515416e291); // exact!
-
- BOOST_TEST(test_attr("2.0332938517515416e307", double_, d));
- BOOST_TEST(d == 2.0332938517515416e307); // exact!
-#endif
-
- using boost::math::fpclassify;
- using boost::spirit::detail::signbit; // Boost version is broken
-
- BOOST_TEST(test("-inf", double_));
- BOOST_TEST(test("-infinity", double_));
- BOOST_TEST(test_attr("-inf", double_, d) &&
- FP_INFINITE == fpclassify(d) && signbit(d));
- BOOST_TEST(test_attr("-infinity", double_, d) &&
- FP_INFINITE == fpclassify(d) && signbit(d));
- BOOST_TEST(test("-INF", double_));
- BOOST_TEST(test("-INFINITY", double_));
- BOOST_TEST(test_attr("-INF", double_, d) &&
- FP_INFINITE == fpclassify(d) && signbit(d));
- BOOST_TEST(test_attr("-INFINITY", double_, d) &&
- FP_INFINITE == fpclassify(d) && signbit(d));
-
- BOOST_TEST(test("-nan", double_));
- BOOST_TEST(test_attr("-nan", double_, d) &&
- FP_NAN == fpclassify(d) && signbit(d));
- BOOST_TEST(test("-NAN", double_));
- BOOST_TEST(test_attr("-NAN", double_, d) &&
- FP_NAN == fpclassify(d) && signbit(d));
-
- BOOST_TEST(test("-nan(...)", double_));
- BOOST_TEST(test_attr("-nan(...)", double_, d) &&
- FP_NAN == fpclassify(d) && signbit(d));
- BOOST_TEST(test("-NAN(...)", double_));
- BOOST_TEST(test_attr("-NAN(...)", double_, d) &&
- FP_NAN == fpclassify(d) && signbit(d));
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // strict real number tests
- ///////////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::real_parser;
- using boost::spirit::qi::parse;
- using boost::spirit::qi::strict_ureal_policies;
- using boost::spirit::qi::strict_real_policies;
-
- real_parser<double, strict_ureal_policies<double> > strict_udouble;
- real_parser<double, strict_real_policies<double> > strict_double;
- double d;
-
- BOOST_TEST(!test("1234", strict_udouble));
- BOOST_TEST(!test_attr("1234", strict_udouble, d));
-
- BOOST_TEST(test("1.2", strict_udouble));
- BOOST_TEST(test_attr("1.2", strict_udouble, d) && compare(d, 1.2));
-
- BOOST_TEST(!test("-1234", strict_double));
- BOOST_TEST(!test_attr("-1234", strict_double, d));
-
- BOOST_TEST(test("123.", strict_double));
- BOOST_TEST(test_attr("123.", strict_double, d) && compare(d, 123));
-
- BOOST_TEST(test("3.E6", strict_double));
- BOOST_TEST(test_attr("3.E6", strict_double, d) && compare(d, 3e6));
-
- real_parser<double, no_trailing_dot_policy<double> > notrdot_real;
- real_parser<double, no_leading_dot_policy<double> > nolddot_real;
-
- BOOST_TEST(!test("1234.", notrdot_real)); // Bad trailing dot
- BOOST_TEST(!test(".1234", nolddot_real)); // Bad leading dot
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Special thousands separated numbers
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::spirit::qi::real_parser;
- using boost::spirit::qi::parse;
- real_parser<double, ts_real_policies<double> > ts_real;
- double d;
-
- BOOST_TEST(test("123,456,789.01", ts_real));
- BOOST_TEST(test_attr("123,456,789.01", ts_real, d) && compare(d, 123456789.01));
-
- BOOST_TEST(test("12,345,678.90", ts_real));
- BOOST_TEST(test_attr("12,345,678.90", ts_real, d) && compare(d, 12345678.90));
-
- BOOST_TEST(test("1,234,567.89", ts_real));
- BOOST_TEST(test_attr("1,234,567.89", ts_real, d) && compare(d, 1234567.89));
-
- BOOST_TEST(!test("1234,567,890", ts_real));
- BOOST_TEST(!test("1,234,5678,9", ts_real));
- BOOST_TEST(!test("1,234,567.89e6", ts_real));
- BOOST_TEST(!test("1,66", ts_real));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Custom data type
- ///////////////////////////////////////////////////////////////////////////
- {
- using boost::math::concepts::real_concept;
- using boost::spirit::qi::real_parser;
- using boost::spirit::qi::real_policies;
- using boost::spirit::qi::parse;
-
- real_parser<real_concept, real_policies<real_concept> > custom_real;
- real_concept d;
-
- BOOST_TEST(test("-1234", custom_real));
- BOOST_TEST(test_attr("-1234", custom_real, d) && compare(d, -1234));
-
- BOOST_TEST(test("-1.2e3", custom_real));
- BOOST_TEST(test_attr("-1.2e3", custom_real, d) && compare(d, -1.2e3));
-
- BOOST_TEST(test("+1.2e3", custom_real));
- BOOST_TEST(test_attr("+1.2e3", custom_real, d) && compare(d, 1.2e3));
-
- BOOST_TEST(test("-0.1", custom_real));
- BOOST_TEST(test_attr("-0.1", custom_real, d) && compare(d, -0.1));
-
- BOOST_TEST(test("-1.2e-3", custom_real));
- BOOST_TEST(test_attr("-1.2e-3", custom_real, d) && compare(d, -1.2e-3));
-
- BOOST_TEST(test("-1.e2", custom_real));
- BOOST_TEST(test_attr("-1.e2", custom_real, d) && compare(d, -1.e2));
-
- BOOST_TEST(test("-.2e3", custom_real));
- BOOST_TEST(test_attr("-.2e3", custom_real, d) && compare(d, -.2e3));
-
- BOOST_TEST(test("-2e3", custom_real));
- BOOST_TEST(test_attr("-2e3", custom_real, d) && compare(d, -2e3));
-
- BOOST_TEST(!test("-e3", custom_real));
- BOOST_TEST(!test_attr("-e3", custom_real, d));
-
- BOOST_TEST(!test("-1.2e", custom_real));
- BOOST_TEST(!test_attr("-1.2e", custom_real, d));
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // custom real tests
- ///////////////////////////////////////////////////////////////////////////
- //~ {
- //~ using boost::spirit::qi::double_;
- //~ custom_real n;
-
- //~ BOOST_TEST(test_attr("-123456e6", double_, n));
- //~ }
-
- // this should pass, but currently doesn't because of the way the real
- // parser handles the fractional part of a number
- {
- using boost::spirit::qi::float_;
-
- float f;
- BOOST_TEST(test_attr("123233.4124", float_, f) && f == 123233.4140625f);
- }
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/qi/real2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/real2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,101 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2010 Hartmut Kaiser
+
+ 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 "real.hpp"
+
+int
+main()
+{
+ using spirit_test::test;
+ using spirit_test::test_attr;
+///////////////////////////////////////////////////////////////////////////////
+// signed real number tests
+///////////////////////////////////////////////////////////////////////////////
+ {
+ using boost::spirit::qi::double_;
+ using boost::spirit::qi::parse;
+ double d;
+
+ BOOST_TEST(test("-1234", double_));
+ BOOST_TEST(test_attr("-1234", double_, d) && compare(d, -1234));
+
+ BOOST_TEST(test("-1.2e3", double_));
+ BOOST_TEST(test_attr("-1.2e3", double_, d) && compare(d, -1.2e3));
+
+ BOOST_TEST(test("+1.2e3", double_));
+ BOOST_TEST(test_attr("+1.2e3", double_, d) && compare(d, 1.2e3));
+
+ BOOST_TEST(test("-0.1", double_));
+ BOOST_TEST(test_attr("-0.1", double_, d) && compare(d, -0.1));
+
+ BOOST_TEST(test("-1.2e-3", double_));
+ BOOST_TEST(test_attr("-1.2e-3", double_, d) && compare(d, -1.2e-3));
+
+ BOOST_TEST(test("-1.e2", double_));
+ BOOST_TEST(test_attr("-1.e2", double_, d) && compare(d, -1.e2));
+
+ BOOST_TEST(test("-.2e3", double_));
+ BOOST_TEST(test_attr("-.2e3", double_, d) && compare(d, -.2e3));
+
+ BOOST_TEST(test("-2e3", double_));
+ BOOST_TEST(test_attr("-2e3", double_, d) && compare(d, -2e3));
+
+ BOOST_TEST(!test("-e3", double_));
+ BOOST_TEST(!test_attr("-e3", double_, d));
+
+ BOOST_TEST(!test("-1.2e", double_));
+ BOOST_TEST(!test_attr("-1.2e", double_, d));
+
+#if defined(BOOST_SPIRIT_TEST_REAL_PRECISION)
+ BOOST_TEST(test_attr("-5.7222349715140557e+307", double_, d));
+ BOOST_TEST(d == -5.7222349715140557e+307); // exact!
+
+ BOOST_TEST(test_attr("2.0332938517515416e-308", double_, d));
+ BOOST_TEST(d == 2.0332938517515416e-308); // exact!
+
+ BOOST_TEST(test_attr("20332938517515416e291", double_, d));
+ BOOST_TEST(d == 20332938517515416e291); // exact!
+
+ BOOST_TEST(test_attr("2.0332938517515416e307", double_, d));
+ BOOST_TEST(d == 2.0332938517515416e307); // exact!
+#endif
+
+ using boost::math::fpclassify;
+ using boost::spirit::detail::signbit; // Boost version is broken
+
+ BOOST_TEST(test("-inf", double_));
+ BOOST_TEST(test("-infinity", double_));
+ BOOST_TEST(test_attr("-inf", double_, d) &&
+ FP_INFINITE == fpclassify(d) && signbit(d));
+ BOOST_TEST(test_attr("-infinity", double_, d) &&
+ FP_INFINITE == fpclassify(d) && signbit(d));
+ BOOST_TEST(test("-INF", double_));
+ BOOST_TEST(test("-INFINITY", double_));
+ BOOST_TEST(test_attr("-INF", double_, d) &&
+ FP_INFINITE == fpclassify(d) && signbit(d));
+ BOOST_TEST(test_attr("-INFINITY", double_, d) &&
+ FP_INFINITE == fpclassify(d) && signbit(d));
+
+ BOOST_TEST(test("-nan", double_));
+ BOOST_TEST(test_attr("-nan", double_, d) &&
+ FP_NAN == fpclassify(d) && signbit(d));
+ BOOST_TEST(test("-NAN", double_));
+ BOOST_TEST(test_attr("-NAN", double_, d) &&
+ FP_NAN == fpclassify(d) && signbit(d));
+
+ BOOST_TEST(test("-nan(...)", double_));
+ BOOST_TEST(test_attr("-nan(...)", double_, d) &&
+ FP_NAN == fpclassify(d) && signbit(d));
+ BOOST_TEST(test("-NAN(...)", double_));
+ BOOST_TEST(test_attr("-NAN(...)", double_, d) &&
+ FP_NAN == fpclassify(d) && signbit(d));
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/qi/real3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/real3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,78 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2010 Hartmut Kaiser
+
+ 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 "real.hpp"
+
+int
+main()
+{
+ using spirit_test::test;
+ using spirit_test::test_attr;
+
+ ///////////////////////////////////////////////////////////////////////////////
+ // strict real number tests
+ ///////////////////////////////////////////////////////////////////////////////
+ {
+ using boost::spirit::qi::real_parser;
+ using boost::spirit::qi::parse;
+ using boost::spirit::qi::strict_ureal_policies;
+ using boost::spirit::qi::strict_real_policies;
+
+ real_parser<double, strict_ureal_policies<double> > strict_udouble;
+ real_parser<double, strict_real_policies<double> > strict_double;
+ double d;
+
+ BOOST_TEST(!test("1234", strict_udouble));
+ BOOST_TEST(!test_attr("1234", strict_udouble, d));
+
+ BOOST_TEST(test("1.2", strict_udouble));
+ BOOST_TEST(test_attr("1.2", strict_udouble, d) && compare(d, 1.2));
+
+ BOOST_TEST(!test("-1234", strict_double));
+ BOOST_TEST(!test_attr("-1234", strict_double, d));
+
+ BOOST_TEST(test("123.", strict_double));
+ BOOST_TEST(test_attr("123.", strict_double, d) && compare(d, 123));
+
+ BOOST_TEST(test("3.E6", strict_double));
+ BOOST_TEST(test_attr("3.E6", strict_double, d) && compare(d, 3e6));
+
+ real_parser<double, no_trailing_dot_policy<double> > notrdot_real;
+ real_parser<double, no_leading_dot_policy<double> > nolddot_real;
+
+ BOOST_TEST(!test("1234.", notrdot_real)); // Bad trailing dot
+ BOOST_TEST(!test(".1234", nolddot_real)); // Bad leading dot
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Special thousands separated numbers
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ using boost::spirit::qi::real_parser;
+ using boost::spirit::qi::parse;
+ real_parser<double, ts_real_policies<double> > ts_real;
+ double d;
+
+ BOOST_TEST(test("123,456,789.01", ts_real));
+ BOOST_TEST(test_attr("123,456,789.01", ts_real, d) && compare(d, 123456789.01));
+
+ BOOST_TEST(test("12,345,678.90", ts_real));
+ BOOST_TEST(test_attr("12,345,678.90", ts_real, d) && compare(d, 12345678.90));
+
+ BOOST_TEST(test("1,234,567.89", ts_real));
+ BOOST_TEST(test_attr("1,234,567.89", ts_real, d) && compare(d, 1234567.89));
+
+ BOOST_TEST(!test("1234,567,890", ts_real));
+ BOOST_TEST(!test("1,234,5678,9", ts_real));
+ BOOST_TEST(!test("1,234,567.89e6", ts_real));
+ BOOST_TEST(!test("1,66", ts_real));
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/qi/real4.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/real4.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,81 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2010 Hartmut Kaiser
+
+ 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 "real.hpp"
+
+int
+main()
+{
+ using spirit_test::test;
+ using spirit_test::test_attr;
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Custom data type
+ ///////////////////////////////////////////////////////////////////////////
+ {
+ using boost::math::concepts::real_concept;
+ using boost::spirit::qi::real_parser;
+ using boost::spirit::qi::real_policies;
+ using boost::spirit::qi::parse;
+
+ real_parser<real_concept, real_policies<real_concept> > custom_real;
+ real_concept d;
+
+ BOOST_TEST(test("-1234", custom_real));
+ BOOST_TEST(test_attr("-1234", custom_real, d) && compare(d, -1234));
+
+ BOOST_TEST(test("-1.2e3", custom_real));
+ BOOST_TEST(test_attr("-1.2e3", custom_real, d) && compare(d, -1.2e3));
+
+ BOOST_TEST(test("+1.2e3", custom_real));
+ BOOST_TEST(test_attr("+1.2e3", custom_real, d) && compare(d, 1.2e3));
+
+ BOOST_TEST(test("-0.1", custom_real));
+ BOOST_TEST(test_attr("-0.1", custom_real, d) && compare(d, -0.1));
+
+ BOOST_TEST(test("-1.2e-3", custom_real));
+ BOOST_TEST(test_attr("-1.2e-3", custom_real, d) && compare(d, -1.2e-3));
+
+ BOOST_TEST(test("-1.e2", custom_real));
+ BOOST_TEST(test_attr("-1.e2", custom_real, d) && compare(d, -1.e2));
+
+ BOOST_TEST(test("-.2e3", custom_real));
+ BOOST_TEST(test_attr("-.2e3", custom_real, d) && compare(d, -.2e3));
+
+ BOOST_TEST(test("-2e3", custom_real));
+ BOOST_TEST(test_attr("-2e3", custom_real, d) && compare(d, -2e3));
+
+ BOOST_TEST(!test("-e3", custom_real));
+ BOOST_TEST(!test_attr("-e3", custom_real, d));
+
+ BOOST_TEST(!test("-1.2e", custom_real));
+ BOOST_TEST(!test_attr("-1.2e", custom_real, d));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // custom real tests
+ ///////////////////////////////////////////////////////////////////////////
+ //~ {
+ //~ using boost::spirit::qi::double_;
+ //~ custom_real n;
+
+ //~ BOOST_TEST(test_attr("-123456e6", double_, n));
+ //~ }
+
+ // this should pass, but currently doesn't because of the way the real
+ // parser handles the fractional part of a number
+ //{
+ //using boost::spirit::qi::float_;
+
+ //float f;
+ //BOOST_TEST(test_attr("123233.4124", float_, f) && f == 123233.4140625f);
+ //}
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/qi/reorder_test.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/reorder_test.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,79 +0,0 @@
-// Copyright (c) 2010 Olaf Peter
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/qi.hpp>
-#include <boost/fusion/include/nview.hpp>
-
-namespace qi = boost::spirit::qi;
-namespace ascii = boost::spirit::ascii;
-namespace phx = boost::phoenix;
-namespace fusion = boost::fusion;
-namespace mpl = boost::mpl;
-
-int main()
-{
- using fusion::result_of::as_nview;
- using fusion::at_c;
- using boost::optional;
- using boost::variant;
- using ascii::space_type;
- using ascii::no_case;
- using qi::lit;
- using qi::double_;
-
- typedef fusion::vector<
- optional<double>, // 0 - U
- optional<double>, // 1 - V
- optional<double> // 2 - W
- > uvw_type;
-
- typedef as_nview<uvw_type, 0, 1, 2>::type uvw_reordered_type;
- typedef as_nview<uvw_type, 2, 0, 1>::type vwu_reordered_type;
-
- typedef char const* iterator_type;
-
- qi::rule<iterator_type, optional<double>(), space_type> u,v,w;
- qi::rule<iterator_type, uvw_reordered_type(), space_type> uvw;
- qi::rule<iterator_type, vwu_reordered_type(), space_type> vwu;
-
- u = no_case[ "NA" ] | ( double_ >> -lit( "U" ) );
- v = no_case[ "NA" ] | ( double_ >> -lit( "V" ) );
- w = no_case[ "NA" ] | ( double_ >> -lit( "W" ) );
-
- uvw = u > v > w;
- vwu = v > w > u;
-
- uvw_type uvw_data;
- {
- iterator_type first = "1U 2V 3W";
- iterator_type last = first + std::strlen(first);
-
- uvw_reordered_type uvw_result( uvw_data );
-
- BOOST_TEST(qi::phrase_parse(first, last, uvw, ascii::space, uvw_result));
- BOOST_TEST(fusion::at_c<0>(uvw_result) && *fusion::at_c<0>(uvw_result) == 1);
- BOOST_TEST(fusion::at_c<1>(uvw_result) && *fusion::at_c<1>(uvw_result) == 2);
- BOOST_TEST(fusion::at_c<2>(uvw_result) && *fusion::at_c<2>(uvw_result) == 3);
- }
-
- {
- iterator_type first = "2V 3W 1U";
- iterator_type last = first + std::strlen(first);
-
- vwu_reordered_type uvw_result(uvw_data);
-
- BOOST_TEST(qi::phrase_parse(first, last, vwu, ascii::space, uvw_result));
- BOOST_TEST(fusion::at_c<0>(uvw_result) && *fusion::at_c<0>(uvw_result) == 2);
- BOOST_TEST(fusion::at_c<1>(uvw_result) && *fusion::at_c<1>(uvw_result) == 3);
- BOOST_TEST(fusion::at_c<2>(uvw_result) && *fusion::at_c<2>(uvw_result) == 1);
- }
-
- return boost::report_errors();
-}
-
-

Deleted: trunk/libs/spirit/test/qi/repeat_regression.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/repeat_regression.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,44 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2010 Head Geek
-//
-// Distributed under 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 <iostream>
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/qi.hpp>
-
-namespace qi = boost::spirit::qi;
-using qi::omit;
-using qi::repeat;
-using std::cout;
-using std::endl;
-
-typedef qi::rule<std::string::const_iterator, std::string()> strrule_type;
-
-void test(const std::string input, strrule_type rule, std::string result)
-{
- std::string target;
- std::string::const_iterator i = input.begin(), ie = input.end();
-
- BOOST_TEST(qi::parse(i, ie, rule, target) && target == result);
-}
-
-int main()
-{
- strrule_type obsolete_year =
- omit[-qi::char_(" \t")] >>
- repeat(2)[qi::digit] >>
- omit[-qi::char_(" \t")];
- strrule_type correct_year = repeat(4)[qi::digit];
-
- test("1776", correct_year | repeat(2)[qi::digit], "1776");
- test("76", obsolete_year, "76");
- test("76", obsolete_year | correct_year, "76");
- test(" 76", correct_year | obsolete_year, "76");
- test("76", correct_year | obsolete_year, "76");
- test("76", correct_year | repeat(2)[qi::digit], "76");
-
- return boost::report_errors();
-}
-

Deleted: trunk/libs/spirit/test/qi/rule.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/rule.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,489 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under 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)
-=============================================================================*/
-
-// this file deliberately contains non-ascii characters
-// boostinspect:noascii
-
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_string.hpp>
-#include <boost/spirit/include/qi_numeric.hpp>
-#include <boost/spirit/include/qi_auxiliary.hpp>
-#include <boost/spirit/include/qi_directive.hpp>
-#include <boost/spirit/include/qi_nonterminal.hpp>
-#include <boost/spirit/include/qi_action.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_object.hpp>
-#include <boost/spirit/include/phoenix_bind.hpp>
-#include <boost/fusion/include/std_pair.hpp>
-
-#include <string>
-#include <cstring>
-#include <iostream>
-#include "test.hpp"
-
-int
-main()
-{
- using spirit_test::test_attr;
- using spirit_test::test;
-
- using namespace boost::spirit::ascii;
- using namespace boost::spirit::qi::labels;
- using boost::spirit::qi::locals;
- using boost::spirit::qi::rule;
- using boost::spirit::qi::int_;
- using boost::spirit::qi::uint_;
- using boost::spirit::qi::fail;
- using boost::spirit::qi::on_error;
- using boost::spirit::qi::debug;
- using boost::spirit::qi::lit;
-
- namespace phx = boost::phoenix;
-
-
- { // basic tests
-
- rule<char const*> a, b, c, start;
-
- a = 'a';
- b = 'b';
- c = 'c';
-
- a.name("a");
- b.name("b");
- c.name("c");
- start.name("start");
-
- debug(a);
- debug(b);
- debug(c);
- debug(start);
-
- start = *(a | b | c);
- BOOST_TEST(test("abcabcacb", start));
-
- start = (a | b) >> (start | b);
- BOOST_TEST(test("aaaabababaaabbb", start));
- BOOST_TEST(test("aaaabababaaabba", start, false));
-
- // ignore the skipper!
- BOOST_TEST(test("aaaabababaaabba", start, space, false));
- }
-
- { // basic tests with direct initialization
-
- rule<char const*> a ('a');
- rule<char const*> b ('b');
- rule<char const*> c ('c');
- rule<char const*> start = (a | b) >> (start | b);
-
- BOOST_TEST(test("aaaabababaaabbb", start));
- BOOST_TEST(test("aaaabababaaabba", start, false));
-
- // ignore the skipper!
- BOOST_TEST(test("aaaabababaaabba", start, space, false));
- }
-
- { // basic tests w/ skipper
- rule<char const*, space_type> a, b, c, start;
-
- a = 'a';
- b = 'b';
- c = 'c';
-
- a.name("a");
- b.name("b");
- c.name("c");
- start.name("start");
-
- debug(a);
- debug(b);
- debug(c);
- debug(start);
-
- start = *(a | b | c);
- BOOST_TEST(test(" a b c a b c a c b ", start, space));
-
- start = (a | b) >> (start | b);
- BOOST_TEST(test(" a a a a b a b a b a a a b b b ", start, space));
- BOOST_TEST(test(" a a a a b a b a b a a a b b a ", start, space, false));
- }
-
- { // basic tests w/ skipper but no final post-skip
-
- rule<char const*, space_type> a, b, c, start;
-
- a = 'a';
- b = 'b';
- c = 'c';
-
- a.name("a");
- b.name("b");
- c.name("c");
- start.name("start");
-
- debug(a);
- debug(b);
- debug(c);
- debug(start);
-
- start = *(a | b) >> c;
-
- using boost::spirit::qi::phrase_parse;
- using boost::spirit::qi::skip_flag;
- {
- char const *s1 = " a b a a b b a c ... "
- , *const e1 = s1 + std::strlen(s1);
- BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::dont_postskip)
- && s1 == e1 - 5);
- }
-
- start = (a | b) >> (start | c);
- {
- char const *s1 = " a a a a b a b a b a a a b b b c "
- , *const e1 = s1 + std::strlen(s1);
- BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::postskip)
- && s1 == e1);
- }
- {
- char const *s1 = " a a a a b a b a b a a a b b b c "
- , *const e1 = s1 + std::strlen(s1);
- BOOST_TEST(phrase_parse(s1, e1, start, space, skip_flag::dont_postskip)
- && s1 == e1 - 1);
- }
- }
-
- { // test unassigned rule
-
- rule<char const*> a;
- BOOST_TEST(!test("x", a));
- }
-
- { // alias tests
-
- rule<char const*> a, b, c, d, start;
-
- a = 'a';
- b = 'b';
- c = 'c';
- d = start.alias(); // d will always track start
-
- start = *(a | b | c);
- BOOST_TEST(test("abcabcacb", d));
-
- start = (a | b) >> (start | b);
- BOOST_TEST(test("aaaabababaaabbb", d));
- }
-
- { // copy tests
-
- rule<char const*> a, b, c, start;
-
- a = 'a';
- b = 'b';
- c = 'c';
-
- // The FF is the dynamic equivalent of start = *(a | b | c);
- start = a;
- start = start.copy() | b;
- start = start.copy() | c;
- start = *(start.copy());
-
- BOOST_TEST(test("abcabcacb", start));
-
- // The FF is the dynamic equivalent of start = (a | b) >> (start | b);
- start = b;
- start = a | start.copy();
- start = start.copy() >> (start | b);
-
- BOOST_TEST(test("aaaabababaaabbb", start));
- BOOST_TEST(test("aaaabababaaabba", start, false));
- }
-
- { // context tests
-
- char ch;
- rule<char const*, char()> a;
- a = alpha[_val = _1];
-
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
-
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
- }
-
- { // auto rules tests
-
- char ch = '\0';
- rule<char const*, char()> a;
- a %= alpha;
-
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- ch = '\0';
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
-
- a = alpha; // test deduced auto rule behavior
- ch = '\0';
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- ch = '\0';
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
- }
-
- { // auto rules tests: allow stl containers as attributes to
- // sequences (in cases where attributes of the elements
- // are convertible to the value_type of the container or if
- // the element itself is an stl container with value_type
- // that is convertible to the value_type of the attribute).
-
- std::string s;
- rule<char const*, std::string()> r;
- r %= char_ >> *(',' >> char_);
-
- BOOST_TEST(test("a,b,c,d,e,f", r[phx::ref(s) = _1]));
- BOOST_TEST(s == "abcdef");
-
- r = char_ >> *(',' >> char_); // test deduced auto rule behavior
- s.clear();
- BOOST_TEST(test("a,b,c,d,e,f", r[phx::ref(s) = _1]));
- BOOST_TEST(s == "abcdef");
-
- r %= char_ >> char_ >> char_ >> char_ >> char_ >> char_;
- s.clear();
- BOOST_TEST(test("abcdef", r[phx::ref(s) = _1]));
- BOOST_TEST(s == "abcdef");
-
- r = char_ >> char_ >> char_ >> char_ >> char_ >> char_;
- s.clear();
- BOOST_TEST(test("abcdef", r[phx::ref(s) = _1]));
- BOOST_TEST(s == "abcdef");
- }
-
- { // synth attribute value-init
-
- std::string s;
- rule<char const*, char()> r;
- r = alpha[_val += _1];
- BOOST_TEST(test_attr("abcdef", +r, s));
- BOOST_TEST(s == "abcdef");
- }
-
- { // auto rules aliasing tests
-
- char ch = '\0';
- rule<char const*, char()> a, b;
- a %= b;
- b %= alpha;
-
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- ch = '\0';
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
-
- a = b; // test deduced auto rule behavior
- b = alpha;
-
- ch = '\0';
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- ch = '\0';
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
- }
-
- { // context (w/arg) tests
-
- char ch;
- rule<char const*, char(int)> a; // 1 arg
- a = alpha[_val = _1 + _r1];
-
- BOOST_TEST(test("x", a(phx::val(1))[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x' + 1);
-
- BOOST_TEST(test_attr("a", a(1), ch)); // allow scalars as rule args too.
- BOOST_TEST(ch == 'a' + 1);
-
- rule<char const*, char(int, int)> b; // 2 args
- b = alpha[_val = _1 + _r1 + _r2];
- BOOST_TEST(test_attr("a", b(1, 2), ch));
- BOOST_TEST(ch == 'a' + 1 + 2);
- }
-
- { // context (w/ reference arg) tests
-
- char ch;
- rule<char const*, void(char&)> a; // 1 arg (reference)
- a = alpha[_r1 = _1];
-
- BOOST_TEST(test("x", a(phx::ref(ch))));
- BOOST_TEST(ch == 'x');
- }
-
- { // context (w/locals) tests
-
- rule<char const*, locals<char> > a; // 1 local
- a = alpha[_a = _1] >> char_(_a);
- BOOST_TEST(test("aa", a));
- BOOST_TEST(!test("ax", a));
- }
-
- { // context (w/args and locals) tests
-
- rule<char const*, void(int), locals<char> > a; // 1 arg + 1 local
- a = alpha[_a = _1 + _r1] >> char_(_a);
- BOOST_TEST(test("ab", a(phx::val(1))));
- BOOST_TEST(test("xy", a(phx::val(1))));
- BOOST_TEST(!test("ax", a(phx::val(1))));
- }
-
- { // void() has unused type (void == unused_type)
-
- std::pair<int, char> attr;
- rule<char const*, void()> r;
- r = char_;
- BOOST_TEST(test_attr("123ax", int_ >> char_ >> r, attr));
- BOOST_TEST(attr.first == 123);
- BOOST_TEST(attr.second == 'a');
- }
-
- { // bug: test that injected attributes are ok
-
- rule<char const*, char(int) > r;
-
- // problem code:
- r = char_(_r1)[_val = _1];
- }
-
- { // show that ra = rb and ra %= rb works as expected
- rule<char const*, int() > ra, rb;
- int attr;
-
- ra %= int_;
- BOOST_TEST(test_attr("123", ra, attr));
- BOOST_TEST(attr == 123);
-
- rb %= ra;
- BOOST_TEST(test_attr("123", rb, attr));
- BOOST_TEST(attr == 123);
-
- rb = ra;
- BOOST_TEST(test_attr("123", rb, attr));
- BOOST_TEST(attr == 123);
- }
-
- { // std::string as container attribute with auto rules
-
- rule<char const*, std::string()> text;
- text %= +(!char_(')') >> !char_('>') >> char_);
- std::string attr;
- BOOST_TEST(test_attr("x", text, attr));
- BOOST_TEST(attr == "x");
-
- // test deduced auto rule behavior
- text = +(!char_(')') >> !char_('>') >> char_);
- attr.clear();
- BOOST_TEST(test_attr("x", text, attr));
- BOOST_TEST(attr == "x");
- }
-
- { // error handling
-
- using namespace boost::spirit::ascii;
- using boost::phoenix::construct;
- using boost::phoenix::bind;
-
- rule<char const*> r;
- r = '(' > int_ > ',' > int_ > ')';
-
- on_error<fail>
- (
- r, std::cout
- << phx::val("Error! Expecting: ")
- << _4
- << phx::val(", got: \"")
- << construct<std::string>(_3, _2)
- << phx::val("\"")
- << std::endl
- );
-
- BOOST_TEST(test("(123,456)", r));
- BOOST_TEST(!test("(abc,def)", r));
- BOOST_TEST(!test("(123,456]", r));
- BOOST_TEST(!test("(123;456)", r));
- BOOST_TEST(!test("[123,456]", r));
- }
-
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("french")
-#endif
- { // specifying the encoding
-
- typedef boost::spirit::char_encoding::iso8859_1 iso8859_1;
- rule<char const*, iso8859_1> r;
-
- r = no_case['á'];
- BOOST_TEST(test("Á", r));
- r = no_case[char_('á')];
- BOOST_TEST(test("Á", r));
-
- r = no_case[char_("å-ï")];
- BOOST_TEST(test("É", r));
- BOOST_TEST(!test("ÿ", r));
-
- r = no_case["áÁ"];
- BOOST_TEST(test("Áá", r));
- r = no_case[lit("áÁ")];
- BOOST_TEST(test("Áá", r));
- }
-
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("")
-#endif
-
- {
- typedef boost::variant<double, int> v_type;
- rule<const char*, v_type()> r1 = int_;
- v_type v;
- BOOST_TEST(test_attr("1", r1, v) && v.which() == 1 &&
- boost::get<int>(v) == 1);
-
- typedef boost::optional<int> ov_type;
- rule<const char*, ov_type()> r2 = int_;
- ov_type ov;
- BOOST_TEST(test_attr("1", r2, ov) && ov && boost::get<int>(ov) == 1);
- }
-
- // test handling of single element fusion sequences
- {
- using boost::fusion::vector;
- using boost::fusion::at_c;
- rule<const char*, vector<int>()> r = int_;
-
- vector<int> v(0);
- BOOST_TEST(test_attr("1", r, v) && at_c<0>(v) == 1);
- }
-
- {
- using boost::fusion::vector;
- using boost::fusion::at_c;
- rule<const char*, vector<unsigned int>()> r = uint_;
-
- vector<unsigned int> v(0);
- BOOST_TEST(test_attr("1", r, v) && at_c<0>(v) == 1);
- }
-
- return boost::report_errors();
-}
-

Copied: trunk/libs/spirit/test/qi/rule1.cpp (from r67483, /trunk/libs/spirit/test/qi/rule.cpp)
==============================================================================
--- /trunk/libs/spirit/test/qi/rule.cpp (original)
+++ trunk/libs/spirit/test/qi/rule1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -47,7 +47,6 @@
 
     namespace phx = boost::phoenix;
 
-
     { // basic tests
 
         rule<char const*> a, b, c, start;
@@ -160,330 +159,6 @@
         }
     }
 
- { // test unassigned rule
-
- rule<char const*> a;
- BOOST_TEST(!test("x", a));
- }
-
- { // alias tests
-
- rule<char const*> a, b, c, d, start;
-
- a = 'a';
- b = 'b';
- c = 'c';
- d = start.alias(); // d will always track start
-
- start = *(a | b | c);
- BOOST_TEST(test("abcabcacb", d));
-
- start = (a | b) >> (start | b);
- BOOST_TEST(test("aaaabababaaabbb", d));
- }
-
- { // copy tests
-
- rule<char const*> a, b, c, start;
-
- a = 'a';
- b = 'b';
- c = 'c';
-
- // The FF is the dynamic equivalent of start = *(a | b | c);
- start = a;
- start = start.copy() | b;
- start = start.copy() | c;
- start = *(start.copy());
-
- BOOST_TEST(test("abcabcacb", start));
-
- // The FF is the dynamic equivalent of start = (a | b) >> (start | b);
- start = b;
- start = a | start.copy();
- start = start.copy() >> (start | b);
-
- BOOST_TEST(test("aaaabababaaabbb", start));
- BOOST_TEST(test("aaaabababaaabba", start, false));
- }
-
- { // context tests
-
- char ch;
- rule<char const*, char()> a;
- a = alpha[_val = _1];
-
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
-
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
- }
-
- { // auto rules tests
-
- char ch = '\0';
- rule<char const*, char()> a;
- a %= alpha;
-
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- ch = '\0';
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
-
- a = alpha; // test deduced auto rule behavior
- ch = '\0';
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- ch = '\0';
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
- }
-
- { // auto rules tests: allow stl containers as attributes to
- // sequences (in cases where attributes of the elements
- // are convertible to the value_type of the container or if
- // the element itself is an stl container with value_type
- // that is convertible to the value_type of the attribute).
-
- std::string s;
- rule<char const*, std::string()> r;
- r %= char_ >> *(',' >> char_);
-
- BOOST_TEST(test("a,b,c,d,e,f", r[phx::ref(s) = _1]));
- BOOST_TEST(s == "abcdef");
-
- r = char_ >> *(',' >> char_); // test deduced auto rule behavior
- s.clear();
- BOOST_TEST(test("a,b,c,d,e,f", r[phx::ref(s) = _1]));
- BOOST_TEST(s == "abcdef");
-
- r %= char_ >> char_ >> char_ >> char_ >> char_ >> char_;
- s.clear();
- BOOST_TEST(test("abcdef", r[phx::ref(s) = _1]));
- BOOST_TEST(s == "abcdef");
-
- r = char_ >> char_ >> char_ >> char_ >> char_ >> char_;
- s.clear();
- BOOST_TEST(test("abcdef", r[phx::ref(s) = _1]));
- BOOST_TEST(s == "abcdef");
- }
-
- { // synth attribute value-init
-
- std::string s;
- rule<char const*, char()> r;
- r = alpha[_val += _1];
- BOOST_TEST(test_attr("abcdef", +r, s));
- BOOST_TEST(s == "abcdef");
- }
-
- { // auto rules aliasing tests
-
- char ch = '\0';
- rule<char const*, char()> a, b;
- a %= b;
- b %= alpha;
-
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- ch = '\0';
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
-
- a = b; // test deduced auto rule behavior
- b = alpha;
-
- ch = '\0';
- BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- ch = '\0';
- BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
- BOOST_TEST(ch == 'z');
- }
-
- { // context (w/arg) tests
-
- char ch;
- rule<char const*, char(int)> a; // 1 arg
- a = alpha[_val = _1 + _r1];
-
- BOOST_TEST(test("x", a(phx::val(1))[phx::ref(ch) = _1]));
- BOOST_TEST(ch == 'x' + 1);
-
- BOOST_TEST(test_attr("a", a(1), ch)); // allow scalars as rule args too.
- BOOST_TEST(ch == 'a' + 1);
-
- rule<char const*, char(int, int)> b; // 2 args
- b = alpha[_val = _1 + _r1 + _r2];
- BOOST_TEST(test_attr("a", b(1, 2), ch));
- BOOST_TEST(ch == 'a' + 1 + 2);
- }
-
- { // context (w/ reference arg) tests
-
- char ch;
- rule<char const*, void(char&)> a; // 1 arg (reference)
- a = alpha[_r1 = _1];
-
- BOOST_TEST(test("x", a(phx::ref(ch))));
- BOOST_TEST(ch == 'x');
- }
-
- { // context (w/locals) tests
-
- rule<char const*, locals<char> > a; // 1 local
- a = alpha[_a = _1] >> char_(_a);
- BOOST_TEST(test("aa", a));
- BOOST_TEST(!test("ax", a));
- }
-
- { // context (w/args and locals) tests
-
- rule<char const*, void(int), locals<char> > a; // 1 arg + 1 local
- a = alpha[_a = _1 + _r1] >> char_(_a);
- BOOST_TEST(test("ab", a(phx::val(1))));
- BOOST_TEST(test("xy", a(phx::val(1))));
- BOOST_TEST(!test("ax", a(phx::val(1))));
- }
-
- { // void() has unused type (void == unused_type)
-
- std::pair<int, char> attr;
- rule<char const*, void()> r;
- r = char_;
- BOOST_TEST(test_attr("123ax", int_ >> char_ >> r, attr));
- BOOST_TEST(attr.first == 123);
- BOOST_TEST(attr.second == 'a');
- }
-
- { // bug: test that injected attributes are ok
-
- rule<char const*, char(int) > r;
-
- // problem code:
- r = char_(_r1)[_val = _1];
- }
-
- { // show that ra = rb and ra %= rb works as expected
- rule<char const*, int() > ra, rb;
- int attr;
-
- ra %= int_;
- BOOST_TEST(test_attr("123", ra, attr));
- BOOST_TEST(attr == 123);
-
- rb %= ra;
- BOOST_TEST(test_attr("123", rb, attr));
- BOOST_TEST(attr == 123);
-
- rb = ra;
- BOOST_TEST(test_attr("123", rb, attr));
- BOOST_TEST(attr == 123);
- }
-
- { // std::string as container attribute with auto rules
-
- rule<char const*, std::string()> text;
- text %= +(!char_(')') >> !char_('>') >> char_);
- std::string attr;
- BOOST_TEST(test_attr("x", text, attr));
- BOOST_TEST(attr == "x");
-
- // test deduced auto rule behavior
- text = +(!char_(')') >> !char_('>') >> char_);
- attr.clear();
- BOOST_TEST(test_attr("x", text, attr));
- BOOST_TEST(attr == "x");
- }
-
- { // error handling
-
- using namespace boost::spirit::ascii;
- using boost::phoenix::construct;
- using boost::phoenix::bind;
-
- rule<char const*> r;
- r = '(' > int_ > ',' > int_ > ')';
-
- on_error<fail>
- (
- r, std::cout
- << phx::val("Error! Expecting: ")
- << _4
- << phx::val(", got: \"")
- << construct<std::string>(_3, _2)
- << phx::val("\"")
- << std::endl
- );
-
- BOOST_TEST(test("(123,456)", r));
- BOOST_TEST(!test("(abc,def)", r));
- BOOST_TEST(!test("(123,456]", r));
- BOOST_TEST(!test("(123;456)", r));
- BOOST_TEST(!test("[123,456]", r));
- }
-
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("french")
-#endif
- { // specifying the encoding
-
- typedef boost::spirit::char_encoding::iso8859_1 iso8859_1;
- rule<char const*, iso8859_1> r;
-
- r = no_case['á'];
- BOOST_TEST(test("Á", r));
- r = no_case[char_('á')];
- BOOST_TEST(test("Á", r));
-
- r = no_case[char_("å-ï")];
- BOOST_TEST(test("É", r));
- BOOST_TEST(!test("ÿ", r));
-
- r = no_case["áÁ"];
- BOOST_TEST(test("Áá", r));
- r = no_case[lit("áÁ")];
- BOOST_TEST(test("Áá", r));
- }
-
-#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
-#pragma setlocale("")
-#endif
-
- {
- typedef boost::variant<double, int> v_type;
- rule<const char*, v_type()> r1 = int_;
- v_type v;
- BOOST_TEST(test_attr("1", r1, v) && v.which() == 1 &&
- boost::get<int>(v) == 1);
-
- typedef boost::optional<int> ov_type;
- rule<const char*, ov_type()> r2 = int_;
- ov_type ov;
- BOOST_TEST(test_attr("1", r2, ov) && ov && boost::get<int>(ov) == 1);
- }
-
- // test handling of single element fusion sequences
- {
- using boost::fusion::vector;
- using boost::fusion::at_c;
- rule<const char*, vector<int>()> r = int_;
-
- vector<int> v(0);
- BOOST_TEST(test_attr("1", r, v) && at_c<0>(v) == 1);
- }
-
- {
- using boost::fusion::vector;
- using boost::fusion::at_c;
- rule<const char*, vector<unsigned int>()> r = uint_;
-
- vector<unsigned int> v(0);
- BOOST_TEST(test_attr("1", r, v) && at_c<0>(v) == 1);
- }
-
     return boost::report_errors();
 }
 

Added: trunk/libs/spirit/test/qi/rule2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/rule2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,162 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ Distributed under 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)
+=============================================================================*/
+
+// this file deliberately contains non-ascii characters
+// boostinspect:noascii
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_auxiliary.hpp>
+#include <boost/spirit/include/qi_directive.hpp>
+#include <boost/spirit/include/qi_nonterminal.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_object.hpp>
+#include <boost/spirit/include/phoenix_bind.hpp>
+#include <boost/fusion/include/std_pair.hpp>
+
+#include <string>
+#include <cstring>
+#include <iostream>
+#include "test.hpp"
+
+int
+main()
+{
+ using spirit_test::test_attr;
+ using spirit_test::test;
+
+ using namespace boost::spirit::ascii;
+ using namespace boost::spirit::qi::labels;
+ using boost::spirit::qi::locals;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::int_;
+ using boost::spirit::qi::uint_;
+ using boost::spirit::qi::fail;
+ using boost::spirit::qi::on_error;
+ using boost::spirit::qi::debug;
+ using boost::spirit::qi::lit;
+
+ namespace phx = boost::phoenix;
+
+ { // test unassigned rule
+
+ rule<char const*> a;
+ BOOST_TEST(!test("x", a));
+ }
+
+ { // alias tests
+
+ rule<char const*> a, b, c, d, start;
+
+ a = 'a';
+ b = 'b';
+ c = 'c';
+ d = start.alias(); // d will always track start
+
+ start = *(a | b | c);
+ BOOST_TEST(test("abcabcacb", d));
+
+ start = (a | b) >> (start | b);
+ BOOST_TEST(test("aaaabababaaabbb", d));
+ }
+
+ { // copy tests
+
+ rule<char const*> a, b, c, start;
+
+ a = 'a';
+ b = 'b';
+ c = 'c';
+
+ // The FF is the dynamic equivalent of start = *(a | b | c);
+ start = a;
+ start = start.copy() | b;
+ start = start.copy() | c;
+ start = *(start.copy());
+
+ BOOST_TEST(test("abcabcacb", start));
+
+ // The FF is the dynamic equivalent of start = (a | b) >> (start | b);
+ start = b;
+ start = a | start.copy();
+ start = start.copy() >> (start | b);
+
+ BOOST_TEST(test("aaaabababaaabbb", start));
+ BOOST_TEST(test("aaaabababaaabba", start, false));
+ }
+
+ { // context tests
+
+ char ch;
+ rule<char const*, char()> a;
+ a = alpha[_val = _1];
+
+ BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
+ BOOST_TEST(ch == 'x');
+
+ BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
+ BOOST_TEST(ch == 'z');
+ }
+
+ { // auto rules tests
+
+ char ch = '\0';
+ rule<char const*, char()> a;
+ a %= alpha;
+
+ BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
+ BOOST_TEST(ch == 'x');
+ ch = '\0';
+ BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
+ BOOST_TEST(ch == 'z');
+
+ a = alpha; // test deduced auto rule behavior
+ ch = '\0';
+ BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
+ BOOST_TEST(ch == 'x');
+ ch = '\0';
+ BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
+ BOOST_TEST(ch == 'z');
+ }
+
+ { // auto rules tests: allow stl containers as attributes to
+ // sequences (in cases where attributes of the elements
+ // are convertible to the value_type of the container or if
+ // the element itself is an stl container with value_type
+ // that is convertible to the value_type of the attribute).
+
+ std::string s;
+ rule<char const*, std::string()> r;
+ r %= char_ >> *(',' >> char_);
+
+ BOOST_TEST(test("a,b,c,d,e,f", r[phx::ref(s) = _1]));
+ BOOST_TEST(s == "abcdef");
+
+ r = char_ >> *(',' >> char_); // test deduced auto rule behavior
+ s.clear();
+ BOOST_TEST(test("a,b,c,d,e,f", r[phx::ref(s) = _1]));
+ BOOST_TEST(s == "abcdef");
+
+ r %= char_ >> char_ >> char_ >> char_ >> char_ >> char_;
+ s.clear();
+ BOOST_TEST(test("abcdef", r[phx::ref(s) = _1]));
+ BOOST_TEST(s == "abcdef");
+
+ r = char_ >> char_ >> char_ >> char_ >> char_ >> char_;
+ s.clear();
+ BOOST_TEST(test("abcdef", r[phx::ref(s) = _1]));
+ BOOST_TEST(s == "abcdef");
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/spirit/test/qi/rule3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/rule3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,148 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ Distributed under 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)
+=============================================================================*/
+
+// this file deliberately contains non-ascii characters
+// boostinspect:noascii
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_auxiliary.hpp>
+#include <boost/spirit/include/qi_directive.hpp>
+#include <boost/spirit/include/qi_nonterminal.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_object.hpp>
+#include <boost/spirit/include/phoenix_bind.hpp>
+#include <boost/fusion/include/std_pair.hpp>
+
+#include <string>
+#include <cstring>
+#include <iostream>
+#include "test.hpp"
+
+int
+main()
+{
+ using spirit_test::test_attr;
+ using spirit_test::test;
+
+ using namespace boost::spirit::ascii;
+ using namespace boost::spirit::qi::labels;
+ using boost::spirit::qi::locals;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::int_;
+ using boost::spirit::qi::uint_;
+ using boost::spirit::qi::fail;
+ using boost::spirit::qi::on_error;
+ using boost::spirit::qi::debug;
+ using boost::spirit::qi::lit;
+
+ namespace phx = boost::phoenix;
+
+ { // synth attribute value-init
+
+ std::string s;
+ rule<char const*, char()> r;
+ r = alpha[_val += _1];
+ BOOST_TEST(test_attr("abcdef", +r, s));
+ BOOST_TEST(s == "abcdef");
+ }
+
+ { // auto rules aliasing tests
+
+ char ch = '\0';
+ rule<char const*, char()> a, b;
+ a %= b;
+ b %= alpha;
+
+ BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
+ BOOST_TEST(ch == 'x');
+ ch = '\0';
+ BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
+ BOOST_TEST(ch == 'z');
+
+ a = b; // test deduced auto rule behavior
+ b = alpha;
+
+ ch = '\0';
+ BOOST_TEST(test("x", a[phx::ref(ch) = _1]));
+ BOOST_TEST(ch == 'x');
+ ch = '\0';
+ BOOST_TEST(test_attr("z", a, ch)); // attribute is given.
+ BOOST_TEST(ch == 'z');
+ }
+
+ { // context (w/arg) tests
+
+ char ch;
+ rule<char const*, char(int)> a; // 1 arg
+ a = alpha[_val = _1 + _r1];
+
+ BOOST_TEST(test("x", a(phx::val(1))[phx::ref(ch) = _1]));
+ BOOST_TEST(ch == 'x' + 1);
+
+ BOOST_TEST(test_attr("a", a(1), ch)); // allow scalars as rule args too.
+ BOOST_TEST(ch == 'a' + 1);
+
+ rule<char const*, char(int, int)> b; // 2 args
+ b = alpha[_val = _1 + _r1 + _r2];
+ BOOST_TEST(test_attr("a", b(1, 2), ch));
+ BOOST_TEST(ch == 'a' + 1 + 2);
+ }
+
+ { // context (w/ reference arg) tests
+
+ char ch;
+ rule<char const*, void(char&)> a; // 1 arg (reference)
+ a = alpha[_r1 = _1];
+
+ BOOST_TEST(test("x", a(phx::ref(ch))));
+ BOOST_TEST(ch == 'x');
+ }
+
+ { // context (w/locals) tests
+
+ rule<char const*, locals<char> > a; // 1 local
+ a = alpha[_a = _1] >> char_(_a);
+ BOOST_TEST(test("aa", a));
+ BOOST_TEST(!test("ax", a));
+ }
+
+ { // context (w/args and locals) tests
+
+ rule<char const*, void(int), locals<char> > a; // 1 arg + 1 local
+ a = alpha[_a = _1 + _r1] >> char_(_a);
+ BOOST_TEST(test("ab", a(phx::val(1))));
+ BOOST_TEST(test("xy", a(phx::val(1))));
+ BOOST_TEST(!test("ax", a(phx::val(1))));
+ }
+
+ { // void() has unused type (void == unused_type)
+
+ std::pair<int, char> attr;
+ rule<char const*, void()> r;
+ r = char_;
+ BOOST_TEST(test_attr("123ax", int_ >> char_ >> r, attr));
+ BOOST_TEST(attr.first == 123);
+ BOOST_TEST(attr.second == 'a');
+ }
+
+ { // bug: test that injected attributes are ok
+
+ rule<char const*, char(int) > r;
+
+ // problem code:
+ r = char_(_r1)[_val = _1];
+ }
+
+ return boost::report_errors();
+}
+

Added: trunk/libs/spirit/test/qi/rule4.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/rule4.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,171 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ Distributed under 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)
+=============================================================================*/
+
+// this file deliberately contains non-ascii characters
+// boostinspect:noascii
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_auxiliary.hpp>
+#include <boost/spirit/include/qi_directive.hpp>
+#include <boost/spirit/include/qi_nonterminal.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_object.hpp>
+#include <boost/spirit/include/phoenix_bind.hpp>
+#include <boost/fusion/include/std_pair.hpp>
+
+#include <string>
+#include <cstring>
+#include <iostream>
+#include "test.hpp"
+
+int
+main()
+{
+ using spirit_test::test_attr;
+ using spirit_test::test;
+
+ using namespace boost::spirit::ascii;
+ using namespace boost::spirit::qi::labels;
+ using boost::spirit::qi::locals;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::int_;
+ using boost::spirit::qi::uint_;
+ using boost::spirit::qi::fail;
+ using boost::spirit::qi::on_error;
+ using boost::spirit::qi::debug;
+ using boost::spirit::qi::lit;
+
+ namespace phx = boost::phoenix;
+
+
+ { // show that ra = rb and ra %= rb works as expected
+ rule<char const*, int() > ra, rb;
+ int attr;
+
+ ra %= int_;
+ BOOST_TEST(test_attr("123", ra, attr));
+ BOOST_TEST(attr == 123);
+
+ rb %= ra;
+ BOOST_TEST(test_attr("123", rb, attr));
+ BOOST_TEST(attr == 123);
+
+ rb = ra;
+ BOOST_TEST(test_attr("123", rb, attr));
+ BOOST_TEST(attr == 123);
+ }
+
+ { // std::string as container attribute with auto rules
+
+ rule<char const*, std::string()> text;
+ text %= +(!char_(')') >> !char_('>') >> char_);
+ std::string attr;
+ BOOST_TEST(test_attr("x", text, attr));
+ BOOST_TEST(attr == "x");
+
+ // test deduced auto rule behavior
+ text = +(!char_(')') >> !char_('>') >> char_);
+ attr.clear();
+ BOOST_TEST(test_attr("x", text, attr));
+ BOOST_TEST(attr == "x");
+ }
+
+ { // error handling
+
+ using namespace boost::spirit::ascii;
+ using boost::phoenix::construct;
+ using boost::phoenix::bind;
+
+ rule<char const*> r;
+ r = '(' > int_ > ',' > int_ > ')';
+
+ on_error<fail>
+ (
+ r, std::cout
+ << phx::val("Error! Expecting: ")
+ << _4
+ << phx::val(", got: \"")
+ << construct<std::string>(_3, _2)
+ << phx::val("\"")
+ << std::endl
+ );
+
+ BOOST_TEST(test("(123,456)", r));
+ BOOST_TEST(!test("(abc,def)", r));
+ BOOST_TEST(!test("(123,456]", r));
+ BOOST_TEST(!test("(123;456)", r));
+ BOOST_TEST(!test("[123,456]", r));
+ }
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("french")
+#endif
+ { // specifying the encoding
+
+ typedef boost::spirit::char_encoding::iso8859_1 iso8859_1;
+ rule<char const*, iso8859_1> r;
+
+ r = no_case['á'];
+ BOOST_TEST(test("Á", r));
+ r = no_case[char_('á')];
+ BOOST_TEST(test("Á", r));
+
+ r = no_case[char_("å-ï")];
+ BOOST_TEST(test("É", r));
+ BOOST_TEST(!test("ÿ", r));
+
+ r = no_case["áÁ"];
+ BOOST_TEST(test("Áá", r));
+ r = no_case[lit("áÁ")];
+ BOOST_TEST(test("Áá", r));
+ }
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("")
+#endif
+
+ {
+ typedef boost::variant<double, int> v_type;
+ rule<const char*, v_type()> r1 = int_;
+ v_type v;
+ BOOST_TEST(test_attr("1", r1, v) && v.which() == 1 &&
+ boost::get<int>(v) == 1);
+
+ typedef boost::optional<int> ov_type;
+ rule<const char*, ov_type()> r2 = int_;
+ ov_type ov;
+ BOOST_TEST(test_attr("1", r2, ov) && ov && boost::get<int>(ov) == 1);
+ }
+
+ // test handling of single element fusion sequences
+ {
+ using boost::fusion::vector;
+ using boost::fusion::at_c;
+ rule<const char*, vector<int>()> r = int_;
+
+ vector<int> v(0);
+ BOOST_TEST(test_attr("1", r, v) && at_c<0>(v) == 1);
+ }
+
+ {
+ using boost::fusion::vector;
+ using boost::fusion::at_c;
+ rule<const char*, vector<unsigned int>()> r = uint_;
+
+ vector<unsigned int> v(0);
+ BOOST_TEST(test_attr("1", r, v) && at_c<0>(v) == 1);
+ }
+
+ return boost::report_errors();
+}
+

Deleted: trunk/libs/spirit/test/qi/single_element_sequence_attribute.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/single_element_sequence_attribute.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,40 +0,0 @@
-// Copyright (c) 2010 Josh Wilson
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/spirit/include/qi.hpp>
-#include <boost/fusion/include/adapt_struct.hpp>
-#include <boost/variant.hpp>
-#include <string>
-
-namespace qi = boost::spirit::qi;
-
-///////////////////////////////////////////////////////////////////////////////
-struct Number { float base; };
-
-BOOST_FUSION_ADAPT_STRUCT( Number, (float, base) )
-
-void instantiate1()
-{
- qi::symbols<char, Number> sym;
- qi::rule<std::string::const_iterator, Number()> rule;
- rule %= sym; // Caused compiler error after getting r61322
-}
-
-///////////////////////////////////////////////////////////////////////////////
-typedef boost::variant<int, float> internal_type;
-
-struct Number2 { internal_type base; };
-
-BOOST_FUSION_ADAPT_STRUCT( Number2, (internal_type, base) )
-
-void instantiate2()
-{
- qi::symbols<char, Number2> sym;
- qi::rule<std::string::const_iterator, Number2()> rule;
- rule %= sym; // Caused compiler error after getting r61322
-}
-

Deleted: trunk/libs/spirit/test/qi/symbols.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/symbols.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,364 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under 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 <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/qi_string.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_action.hpp>
-#include <boost/spirit/include/qi_auxiliary.hpp>
-#include <boost/spirit/include/qi_directive.hpp>
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/spirit/include/qi_nonterminal.hpp>
-#include <boost/spirit/include/support_argument.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-
-#include <iostream>
-#include "test.hpp"
-
-// Custom string type with a C-style string conversion.
-struct custom_string_c
-{
- custom_string_c(char c) { str[0] = c; str[1] = '\0'; }
-
- operator char*() { return str; }
- operator char const*() const { return str; }
-
-private:
- char str[2];
-};
-
-int
-main()
-{
- using spirit_test::test;
- using spirit_test::test_attr;
- using boost::spirit::qi::symbols;
- using boost::spirit::qi::rule;
- using boost::spirit::qi::lazy;
- using boost::spirit::qi::_r1;
-
- { // basics
- symbols<char, int> sym;
-
- sym.add
- ("Joel")
- ("Ruby")
- ("Tenji")
- ("Tutit")
- ("Kim")
- ("Joey")
- ;
-
- boost::mpl::true_ f = boost::mpl::bool_<boost::spirit::traits::is_parser<symbols<char, int> >::value>();
-
- // silence stupid compiler warnings
- // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
- BOOST_TEST((f.value));
-
- BOOST_TEST((test("Joel", sym)));
- BOOST_TEST((test("Ruby", sym)));
- BOOST_TEST((test("Tenji", sym)));
- BOOST_TEST((test("Tutit", sym)));
- BOOST_TEST((test("Kim", sym)));
- BOOST_TEST((test("Joey", sym)));
- BOOST_TEST((!test("XXX", sym)));
-
- // test copy
- symbols<char, int> sym2;
- sym2 = sym;
- BOOST_TEST((test("Joel", sym2)));
- BOOST_TEST((test("Ruby", sym2)));
- BOOST_TEST((test("Tenji", sym2)));
- BOOST_TEST((test("Tutit", sym2)));
- BOOST_TEST((test("Kim", sym2)));
- BOOST_TEST((test("Joey", sym2)));
- BOOST_TEST((!test("XXX", sym2)));
-
- // make sure it plays well with other parsers
- BOOST_TEST((test("Joelyo", sym >> "yo")));
-
- sym.remove
- ("Joel")
- ("Ruby")
- ;
-
- BOOST_TEST((!test("Joel", sym)));
- BOOST_TEST((!test("Ruby", sym)));
- }
-
- { // comma syntax
- symbols<char, int> sym;
- sym += "Joel", "Ruby", "Tenji", "Tutit", "Kim", "Joey";
-
- BOOST_TEST((test("Joel", sym)));
- BOOST_TEST((test("Ruby", sym)));
- BOOST_TEST((test("Tenji", sym)));
- BOOST_TEST((test("Tutit", sym)));
- BOOST_TEST((test("Kim", sym)));
- BOOST_TEST((test("Joey", sym)));
- BOOST_TEST((!test("XXX", sym)));
-
- sym -= "Joel", "Ruby";
-
- BOOST_TEST((!test("Joel", sym)));
- BOOST_TEST((!test("Ruby", sym)));
- }
-
- { // no-case handling
- using namespace boost::spirit::ascii;
-
- symbols<char, int> sym;
- // NOTE: make sure all entries are in lower-case!!!
- sym = "joel", "ruby", "tenji", "tutit", "kim", "joey";
-
- BOOST_TEST((test("joel", no_case[sym])));
- BOOST_TEST((test("ruby", no_case[sym])));
- BOOST_TEST((test("tenji", no_case[sym])));
- BOOST_TEST((test("tutit", no_case[sym])));
- BOOST_TEST((test("kim", no_case[sym])));
- BOOST_TEST((test("joey", no_case[sym])));
-
- BOOST_TEST((test("JOEL", no_case[sym])));
- BOOST_TEST((test("RUBY", no_case[sym])));
- BOOST_TEST((test("TENJI", no_case[sym])));
- BOOST_TEST((test("TUTIT", no_case[sym])));
- BOOST_TEST((test("KIM", no_case[sym])));
- BOOST_TEST((test("JOEY", no_case[sym])));
-
- // make sure it plays well with other parsers
- BOOST_TEST((test("Joelyo", no_case[sym] >> "yo")));
- }
-
- { // attributes
- symbols<char, int> sym;
-
- sym.add
- ("Joel", 1)
- ("Ruby", 2)
- ("Tenji", 3)
- ("Tutit", 4)
- ("Kim", 5)
- ("Joey", 6)
- ;
-
- int i;
- BOOST_TEST((test_attr("Joel", sym, i)));
- BOOST_TEST(i == 1);
- BOOST_TEST((test_attr("Ruby", sym, i)));
- BOOST_TEST(i == 2);
- BOOST_TEST((test_attr("Tenji", sym, i)));
- BOOST_TEST(i == 3);
- BOOST_TEST((test_attr("Tutit", sym, i)));
- BOOST_TEST(i == 4);
- BOOST_TEST((test_attr("Kim", sym, i)));
- BOOST_TEST(i == 5);
- BOOST_TEST((test_attr("Joey", sym, i)));
- BOOST_TEST(i == 6);
- BOOST_TEST((!test_attr("XXX", sym, i)));
-
- // double add:
-
- sym.add("Joel", 265);
- BOOST_TEST((test_attr("Joel", sym, i)));
- BOOST_TEST(i == 1);
- }
-
- { // actions
- namespace phx = boost::phoenix;
- using boost::spirit::_1;
-
- symbols<char, int> sym;
- sym.add
- ("Joel", 1)
- ("Ruby", 2)
- ("Tenji", 3)
- ("Tutit", 4)
- ("Kim", 5)
- ("Joey", 6)
- ;
-
- int i;
- BOOST_TEST((test("Joel", sym[phx::ref(i) = _1])));
- BOOST_TEST(i == 1);
- BOOST_TEST((test("Ruby", sym[phx::ref(i) = _1])));
- BOOST_TEST(i == 2);
- BOOST_TEST((test("Tenji", sym[phx::ref(i) = _1])));
- BOOST_TEST(i == 3);
- BOOST_TEST((test("Tutit", sym[phx::ref(i) = _1])));
- BOOST_TEST(i == 4);
- BOOST_TEST((test("Kim", sym[phx::ref(i) = _1])));
- BOOST_TEST(i == 5);
- BOOST_TEST((test("Joey", sym[phx::ref(i) = _1])));
- BOOST_TEST(i == 6);
- BOOST_TEST((!test("XXX", sym[phx::ref(i) = _1])));
- }
-
- { // construction from symbol array
- char const* syms[] = {"Joel","Ruby","Tenji","Tutit","Kim","Joey"};
- symbols<char, int> sym(syms);
-
- BOOST_TEST((test("Joel", sym)));
- BOOST_TEST((test("Ruby", sym)));
- BOOST_TEST((test("Tenji", sym)));
- BOOST_TEST((test("Tutit", sym)));
- BOOST_TEST((test("Kim", sym)));
- BOOST_TEST((test("Joey", sym)));
- BOOST_TEST((!test("XXX", sym)));
- }
-
- { // construction from 2 arrays
-
- char const* syms[] = {"Joel","Ruby","Tenji","Tutit","Kim","Joey"};
- int data[] = {1,2,3,4,5,6};
- symbols<char, int> sym(syms, data);
-
- int i;
- BOOST_TEST((test_attr("Joel", sym, i)));
- BOOST_TEST(i == 1);
- BOOST_TEST((test_attr("Ruby", sym, i)));
- BOOST_TEST(i == 2);
- BOOST_TEST((test_attr("Tenji", sym, i)));
- BOOST_TEST(i == 3);
- BOOST_TEST((test_attr("Tutit", sym, i)));
- BOOST_TEST(i == 4);
- BOOST_TEST((test_attr("Kim", sym, i)));
- BOOST_TEST(i == 5);
- BOOST_TEST((test_attr("Joey", sym, i)));
- BOOST_TEST(i == 6);
- BOOST_TEST((!test_attr("XXX", sym, i)));
- }
-
- { // allow std::string and other string types
- symbols<> sym;
-
- // const and non-const std::string
- std::string a("abc");
- std::string const b("def");
- sym += a;
- sym += b;
- BOOST_TEST((test("abc", sym)));
- BOOST_TEST((test("def", sym)));
- sym = a;
- BOOST_TEST((test("abc", sym)));
- BOOST_TEST((!test("def", sym)));
-
- // non-const C-style string
- char arr[2]; arr[0] = 'a'; arr[1] = '\0';
- sym = arr;
- BOOST_TEST((test("a", sym)));
- BOOST_TEST((!test("b", sym)));
-
- // const and non-const custom string type
- custom_string_c c('x');
- custom_string_c const cc('y');
- sym = c, cc;
- BOOST_TEST((test("x", sym)));
- BOOST_TEST((test("y", sym)));
- BOOST_TEST((!test("z", sym)));
- }
-
- {
- namespace phx = boost::phoenix;
-
- symbols<char, int> sym;
- sym.add
- ("a", 1)
- ("b", 2)
- ;
-
- rule<char const*, int(symbols<char, int>&)> r;
- r %= lazy(_r1);
-
- int i = 0;
- BOOST_TEST(test_attr("a", r(phx::ref(sym)), i));
- BOOST_TEST(i == 1);
- BOOST_TEST(test_attr("b", r(phx::ref(sym)), i));
- BOOST_TEST(i == 2);
- BOOST_TEST(!test("c", r(phx::ref(sym))));
- }
-
- { // find
-
- symbols<char, int> sym;
- sym.add("a", 1)("b", 2);
-
- BOOST_TEST(!sym.find("c"));
-
- BOOST_TEST(sym.find("a") && *sym.find("a") == 1);
- BOOST_TEST(sym.find("b") && *sym.find("b") == 2);
-
- BOOST_TEST(sym.at("a") == 1);
- BOOST_TEST(sym.at("b") == 2);
- BOOST_TEST(sym.at("c") == 0);
-
- BOOST_TEST(sym.find("a") && *sym.find("a") == 1);
- BOOST_TEST(sym.find("b") && *sym.find("b") == 2);
- BOOST_TEST(sym.find("c") && *sym.find("c") == 0);
-
- symbols<char, int> const_sym(sym);
-
- BOOST_TEST(const_sym.find("a") && *const_sym.find("a") == 1);
- BOOST_TEST(const_sym.find("b") && *const_sym.find("b") == 2);
- BOOST_TEST(const_sym.find("c") && *const_sym.find("c") == 0);
- BOOST_TEST(!const_sym.find("d"));
-
- char const *str1 = "all";
- char const *first = str1, *last = str1 + 3;
- BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str1 + 1);
-
- char const *str2 = "dart";
- first = str2; last = str2 + 4;
- BOOST_TEST(!sym.prefix_find(first, last) && first == str2);
- }
-
- { // Substrings
-
- symbols<char, int> sym;
- BOOST_TEST(sym.at("foo") == 0);
- sym.at("foo") = 1;
- BOOST_TEST(sym.at("foo") == 1);
- BOOST_TEST(sym.at("fool") == 0);
- sym.at("fool") = 2;
- BOOST_TEST(sym.find("foo") && *sym.find("foo") == 1);
- BOOST_TEST(sym.find("fool") && *sym.find("fool") == 2);
- BOOST_TEST(!sym.find("foolish"));
- BOOST_TEST(!sym.find("foot"));
- BOOST_TEST(!sym.find("afoot"));
-
- char const *str, *first, *last;
- str = "foolish"; first = str; last = str + 7;
- BOOST_TEST(*sym.prefix_find(first, last) == 2 && first == str + 4);
-
- first = str; last = str + 4;
- BOOST_TEST(*sym.prefix_find(first, last) == 2 && first == str + 4);
-
- str = "food"; first = str; last = str + 4;
- BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str + 3);
-
- first = str; last = str + 3;
- BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str + 3);
-
- first = str; last = str + 2;
- BOOST_TEST(!sym.prefix_find(first, last) && first == str);
- }
-
- {
- // remove bug
-
- std::string s;
- symbols<char, double> vars;
-
- vars.add("l1", 12.0);
- vars.add("l2", 0.0);
- vars.remove("l2");
- vars.find("l1");
- double* d = vars.find("l1");
- BOOST_TEST(d != 0);
- }
-
- return boost::report_errors();
-}

Copied: trunk/libs/spirit/test/qi/symbols1.cpp (from r67483, /trunk/libs/spirit/test/qi/symbols.cpp)
==============================================================================
--- /trunk/libs/spirit/test/qi/symbols.cpp (original)
+++ trunk/libs/spirit/test/qi/symbols1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -197,168 +197,5 @@
         BOOST_TEST((!test("XXX", sym[phx::ref(i) = _1])));
     }
 
- { // construction from symbol array
- char const* syms[] = {"Joel","Ruby","Tenji","Tutit","Kim","Joey"};
- symbols<char, int> sym(syms);
-
- BOOST_TEST((test("Joel", sym)));
- BOOST_TEST((test("Ruby", sym)));
- BOOST_TEST((test("Tenji", sym)));
- BOOST_TEST((test("Tutit", sym)));
- BOOST_TEST((test("Kim", sym)));
- BOOST_TEST((test("Joey", sym)));
- BOOST_TEST((!test("XXX", sym)));
- }
-
- { // construction from 2 arrays
-
- char const* syms[] = {"Joel","Ruby","Tenji","Tutit","Kim","Joey"};
- int data[] = {1,2,3,4,5,6};
- symbols<char, int> sym(syms, data);
-
- int i;
- BOOST_TEST((test_attr("Joel", sym, i)));
- BOOST_TEST(i == 1);
- BOOST_TEST((test_attr("Ruby", sym, i)));
- BOOST_TEST(i == 2);
- BOOST_TEST((test_attr("Tenji", sym, i)));
- BOOST_TEST(i == 3);
- BOOST_TEST((test_attr("Tutit", sym, i)));
- BOOST_TEST(i == 4);
- BOOST_TEST((test_attr("Kim", sym, i)));
- BOOST_TEST(i == 5);
- BOOST_TEST((test_attr("Joey", sym, i)));
- BOOST_TEST(i == 6);
- BOOST_TEST((!test_attr("XXX", sym, i)));
- }
-
- { // allow std::string and other string types
- symbols<> sym;
-
- // const and non-const std::string
- std::string a("abc");
- std::string const b("def");
- sym += a;
- sym += b;
- BOOST_TEST((test("abc", sym)));
- BOOST_TEST((test("def", sym)));
- sym = a;
- BOOST_TEST((test("abc", sym)));
- BOOST_TEST((!test("def", sym)));
-
- // non-const C-style string
- char arr[2]; arr[0] = 'a'; arr[1] = '\0';
- sym = arr;
- BOOST_TEST((test("a", sym)));
- BOOST_TEST((!test("b", sym)));
-
- // const and non-const custom string type
- custom_string_c c('x');
- custom_string_c const cc('y');
- sym = c, cc;
- BOOST_TEST((test("x", sym)));
- BOOST_TEST((test("y", sym)));
- BOOST_TEST((!test("z", sym)));
- }
-
- {
- namespace phx = boost::phoenix;
-
- symbols<char, int> sym;
- sym.add
- ("a", 1)
- ("b", 2)
- ;
-
- rule<char const*, int(symbols<char, int>&)> r;
- r %= lazy(_r1);
-
- int i = 0;
- BOOST_TEST(test_attr("a", r(phx::ref(sym)), i));
- BOOST_TEST(i == 1);
- BOOST_TEST(test_attr("b", r(phx::ref(sym)), i));
- BOOST_TEST(i == 2);
- BOOST_TEST(!test("c", r(phx::ref(sym))));
- }
-
- { // find
-
- symbols<char, int> sym;
- sym.add("a", 1)("b", 2);
-
- BOOST_TEST(!sym.find("c"));
-
- BOOST_TEST(sym.find("a") && *sym.find("a") == 1);
- BOOST_TEST(sym.find("b") && *sym.find("b") == 2);
-
- BOOST_TEST(sym.at("a") == 1);
- BOOST_TEST(sym.at("b") == 2);
- BOOST_TEST(sym.at("c") == 0);
-
- BOOST_TEST(sym.find("a") && *sym.find("a") == 1);
- BOOST_TEST(sym.find("b") && *sym.find("b") == 2);
- BOOST_TEST(sym.find("c") && *sym.find("c") == 0);
-
- symbols<char, int> const_sym(sym);
-
- BOOST_TEST(const_sym.find("a") && *const_sym.find("a") == 1);
- BOOST_TEST(const_sym.find("b") && *const_sym.find("b") == 2);
- BOOST_TEST(const_sym.find("c") && *const_sym.find("c") == 0);
- BOOST_TEST(!const_sym.find("d"));
-
- char const *str1 = "all";
- char const *first = str1, *last = str1 + 3;
- BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str1 + 1);
-
- char const *str2 = "dart";
- first = str2; last = str2 + 4;
- BOOST_TEST(!sym.prefix_find(first, last) && first == str2);
- }
-
- { // Substrings
-
- symbols<char, int> sym;
- BOOST_TEST(sym.at("foo") == 0);
- sym.at("foo") = 1;
- BOOST_TEST(sym.at("foo") == 1);
- BOOST_TEST(sym.at("fool") == 0);
- sym.at("fool") = 2;
- BOOST_TEST(sym.find("foo") && *sym.find("foo") == 1);
- BOOST_TEST(sym.find("fool") && *sym.find("fool") == 2);
- BOOST_TEST(!sym.find("foolish"));
- BOOST_TEST(!sym.find("foot"));
- BOOST_TEST(!sym.find("afoot"));
-
- char const *str, *first, *last;
- str = "foolish"; first = str; last = str + 7;
- BOOST_TEST(*sym.prefix_find(first, last) == 2 && first == str + 4);
-
- first = str; last = str + 4;
- BOOST_TEST(*sym.prefix_find(first, last) == 2 && first == str + 4);
-
- str = "food"; first = str; last = str + 4;
- BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str + 3);
-
- first = str; last = str + 3;
- BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str + 3);
-
- first = str; last = str + 2;
- BOOST_TEST(!sym.prefix_find(first, last) && first == str);
- }
-
- {
- // remove bug
-
- std::string s;
- symbols<char, double> vars;
-
- vars.add("l1", 12.0);
- vars.add("l2", 0.0);
- vars.remove("l2");
- vars.find("l1");
- double* d = vars.find("l1");
- BOOST_TEST(d != 0);
- }
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/qi/symbols2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/symbols2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,208 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+
+ Distributed under 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 <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/qi_auxiliary.hpp>
+#include <boost/spirit/include/qi_directive.hpp>
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_nonterminal.hpp>
+#include <boost/spirit/include/support_argument.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+
+#include <iostream>
+#include "test.hpp"
+
+// Custom string type with a C-style string conversion.
+struct custom_string_c
+{
+ custom_string_c(char c) { str[0] = c; str[1] = '\0'; }
+
+ operator char*() { return str; }
+ operator char const*() const { return str; }
+
+private:
+ char str[2];
+};
+
+int
+main()
+{
+ using spirit_test::test;
+ using spirit_test::test_attr;
+ using boost::spirit::qi::symbols;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::lazy;
+ using boost::spirit::qi::_r1;
+
+ { // construction from symbol array
+ char const* syms[] = {"Joel","Ruby","Tenji","Tutit","Kim","Joey"};
+ symbols<char, int> sym(syms);
+
+ BOOST_TEST((test("Joel", sym)));
+ BOOST_TEST((test("Ruby", sym)));
+ BOOST_TEST((test("Tenji", sym)));
+ BOOST_TEST((test("Tutit", sym)));
+ BOOST_TEST((test("Kim", sym)));
+ BOOST_TEST((test("Joey", sym)));
+ BOOST_TEST((!test("XXX", sym)));
+ }
+
+ { // construction from 2 arrays
+
+ char const* syms[] = {"Joel","Ruby","Tenji","Tutit","Kim","Joey"};
+ int data[] = {1,2,3,4,5,6};
+ symbols<char, int> sym(syms, data);
+
+ int i;
+ BOOST_TEST((test_attr("Joel", sym, i)));
+ BOOST_TEST(i == 1);
+ BOOST_TEST((test_attr("Ruby", sym, i)));
+ BOOST_TEST(i == 2);
+ BOOST_TEST((test_attr("Tenji", sym, i)));
+ BOOST_TEST(i == 3);
+ BOOST_TEST((test_attr("Tutit", sym, i)));
+ BOOST_TEST(i == 4);
+ BOOST_TEST((test_attr("Kim", sym, i)));
+ BOOST_TEST(i == 5);
+ BOOST_TEST((test_attr("Joey", sym, i)));
+ BOOST_TEST(i == 6);
+ BOOST_TEST((!test_attr("XXX", sym, i)));
+ }
+
+ { // allow std::string and other string types
+ symbols<> sym;
+
+ // const and non-const std::string
+ std::string a("abc");
+ std::string const b("def");
+ sym += a;
+ sym += b;
+ BOOST_TEST((test("abc", sym)));
+ BOOST_TEST((test("def", sym)));
+ sym = a;
+ BOOST_TEST((test("abc", sym)));
+ BOOST_TEST((!test("def", sym)));
+
+ // non-const C-style string
+ char arr[2]; arr[0] = 'a'; arr[1] = '\0';
+ sym = arr;
+ BOOST_TEST((test("a", sym)));
+ BOOST_TEST((!test("b", sym)));
+
+ // const and non-const custom string type
+ custom_string_c c('x');
+ custom_string_c const cc('y');
+ sym = c, cc;
+ BOOST_TEST((test("x", sym)));
+ BOOST_TEST((test("y", sym)));
+ BOOST_TEST((!test("z", sym)));
+ }
+
+ {
+ namespace phx = boost::phoenix;
+
+ symbols<char, int> sym;
+ sym.add
+ ("a", 1)
+ ("b", 2)
+ ;
+
+ rule<char const*, int(symbols<char, int>&)> r;
+ r %= lazy(_r1);
+
+ int i = 0;
+ BOOST_TEST(test_attr("a", r(phx::ref(sym)), i));
+ BOOST_TEST(i == 1);
+ BOOST_TEST(test_attr("b", r(phx::ref(sym)), i));
+ BOOST_TEST(i == 2);
+ BOOST_TEST(!test("c", r(phx::ref(sym))));
+ }
+
+ { // find
+
+ symbols<char, int> sym;
+ sym.add("a", 1)("b", 2);
+
+ BOOST_TEST(!sym.find("c"));
+
+ BOOST_TEST(sym.find("a") && *sym.find("a") == 1);
+ BOOST_TEST(sym.find("b") && *sym.find("b") == 2);
+
+ BOOST_TEST(sym.at("a") == 1);
+ BOOST_TEST(sym.at("b") == 2);
+ BOOST_TEST(sym.at("c") == 0);
+
+ BOOST_TEST(sym.find("a") && *sym.find("a") == 1);
+ BOOST_TEST(sym.find("b") && *sym.find("b") == 2);
+ BOOST_TEST(sym.find("c") && *sym.find("c") == 0);
+
+ symbols<char, int> const_sym(sym);
+
+ BOOST_TEST(const_sym.find("a") && *const_sym.find("a") == 1);
+ BOOST_TEST(const_sym.find("b") && *const_sym.find("b") == 2);
+ BOOST_TEST(const_sym.find("c") && *const_sym.find("c") == 0);
+ BOOST_TEST(!const_sym.find("d"));
+
+ char const *str1 = "all";
+ char const *first = str1, *last = str1 + 3;
+ BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str1 + 1);
+
+ char const *str2 = "dart";
+ first = str2; last = str2 + 4;
+ BOOST_TEST(!sym.prefix_find(first, last) && first == str2);
+ }
+
+ { // Substrings
+
+ symbols<char, int> sym;
+ BOOST_TEST(sym.at("foo") == 0);
+ sym.at("foo") = 1;
+ BOOST_TEST(sym.at("foo") == 1);
+ BOOST_TEST(sym.at("fool") == 0);
+ sym.at("fool") = 2;
+ BOOST_TEST(sym.find("foo") && *sym.find("foo") == 1);
+ BOOST_TEST(sym.find("fool") && *sym.find("fool") == 2);
+ BOOST_TEST(!sym.find("foolish"));
+ BOOST_TEST(!sym.find("foot"));
+ BOOST_TEST(!sym.find("afoot"));
+
+ char const *str, *first, *last;
+ str = "foolish"; first = str; last = str + 7;
+ BOOST_TEST(*sym.prefix_find(first, last) == 2 && first == str + 4);
+
+ first = str; last = str + 4;
+ BOOST_TEST(*sym.prefix_find(first, last) == 2 && first == str + 4);
+
+ str = "food"; first = str; last = str + 4;
+ BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str + 3);
+
+ first = str; last = str + 3;
+ BOOST_TEST(*sym.prefix_find(first, last) == 1 && first == str + 3);
+
+ first = str; last = str + 2;
+ BOOST_TEST(!sym.prefix_find(first, last) && first == str);
+ }
+
+ {
+ // remove bug
+
+ std::string s;
+ symbols<char, double> vars;
+
+ vars.add("l1", 12.0);
+ vars.add("l2", 0.0);
+ vars.remove("l2");
+ vars.find("l1");
+ double* d = vars.find("l1");
+ BOOST_TEST(d != 0);
+ }
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/qi/utree.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/utree.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,402 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-// Copyright (c) 2001-2010 Joel de Guzman
-// Copyright (c) 2010 Bryce Lelbach
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/include/support_utree.hpp>
-#include <boost/mpl/print.hpp>
-
-#include <sstream>
-
-#include "test.hpp"
-
-inline bool check(boost::spirit::utree const& val, std::string expected)
-{
- std::stringstream s;
- s << val;
- if (s.str() == expected + " ")
- return true;
-
- std::cerr << "got result: " << s.str()
- << ", expected: " << expected << std::endl;
- return false;
-}
-
-int main()
-{
- using spirit_test::test_attr;
- using boost::spirit::utree;
- using boost::spirit::utree_type;
- using boost::spirit::utf8_string_range_type;
- using boost::spirit::utf8_symbol_type;
- using boost::spirit::utf8_string_type;
-
- using boost::spirit::qi::real_parser;
- using boost::spirit::qi::strict_real_policies;
- using boost::spirit::qi::digit;
- using boost::spirit::qi::char_;
- using boost::spirit::qi::string;
- using boost::spirit::qi::int_;
- using boost::spirit::qi::double_;
- using boost::spirit::qi::space;
- using boost::spirit::qi::space_type;
- using boost::spirit::qi::rule;
- using boost::spirit::qi::as;
- using boost::spirit::qi::lexeme;
-
- // primitive data types
- {
- utree ut;
- BOOST_TEST(test_attr("x", char_, ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"x\""));
- ut.clear();
- BOOST_TEST(test_attr("123", int_, ut) &&
- ut.which() == utree_type::int_type && check(ut, "123"));
- ut.clear();
- BOOST_TEST(test_attr("123.45", double_, ut) &&
- ut.which() == utree_type::double_type && check(ut, "123.45"));
- ut.clear();
-
- rule<char const*, utf8_string_type()> r1 = lexeme[*char_];
-
- BOOST_TEST(test_attr("foo", r1, ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"foo\""));
- ut.clear();
-
- rule<char const*, utf8_symbol_type()> r2 = lexeme[*char_];
-
- BOOST_TEST(test_attr("xyz", r2, ut) &&
- ut.which() == utree_type::symbol_type && check(ut, "xyz"));
- }
-
- // single character parsers
- {
- utree ut;
-
- // this rule returns a utree string
- rule<char const*, utree()> r1 = char_("abc");
-
- // this rule forces a utree list to be returned
- rule<char const*, utree::list_type()> r2 = char_("abc");
-
- BOOST_TEST(test_attr("a", r1, ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"a\""));
- ut.clear();
- BOOST_TEST(test_attr("a", r2, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"a\" )"));
- }
-
- // sequences
- {
- using boost::spirit::qi::as_string;
-
- utree ut;
- BOOST_TEST(test_attr("xy", char_ >> char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
- BOOST_TEST(test_attr("123 456", int_ >> int_, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
- ut.clear();
- BOOST_TEST(test_attr("1.23 4.56", double_ >> double_, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
- ut.clear();
- BOOST_TEST(test_attr("1.2ab", double_ >> *char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.2 \"a\" \"b\" )"));
- ut.clear();
- BOOST_TEST(test_attr("ab1.2", *~digit >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
-
- // forces a utree list
- rule<char const*, utree::list_type()> r1 = double_;
-
- ut.clear();
- BOOST_TEST(test_attr("1.2ab", r1 >> *char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( ( 1.2 ) \"a\" \"b\" )"));
- ut.clear();
- BOOST_TEST(test_attr("ab1.2", *~digit >> r1, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" ( 1.2 ) )"));
- ut.clear();
-
- // implicitly a utree list, because of sequence attribute rules
- rule<char const*, utree()> r2 = int_ >> char_("!") >> double_;
-
- BOOST_TEST(test_attr("17!3.14", r2, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 17 \"!\" 3.14 )"));
- ut.clear();
-
- rule<char const*, utree()> r3 = double_ >> as_string[string("foo")] >> int_;
-
- BOOST_TEST(test_attr("0.5foo5", r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 0.5 \"foo\" 5 )"));
- ut.clear();
- }
-
- // kleene star
- {
- typedef real_parser<double, strict_real_policies<double> >
- strict_double_type;
- strict_double_type const strict_double = strict_double_type();
-
- utree ut;
- BOOST_TEST(test_attr("xy", *char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
- BOOST_TEST(test_attr("123 456", *int_, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
- ut.clear();
- BOOST_TEST(test_attr("1.23 4.56", *double_, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
- ut.clear();
-
- rule<char const*, utree(), space_type> r1 =
- strict_double | int_ | ~char_("()") | ('(' >> *r1 >> ')');
-
- BOOST_TEST(test_attr("(x y)", r1, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
- BOOST_TEST(test_attr("(((123)) 456)", r1, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( ( ( 123 ) ) 456 )"));
- ut.clear();
- BOOST_TEST(test_attr("((1.23 4.56))", r1, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( ( 1.23 4.56 ) )"));
- ut.clear();
- BOOST_TEST(test_attr("x", r1, ut, space) &&
- ut.which() == utree_type::string_type && check(ut, "\"x\""));
- ut.clear();
- BOOST_TEST(test_attr("123", r1, ut, space) &&
- ut.which() == utree_type::int_type && check(ut, "123"));
- ut.clear();
- BOOST_TEST(test_attr("123.456", r1, ut, space) &&
- ut.which() == utree_type::double_type && check(ut, "123.456"));
- ut.clear();
- BOOST_TEST(test_attr("()", r1, ut, space) &&
- ut.which() == utree_type::list_type &&
- check(ut, "( )"));
- ut.clear();
- BOOST_TEST(test_attr("((()))", r1, ut, space) &&
- ut.which() == utree_type::list_type &&
- check(ut, "( ( ( ) ) )"));
- ut.clear();
- }
-
- // lists
- {
- utree ut;
- BOOST_TEST(test_attr("x,y", char_ % ',', ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
- BOOST_TEST(test_attr("123,456", int_ % ',', ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
- ut.clear();
- BOOST_TEST(test_attr("1.23,4.56", double_ % ',', ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
-
- rule<char const*, std::vector<char>()> r1 = char_ % ',';
- ut.clear();
- BOOST_TEST(test_attr("x,y", r1, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
-
- rule<char const*, std::vector<int>()> r2 = int_ % ',';
- ut.clear();
- BOOST_TEST(test_attr("123,456", r2, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
-
- rule<char const*, std::vector<double>()> r3 = double_ % ',';
- ut.clear();
- BOOST_TEST(test_attr("1.23,4.56", r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
-
- rule<char const*, utree()> r4 = double_ % ',';
- ut.clear();
- BOOST_TEST(test_attr("1.23,4.56", r4, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
- }
-
- // alternatives
- {
- typedef real_parser<double, strict_real_policies<double> >
- strict_double_type;
- strict_double_type const strict_double = strict_double_type();
-
- utree ut;
- BOOST_TEST(test_attr("10", strict_double | int_, ut) &&
- ut.which() == utree_type::int_type && check(ut, "10"));
- ut.clear();
- BOOST_TEST(test_attr("10.2", strict_double | int_, ut) &&
- ut.which() == utree_type::double_type && check(ut, "10.2"));
-
- rule<char const*, boost::variant<int, double>()> r1 = strict_double | int_;
- ut.clear();
- BOOST_TEST(test_attr("10", r1, ut) &&
- ut.which() == utree_type::int_type && check(ut, "10"));
- ut.clear();
- BOOST_TEST(test_attr("10.2", r1, ut) &&
- ut.which() == utree_type::double_type && check(ut, "10.2"));
-
- rule<char const*, utree()> r2 = strict_double | int_;
- ut.clear();
- BOOST_TEST(test_attr("10", r2, ut) &&
- ut.which() == utree_type::int_type && check(ut, "10"));
- ut.clear();
- BOOST_TEST(test_attr("10.2", r2, ut) &&
- ut.which() == utree_type::double_type && check(ut, "10.2"));
-
- rule<char const*, utree::list_type()> r3 = strict_double | int_;
- ut.clear();
- BOOST_TEST(test_attr("10", r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 10 )"));
- ut.clear();
- BOOST_TEST(test_attr("10.2", r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 10.2 )"));
- }
-
- // optionals
- {
- utree ut;
- BOOST_TEST(test_attr("x", -char_, ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"x\""));
- ut.clear();
- BOOST_TEST(test_attr("", -char_, ut) &&
- ut.which() == utree_type::invalid_type &&
- check(ut, "<invalid>"));
- }
-
- // as_string
- {
- using boost::spirit::qi::as_string;
-
- utree ut;
- BOOST_TEST(test_attr("xy", as_string[char_ >> char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("ab1.2", as_string[*~digit] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("xy", as_string[*char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", as_string[char_ >> ',' >> char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", char_ >> ',' >> char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
-
- BOOST_TEST(test_attr("a,b1.2", as_string[~digit % ','] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("a,b1.2", ~digit % ',' >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
- ut.clear();
- }
-
- // as
- {
- typedef as<std::string> as_string_type;
- as_string_type const as_string = as_string_type();
-
- typedef as<utf8_symbol_type> as_symbol_type;
- as_symbol_type const as_symbol = as_symbol_type();
-
- utree ut;
- BOOST_TEST(test_attr("xy", as_string[char_ >> char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("ab1.2", as_string[*~digit] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("xy", as_string[*char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", as_string[char_ >> ',' >> char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", char_ >> ',' >> char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
-
- BOOST_TEST(test_attr("a,b1.2", as_string[~digit % ','] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("a,b1.2", ~digit % ',' >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("xy", as_symbol[char_ >> char_], ut) &&
- ut.which() == utree_type::symbol_type && check(ut, "xy"));
- ut.clear();
-
- BOOST_TEST(test_attr("ab1.2", as_symbol[*~digit] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( ab 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("xy", as_symbol[*char_], ut) &&
- ut.which() == utree_type::symbol_type && check(ut, "xy"));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", as_symbol[char_ >> ',' >> char_], ut) &&
- ut.which() == utree_type::symbol_type && check(ut, "xy"));
- ut.clear();
- BOOST_TEST(test_attr("a,b1.2", as_symbol[~digit % ','] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( ab 1.2 )"));
- ut.clear();
- }
-
- // subtrees
- {
- // -(+int_) is forcing a subtree
- utree ut;
- BOOST_TEST(test_attr("1 2", int_ >> ' ' >> -(+int_), ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("1 2", int_ >> ' ' >> *int_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 )"));
- ut.clear();
-
- rule<char const*, std::vector<int>()> r1 = int_ % ',';
- BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r1, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 3 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("1,2 2,3", r1 >> ' ' >> r1, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 2 3 )"));
- ut.clear();
-
- rule<char const*, utree()> r2 = int_ % ',';
- BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r2, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 3 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("1,2 2,3", r2 >> ' ' >> r2, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 2 3 )"));
- ut.clear();
-
- rule<char const*, utree::list_type()> r3 = int_ % ',';
- BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 ( 2 3 ) )"));
- ut.clear();
-
- BOOST_TEST(test_attr("1,2 2,3", r3 >> ' ' >> r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( ( 1 2 ) ( 2 3 ) )"));
- ut.clear();
- }
-
- return boost::report_errors();
-}

Copied: trunk/libs/spirit/test/qi/utree1.cpp (from r67483, /trunk/libs/spirit/test/qi/utree.cpp)
==============================================================================
--- /trunk/libs/spirit/test/qi/utree.cpp (original)
+++ trunk/libs/spirit/test/qi/utree1.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -137,266 +137,5 @@
         ut.clear();
     }
 
- // kleene star
- {
- typedef real_parser<double, strict_real_policies<double> >
- strict_double_type;
- strict_double_type const strict_double = strict_double_type();
-
- utree ut;
- BOOST_TEST(test_attr("xy", *char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
- BOOST_TEST(test_attr("123 456", *int_, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
- ut.clear();
- BOOST_TEST(test_attr("1.23 4.56", *double_, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
- ut.clear();
-
- rule<char const*, utree(), space_type> r1 =
- strict_double | int_ | ~char_("()") | ('(' >> *r1 >> ')');
-
- BOOST_TEST(test_attr("(x y)", r1, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
- BOOST_TEST(test_attr("(((123)) 456)", r1, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( ( ( 123 ) ) 456 )"));
- ut.clear();
- BOOST_TEST(test_attr("((1.23 4.56))", r1, ut, space) &&
- ut.which() == utree_type::list_type && check(ut, "( ( 1.23 4.56 ) )"));
- ut.clear();
- BOOST_TEST(test_attr("x", r1, ut, space) &&
- ut.which() == utree_type::string_type && check(ut, "\"x\""));
- ut.clear();
- BOOST_TEST(test_attr("123", r1, ut, space) &&
- ut.which() == utree_type::int_type && check(ut, "123"));
- ut.clear();
- BOOST_TEST(test_attr("123.456", r1, ut, space) &&
- ut.which() == utree_type::double_type && check(ut, "123.456"));
- ut.clear();
- BOOST_TEST(test_attr("()", r1, ut, space) &&
- ut.which() == utree_type::list_type &&
- check(ut, "( )"));
- ut.clear();
- BOOST_TEST(test_attr("((()))", r1, ut, space) &&
- ut.which() == utree_type::list_type &&
- check(ut, "( ( ( ) ) )"));
- ut.clear();
- }
-
- // lists
- {
- utree ut;
- BOOST_TEST(test_attr("x,y", char_ % ',', ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
- BOOST_TEST(test_attr("123,456", int_ % ',', ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
- ut.clear();
- BOOST_TEST(test_attr("1.23,4.56", double_ % ',', ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
-
- rule<char const*, std::vector<char>()> r1 = char_ % ',';
- ut.clear();
- BOOST_TEST(test_attr("x,y", r1, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
-
- rule<char const*, std::vector<int>()> r2 = int_ % ',';
- ut.clear();
- BOOST_TEST(test_attr("123,456", r2, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
-
- rule<char const*, std::vector<double>()> r3 = double_ % ',';
- ut.clear();
- BOOST_TEST(test_attr("1.23,4.56", r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
-
- rule<char const*, utree()> r4 = double_ % ',';
- ut.clear();
- BOOST_TEST(test_attr("1.23,4.56", r4, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
- }
-
- // alternatives
- {
- typedef real_parser<double, strict_real_policies<double> >
- strict_double_type;
- strict_double_type const strict_double = strict_double_type();
-
- utree ut;
- BOOST_TEST(test_attr("10", strict_double | int_, ut) &&
- ut.which() == utree_type::int_type && check(ut, "10"));
- ut.clear();
- BOOST_TEST(test_attr("10.2", strict_double | int_, ut) &&
- ut.which() == utree_type::double_type && check(ut, "10.2"));
-
- rule<char const*, boost::variant<int, double>()> r1 = strict_double | int_;
- ut.clear();
- BOOST_TEST(test_attr("10", r1, ut) &&
- ut.which() == utree_type::int_type && check(ut, "10"));
- ut.clear();
- BOOST_TEST(test_attr("10.2", r1, ut) &&
- ut.which() == utree_type::double_type && check(ut, "10.2"));
-
- rule<char const*, utree()> r2 = strict_double | int_;
- ut.clear();
- BOOST_TEST(test_attr("10", r2, ut) &&
- ut.which() == utree_type::int_type && check(ut, "10"));
- ut.clear();
- BOOST_TEST(test_attr("10.2", r2, ut) &&
- ut.which() == utree_type::double_type && check(ut, "10.2"));
-
- rule<char const*, utree::list_type()> r3 = strict_double | int_;
- ut.clear();
- BOOST_TEST(test_attr("10", r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 10 )"));
- ut.clear();
- BOOST_TEST(test_attr("10.2", r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 10.2 )"));
- }
-
- // optionals
- {
- utree ut;
- BOOST_TEST(test_attr("x", -char_, ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"x\""));
- ut.clear();
- BOOST_TEST(test_attr("", -char_, ut) &&
- ut.which() == utree_type::invalid_type &&
- check(ut, "<invalid>"));
- }
-
- // as_string
- {
- using boost::spirit::qi::as_string;
-
- utree ut;
- BOOST_TEST(test_attr("xy", as_string[char_ >> char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("ab1.2", as_string[*~digit] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("xy", as_string[*char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", as_string[char_ >> ',' >> char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", char_ >> ',' >> char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
-
- BOOST_TEST(test_attr("a,b1.2", as_string[~digit % ','] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("a,b1.2", ~digit % ',' >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
- ut.clear();
- }
-
- // as
- {
- typedef as<std::string> as_string_type;
- as_string_type const as_string = as_string_type();
-
- typedef as<utf8_symbol_type> as_symbol_type;
- as_symbol_type const as_symbol = as_symbol_type();
-
- utree ut;
- BOOST_TEST(test_attr("xy", as_string[char_ >> char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("ab1.2", as_string[*~digit] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("xy", as_string[*char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", as_string[char_ >> ',' >> char_], ut) &&
- ut.which() == utree_type::string_type && check(ut, "\"xy\""));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", char_ >> ',' >> char_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
- ut.clear();
-
- BOOST_TEST(test_attr("a,b1.2", as_string[~digit % ','] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("a,b1.2", ~digit % ',' >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("xy", as_symbol[char_ >> char_], ut) &&
- ut.which() == utree_type::symbol_type && check(ut, "xy"));
- ut.clear();
-
- BOOST_TEST(test_attr("ab1.2", as_symbol[*~digit] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( ab 1.2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("xy", as_symbol[*char_], ut) &&
- ut.which() == utree_type::symbol_type && check(ut, "xy"));
- ut.clear();
-
- BOOST_TEST(test_attr("x,y", as_symbol[char_ >> ',' >> char_], ut) &&
- ut.which() == utree_type::symbol_type && check(ut, "xy"));
- ut.clear();
- BOOST_TEST(test_attr("a,b1.2", as_symbol[~digit % ','] >> double_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( ab 1.2 )"));
- ut.clear();
- }
-
- // subtrees
- {
- // -(+int_) is forcing a subtree
- utree ut;
- BOOST_TEST(test_attr("1 2", int_ >> ' ' >> -(+int_), ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("1 2", int_ >> ' ' >> *int_, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 )"));
- ut.clear();
-
- rule<char const*, std::vector<int>()> r1 = int_ % ',';
- BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r1, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 3 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("1,2 2,3", r1 >> ' ' >> r1, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 2 3 )"));
- ut.clear();
-
- rule<char const*, utree()> r2 = int_ % ',';
- BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r2, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 3 )"));
- ut.clear();
-
- BOOST_TEST(test_attr("1,2 2,3", r2 >> ' ' >> r2, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 2 2 3 )"));
- ut.clear();
-
- rule<char const*, utree::list_type()> r3 = int_ % ',';
- BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( 1 ( 2 3 ) )"));
- ut.clear();
-
- BOOST_TEST(test_attr("1,2 2,3", r3 >> ' ' >> r3, ut) &&
- ut.which() == utree_type::list_type && check(ut, "( ( 1 2 ) ( 2 3 ) )"));
- ut.clear();
- }
-
     return boost::report_errors();
 }

Added: trunk/libs/spirit/test/qi/utree2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/utree2.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,135 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2010 Joel de Guzman
+// Copyright (c) 2010 Bryce Lelbach
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/support_utree.hpp>
+#include <boost/mpl/print.hpp>
+
+#include <sstream>
+
+#include "test.hpp"
+
+inline bool check(boost::spirit::utree const& val, std::string expected)
+{
+ std::stringstream s;
+ s << val;
+ if (s.str() == expected + " ")
+ return true;
+
+ std::cerr << "got result: " << s.str()
+ << ", expected: " << expected << std::endl;
+ return false;
+}
+
+int main()
+{
+ using spirit_test::test_attr;
+ using boost::spirit::utree;
+ using boost::spirit::utree_type;
+ using boost::spirit::utf8_string_range_type;
+ using boost::spirit::utf8_symbol_type;
+ using boost::spirit::utf8_string_type;
+
+ using boost::spirit::qi::real_parser;
+ using boost::spirit::qi::strict_real_policies;
+ using boost::spirit::qi::digit;
+ using boost::spirit::qi::char_;
+ using boost::spirit::qi::string;
+ using boost::spirit::qi::int_;
+ using boost::spirit::qi::double_;
+ using boost::spirit::qi::space;
+ using boost::spirit::qi::space_type;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::as;
+ using boost::spirit::qi::lexeme;
+
+ // kleene star
+ {
+ typedef real_parser<double, strict_real_policies<double> >
+ strict_double_type;
+ strict_double_type const strict_double = strict_double_type();
+
+ utree ut;
+ BOOST_TEST(test_attr("xy", *char_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
+ ut.clear();
+ BOOST_TEST(test_attr("123 456", *int_, ut, space) &&
+ ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
+ ut.clear();
+ BOOST_TEST(test_attr("1.23 4.56", *double_, ut, space) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
+ ut.clear();
+
+ rule<char const*, utree(), space_type> r1 =
+ strict_double | int_ | ~char_("()") | ('(' >> *r1 >> ')');
+
+ BOOST_TEST(test_attr("(x y)", r1, ut, space) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
+ ut.clear();
+ BOOST_TEST(test_attr("(((123)) 456)", r1, ut, space) &&
+ ut.which() == utree_type::list_type && check(ut, "( ( ( 123 ) ) 456 )"));
+ ut.clear();
+ BOOST_TEST(test_attr("((1.23 4.56))", r1, ut, space) &&
+ ut.which() == utree_type::list_type && check(ut, "( ( 1.23 4.56 ) )"));
+ ut.clear();
+ BOOST_TEST(test_attr("x", r1, ut, space) &&
+ ut.which() == utree_type::string_type && check(ut, "\"x\""));
+ ut.clear();
+ BOOST_TEST(test_attr("123", r1, ut, space) &&
+ ut.which() == utree_type::int_type && check(ut, "123"));
+ ut.clear();
+ BOOST_TEST(test_attr("123.456", r1, ut, space) &&
+ ut.which() == utree_type::double_type && check(ut, "123.456"));
+ ut.clear();
+ BOOST_TEST(test_attr("()", r1, ut, space) &&
+ ut.which() == utree_type::list_type &&
+ check(ut, "( )"));
+ ut.clear();
+ BOOST_TEST(test_attr("((()))", r1, ut, space) &&
+ ut.which() == utree_type::list_type &&
+ check(ut, "( ( ( ) ) )"));
+ ut.clear();
+ }
+
+ // lists
+ {
+ utree ut;
+ BOOST_TEST(test_attr("x,y", char_ % ',', ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
+ ut.clear();
+ BOOST_TEST(test_attr("123,456", int_ % ',', ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
+ ut.clear();
+ BOOST_TEST(test_attr("1.23,4.56", double_ % ',', ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
+
+ rule<char const*, std::vector<char>()> r1 = char_ % ',';
+ ut.clear();
+ BOOST_TEST(test_attr("x,y", r1, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
+
+ rule<char const*, std::vector<int>()> r2 = int_ % ',';
+ ut.clear();
+ BOOST_TEST(test_attr("123,456", r2, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 123 456 )"));
+
+ rule<char const*, std::vector<double>()> r3 = double_ % ',';
+ ut.clear();
+ BOOST_TEST(test_attr("1.23,4.56", r3, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
+
+ rule<char const*, utree()> r4 = double_ % ',';
+ ut.clear();
+ BOOST_TEST(test_attr("1.23,4.56", r4, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/qi/utree3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/utree3.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,137 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2010 Joel de Guzman
+// Copyright (c) 2010 Bryce Lelbach
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/support_utree.hpp>
+#include <boost/mpl/print.hpp>
+
+#include <sstream>
+
+#include "test.hpp"
+
+inline bool check(boost::spirit::utree const& val, std::string expected)
+{
+ std::stringstream s;
+ s << val;
+ if (s.str() == expected + " ")
+ return true;
+
+ std::cerr << "got result: " << s.str()
+ << ", expected: " << expected << std::endl;
+ return false;
+}
+
+int main()
+{
+ using spirit_test::test_attr;
+ using boost::spirit::utree;
+ using boost::spirit::utree_type;
+ using boost::spirit::utf8_string_range_type;
+ using boost::spirit::utf8_symbol_type;
+ using boost::spirit::utf8_string_type;
+
+ using boost::spirit::qi::real_parser;
+ using boost::spirit::qi::strict_real_policies;
+ using boost::spirit::qi::digit;
+ using boost::spirit::qi::char_;
+ using boost::spirit::qi::string;
+ using boost::spirit::qi::int_;
+ using boost::spirit::qi::double_;
+ using boost::spirit::qi::space;
+ using boost::spirit::qi::space_type;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::as;
+ using boost::spirit::qi::lexeme;
+
+ // alternatives
+ {
+ typedef real_parser<double, strict_real_policies<double> >
+ strict_double_type;
+ strict_double_type const strict_double = strict_double_type();
+
+ utree ut;
+ BOOST_TEST(test_attr("10", strict_double | int_, ut) &&
+ ut.which() == utree_type::int_type && check(ut, "10"));
+ ut.clear();
+ BOOST_TEST(test_attr("10.2", strict_double | int_, ut) &&
+ ut.which() == utree_type::double_type && check(ut, "10.2"));
+
+ rule<char const*, boost::variant<int, double>()> r1 = strict_double | int_;
+ ut.clear();
+ BOOST_TEST(test_attr("10", r1, ut) &&
+ ut.which() == utree_type::int_type && check(ut, "10"));
+ ut.clear();
+ BOOST_TEST(test_attr("10.2", r1, ut) &&
+ ut.which() == utree_type::double_type && check(ut, "10.2"));
+
+ rule<char const*, utree()> r2 = strict_double | int_;
+ ut.clear();
+ BOOST_TEST(test_attr("10", r2, ut) &&
+ ut.which() == utree_type::int_type && check(ut, "10"));
+ ut.clear();
+ BOOST_TEST(test_attr("10.2", r2, ut) &&
+ ut.which() == utree_type::double_type && check(ut, "10.2"));
+
+ rule<char const*, utree::list_type()> r3 = strict_double | int_;
+ ut.clear();
+ BOOST_TEST(test_attr("10", r3, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 10 )"));
+ ut.clear();
+ BOOST_TEST(test_attr("10.2", r3, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 10.2 )"));
+ }
+
+ // optionals
+ {
+ utree ut;
+ BOOST_TEST(test_attr("x", -char_, ut) &&
+ ut.which() == utree_type::string_type && check(ut, "\"x\""));
+ ut.clear();
+ BOOST_TEST(test_attr("", -char_, ut) &&
+ ut.which() == utree_type::invalid_type &&
+ check(ut, "<invalid>"));
+ }
+
+ // as_string
+ {
+ using boost::spirit::qi::as_string;
+
+ utree ut;
+ BOOST_TEST(test_attr("xy", as_string[char_ >> char_], ut) &&
+ ut.which() == utree_type::string_type && check(ut, "\"xy\""));
+ ut.clear();
+
+ BOOST_TEST(test_attr("ab1.2", as_string[*~digit] >> double_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("xy", as_string[*char_], ut) &&
+ ut.which() == utree_type::string_type && check(ut, "\"xy\""));
+ ut.clear();
+
+ BOOST_TEST(test_attr("x,y", as_string[char_ >> ',' >> char_], ut) &&
+ ut.which() == utree_type::string_type && check(ut, "\"xy\""));
+ ut.clear();
+
+ BOOST_TEST(test_attr("x,y", char_ >> ',' >> char_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("a,b1.2", as_string[~digit % ','] >> double_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("a,b1.2", ~digit % ',' >> double_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
+ ut.clear();
+ }
+
+ return boost::report_errors();
+}

Added: trunk/libs/spirit/test/qi/utree4.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/utree4.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
@@ -0,0 +1,151 @@
+// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2010 Joel de Guzman
+// Copyright (c) 2010 Bryce Lelbach
+//
+// Distributed under 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 <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/support_utree.hpp>
+#include <boost/mpl/print.hpp>
+
+#include <sstream>
+
+#include "test.hpp"
+
+inline bool check(boost::spirit::utree const& val, std::string expected)
+{
+ std::stringstream s;
+ s << val;
+ if (s.str() == expected + " ")
+ return true;
+
+ std::cerr << "got result: " << s.str()
+ << ", expected: " << expected << std::endl;
+ return false;
+}
+
+int main()
+{
+ using spirit_test::test_attr;
+ using boost::spirit::utree;
+ using boost::spirit::utree_type;
+ using boost::spirit::utf8_string_range_type;
+ using boost::spirit::utf8_symbol_type;
+ using boost::spirit::utf8_string_type;
+
+ using boost::spirit::qi::real_parser;
+ using boost::spirit::qi::strict_real_policies;
+ using boost::spirit::qi::digit;
+ using boost::spirit::qi::char_;
+ using boost::spirit::qi::string;
+ using boost::spirit::qi::int_;
+ using boost::spirit::qi::double_;
+ using boost::spirit::qi::space;
+ using boost::spirit::qi::space_type;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::as;
+ using boost::spirit::qi::lexeme;
+
+ // as
+ {
+ typedef as<std::string> as_string_type;
+ as_string_type const as_string = as_string_type();
+
+ typedef as<utf8_symbol_type> as_symbol_type;
+ as_symbol_type const as_symbol = as_symbol_type();
+
+ utree ut;
+ BOOST_TEST(test_attr("xy", as_string[char_ >> char_], ut) &&
+ ut.which() == utree_type::string_type && check(ut, "\"xy\""));
+ ut.clear();
+
+ BOOST_TEST(test_attr("ab1.2", as_string[*~digit] >> double_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("xy", as_string[*char_], ut) &&
+ ut.which() == utree_type::string_type && check(ut, "\"xy\""));
+ ut.clear();
+
+ BOOST_TEST(test_attr("x,y", as_string[char_ >> ',' >> char_], ut) &&
+ ut.which() == utree_type::string_type && check(ut, "\"xy\""));
+ ut.clear();
+
+ BOOST_TEST(test_attr("x,y", char_ >> ',' >> char_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"x\" \"y\" )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("a,b1.2", as_string[~digit % ','] >> double_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"ab\" 1.2 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("a,b1.2", ~digit % ',' >> double_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("xy", as_symbol[char_ >> char_], ut) &&
+ ut.which() == utree_type::symbol_type && check(ut, "xy"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("ab1.2", as_symbol[*~digit] >> double_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( ab 1.2 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("xy", as_symbol[*char_], ut) &&
+ ut.which() == utree_type::symbol_type && check(ut, "xy"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("x,y", as_symbol[char_ >> ',' >> char_], ut) &&
+ ut.which() == utree_type::symbol_type && check(ut, "xy"));
+ ut.clear();
+ BOOST_TEST(test_attr("a,b1.2", as_symbol[~digit % ','] >> double_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( ab 1.2 )"));
+ ut.clear();
+ }
+
+ // subtrees
+ {
+ // -(+int_) is forcing a subtree
+ utree ut;
+ BOOST_TEST(test_attr("1 2", int_ >> ' ' >> -(+int_), ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1 2 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("1 2", int_ >> ' ' >> *int_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1 2 )"));
+ ut.clear();
+
+ rule<char const*, std::vector<int>()> r1 = int_ % ',';
+ BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r1, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1 2 3 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("1,2 2,3", r1 >> ' ' >> r1, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1 2 2 3 )"));
+ ut.clear();
+
+ rule<char const*, utree()> r2 = int_ % ',';
+ BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r2, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1 2 3 )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("1,2 2,3", r2 >> ' ' >> r2, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1 2 2 3 )"));
+ ut.clear();
+
+ rule<char const*, utree::list_type()> r3 = int_ % ',';
+ BOOST_TEST(test_attr("1 2,3", int_ >> ' ' >> r3, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1 ( 2 3 ) )"));
+ ut.clear();
+
+ BOOST_TEST(test_attr("1,2 2,3", r3 >> ' ' >> r3, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( ( 1 2 ) ( 2 3 ) )"));
+ ut.clear();
+ }
+
+ return boost::report_errors();
+}

Deleted: trunk/libs/spirit/test/support/multi_pass_regression001.cpp
==============================================================================
--- trunk/libs/spirit/test/support/multi_pass_regression001.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,26 +0,0 @@
-// Copyright (c) 2010 Chris Hoeppler
-//
-// Distributed under 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)
-
-// This code below failed to compile with MSVC starting with Boost V1.42
-
-#include <vector>
-#include <boost/spirit/include/classic_position_iterator.hpp>
-#include <boost/spirit/include/qi.hpp>
-
-namespace char_enc = boost::spirit::ascii;
-namespace qi = boost::spirit::qi;
-
-int main()
-{
- typedef std::vector<char> file_storage;
- typedef boost::spirit::classic::position_iterator<
- file_storage::const_iterator> iterator_type;
-
- qi::rule<iterator_type, std::string(), qi::blank_type> top =
- qi::lexeme[+char_enc::alpha];
-
- return 0;
-}
-

Deleted: trunk/libs/spirit/test/support/multi_pass_regression002.cpp
==============================================================================
--- trunk/libs/spirit/test/support/multi_pass_regression002.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,107 +0,0 @@
-// Copyright (c) 2010 Larry Evans
-//
-// Distributed under 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)
-
-//Purpose:
-// Demonstrate error in non-classic multi_pass iterator compilation.
-//
-
-#include <boost/spirit/home/qi.hpp>
-#include <boost/spirit/home/support.hpp>
-#include <boost/spirit/home/support/multi_pass.hpp>
-#include <boost/spirit/home/support/iterators/detail/functor_input_policy.hpp>
-
-#include <fstream>
-
-//[iterate_a2m:
-// copied from:
-// http://www.boost.org/doc/libs/1_41_0/libs/spirit/doc/html/spirit/support/multi_pass.html
-
-// define the function object
-template<typename CharT=char>
-class istreambuf_functor
-{
-public:
- typedef
- std::istreambuf_iterator<CharT>
- buf_iterator_type;
- typedef
- typename buf_iterator_type::int_type
- result_type;
- static
- result_type
- eof;
-
- istreambuf_functor(void)
- : current_chr(eof)
- {}
-
- istreambuf_functor(std::ifstream& input)
- : my_first(input)
- , current_chr(eof)
- {}
-
- result_type operator()()
- {
- buf_iterator_type last;
- if (my_first == last)
- {
- return eof;
- }
- current_chr=*my_first;
- ++my_first;
- return current_chr;
- }
-
-private:
- buf_iterator_type my_first;
- result_type current_chr;
-};
-
-template<typename CharT>
- typename istreambuf_functor<CharT>::result_type
- istreambuf_functor<CharT>::
-eof
-( istreambuf_functor<CharT>::buf_iterator_type::traits_type::eof()
-)
-;
-
-//]iterate_a2m:
-
-typedef istreambuf_functor<char> base_iterator_type;
-
-typedef
- boost::spirit::multi_pass
- < base_iterator_type
- , boost::spirit::iterator_policies::default_policy
- < boost::spirit::iterator_policies::first_owner
- , boost::spirit::iterator_policies::no_check
- , boost::spirit::iterator_policies::functor_input
- , boost::spirit::iterator_policies::split_std_deque
- >
- >
-chr_iterator_type;
-
-// ======================================================================
-// Main
-int main(int argc, char** argv)
-{
- std::ifstream in("multi_pass.txt");
-
- unsigned num_toks=0;
- unsigned const max_toks=10;
-
- base_iterator_type base_first(in);
- chr_iterator_type chr_first(base_first);
- chr_iterator_type chr_last;
- for
- (
- ; (chr_first != chr_last && ++num_toks < max_toks)
- ; ++chr_first
- )
- {
- std::cout<<":num_toks="<<num_toks<<":chr="<<*chr_first<<"\n";
- }
- return 0;
-}

Deleted: trunk/libs/spirit/test/support/multi_pass_regression003.cpp
==============================================================================
--- trunk/libs/spirit/test/support/multi_pass_regression003.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,61 +0,0 @@
-// Copyright (c) 2010 Peter Schueller
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <vector>
-#include <istream>
-#include <sstream>
-#include <iostream>
-
-#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/include/support_multi_pass.hpp>
-
-namespace qi = boost::spirit::qi;
-namespace ascii = boost::spirit::ascii;
-
-std::vector<double> parse(std::istream& input)
-{
- // iterate over stream input
- typedef std::istreambuf_iterator<char> base_iterator_type;
- base_iterator_type in_begin(input);
-
- // convert input iterator to forward iterator, usable by spirit parser
- typedef boost::spirit::multi_pass<base_iterator_type> forward_iterator_type;
- forward_iterator_type fwd_begin = boost::spirit::make_default_multi_pass(in_begin);
- forward_iterator_type fwd_end;
-
- // prepare output
- std::vector<double> output;
-
- // parse
- bool r = qi::phrase_parse(
- fwd_begin, fwd_end, // iterators over input
- qi::double_ >> *(',' >> qi::double_) >> qi::eoi, // recognize list of doubles
- ascii::space | '#' >> *(ascii::char_ - qi::eol) >> qi::eol, // comment skipper
- output); // doubles are stored into this object
-
- // error detection
- if( !r || fwd_begin != fwd_end )
- throw std::runtime_error("parse error");
-
- // return result
- return output;
-}
-
-int main()
-{
- try {
- std::stringstream str("1.0,2.0\n");
- std::vector<double> values = parse(str);
- BOOST_TEST(values.size() == 2 && values[0] == 1.0 && values[1] == 2.0);
- }
- catch(std::exception const&) {
- BOOST_TEST(false);
- }
- return boost::report_errors();
-}

Deleted: trunk/libs/spirit/test/support/utree_test.cpp
==============================================================================
--- trunk/libs/spirit/test/support/utree_test.cpp 2010-12-29 16:17:01 EST (Wed, 29 Dec 2010)
+++ (empty file)
@@ -1,397 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
- Copyright (c) 2001-2010 Hartmut Kaiser
- Copyright (c) 2010 Bryce Lelbach
-
- Distributed under 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 <boost/config/warning_disable.hpp>
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/support_utree.hpp>
-
-#include <iostream>
-#include <sstream>
-#include <cstdlib>
-
-inline bool check(boost::spirit::utree const& val, std::string expected)
-{
- std::stringstream s;
- s << val;
- if (s.str() == expected + " ")
- return true;
-
- std::cerr << "got result: " << s.str()
- << ", expected: " << expected << std::endl;
- return false;
-}
-
-struct one_two_three
-{
- boost::spirit::utree operator()(boost::spirit::scope) const
- {
- return boost::spirit::utree(123);
- }
-};
-
-int main()
-{
- using boost::spirit::utree;
- using boost::spirit::utf8_symbol_type;
- using boost::spirit::binary_string_type;
-
- {
- // test the size
- std::cout << "size of utree is: "
- << sizeof(utree) << " bytes" << std::endl;
- BOOST_TEST(sizeof(utree) == sizeof(void*[4]));
- }
-
- {
- utree val(utree::nil);
- BOOST_TEST(check(val, "<nil>"));
- }
-
- {
- utree val(utree::list);
- BOOST_TEST(check(val, "( )"));
- }
-
- {
- utree val(true);
- BOOST_TEST(check(val, "true"));
- }
-
- {
- utree val(123);
- BOOST_TEST(check(val, "123"));
- }
-
- {
- // single element string
- utree val('x');
- BOOST_TEST(check(val, "\"x\""));
-
- // empty string
- utree val1("");
- BOOST_TEST(check(val1, "\"\""));
- }
-
- {
- utree val(123.456);
- BOOST_TEST(check(val, "123.456"));
- }
-
- { // strings
- utree val("Hello, World");
- BOOST_TEST(check(val, "\"Hello, World\""));
- utree val2;
- val2 = val;
- BOOST_TEST(check(val2, "\"Hello, World\""));
- utree val3("Hello, World. Chuckie is back!!!");
- val = val3;
- BOOST_TEST(check(val, "\"Hello, World. Chuckie is back!!!\""));
-
- utree val4("Apple");
- utree val5("Apple");
- BOOST_TEST(val4 == val5);
-
- utree val6("ApplePie");
- BOOST_TEST(val4 < val6);
- }
-
- { // symbols
- utree val(utf8_symbol_type("Hello, World"));
- BOOST_TEST(check(val, "Hello, World"));
- utree val2;
- val2 = val;
- BOOST_TEST(check(val2, "Hello, World"));
- utree val3(utf8_symbol_type("Hello, World. Chuckie is back!!!"));
- val = val3;
- BOOST_TEST(check(val, "Hello, World. Chuckie is back!!!"));
-
- utree val4(utf8_symbol_type("Apple"));
- utree val5(utf8_symbol_type("Apple"));
- BOOST_TEST(val4 == val5);
-
- utree val6(utf8_symbol_type("ApplePie"));
- BOOST_TEST(val4 < val6);
- }
-
- { // binary_strings
- utree val(binary_string_type("\xDE#\xAD"));
- BOOST_TEST(check(val, "#de23ad#" /* FIXME?: "#\xDE#\xAD#" */));
- utree val2;
- val2 = val;
- BOOST_TEST(check(val2, "#de23ad#" /* FIXME?: "#\xDE#\xAD#" */));
- utree val3(binary_string_type("\xDE\xAD\xBE\xEF"));
- val = val3;
- BOOST_TEST(check(val, "#deadbeef#" /* FIXME?: "#\xDE\xAD\xBE\xEF#" */));
-
- utree val4(binary_string_type("\x01"));
- utree val5(binary_string_type("\x01"));
- BOOST_TEST(val4 == val5);
-
- utree val6(binary_string_type("\x01\x02"));
- BOOST_TEST(val4 < val6);
- }
-
- {
- utree val;
- val.push_back(123);
- val.push_back("Chuckie");
- BOOST_TEST(val.size() == 2);
- utree val2;
- val2.push_back(123.456);
- val2.push_back("Mah Doggie");
- val.push_back(val2);
- BOOST_TEST(val.size() == 3);
- BOOST_TEST(check(val, "( 123 \"Chuckie\" ( 123.456 \"Mah Doggie\" ) )"));
- BOOST_TEST(check(val.front(), "123"));
-
- utree val3(utree::nil);
- val3.swap(val);
- BOOST_TEST(val3.size() == 3);
- BOOST_TEST(check(val, "<nil>"));
- val3.swap(val);
- BOOST_TEST(check(val, "( 123 \"Chuckie\" ( 123.456 \"Mah Doggie\" ) )"));
- val.push_back("another string");
- BOOST_TEST(val.size() == 4);
- BOOST_TEST(check(val, "( 123 \"Chuckie\" ( 123.456 \"Mah Doggie\" ) \"another string\" )"));
- val.pop_front();
- BOOST_TEST(check(val, "( \"Chuckie\" ( 123.456 \"Mah Doggie\" ) \"another string\" )"));
- utree::iterator i = val.begin();
- ++++i;
- val.insert(i, "Right in the middle");
- BOOST_TEST(val.size() == 4);
- BOOST_TEST(check(val, "( \"Chuckie\" ( 123.456 \"Mah Doggie\" ) \"Right in the middle\" \"another string\" )"));
- val.pop_back();
- BOOST_TEST(check(val, "( \"Chuckie\" ( 123.456 \"Mah Doggie\" ) \"Right in the middle\" )"));
- BOOST_TEST(val.size() == 3);
- utree::iterator it = val.end(); --it;
- val.erase(it);
- BOOST_TEST(check(val, "( \"Chuckie\" ( 123.456 \"Mah Doggie\" ) )"));
- BOOST_TEST(val.size() == 2);
-
- val.insert(val.begin(), val2.begin(), val2.end());
- BOOST_TEST(check(val, "( 123.456 \"Mah Doggie\" \"Chuckie\" ( 123.456 \"Mah Doggie\" ) )"));
- BOOST_TEST(val.size() == 4);
- }
-
- {
- utree val;
- val.insert(val.end(), 123);
- val.insert(val.end(), "Mia");
- val.insert(val.end(), "Chuckie");
- val.insert(val.end(), "Poly");
- val.insert(val.end(), "Mochi");
- BOOST_TEST(check(val, "( 123 \"Mia\" \"Chuckie\" \"Poly\" \"Mochi\" )"));
- }
-
- {
- utree a(utree::nil), b(utree::nil);
- BOOST_TEST(a == b);
- a = 123;
- BOOST_TEST(a != b);
- b = 123;
- BOOST_TEST(a == b);
- a = 100.00;
- BOOST_TEST(a < b);
-
- b = a = utree(utree::invalid);
- BOOST_TEST(a == b);
- a.push_back(1);
- a.push_back("two");
- a.push_back(3.0);
- b.push_back(1);
- b.push_back("two");
- b.push_back(3.0);
- BOOST_TEST(a == b);
- b.push_back(4);
- BOOST_TEST(a != b);
- BOOST_TEST(a < b);
- }
-
- {
- utree a(utree::list);
- a.push_back(1);
- a.push_back(2);
- a.push_back(3);
- a.push_back(4);
- a.push_back(5);
- a.push_back(6);
- a.push_back(7);
- a.push_back(8);
- a.push_back(9);
- a.push_back(10);
- a.push_back(11);
- a.push_back(12);
-
- BOOST_TEST(a[0] == utree(1));
- BOOST_TEST(a[1] == utree(2));
- BOOST_TEST(a[2] == utree(3));
- BOOST_TEST(a[3] == utree(4));
- BOOST_TEST(a[4] == utree(5));
- BOOST_TEST(a[5] == utree(6));
- BOOST_TEST(a[6] == utree(7));
- BOOST_TEST(a[7] == utree(8));
- BOOST_TEST(a[8] == utree(9));
- BOOST_TEST(a[9] == utree(10));
- BOOST_TEST(a[10] == utree(11));
- BOOST_TEST(a[11] == utree(12));
- }
-
- {
- // test empty list
- utree a;
- a.push_back(1);
- a.pop_front();
- BOOST_TEST(check(a, "( )"));
-
- // the other way around
- utree b;
- b.push_front(1);
- b.pop_back();
- BOOST_TEST(check(b, "( )"));
- }
-
- { // test references
- utree val(123);
- utree ref(boost::ref(val));
- BOOST_TEST(check(ref, "123"));
- BOOST_TEST(ref == utree(123));
-
- val.clear();
- val.push_back(1);
- val.push_back(2);
- val.push_back(3);
- val.push_back(4);
- BOOST_TEST(check(ref, "( 1 2 3 4 )"));
- BOOST_TEST(ref[0] == utree(1));
- BOOST_TEST(ref[1] == utree(2));
- BOOST_TEST(ref[2] == utree(3));
- BOOST_TEST(ref[3] == utree(4));
- }
-
- { // put it in an array
-
- utree vals[] = {
- utree(123),
- utree("Hello, World"),
- utree(123.456)
- };
-
- BOOST_TEST(check(vals[0], "123"));
- BOOST_TEST(check(vals[1], "\"Hello, World\""));
- BOOST_TEST(check(vals[2], "123.456"));
- }
-
- { // operators
-
- BOOST_TEST((utree(true) && utree(true)) == utree(true));
- BOOST_TEST((utree(true) || utree(false)) == utree(true));
- BOOST_TEST(!utree(true) == utree(false));
-
- BOOST_TEST((utree(456) + utree(123)) == utree(456 + 123));
- BOOST_TEST((utree(456) + utree(123.456)) == utree(456 + 123.456));
- BOOST_TEST((utree(456) - utree(123)) == utree(456 - 123));
- BOOST_TEST((utree(456) - utree(123.456)) == utree(456 - 123.456));
- BOOST_TEST((utree(456) * utree(123)) == utree(456 * 123));
- BOOST_TEST((utree(456) * utree(123.456)) == utree(456 * 123.456));
- BOOST_TEST((utree(456) / utree(123)) == utree(456 / 123));
- BOOST_TEST((utree(456) / utree(123.456)) == utree(456 / 123.456));
- BOOST_TEST((utree(456) % utree(123)) == utree(456 % 123));
- BOOST_TEST(-utree(456) == utree(-456));
-
- BOOST_TEST((utree(456) & utree(123)) == utree(456 & 123));
- BOOST_TEST((utree(456) | utree(123)) == utree(456 | 123));
- BOOST_TEST((utree(456) ^ utree(123)) == utree(456 ^ 123));
- BOOST_TEST((utree(456) << utree(3)) == utree(456 << 3));
- BOOST_TEST((utree(456) >> utree(2)) == utree(456 >> 2));
- BOOST_TEST(~utree(456) == utree(~456));
- }
-
- { // test reference iterator
- utree val;
- val.push_back(1);
- val.push_back(2);
- val.push_back(3);
- val.push_back(4);
- BOOST_TEST(check(val, "( 1 2 3 4 )"));
-
- utree::ref_iterator b = val.ref_begin();
- utree::ref_iterator e = val.ref_end();
-
- utree ref(boost::make_iterator_range(b, e));
- BOOST_TEST(ref[0] == utree(1));
- BOOST_TEST(ref[1] == utree(2));
- BOOST_TEST(ref[2] == utree(3));
- BOOST_TEST(ref[3] == utree(4));
- BOOST_TEST(check(ref, "( 1 2 3 4 )"));
- }
-
- {
- // check the tag
- utree x;
- x.tag(123);
- BOOST_TEST(x.tag() == 123);
- }
-
- {
- // test functions
- using boost::spirit::stored_function;
- using boost::spirit::scope;
-
- utree f = stored_function<one_two_three>();
- f.eval(scope());
- }
-
- {
- // shallow ranges
- using boost::spirit::shallow;
-
- utree val;
- val.push_back(1);
- val.push_back(2);
- val.push_back(3);
- val.push_back(4);
-
- utree::iterator i = val.begin(); ++i;
- utree alias(utree::range(i, val.end()), shallow);
-
- BOOST_TEST(check(alias, "( 2 3 4 )"));
- BOOST_TEST(alias.size() == 3);
- BOOST_TEST(alias.front() == 2);
- BOOST_TEST(alias.back() == 4);
- BOOST_TEST(!alias.empty());
- BOOST_TEST(alias[1] == 3);
- }
-
- {
- // shallow string ranges
- using boost::spirit::utf8_string_range_type;
- using boost::spirit::shallow;
-
- char const* s = "Hello, World";
- utree val(utf8_string_range_type(s, s + strlen(s)), shallow);
- BOOST_TEST(check(val, "\"Hello, World\""));
-
- utf8_string_range_type r = val.get<utf8_string_range_type>();
- utf8_string_range_type pf(r.begin()+1, r.end()-1);
- val = utree(pf, shallow);
- BOOST_TEST(check(val, "\"ello, Worl\""));
- }
-
- {
- // any pointer
- using boost::spirit::any_ptr;
-
- int n = 123;
- utree up = any_ptr(&n);
- BOOST_TEST(*up.get<int*>() == 123);
- }
-
- 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