It covers:
Minimal local test adapters are used only as test doubles to observe registration and resolution behavior through the public factory API.
out, cfg, and env must not be NULL.env->mem must not be NULL.env->mem->calloc and env->mem->free must not be NULL.STREAM_STATUS_OK.*out.stream_destroy_factory().STREAM_STATUS_INVALID for invalid arguments*out unchanged if out is not NULL.stream_destroy_factory() does nothing if fact == NULL or *fact == NULL.*fact to NULL.| WHEN | EXPECT |
|---|---|
stream_create_factory(out, cfg, env) is called with valid arguments | returns STREAM_STATUS_OK;stores a non- NULL factory handle in *out;the produced handle is eligible for destruction by stream_destroy_factory() |
out == NULL | returns STREAM_STATUS_INVALID;no factory handle is produced |
cfg == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
env == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
env != NULL but env->mem == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
env->mem != NULL but env->mem->calloc == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
env->mem != NULL but env->mem->free == NULL and out != NULL | returns STREAM_STATUS_INVALID;leaves *out unchanged |
stream_create_factory() succeeds and stream_destroy_factory() is called twice | first stream_destroy_factory(&fact) releases the handle and sets fact to NULL;second stream_destroy_factory(&fact) is a no-op and keeps fact as NULL |
fact designates a valid factory instance previously created by stream_create_factory().fact and desc must not be NULL.desc->key and desc->ctor must not be NULL.desc->key must not be empty.STREAM_STATUS_OK.stream_factory_create_stream() with the registered key can resolve the descriptor.STREAM_STATUS_INVALID for invalid argumentsSTREAM_STATUS_ALREADY_EXISTS if the key is already registeredSTREAM_STATUS_FULL if the factory capacity is exhaustedtest_stream_ctor_1()test_stream_ctor_2()| WHEN | EXPECT |
|---|---|
stream_factory_add_adapter(fact, desc) is called with a valid factory and a valid descriptor whose key is not yet registered, and the factory has not reached its registration capacity | returns STREAM_STATUS_OK;a later call to stream_factory_create_stream() with that key returns STREAM_STATUS_OK;the produced stream corresponds to the registered descriptor |
fact == NULL | returns STREAM_STATUS_INVALID |
desc == NULL | returns STREAM_STATUS_INVALID |
desc != NULL but desc->key == NULL | returns STREAM_STATUS_INVALID |
desc != NULL but desc->key is an empty string | returns STREAM_STATUS_INVALID |
desc != NULL but desc->ctor == NULL | returns STREAM_STATUS_INVALID |
| a descriptor is added with a key that is already registered | returns STREAM_STATUS_ALREADY_EXISTS;a later call to stream_factory_create_stream() with that key returns STREAM_STATUS_OK;the produced stream corresponds to the previously registered descriptor |
| the factory has reached its registration capacity and a new descriptor is added | returns STREAM_STATUS_FULL;a later call to stream_factory_create_stream() with the new key returns STREAM_STATUS_NOT_FOUND;no stream handle is produced |
stream_factory_create_stream().