LexLeo 0.0.0-dev+f8e5087-dirty
Technical documentation
Loading...
Searching...
No Matches
unit_test_stdio_stream.c File Reference

Unit tests implementation for the stdio_stream adapter. More...

Include dependency graph for unit_test_stdio_stream.c:

Go to the source code of this file.

Enumerations

enum  stdio_stream_create_stream_scenario_t {
  STDIO_STREAM_CREATE_STREAM_SCENARIO_OK = 0 , STDIO_STREAM_CREATE_STREAM_SCENARIO_OUT_NULL , STDIO_STREAM_CREATE_STREAM_SCENARIO_ARGS_NULL , STDIO_STREAM_CREATE_STREAM_SCENARIO_CFG_NULL ,
  STDIO_STREAM_CREATE_STREAM_SCENARIO_ENV_NULL , STDIO_STREAM_CREATE_STREAM_SCENARIO_UNSUPPORTED_KIND , STDIO_STREAM_CREATE_STREAM_SCENARIO_OOM
}
 Scenarios for stdio_stream_create_stream(). More...
 
enum  stdio_stream_create_desc_scenario_t {
  STDIO_STREAM_CREATE_DESC_SCENARIO_OK = 0 , STDIO_STREAM_CREATE_DESC_SCENARIO_OUT_NULL , STDIO_STREAM_CREATE_DESC_SCENARIO_KEY_NULL , STDIO_STREAM_CREATE_DESC_SCENARIO_KEY_EMPTY ,
  STDIO_STREAM_CREATE_DESC_SCENARIO_CFG_NULL , STDIO_STREAM_CREATE_DESC_SCENARIO_ENV_NULL , STDIO_STREAM_CREATE_DESC_SCENARIO_MEM_NULL , STDIO_STREAM_CREATE_DESC_SCENARIO_OOM
}
 Scenarios for stdio_stream_create_desc(). More...
 
enum  stdio_stream_ctor_scenario_t {
  STDIO_STREAM_CTOR_SCENARIO_OK = 0 , STDIO_STREAM_CTOR_SCENARIO_OUT_NULL , STDIO_STREAM_CTOR_SCENARIO_ARGS_NULL , STDIO_STREAM_CTOR_SCENARIO_UD_NULL ,
  STDIO_STREAM_CTOR_SCENARIO_UNSUPPORTED_KIND , STDIO_STREAM_CTOR_SCENARIO_OOM
}
 Scenarios for stdio_stream_ctor(). More...
 
enum  stdio_stream_write_scenario_t {
  STDIO_STREAM_WRITE_SCENARIO_OK_STDOUT = 0 , STDIO_STREAM_WRITE_SCENARIO_OK_STDERR , STDIO_STREAM_WRITE_SCENARIO_ZERO_LEN , STDIO_STREAM_WRITE_SCENARIO_BUF_NULL_ZERO_LEN ,
  STDIO_STREAM_WRITE_SCENARIO_BUF_NULL_NONZERO , STDIO_STREAM_WRITE_SCENARIO_ST_NULL_STDOUT , STDIO_STREAM_WRITE_SCENARIO_ST_NULL_STDERR , STDIO_STREAM_WRITE_SCENARIO_STDIN_FORBIDDEN
}
 Scenarios for stdio_stream_write(). More...
 
enum  stdio_stream_read_scenario_t {
  STDIO_STREAM_READ_SCENARIO_ZERO_LEN = 0 , STDIO_STREAM_READ_SCENARIO_BUF_NULL_ZERO_LEN , STDIO_STREAM_READ_SCENARIO_BUF_NULL_NONZERO , STDIO_STREAM_READ_SCENARIO_STDOUT_FORBIDDEN ,
  STDIO_STREAM_READ_SCENARIO_STDERR_FORBIDDEN , STDIO_STREAM_READ_SCENARIO_ST_NULL_STDIN , STDIO_STREAM_READ_SCENARIO_OK_STDIN , STDIO_STREAM_READ_SCENARIO_PARTIAL_STDIN
}
 Scenarios for stdio_stream_read(). More...
 
enum  stdio_stream_flush_scenario_t { STDIO_STREAM_FLUSH_SCENARIO_STDIN_FORBIDDEN , STDIO_STREAM_FLUSH_SCENARIO_OK_STDOUT , STDIO_STREAM_FLUSH_SCENARIO_OK_STDERR }
 Scenarios for stdio_stream_flush(). More...
 
enum  stdio_stream_close_scenario_t { STDIO_STREAM_CLOSE_SCENARIO_OK_STDIN = 0 , STDIO_STREAM_CLOSE_SCENARIO_OK_STDOUT , STDIO_STREAM_CLOSE_SCENARIO_OK_STDERR }
 Scenarios for stdio_stream_close(). More...
 

Functions

static void test_stdio_stream_default_cfg (void **state)
 Test stdio_stream_default_cfg().
 
static void test_stdio_stream_default_env (void **state)
 Test stdio_stream_default_env().
 
int main (void)
 

Detailed Description

This file implements the unit-level validation of the stdio_stream adapter contracts.

Covered surfaces:

Test strategy:

  • CR helpers are tested directly.
  • Construction helpers and descriptor helpers are tested with parametric scenario-driven unit tests.
  • Private backend callbacks are not called directly; they are exercised through the public stream port wrappers.
  • fake_stdio is used to observe standard-stream behavior and state transitions.
  • fake_memory is used to inject allocation failures and to verify memory invariants at teardown.

See also:

Definition in file unit_test_stdio_stream.c.

Enumeration Type Documentation

◆ stdio_stream_close_scenario_t

static stream_status_t stdio_stream_close( void *backend );

This private callback is exercised through the public stream_destroy() API on streams created by stdio_stream_create_stream().

Invalid arguments:

  • backend == NULL

Success:

  • Returns STREAM_STATUS_OK.
  • Releases the stdio_stream backend container through its injected memory operations.

Failure:

  • Returns STREAM_STATUS_INVALID for invalid arguments.

Doubles:

  • fake_memory

Fake behavior:

  • the stdio_stream backend wraps a borrowed standard stream
  • the underlying standard stream is not owned by the backend container
  • close releases only the backend container
  • close does not close the underlying standard stream itself

Isolation:

  • the callback is not called directly
  • behavior is exercised through the public stream port wrapper

See also:

The scenarios below define the test oracle for stdio_stream_close().

Enumerator
STDIO_STREAM_CLOSE_SCENARIO_OK_STDIN 

WHEN stream_destroy(&s) is called with a valid stream handle AND args->kind == STDIO_STREAM_KIND_STDIN EXPECT:

  • 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_SCENARIO_OK_STDOUT 

WHEN stream_destroy(&s) is called with a valid stream handle AND args->kind == STDIO_STREAM_KIND_STDOUT EXPECT:

  • 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_SCENARIO_OK_STDERR 

WHEN stream_destroy(&s) is called with a valid stream handle AND args->kind == STDIO_STREAM_KIND_STDERR EXPECT:

  • the backend container bound to the stream is released
  • the stream handle is destroyed
  • the caller-visible handle is set to NULL

Definition at line 2842 of file unit_test_stdio_stream.c.

◆ stdio_stream_create_desc_scenario_t

stream_status_t stdio_stream_create_desc( stream_adapter_desc_t *out, stream_key_t key, const stdio_stream_cfg_t *cfg, const stdio_stream_env_t *env, const osal_mem_ops_t *mem );

Invalid arguments:

  • out, key, cfg, env, mem must not be NULL.
  • key must not be an empty string.

Success:

  • Returns STREAM_STATUS_OK.
  • Stores a valid adapter descriptor in *out.
  • The produced descriptor must later be released via out->ud_dtor().

Failure:

  • Returns:
    • STREAM_STATUS_INVALID for invalid arguments
    • STREAM_STATUS_OOM on allocation failure
  • If out is not NULL, resets *out to an empty descriptor.

Doubles:

  • fake_stdio
  • fake_memory

See also:

The scenarios below define the test oracle for stdio_stream_create_desc().

Enumerator
STDIO_STREAM_CREATE_DESC_SCENARIO_OK 

WHEN stdio_stream_create_desc(out, key, cfg, env, mem) is called with valid arguments EXPECT:

  • returns STREAM_STATUS_OK
  • stores a valid adapter descriptor in *out
  • the produced descriptor is eligible for later destruction via out->ud_dtor()
STDIO_STREAM_CREATE_DESC_SCENARIO_OUT_NULL 

WHEN out == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • no descriptor is produced
STDIO_STREAM_CREATE_DESC_SCENARIO_KEY_NULL 

WHEN key == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • resets *out to an empty descriptor
STDIO_STREAM_CREATE_DESC_SCENARIO_KEY_EMPTY 

WHEN key is an empty string and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • resets *out to an empty descriptor
STDIO_STREAM_CREATE_DESC_SCENARIO_CFG_NULL 

WHEN cfg == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • resets *out to an empty descriptor
STDIO_STREAM_CREATE_DESC_SCENARIO_ENV_NULL 

