Unit tests implementation for the stream port. More...
#include "stream/borrowers/stream.h"#include "stream/lifecycle/stream_lifecycle.h"#include "stream/adapters/stream_adapters_api.h"#include "stream/cr/stream_cr_api.h"#include "osal/mem/osal_mem.h"#include "osal/mem/test/osal_mem_fake_provider.h"#include "policy/lexleo_cstd_types.h"#include "policy/lexleo_cstd_lib.h"#include "policy/lexleo_cstd_jmp.h"#include "lexleo_cmocka.h"
Go to the source code of this file.
Functions | |
| static void | test_stream_default_ops (void **state) |
Test stream_default_ops(). | |
| static void | test_stream_default_env (void **state) |
Test stream_default_env(). | |
This file implements the unit-level validation of the stream port contracts.
Covered surfaces:
stream_default_ops(), stream_default_env()stream_create(), stream_destroy()stream_read(), stream_write(), stream_flush()Test strategy:
fake_memoryfake_stream_backend_tSee also:
Definition in file unit_test_stream.c.
stream_status_t stream_flush(stream_t *s);
Precondition:
s != NULL, s has been created by stream_create() with fake_stream_vtbl and fake_stream_backend.Doubles:
See also:
The scenarios below define the test oracle for stream_flush().
Definition at line 1554 of file unit_test_stream.c.
stream_status_t stream_create( stream_t **out, const stream_vtbl_t *vtbl, void *backend, const stream_env_t *env );
void stream_destroy(stream_t **s);
Invalid arguments:
out, vtbl, env must not be NULL.vtbl->read, vtbl->write, vtbl->flush, vtbl->close must not be NULL.env->mem must not be NULL.Success:
*out.stream_destroy().Failure:
*out unchanged if out is not NULL.Lifecycle:
stream_destroy() does nothing if s is NULL or *s is NULL.*s to NULL.Doubles:
See also:
The scenarios below define the test oracle for stream_create() and stream_destroy().
| Enumerator | |
|---|---|
| STREAM_LIFECYCLE_SCENARIO_OK | WHEN
|
| STREAM_LIFECYCLE_SCENARIO_OUT_NULL | WHEN
|
| STREAM_LIFECYCLE_SCENARIO_VTBL_NULL | WHEN
|
| STREAM_LIFECYCLE_SCENARIO_ENV_NULL | WHEN
|
| STREAM_LIFECYCLE_SCENARIO_ENV_MEM_NULL | WHEN
|
| STREAM_LIFECYCLE_SCENARIO_OOM | WHEN allocation of the stream handle fails (allocator reports OOM) EXPECT:
Notes:
|
| STREAM_LIFECYCLE_SCENARIO_DESTROY_IDEMPOTENT | WHEN
Notes:
|
| STREAM_LIFECYCLE_SCENARIO_VTBL_READ_NULL | WHEN
Notes:
|
Definition at line 330 of file unit_test_stream.c.
size_t stream_read(stream_t *s, void *buf, size_t n, stream_status_t *st);
Precondition:
s != NULL, s has been created by stream_create() with fake_stream_vtbl and fake_stream_backend.Doubles:
See also:
The scenarios below define the test oracle for stream_read().
Definition at line 714 of file unit_test_stream.c.
size_t stream_write(stream_t *s, const void *buf, size_t n, stream_status_t *st);
Precondition:
s != NULL, s has been created by stream_create() with fake_stream_vtbl and fake_stream_backend.Doubles:
See also:
The scenarios below define the test oracle for stream_write().
Definition at line 1134 of file unit_test_stream.c.
|
static |
stream_env_t stream_default_env(const osal_mem_ops_t *mem_ops);
Success:
ret.mem == mem_ops.Failure:
Doubles:
osal_mem_ops_tSee also:
Definition at line 278 of file unit_test_stream.c.
|
static |
const stream_ops_t *stream_default_ops(void);
Success:
ret, ret->read, ret->write and ret->flush are non-NULL.Failure:
See also:
Definition at line 251 of file unit_test_stream.c.