diff options
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale/locale/encoding.cc')
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/locale/encoding.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/locale/encoding.cc b/libstdc++-v3/testsuite/22_locale/locale/encoding.cc new file mode 100644 index 0000000..18825fb --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/locale/encoding.cc @@ -0,0 +1,36 @@ +// { dg-options "-lstdc++exp" } +// { dg-do run { target c++26 } } +// { dg-require-namedlocale "en_US.ISO8859-1" } +// { dg-require-namedlocale "fr_FR.ISO8859-15" } + +#include <locale> +#include <testsuite_hooks.h> + +void +test_encoding() +{ + const std::locale c = std::locale::classic(); + std::text_encoding c_enc = c.encoding(); + VERIFY( c_enc == std::text_encoding::ASCII ); + + const std::locale fr = std::locale(ISO_8859(15, fr_FR)); + std::text_encoding fr_enc = fr.encoding(); + VERIFY( fr_enc == std::text_encoding::ISO885915 ); + + const std::locale en = std::locale(ISO_8859(1, en_US)); + std::text_encoding en_enc = en.encoding(); + VERIFY( en_enc == std::text_encoding::ISOLatin1 ); + +#if __cpp_exceptions + try { + const std::locale c_utf8 = std::locale("C.UTF-8"); + VERIFY( c_utf8.encoding() == std::text_encoding::UTF8 ); + } catch (...) { + } +#endif +} + +int main() +{ + test_encoding(); +} |