START_TEST(array_for_each)
{
	int ai[6];
	char ac[10];
	struct as {
		int a;
		char b;
		int *ptr;
	} as[32];

	for (size_t i = 0; i < 6; i++)
		ai[i] = 20 + i;
	for (size_t i = 0; i < 10; i++)
		ac[i] = 100 + i;
	for (size_t i = 0; i < 32; i++) {
		as[i].a = 10 + i;
		as[i].b = 20 + i;
		as[i].ptr = (int*)0xab + i;
	}

	int iexpected = 20;
	ARRAY_FOR_EACH(ai, entry) {
		ck_assert_int_eq(*entry, iexpected);
		++iexpected;
	}
	ck_assert_int_eq(iexpected, 26);

	int cexpected = 100;
	ARRAY_FOR_EACH(ac, entry) {
		ck_assert_int_eq(*entry, cexpected);
		++cexpected;
	}
	ck_assert_int_eq(cexpected, 110);

	struct as sexpected = {
		.a = 10,
		.b = 20,
		.ptr = (int*)0xab,
	};
	ARRAY_FOR_EACH(as, entry) {
		ck_assert_int_eq(entry->a, sexpected.a);
		ck_assert_int_eq(entry->b, sexpected.b);
		ck_assert_ptr_eq(entry->ptr, sexpected.ptr);
		++sexpected.a;
		++sexpected.b;
		++sexpected.ptr;
	}
	ck_assert_int_eq(sexpected.a, 42);
}
START_TEST(array_for_each)
{
	int ai[6];
	char ac[10];
	struct as {
		int a;
		char b;
		int *ptr;
	} as[32];

	for (size_t i = 0; i < 6; i++)
		ai[i] = 20 + i;
	for (size_t i = 0; i < 10; i++)
		ac[i] = 100 + i;
	for (size_t i = 0; i < 32; i++) {
		as[i].a = 10 + i;
		as[i].b = 20 + i;
		as[i].ptr = (int*)0xab + i;
	}

	int iexpected = 20;
	ARRAY_FOR_EACH(ai, entry) {
		ck_assert_int_eq(*entry, iexpected);
		++iexpected;
	}
	ck_assert_int_eq(iexpected, 26);

	int cexpected = 100;
	ARRAY_FOR_EACH(ac, entry) {
		ck_assert_int_eq(*entry, cexpected);
		++cexpected;
	}
	ck_assert_int_eq(cexpected, 110);

	struct as sexpected = {
		.a = 10,
		.b = 20,
		.ptr = (int*)0xab,
	};
	ARRAY_FOR_EACH(as, entry) {
		ck_assert_int_eq(entry->a, sexpected.a);
		ck_assert_int_eq(entry->b, sexpected.b);
		ck_assert_ptr_eq(entry->ptr, sexpected.ptr);
		++sexpected.a;
		++sexpected.b;
		++sexpected.ptr;
	}
	ck_assert_int_eq(sexpected.a, 42);
}