1 // Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey 2 // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ 3 4 #include "test.hpp" 5 #include "verify_char.hpp" 6 #include "verify_meta.hpp" 7 #include "verify_rule.hpp" 8 9 namespace TAO_PEGTL_NAMESPACE 10 { unit_test()11 void unit_test() 12 { 13 verify_meta< bytes< 0 >, internal::success >(); 14 verify_meta< bytes< 1 >, internal::bytes< 1 > >(); 15 verify_meta< bytes< 42 >, internal::bytes< 42 > >(); 16 17 verify_analyze< bytes< 0 > >( __LINE__, __FILE__, false, false ); 18 19 verify_rule< bytes< 0 > >( __LINE__, __FILE__, "", result_type::success, 0 ); 20 verify_rule< bytes< 0 > >( __LINE__, __FILE__, "a", result_type::success, 1 ); 21 22 verify_analyze< bytes< 1 > >( __LINE__, __FILE__, true, false ); 23 24 for( char c = 0; c < 127; ++c ) { 25 verify_char< bytes< 1 > >( __LINE__, __FILE__, c, result_type::success ); 26 } 27 verify_rule< bytes< 1 > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); 28 verify_rule< bytes< 1 > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); 29 30 verify_analyze< bytes< 2 > >( __LINE__, __FILE__, true, false ); 31 verify_analyze< bytes< 42 > >( __LINE__, __FILE__, true, false ); 32 33 verify_rule< bytes< 3 > >( __LINE__, __FILE__, "abcd", result_type::success, 1 ); 34 verify_rule< bytes< 4 > >( __LINE__, __FILE__, "abcd", result_type::success, 0 ); 35 verify_rule< bytes< 5 > >( __LINE__, __FILE__, "abcd", result_type::local_failure, 4 ); 36 37 verify_rule< bytes< 4 > >( __LINE__, __FILE__, "abcdefghij", result_type::success, 6 ); 38 } 39 40 } // namespace TAO_PEGTL_NAMESPACE 41 42 #include "main.hpp" 43