Moved atom functions to dlls/kernel.
[wine] / dlls / kernel / tests / profile.c
1 /*
2  * Unit tests for profile functions
3  *
4  * Copyright (c) 2003 Stefan Leichter
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "wine/test.h"
22 #include "winbase.h"
23 #include "windows.h"
24
25 #define KEY      "ProfileInt"
26 #define SECTION  "Test"
27 #define TESTFILE ".\\testwine.ini"
28
29 struct _profileInt { 
30     LPCSTR section;
31     LPCSTR key;
32     LPCSTR value;
33     LPCSTR iniFile;
34     INT defaultVal;
35     UINT result;
36 };
37
38 static void test_profile_int(void)
39 {
40     struct _profileInt profileInt[]={
41          { NULL,    NULL, NULL,          NULL,     70, 0          }, /*  0 */
42          { NULL,    NULL, NULL,          TESTFILE, -1, 4294967295U},
43          { NULL,    NULL, NULL,          TESTFILE,  1, 1          },
44          { SECTION, NULL, NULL,          TESTFILE, -1, 4294967295U},
45          { SECTION, NULL, NULL,          TESTFILE,  1, 1          },
46          { NULL,    KEY,  NULL,          TESTFILE, -1, 4294967295U}, /*  5 */
47          { NULL,    KEY,  NULL,          TESTFILE,  1, 1          },
48          { SECTION, KEY,  NULL,          TESTFILE, -1, 4294967295U},
49          { SECTION, KEY,  NULL,          TESTFILE,  1, 1          },
50          { SECTION, KEY,  "-1",          TESTFILE, -1, 4294967295U},
51          { SECTION, KEY,  "-1",          TESTFILE,  1, 4294967295U}, /* 10 */
52          { SECTION, KEY,  "1",           TESTFILE, -1, 1          },
53          { SECTION, KEY,  "1",           TESTFILE,  1, 1          },
54          { SECTION, KEY,  "+1",          TESTFILE, -1, 1          },
55          { SECTION, KEY,  "+1",          TESTFILE,  1, 1          },
56          { SECTION, KEY,  "4294967296",  TESTFILE, -1, 0          }, /* 15 */
57          { SECTION, KEY,  "4294967296",  TESTFILE,  1, 0          },
58          { SECTION, KEY,  "4294967297",  TESTFILE, -1, 1          },
59          { SECTION, KEY,  "4294967297",  TESTFILE,  1, 1          },
60          { SECTION, KEY,  "-4294967297", TESTFILE, -1, 4294967295U},
61          { SECTION, KEY,  "-4294967297", TESTFILE,  1, 4294967295U}, /* 20 */
62          { SECTION, KEY,  "42A94967297", TESTFILE, -1, 42         },
63          { SECTION, KEY,  "42A94967297", TESTFILE,  1, 42         },
64          { SECTION, KEY,  "B4294967297", TESTFILE, -1, 0          },
65          { SECTION, KEY,  "B4294967297", TESTFILE,  1, 0          },
66     };
67     int i, num_test = (sizeof(profileInt)/sizeof(struct _profileInt));
68     UINT res;
69
70     DeleteFileA( TESTFILE);
71
72     for (i=0; i < num_test; i++) {
73         if (profileInt[i].value)
74             WritePrivateProfileStringA(SECTION, KEY, profileInt[i].value, 
75                                       profileInt[i].iniFile);
76
77        res = GetPrivateProfileIntA(profileInt[i].section, profileInt[i].key, 
78                  profileInt[i].defaultVal, profileInt[i].iniFile); 
79        ok(res == profileInt[i].result, "test<%02d>: ret<%010u> exp<%010u>",
80                                        i, res, profileInt[i].result);
81     }
82
83     DeleteFileA( TESTFILE);
84 }
85
86 START_TEST(profile)
87 {
88     test_profile_int();
89 }