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