WHEN env == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • resets *out to an empty descriptor
STDIO_STREAM_CREATE_DESC_SCENARIO_MEM_NULL 

WHEN mem == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • resets *out to an empty descriptor
STDIO_STREAM_CREATE_DESC_SCENARIO_OOM 

WHEN allocation required by stdio_stream_create_desc() fails EXPECT:

  • returns STREAM_STATUS_OOM
  • resets *out to an empty descriptor

Notes:

  • This scenario is exercised by configuring fake_memory to fail the allocation performed during descriptor construction.

Definition at line 571 of file unit_test_stdio_stream.c.

◆ stdio_stream_create_stream_scenario_t

stream_status_t stdio_stream_create_stream( stream_t **out, const stdio_stream_args_t *args, const stdio_stream_cfg_t *cfg, const stdio_stream_env_t *env);

Contract:

Doubles:

  • fake_stdio
  • fake_memory

See also:

The scenarios below define the test oracle for stdio_stream_create_stream().

Enumerator
STDIO_STREAM_CREATE_STREAM_SCENARIO_OK 

WHEN stdio_stream_create_stream(out, args, cfg, env) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDOUT EXPECT:

  • 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
STDIO_STREAM_CREATE_STREAM_SCENARIO_OUT_NULL 

WHEN out == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • no stream handle is produced
STDIO_STREAM_CREATE_STREAM_SCENARIO_ARGS_NULL 

WHEN args == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STDIO_STREAM_CREATE_STREAM_SCENARIO_CFG_NULL 

WHEN cfg == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STDIO_STREAM_CREATE_STREAM_SCENARIO_ENV_NULL 

WHEN env == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STDIO_STREAM_CREATE_STREAM_SCENARIO_UNSUPPORTED_KIND 

WHEN args != NULL but args->kind does not designate a supported stdio_stream_kind_t value and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STDIO_STREAM_CREATE_STREAM_SCENARIO_OOM 

WHEN allocation required by stdio_stream_create_stream() fails EXPECT:

  • returns STREAM_STATUS_OOM
  • leaves *out unchanged

Notes:

  • This scenario is exercised by configuring fake_memory to fail the allocation performed during stream creation.

Definition at line 158 of file unit_test_stdio_stream.c.

◆ stdio_stream_ctor_scenario_t

stream_status_t stdio_stream_ctor( const void *ud, const void *args, stream_t **out);

Contract:

Doubles:

  • fake_stdio
  • fake_memory

See also:

The scenarios below define the test oracle for stdio_stream_ctor().

Enumerator
STDIO_STREAM_CTOR_SCENARIO_OK 

WHEN stdio_stream_ctor(ud, args, out) is called with valid arguments and args->kind == STDIO_STREAM_KIND_STDOUT EXPECT:

  • 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
STDIO_STREAM_CTOR_SCENARIO_OUT_NULL 

WHEN out == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • no stream handle is produced
STDIO_STREAM_CTOR_SCENARIO_ARGS_NULL 

WHEN args == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STDIO_STREAM_CTOR_SCENARIO_UD_NULL 

WHEN ud == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STDIO_STREAM_CTOR_SCENARIO_UNSUPPORTED_KIND 

WHEN args != NULL but args->kind does not designate a supported stdio_stream_kind_t value and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STDIO_STREAM_CTOR_SCENARIO_OOM 

WHEN allocation required by stdio_stream_ctor() fails EXPECT:

  • returns STREAM_STATUS_OOM
  • leaves *out unchanged

Notes:

  • This scenario is exercised by configuring fake_memory to fail the allocation performed during delegated stream creation.

Definition at line 958 of file unit_test_stdio_stream.c.

◆ stdio_stream_flush_scenario_t

static stream_status_t stdio_stream_flush( void *backend );

This private callback is exercised through the public stream_flush() API on streams created by stdio_stream_create_stream().

Invalid arguments:

  • backend == NULL

Success:

  • Returns STREAM_STATUS_OK.
  • Transfers buffered data from the wrapped standard stream to its sink backing when that stream supports flushing.

Failure:

  • Returns STREAM_STATUS_INVALID for invalid arguments.
  • Returns STREAM_STATUS_IO_ERROR when the bound standard stream does not support flushing.
  • Leaves the fake buffered state unchanged on failure paths covered here.

Doubles:

  • fake_stdio
  • fake_memory

