Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Add array-testing assertions #2

Open
matatk opened this issue Dec 7, 2015 · 2 comments
Open

Add array-testing assertions #2

matatk opened this issue Dec 7, 2015 · 2 comments

Comments

@matatk
Copy link
Contributor

matatk commented Dec 7, 2015

We discussed and @MarkWithall suggested these offline; they ought to be noted here too :-)...

  • ASSERT_ARRAY_EQUAL(actual, expected, length, message)
  • ASSERT_ARRAY_LENGTH(array, expected_length, message)

I'm not able to 100% guarantee that I'd have the cycles or be able to do it correctly, but I might be able to have a go at this, so feel free to assign to me if you would like a PR.

Currently @tomfinnie and I are testing arrays and will be using a for loop, which I gather will work in the sense that we can have more than one ASSERT per TEST, but I gather that it would only break on the first ASSERT as-is. Specifically the thing we're trying to do is assert that one (and only one) element in the array has been set to NULL -- that's actually not quite covered by the above, I think (we don't know/care what the other values are), so this specific behaviour looks like it'll be extra to the above-listed assertions.

@MarkWithall
Copy link
Owner

Just a thought: I don't believe one can check the length of an array in C, as an array is just a pointer to the starting memory location and a type; with no other information.

@matatk
Copy link
Contributor Author

matatk commented Mar 8, 2016

Ah, yes, of course. I think that ASSERT_ARRAY_EQUAL would still be do-able, with great care. Maybe even ASSERT_ARRAY_LENGTH one, with even greater care (though perhaps it's not possible practicably), but perhaps it's worth leaving these to the application for now (we were able to use a for loop, as described).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants