It covers:
See stdio_stream_default_cfg() specifications
| WHEN | EXPECT |
|---|---|
stdio_stream_default_cfg() is called | returns a value-initialized stdio_stream_cfg_t;ret.reserved == 0 |
stdio_stream adapter.See stdio_stream_default_env() specifications
env.stdio_ops == stdio_ops.env.mem == mem.env.port_env == *port_env.osal_stdio_ops_t *osal_mem_ops_t *stream_env_t| WHEN | EXPECT |
|---|---|
stdio_stream_default_env(stdio_ops, mem, port_env) is called with valid input | returns a stdio_stream_env_t such that env.stdio_ops == stdio_ops, env.mem == mem, and env.port_env == *port_env |
stream port environment provided by the caller.See stdio_stream_create_stream() specifications
STREAM_STATUS_OK.*out.args->kind.STREAM_STATUS_INVALID when one or more input arguments are invalid.STREAM_STATUS_OOM when allocation required during stream creation fails.*out unchanged on failure when out != NULL.| WHEN | EXPECT |
|---|---|
stdio_stream_create_stream(out, args, cfg, env) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDOUT | returns STREAM_STATUS_OK;stores a non-NULL stream handle in *out;the produced stream forwards borrower-side write operations to the standard output stream |
out == NULL | returns STREAM_STATUS_INVALID;no stream handle is produced |
args == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
cfg == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
env == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
args != NULL but args->kind does not designate a supported stdio_stream_kind_t value and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
allocation required by stdio_stream_create_stream() fails | returns STREAM_STATUS_OOM;leaves *out unchanged |
STDIO_STREAM_KIND_STDOUT and validates that the created stream is operational through the public borrower-side stream_write() API.fake_memory to fail the allocation performed during stream creation.out != NULL.See stdio_stream_create_desc() specifications
STREAM_STATUS_OK.*out.out->ud_dtor().STREAM_STATUS_INVALID for invalid arguments.STREAM_STATUS_OOM on allocation failure.out != NULL, resets *out to an empty descriptor on failure.| WHEN | EXPECT |
|---|---|
stdio_stream_create_desc(out, key, cfg, env, mem) is called with valid arguments | returns STREAM_STATUS_OK;stores a valid adapter descriptor in *out;the produced descriptor is eligible for later destruction via out->ud_dtor() |
out == NULL | returns STREAM_STATUS_INVALID;no descriptor is produced |
key == NULL and out != NULL | returns STREAM_STATUS_INVALID;resets *out to an empty descriptor |
key is an empty string and out != NULL | returns STREAM_STATUS_INVALID;resets *out to an empty descriptor |
cfg == NULL and out != NULL | returns STREAM_STATUS_INVALID;resets *out to an empty descriptor |
env == NULL and out != NULL | returns STREAM_STATUS_INVALID;resets *out to an empty descriptor |
mem == NULL and out != NULL | returns STREAM_STATUS_INVALID;resets *out to an empty descriptor |
allocation required by stdio_stream_create_desc() fails | returns STREAM_STATUS_OOM;resets *out to an empty descriptor |
key, ctor, ud, and ud_dtor fields.fake_memory to fail the allocation performed during descriptor construction.out != NULL.See stdio_stream_ctor() specifications
STREAM_STATUS_OK.*out.((const stdio_stream_args_t *)args)->kind.STREAM_STATUS_INVALID when one or more input arguments are invalid.STREAM_STATUS_OOM when allocation required during delegated stream creation fails.*out unchanged on failure when out != NULL.| WHEN | EXPECT |
|---|---|
stdio_stream_ctor(ud, args, out) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDOUT | returns STREAM_STATUS_OK;stores a non-NULL stream handle in *out;the produced stream forwards borrower-side write operations to the standard output stream |
out == NULL | returns STREAM_STATUS_INVALID;no stream handle is produced |
args == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
ud == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
args != NULL but args->kind does not designate a supported stdio_stream_kind_t value and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
allocation required by stdio_stream_ctor() fails | returns STREAM_STATUS_OOM;leaves *out unchanged |
STDIO_STREAM_KIND_STDOUT and validates that the constructed stream is operational through the public borrower-side stream_write() API.fake_memory to fail the allocation performed during delegated stream creation.out != NULL.stdio_stream_create_stream() using the configuration and environment snapshot stored in ud.See stdio_stream_write() specifications
Internally exercised backend callback:
STREAM_STATUS_OK in *st when st != NULL.0 and stores STREAM_STATUS_INVALID in *st for invalid arguments when st != NULL.0 and stores STREAM_STATUS_IO_ERROR in *st when the bound standard stream does not support writing.| WHEN | EXPECT |
|---|---|
stream_write(s, buf, n, &st) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDOUT | returns n;st == STREAM_STATUS_OK;the n bytes from buf are appended to the buffered backing of the bound standard output stream |
stream_write(s, buf, n, &st) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDERR | returns n;st == STREAM_STATUS_OK;the n bytes from buf are appended to the buffered backing of the bound standard error stream |
stream_write(s, buf, 0, &st) is called and args->kind designates an output-oriented standard stream and buf != NULL | returns 0;st == STREAM_STATUS_OK;the buffered backing of the bound standard stream is unchanged |
stream_write(s, NULL, 0, &st) is called and args->kind designates an output-oriented standard stream | returns 0;st == STREAM_STATUS_OK;the buffered backing of the bound standard stream is unchanged |
stream_write(s, NULL, n, &st) is called with n > 0 and args->kind designates an output-oriented standard stream | returns 0;st == STREAM_STATUS_INVALID;the buffered backing of the bound standard stream is unchanged |
stream_write(s, buf, n, NULL) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDOUT | returns n;the n bytes from buf are appended to the buffered backing of the bound standard output stream;no status is written |
stream_write(s, buf, n, NULL) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDERR | returns n;the n bytes from buf are appended to the buffered backing of the bound standard error stream;no status is written |
stream_write(s, buf, n, &st) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDIN | returns 0;st == STREAM_STATUS_IO_ERROR;the buffered backing of the bound standard stream is unchanged |
stdio_stream_write() callback through the public stream_write() wrapper.fake_stdio.See stdio_stream_read() specifications
Internally exercised backend callback:
buf when that stream supports reading.STREAM_STATUS_OK in *st when st != NULL.0 and stores STREAM_STATUS_INVALID in *st for invalid arguments when st != NULL.0 and stores STREAM_STATUS_IO_ERROR in *st when the bound standard stream does not support reading.| WHEN | EXPECT |
|---|---|
stream_read(s, buf, 0, &st) is called and args->kind == STDIO_STREAM_KIND_STDIN and buf != NULL | returns 0;st == STREAM_STATUS_OK;the fake read position of the bound standard input stream is unchanged; buf is unchanged;the buffered backing of the bound standard input stream is unchanged |
stream_read(s, NULL, 0, &st) is called and args->kind == STDIO_STREAM_KIND_STDIN | returns 0;st == STREAM_STATUS_OK;the fake read position of the bound standard input stream is unchanged; the buffered backing of the bound standard input stream is unchanged |
stream_read(s, NULL, n, &st) is called with n > 0 and args->kind == STDIO_STREAM_KIND_STDIN | returns 0;st == STREAM_STATUS_INVALID;the fake read position of the bound standard input stream is unchanged; the buffered backing of the bound standard input stream is unchanged |
stream_read(s, buf, n, &st) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDOUT | returns 0;st == STREAM_STATUS_IO_ERROR;the fake read position of the bound standard stream is unchanged; buf is unchanged;the buffered backing of the bound standard stream is unchanged |
stream_read(s, buf, n, &st) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDERR | returns 0;st == STREAM_STATUS_IO_ERROR;the fake read position of the bound standard stream is unchanged; buf is unchanged;the buffered backing of the bound standard stream is unchanged |
stream_read(s, buf, n, NULL) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDIN | returns the number of bytes actually read, up to n;the bytes read from the buffered backing of the bound standard input stream are copied into buf;the fake read position of the bound standard input stream is advanced by the number of bytes actually read; the buffered backing of the bound standard input stream is unchanged; no status is written |
stream_read(s, buf, n, &st) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDIN | returns the number of bytes actually read, up to n;st == STREAM_STATUS_OK;the bytes read from the buffered backing of the bound standard input stream are copied into buf;the fake read position of the bound standard input stream is advanced by the number of bytes actually read; the buffered backing of the bound standard input stream is unchanged |
stream_read(s, buf, n, &st) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDIN and n is greater than the number of bytes currently available in the buffered backing | returns the number of bytes actually available in the buffered backing;st == STREAM_STATUS_OK;only the available bytes are copied into buf;the fake read position of the bound standard input stream is advanced by the number of bytes actually read; the buffered backing of the bound standard input stream is unchanged |
stdio_stream_read() callback through the public stream_read() wrapper.fake_stdio models readable standard-stream data through an explicit internal buffered_backing and a tracked read cursor.See stdio_stream_flush() specifications
Internally exercised backend callback:
STREAM_STATUS_OK.STREAM_STATUS_IO_ERROR when the bound standard stream does not support flushing.| WHEN | EXPECT |
|---|---|
stream_flush(s) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDIN | returns STREAM_STATUS_IO_ERROR;the buffered backing of the bound standard stream is unchanged; the sink backing of the bound standard stream is unchanged |
stream_flush(s) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDOUT | returns STREAM_STATUS_OK;buffered data from the bound standard output stream is transferred to its sink backing according to the fake flush behavior |
stream_flush(s) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDERR | returns STREAM_STATUS_OK;buffered data from the bound standard error stream is transferred to its sink backing according to the fake flush behavior |
stdio_stream_flush() callback through the public stream_flush() wrapper.fake_stdio models standard streams with an explicit buffered_backing and a flushed-output sink_backing.See stdio_stream_close() specifications
Internally exercised backend callback:
stdio_stream backend container through its injected memory operations.NULL.| WHEN | EXPECT |
|---|---|
stream_destroy(&s) is called with a valid stream handle and args->kind == STDIO_STREAM_KIND_STDIN | the backend container bound to the stream is released; the stream handle is destroyed; the caller-visible handle is set to NULL |
stream_destroy(&s) is called with a valid stream handle and args->kind == STDIO_STREAM_KIND_STDOUT | the backend container bound to the stream is released; the stream handle is destroyed; the caller-visible handle is set to NULL |
stream_destroy(&s) is called with a valid stream handle and args->kind == STDIO_STREAM_KIND_STDERR | the backend container bound to the stream is released; the stream handle is destroyed; the caller-visible handle is set to NULL |
stdio_stream_close() callback through the public stream_destroy() wrapper.stdio_stream backend container.fake_memory.