Fake behavior:

  • fake_stdio models standard streams with an explicit internal buffer (buffered_backing) and a flushed output (sink_backing)
  • write operations append to the buffered backing
  • flush operations transfer as many buffered bytes as possible to the sink backing
  • transferred bytes are removed from the buffered backing
  • if the sink backing has insufficient remaining capacity, unflushed bytes remain buffered
  • no implicit flush occurs outside the explicit flush operation

Isolation:

  • the callback is not called directly
  • behavior is exercised through the public stream port wrapper

See also:

The scenarios below define the test oracle for stdio_stream_flush().

Enumerator
STDIO_STREAM_FLUSH_SCENARIO_STDIN_FORBIDDEN 

WHEN stream_flush(s) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDIN EXPECT:

  • 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
STDIO_STREAM_FLUSH_SCENARIO_OK_STDOUT 

WHEN stream_flush(s) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDOUT EXPECT:

  • returns STREAM_STATUS_OK
  • buffered data from the bound standard output stream is transferred to its sink backing according to the fake flush behavior
STDIO_STREAM_FLUSH_SCENARIO_OK_STDERR 

WHEN stream_flush(s) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDERR EXPECT:

  • returns STREAM_STATUS_OK
  • buffered data from the bound standard error stream is transferred to its sink backing according to the fake flush behavior

Definition at line 2438 of file unit_test_stdio_stream.c.

◆ stdio_stream_read_scenario_t

static size_t stdio_stream_read( void *backend, void *buf, size_t n, stream_status_t *st );

This private callback is exercised through the public stream_read() API on streams created by stdio_stream_create_stream().

Invalid arguments:

  • backend == NULL
  • buf == NULL && n > 0

Success:

  • Returns the number of bytes read.
  • Copies bytes from the buffered backing of the wrapped standard stream into buf when that stream supports reading.
  • Advances the fake read position by the number of bytes actually read.
  • Sets *st to STREAM_STATUS_OK when st != NULL.

Failure:

  • Returns 0 and sets *st to STREAM_STATUS_INVALID for invalid arguments when st != NULL.
  • Returns 0 and sets *st to STREAM_STATUS_IO_ERROR when the bound standard stream does not support reading.
  • Leaves the buffered backing unchanged.

Doubles:

  • fake_stdio
  • fake_memory

Fake behavior:

  • fake_stdio models readable standard-stream data with an explicit internal buffer (buffered_backing)
  • read operations copy bytes from the buffered backing into the caller buffer
  • read operations advance the fake read cursor without mutating the buffered backing itself
  • the fake read cursor is tracked with read_pos

Isolation:

  • the callback is not called directly
  • behavior is exercised through the public stream port wrapper

See also:

The scenarios below define the test oracle for stdio_stream_read().

Enumerator
STDIO_STREAM_READ_SCENARIO_ZERO_LEN 

WHEN stream_read(s, buf, 0, &st) is called AND args->kind == STDIO_STREAM_KIND_STDIN AND buf != NULL AND st != NULL EXPECT:

  • 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
STDIO_STREAM_READ_SCENARIO_BUF_NULL_ZERO_LEN 

WHEN stream_read(s, NULL, 0, &st) is called AND args->kind == STDIO_STREAM_KIND_STDIN AND st != NULL EXPECT:

  • 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
STDIO_STREAM_READ_SCENARIO_BUF_NULL_NONZERO 

WHEN stream_read(s, NULL, n, &st) is called with n > 0 AND args->kind == STDIO_STREAM_KIND_STDIN AND st != NULL EXPECT:

  • 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
STDIO_STREAM_READ_SCENARIO_STDOUT_FORBIDDEN 

WHEN stream_read(s, buf, n, &st) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDOUT AND st != NULL EXPECT:

  • 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
STDIO_STREAM_READ_SCENARIO_STDERR_FORBIDDEN 

WHEN stream_read(s, buf, n, &st) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDERR AND st != NULL EXPECT:

  • 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
STDIO_STREAM_READ_SCENARIO_ST_NULL_STDIN 

WHEN stream_read(s, buf, n, NULL) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDIN EXPECT:

  • 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
STDIO_STREAM_READ_SCENARIO_OK_STDIN 

WHEN stream_read(s, buf, n, &st) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDIN AND st != NULL EXPECT:

  • 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
STDIO_STREAM_READ_SCENARIO_PARTIAL_STDIN 

WHEN 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 AND st != NULL EXPECT:

  • 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

Definition at line 1855 of file unit_test_stdio_stream.c.

◆ stdio_stream_write_scenario_t

static size_t stdio_stream_write( void *backend, const void *buf, size_t n, stream_status_t *st );

