Add tests for new locale.h functions
This commit is contained in:
+3
-1
@@ -46,7 +46,9 @@ EXPECT_NAMES=\
|
||||
glob \
|
||||
iso646 \
|
||||
libgen \
|
||||
locale \
|
||||
locale/duplocale \
|
||||
locale/newlocale \
|
||||
locale/setlocale \
|
||||
math \
|
||||
regex \
|
||||
select \
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main() {
|
||||
struct lconv *lconv0 = localeconv();
|
||||
|
||||
locale_t locale0 = uselocale(NULL);
|
||||
assert(locale0 == LC_GLOBAL_LOCALE);
|
||||
|
||||
locale_t locale1 = uselocale(LC_GLOBAL_LOCALE);
|
||||
assert(locale1 == LC_GLOBAL_LOCALE);
|
||||
|
||||
struct lconv *lconv1 = localeconv();
|
||||
assert(lconv0 == lconv1);
|
||||
|
||||
locale_t locale2 = newlocale(LC_ALL_MASK, "C", (locale_t)0);
|
||||
assert(locale2 != LC_GLOBAL_LOCALE);
|
||||
|
||||
struct lconv *lconv2 = localeconv();
|
||||
assert(lconv2 == lconv1);
|
||||
|
||||
locale_t locale3 = duplocale(locale2);
|
||||
assert(locale3 != locale2);
|
||||
assert(locale3 != LC_GLOBAL_LOCALE);
|
||||
|
||||
locale_t locale4 = uselocale(locale3);
|
||||
assert(locale4 == locale1);
|
||||
|
||||
struct lconv *lconv3 = localeconv();
|
||||
assert(lconv3 != lconv2);
|
||||
|
||||
// should not crash
|
||||
freelocale(locale3);
|
||||
freelocale(locale2);
|
||||
freelocale(locale1);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main() {
|
||||
locale_t locale0 = newlocale(LC_ALL_MASK, "C", (locale_t)0);
|
||||
assert(locale0 != (locale_t)0);
|
||||
|
||||
locale_t locale1 = newlocale(LC_ALL_MASK, "non-existent-locale", (locale_t)0);
|
||||
assert(locale1 == (locale_t)0);
|
||||
|
||||
// TODO: test with existing custom locale
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user