Example #1
0
int main () {
    test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
    test ( "ABCDE");
    test ( "a" );
    test ( "" );

    test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
    test ( L"ABCDE" );
    test ( L"a" );
    test ( L"" );

#if __cplusplus >= 201103L
    test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
    test ( u"ABCDE" );
    test ( u"a" );
    test ( u"" );

    test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
    test ( U"ABCDE" );
    test ( U"a" );
    test ( U"" );
#endif
    
#if _LIBCPP_STD_VER > 11
    {
    constexpr std::experimental::string_view sv1 { "ABCDE", 5 };

    {
    constexpr std::experimental::string_view sv2 = sv1.substr ( 0, 3 );
    static_assert ( sv2.size() == 3, "" );
    static_assert ( sv2[0] == 'A', "" );
    static_assert ( sv2[1] == 'B', "" );
    static_assert ( sv2[2] == 'C', "" );
    }
    
    {
    constexpr std::experimental::string_view sv2 = sv1.substr ( 3, 0 );
    static_assert ( sv2.size() == 0, "" );
    }

    {
    constexpr std::experimental::string_view sv2 = sv1.substr ( 3, 3 );
    static_assert ( sv2.size() == 2, "" );
    static_assert ( sv2[0] == 'D', "" );
    static_assert ( sv2[1] == 'E', "" );
    }
    }
#endif
}
Example #2
0
		static OutputContainer splitted(const std::experimental::string_view &collection, const Element &element) {
			OutputContainer output;
			if(!collection.empty()) {
				unsigned int start = 0, i = 0;
				for(; i != collection.size();) {
					if(collection[i] == element) {
						output.push_back(collection.substr(start, i-start));
						++i;
						start = i;
					} else
						++i;
				}
				output.push_back(collection.substr(start, i));
			}
			return output;
		}
Example #3
0
int main () {
    test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
    test ( "ABCDE");
    test ( "a" );
    test ( "" );

    test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
    test ( L"ABCDE" );
    test ( L"a" );
    test ( L"" );

    test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
    test ( u"ABCDE" );
    test ( u"a" );
    test ( u"" );

    test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
    test ( U"ABCDE" );
    test ( U"a" );
    test ( U"" );
    
    {
    constexpr std::experimental::string_view sv1 { "ABCDE", 5 };

    {
    constexpr std::experimental::string_view sv2 = sv1.substr ( 0, 3 );
    static_assert ( sv2.size() == 3, "" );
    static_assert ( sv2[0] == 'A', "" );
    static_assert ( sv2[1] == 'B', "" );
    static_assert ( sv2[2] == 'C', "" );
    }
    
    {
    constexpr std::experimental::string_view sv2 = sv1.substr ( 3, 0 );
    static_assert ( sv2.size() == 0, "" );
    }

    {
    constexpr std::experimental::string_view sv2 = sv1.substr ( 3, 3 );
    static_assert ( sv2.size() == 2, "" );
    static_assert ( sv2[0] == 'D', "" );
    static_assert ( sv2[1] == 'E', "" );
    }
    }
    
}
Example #4
0
bool Tial::Utility::Logger::toBeLoggedRuntime(Level level, const std::experimental::string_view &module) {
	auto moduleLevel = levels.find(module.to_string());
	if(moduleLevel == levels.end()) {
		auto sep = module.rfind("::");
		if(sep == module.npos)
			return level >= globalLevel;

		return toBeLoggedRuntime(level, module.substr(0, sep));
	}
	return level >= moduleLevel->second;
}