Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1361, add doxygen for UT_ConfigureGenericStubReturnValue #1362

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion ut_assert/inc/utstubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,39 @@ void UT_ResetState(UT_EntryKey_t FuncKey);
void UT_SetDeferredRetcode(UT_EntryKey_t FuncKey, int32 Count, UT_IntReturn_t Retcode);

/**
* \param FuncKey The stub function to add the return code to.
* Add a type-agnostic return code entry for the given stub function
*
* This allocates a return value entry in the UT Assert state table and associates it with the
* specified stub function. The DeferCount parameter determines how many times the stub must
* be invoked before the return value is used. If this is passed in as 0, the value will be used
* for all stub invocations, and will be retained until the state is reset. For nonzero defer counts,
* the value acts as a decrement counter, and will be used once the counter reaches 0. In these cases,
* the value will be discarded/forgotten once it has been used by the stub.
*
* The handling of the value depends on the ValueGenre:
*
* #UT_ValueGenre_OPAQUE - The object will be used directly as the return value from the stub, and no
* conversion of any type will be attempted.
* #UT_ValueGenre_INTEGER - The object is an integer, and thus may be converted to numbers of other sizes/types
* using integer value semantics.
* #UT_ValueGenre_FLOAT - The object is a floating point, and thus may be converted to numbers of other
* sizes/types using floating point value semantics.
* #UT_ValueGenre_POINTER - The object is a pointer, no conversions will be attempted, and the size must be
* equal to sizeof(void*)
*
* \note for OPAQUE values, the passed-in pointer value is held directly, and will be dereferenced at the
* time when the called stub returns the value. Notably, the content is NOT cached in the UtAssert internal
* storage structures, so the caller must ensure that the pointed-to object remains valid and does not go
* out of scope for the remainder of the test case, or until UT_ResetState is called. Conversely, for INTEGER,
* FLOAT, or POINTER value genres, the content will be copied into the internal storage structures, so in
* these cases, the pointed-to value may be immediately reused or freed by the caller.
*
* \param FuncKey The stub function to add the return code to.
* \param ValuePtr Pointer to the value to return
* \param ValueSize Size of the object referred to by ValuePtr
* \param ValueGenre Genre of the object referred to by ValuePtr
* \param DeferCount Number of times the stub needs to be called until this value is used
* \param TypeName Data type as an ASCII string, for possible type matching (may be set from a preprocessor macro)
*/
void UT_ConfigureGenericStubReturnValue(UT_EntryKey_t FuncKey, const void *ValuePtr, size_t ValueSize,
UT_ValueGenre_t ValueGenre, int32 DeferCount, const char *TypeName);
Expand Down