diff options
Diffstat (limited to '')
-rw-r--r-- | src/boost/tools/cmake/test/locale/CMakeLists.txt | 21 | ||||
-rw-r--r-- | src/boost/tools/cmake/test/locale/main.cpp | 32 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/boost/tools/cmake/test/locale/CMakeLists.txt b/src/boost/tools/cmake/test/locale/CMakeLists.txt new file mode 100644 index 000000000..294322903 --- /dev/null +++ b/src/boost/tools/cmake/test/locale/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2018, 2019, 2021 Peter Dimov +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_locale_install_test LANGUAGES CXX) + +if(BOOST_RUNTIME_LINK STREQUAL "static") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") +endif() + +find_package(boost_locale REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::locale) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>) diff --git a/src/boost/tools/cmake/test/locale/main.cpp b/src/boost/tools/cmake/test/locale/main.cpp new file mode 100644 index 000000000..4a7056365 --- /dev/null +++ b/src/boost/tools/cmake/test/locale/main.cpp @@ -0,0 +1,32 @@ +// Copyright 2009-2011 Artyom Beilis (Tonkikh) +// Copyright 2021 Peter Dimov +// 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/locale.hpp> +#include <iostream> +#include <ctime> + +int main() +{ + boost::locale::generator gen; + + std::locale loc = gen( "en_US.UTF-8" ); + + std::cout.imbue( loc ); + + std::cout << boost::locale::format( "Today {1,date} at {1,time} we had run our first localization example" ) % std::time( 0 ) << std::endl; + + std::cout << "This is how we show numbers in this locale " << boost::locale::as::number << 103.34 << std::endl; + std::cout << "This is how we show currency in this locale " << boost::locale::as::currency << 103.34 << std::endl; + + std::cout << "This is typical date in the locale " << boost::locale::as::date << std::time( 0 ) << std::endl; + std::cout << "This is typical time in the locale " << boost::locale::as::time << std::time( 0 ) << std::endl; + + std::string str( "Hello World!" ); + + std::cout << "This is upper case " << boost::locale::to_upper( str, loc ) << std::endl; + std::cout << "This is lower case " << boost::locale::to_lower( str, loc ) << std::endl; + std::cout << "This is title case " << boost::locale::to_title( str, loc ) << std::endl; + std::cout << "This is fold case " << boost::locale::fold_case( str, loc ) << std::endl; +} |