This private callback is exercised through the public stream_write() API on streams created by stdio_stream_create_stream().

Invalid arguments:

  • backend == NULL
  • buf == NULL && n > 0

Success:

  • Returns the number of bytes written.
  • Appends bytes to the buffered backing of the wrapped standard stream when that stream supports writing.
  • Sets *st to STREAM_STATUS_OK when st != NULL.

Failure:

  • Returns 0 and sets *st to STREAM_STATUS_INVALID for invalid arguments when st != NULL.
  • Returns 0 and sets *st to STREAM_STATUS_IO_ERROR when the bound standard stream does not support writing.
  • Leaves the fake buffered state unchanged on failure paths covered here.

Doubles:

  • fake_stdio
  • fake_memory

Fake behavior:

  • fake_stdio models standard streams with an explicit internal buffer (buffered_backing) and a flushed output (sink_backing)
  • write operations append to the buffered backing
  • flush operations transfer buffered data to the sink backing
  • no implicit flush occurs during write

Isolation:

  • the callback is not called directly
  • behavior is exercised through the public stream port wrapper

See also:

The scenarios below define the test oracle for stdio_stream_write().

Enumerator
STDIO_STREAM_WRITE_SCENARIO_OK_STDOUT 

WHEN stream_write(s, buf, n, &st) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDOUT AND st != NULL EXPECT:

  • returns n
  • st == STREAM_STATUS_OK
  • the n bytes from buf are appended to the buffered backing of the bound standard output stream
  • the sink backing of the bound standard output stream is unchanged
STDIO_STREAM_WRITE_SCENARIO_OK_STDERR 

WHEN stream_write(s, buf, n, &st) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDERR AND st != NULL EXPECT:

  • returns n
  • st == STREAM_STATUS_OK
  • the n bytes from buf are appended to the buffered backing of the bound standard error stream
  • the sink backing of the bound standard error stream is unchanged
STDIO_STREAM_WRITE_SCENARIO_ZERO_LEN 

WHEN stream_write(s, buf, 0, &st) is called AND args->kind designates an output-oriented standard stream AND buf != NULL AND st != NULL EXPECT:

  • returns 0
  • st == STREAM_STATUS_OK
  • the buffered backing of the bound standard stream is unchanged
STDIO_STREAM_WRITE_SCENARIO_BUF_NULL_ZERO_LEN 

WHEN stream_write(s, NULL, 0, &st) is called AND args->kind designates an output-oriented standard stream AND st != NULL EXPECT:

  • returns 0
  • st == STREAM_STATUS_OK
  • the buffered backing of the bound standard stream is unchanged
STDIO_STREAM_WRITE_SCENARIO_BUF_NULL_NONZERO 

WHEN stream_write(s, NULL, n, &st) is called with n > 0 AND args->kind designates an output-oriented standard stream AND st != NULL EXPECT:

  • returns 0
  • st == STREAM_STATUS_INVALID
  • the buffered backing of the bound standard stream is unchanged
STDIO_STREAM_WRITE_SCENARIO_ST_NULL_STDOUT 

WHEN stream_write(s, buf, n, NULL) is called with valid arguments AND args->kind designates an output-oriented standard stream EXPECT:

  • returns n
  • the n bytes from buf are appended to the buffered backing of the bound standard output stream
  • the sink backing of the bound standard output stream is unchanged
  • no status is written
STDIO_STREAM_WRITE_SCENARIO_ST_NULL_STDERR 

WHEN stream_write(s, buf, n, NULL) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDERR EXPECT:

  • returns n
  • the n bytes from buf are appended to the buffered backing of the bound standard error stream
  • the sink backing of the bound standard error stream is unchanged
  • no status is written
STDIO_STREAM_WRITE_SCENARIO_STDIN_FORBIDDEN 

WHEN stream_write(s, buf, n, &st) is called with valid arguments AND args->kind == STDIO_STREAM_KIND_STDIN AND st != NULL EXPECT:

  • returns 0
  • st == STREAM_STATUS_IO_ERROR
  • the buffered backing of the bound standard stream is unchanged

Definition at line 1343 of file unit_test_stdio_stream.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 3081 of file unit_test_stdio_stream.c.

◆ test_stdio_stream_default_cfg()

static void test_stdio_stream_default_cfg ( void **  state)
static

stdio_stream_cfg_t stdio_stream_default_cfg(void);

Success:

Failure:

  • None.

See also:

Definition at line 79 of file unit_test_stdio_stream.c.

◆ test_stdio_stream_default_env()

static void test_stdio_stream_default_env ( void **  state)
static