summaryrefslogtreecommitdiff
path: root/test/src/test/foreach.i
blob: e7b933d22922d0f34659c822a02d6172451ba53c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdbool.h>

static void foreachfn(void * const _ptr) {
	unsigned int * ptr = _ptr;
	unsigned int   val = *ptr;
	val %= 0x2;
	*ptr = val;
}

static bool zaptest_test_foreach(void) {
	unsigned int arr[] = {
		0x0u,
		0x1u,
		0x2u,
		0x3u,
	};
	zap_foreach(arr,sizeof (arr[0x0u]),sizeof (arr) / sizeof (arr[0x0u]),foreachfn);
	zaptest_chk(arr[0x0u],0x0u,unsigned int,"%X");
	zaptest_chk(arr[0x1u],0x1u,unsigned int,"%X");
	zaptest_chk(arr[0x2u],0x0u,unsigned int,"%X");
	zaptest_chk(arr[0x3u],0x1u,unsigned int,"%X");
	return false;
}