summaryrefslogtreecommitdiff
path: root/tests/features-parsing.c
blob: f31c7be0ad60ade03af96c58445ae20fadbdef45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Sample code to dump all feature codes and their descriptions */

#include <gammu.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "../libgammu/gsmphones.h"

int single_test(const char *string, GSM_Error expected)
{
	GSM_Feature features[GSM_MAX_PHONE_FEATURES + 1];
	GSM_Error real;

	real = GSM_SetFeatureString(features, string);

	if (real != expected) {
		printf("Failed parsing of %s (got %s, expected %s)\n", string, GSM_ErrorString(real), GSM_ErrorString(expected));
		return 1;
	}
	return 0;
}

int main(int argc, char **argv)
{
	int rc = 0;
	GSM_Debug_Info *debug_info;

	debug_info = GSM_GetGlobalDebug();
	GSM_SetDebugFileDescriptor(stderr, FALSE, debug_info);
	GSM_SetDebugLevel("textall", debug_info);

	rc |= single_test("CAL33, CAL52,SQWE", ERR_NONE);
	rc |= single_test("CAL33, FOO,SQWE", ERR_BADFEATURE);
	rc |= single_test("CAL33, NO_ATOBEX ,SQWE", ERR_NONE);
	rc |=
	    single_test
	    ("CAL33, NO_ATOBEX ,SQWE, CAL33, NO_ATOBEX ,SQWE, CAL52,CAL33, NO_ATOBEX ,SQWE, CAL33, NO_ATOBEX ,SQWE, CAL52,CAL33, NO_ATOBEX ,SQWE, CAL33, NO_ATOBEX ,SQWE, CAL52",
	     ERR_MOREMEMORY);

	return rc;
}

/* Editor configuration
 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72:
 */