]> git.sesse.net Git - vlc/blob - test/native/i18n.c
Merge back branch 0.8.6-playlist-vlm to trunk.
[vlc] / test / native / i18n.c
1 /*****************************************************************************
2  * i18n: I18n tests
3  *****************************************************************************
4  * Copyright (C) 2006 RĂ©mi Denis-Courmont
5  * $Id: i18n_atof.c 14675 2006-03-08 12:25:29Z courmisch $
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20  *****************************************************************************/
21
22 #include "../pyunit.h"
23 #include <vlc/vlc.h>
24 #include "charset.h"
25
26 PyObject *i18n_atof_test( PyObject *self, PyObject *args )
27 {
28     const char dot9[] = "999999.999999";
29     const char comma9[] = "999999,999999";
30     const char sharp9[] = "999999#999999";
31     char *end;
32
33     ASSERT (i18n_atof("0") == 0.,"");
34     ASSERT (i18n_atof("1") == 1.,"");
35     ASSERT (i18n_atof("1.") == 1.,"");
36     ASSERT (i18n_atof("1,") == 1.,"");
37     ASSERT (i18n_atof("1#") == 1.,"");
38     ASSERT (i18n_atof(dot9) == 999999.999999,"");
39     ASSERT (i18n_atof(comma9) == 999999.999999,"");
40     ASSERT (i18n_atof(sharp9) == 999999.,"");
41     ASSERT (i18n_atof("invalid") == 0.,"");
42
43     ASSERT (us_atof("0") == 0.,"");
44     ASSERT (us_atof("1") == 1.,"");
45     ASSERT (us_atof("1.") == 1.,"");
46     ASSERT (us_atof("1,") == 1.,"");
47     ASSERT (us_atof("1#") == 1.,"");
48     ASSERT (us_atof(dot9) == 999999.999999,"");
49     ASSERT (us_atof(comma9) == 999999.,"");
50     ASSERT (us_atof(sharp9) == 999999.,"");
51     ASSERT (us_atof("invalid") == 0.,"");
52     ASSERT ((i18n_strtod(dot9, &end ) == 999999.999999)
53            && (*end == '\0'),"");
54     ASSERT ((i18n_strtod(comma9, &end ) == 999999.999999)
55            && (*end == '\0'),"");
56     ASSERT ((i18n_strtod(sharp9, &end ) == 999999.)
57            && (*end == '#'),"");
58     ASSERT ((us_strtod(dot9, &end ) == 999999.999999)
59            && (*end == '\0'),"");
60     ASSERT ((us_strtod(comma9, &end ) == 999999.)
61            && (*end == ','),"");
62     ASSERT ((us_strtod(sharp9, &end ) == 999999.)
63            && (*end == '#'),"");
64
65     Py_INCREF( Py_None);
66     return Py_None;
67 }