blob: 914d358db8624a7c6b19d5ed7de84f4db7069500 [file] [log] [blame] [edit]
/* Copyright (C) 1999-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include "third_party/glibc_locales/glibc_locales.h"
#define FAIL(str, args...) \
{ \
printf("FAIL: " str "\n", ##args); \
++errors; \
}
int main(int argc, char *argv[]) {
int errors = 0;
for (int c = 0; c < 128; ++c) {
if (google_iswlower(c)) {
/* Get corresponding upper case character. */
int up = google_towupper(c);
/* This should have no effect. */
int low = google_towlower(c);
if ((c != low) || (up == c) || (up == low))
FAIL("iswlower/towupper/towlower for character \\%x wrong\n", c);
}
if (google_iswupper(c)) {
/* Get corresponding lower case character. */
int low = google_towlower(c);
/* This should have no effect. */
int up = google_towupper(c);
if ((c != up) || (low == c) || (up == low))
FAIL("iswupper/towlower/towupper for character \\%x wrong\n", c);
}
}
/* Finally some specific tests. */
if (!google_iswupper(L'A') || google_iswlower(L'A'))
FAIL("!iswupper/iswlower (L'A') wrong\n");
if (google_iswupper(L'a') || !google_iswlower(L'a'))
FAIL("iswupper/!iswlower (L'a') wrong\n");
if (google_towlower(L'A') != L'a') FAIL("towlower(L'A') wrong\n");
if (google_towupper(L'a') != L'A') FAIL("towupper(L'a') wrong\n");
if (errors != 0) {
printf("Result: %d error%s\n", errors, errors == 1 ? "" : "s");
return 1;
}
printf("PASS: No errors\n");
return 0;
}