Translation update done using Pootle.
[gammu.git] / tests / inifile.c
blob101b95dc68c44827e77db1f6efb12cdd58ed8960
1 /**
2 * INI file parsing tests.
3 */
5 #include <gammu.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include "common.h"
11 int main(int argc, char **argv)
13 GSM_Error error;
14 INI_Section *ini = NULL;
15 int intval;
16 gboolean boolval;
17 char *strval;
19 /* Check parameters */
20 if (argc != 2) {
21 printf("Not enough parameters!\nUsage: inifile ini_file\n");
22 return 1;
25 error = INI_ReadFile(argv[1], FALSE, &ini);
26 gammu_test_result(error, "INI_ReadFile");
27 test_result(ini != NULL);
29 intval = INI_GetInt(ini, "section", "intval", -1);
30 test_result(intval == 65536);
32 boolval = INI_GetBool(ini, "section", "trueval", FALSE);
33 test_result(boolval == TRUE);
35 boolval = INI_GetBool(ini, "section", "falseval", TRUE);
36 test_result(boolval == FALSE);
38 boolval = INI_GetBool(ini, "section", "notexistingval", TRUE);
39 test_result(boolval == TRUE);
41 boolval = INI_GetBool(ini, "section", "intval", FALSE);
42 test_result(boolval == FALSE);
44 boolval = INI_GetBool(ini, "section", "intval", TRUE);
45 test_result(boolval == TRUE);
47 strval = INI_GetValue(ini, "section", "val1", FALSE);
48 test_result(strval != NULL);
49 test_result(strcmp(strval, "ABCDE abcde") == 0);
51 INI_Free(ini);
53 return 0;