xref: /aosp_15_r20/external/llvm-libc/test/src/locale/locale_test.cpp (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- Unittests for locale ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "src/locale/freelocale.h"
10 #include "src/locale/newlocale.h"
11 #include "src/locale/uselocale.h"
12 
13 #include "test/UnitTest/Test.h"
14 
15 #include "include/llvm-libc-macros/locale-macros.h"
16 
TEST(LlvmLibcLocale,DefaultLocale)17 TEST(LlvmLibcLocale, DefaultLocale) {
18   locale_t new_locale = LIBC_NAMESPACE::newlocale(LC_ALL, "C", nullptr);
19   EXPECT_NE(new_locale, static_cast<locale_t>(nullptr));
20 
21   locale_t old_locale = LIBC_NAMESPACE::uselocale(new_locale);
22   EXPECT_NE(old_locale, static_cast<locale_t>(nullptr));
23 
24   LIBC_NAMESPACE::freelocale(new_locale);
25 
26   LIBC_NAMESPACE::uselocale(old_locale);
27 }
28