зеркало из https://github.com/Azure/sf-c-util.git
Add uint8_t support in SF configuration (#115)
* Add uint8_t support in configuration_reader * More uint8_t * Fix the bug
This commit is contained in:
Родитель
03b73a6c72
Коммит
0b667dda8d
|
@ -7,10 +7,12 @@
|
|||
## Exposed API
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint64_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint64_t*, value)(0, MU_FAILURE);
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint8_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint8_t*, value)(0, MU_FAILURE);
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint32_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint32_t*, value)(0, MU_FAILURE);
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint64_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint64_t*, value)(0, MU_FAILURE);
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_char_string, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, char**, value)(0, MU_FAILURE);
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_thandle_rc_string, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, THANDLE(RC_STRING)*, value)(0, MU_FAILURE);
|
||||
|
@ -20,6 +22,66 @@ MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_wchar_string, IFa
|
|||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_bool, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, bool*, value)(0, MU_FAILURE);
|
||||
```
|
||||
|
||||
### configuration_reader_get_uint8_t
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint8_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint8_t*, value)(0, MU_FAILURE);
|
||||
```
|
||||
|
||||
`configuration_reader_get_uint8_t` reads a configuration value from the code package and returns it as `uint8_t`.
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_001: [** If `activation_context` is `NULL` then `configuration_reader_get_uint8_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_002: [** If `config_package_name` is `NULL` or empty then `configuration_reader_get_uint8_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_003: [** If `section_name` is `NULL` or empty then `configuration_reader_get_uint8_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_004: [** If `parameter_name` is `NULL` or empty then `configuration_reader_get_uint8_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_005: [** If `value` is `NULL` then `configuration_reader_get_uint8_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_006: [** `configuration_reader_get_uint8_t` shall call the `GetConfigurationPackage` function on `activation_context` with `config_package_name`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_007: [** `configuration_reader_get_uint8_t` shall call `GetValue` on the configuration package with `section_name` and `parameter_name`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_008: [** `configuration_reader_get_uint8_t` shall convert the value to `uint8_t` and store it in `value`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_009: [** If the value is outside the range of representable values then `configuration_reader_get_uint8_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_010: [** If there are any other failures then `configuration_reader_get_uint8_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_01_011: [** `configuration_reader_get_uint8_t` shall succeed and return 0. **]**
|
||||
|
||||
### configuration_reader_get_uint8_t
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint32_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint32_t*, value)(0, MU_FAILURE);
|
||||
```
|
||||
|
||||
`configuration_reader_get_uint32_t` reads a configuration value from the code package and returns it as `uint32_t`.
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_012: [** If `activation_context` is `NULL` then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_013: [** If `config_package_name` is `NULL` or empty then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_014: [** If `section_name` is `NULL` or empty then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_015: [** If `parameter_name` is `NULL` or empty then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_016: [** If `value` is `NULL` then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_017: [** `configuration_reader_get_uint32_t` shall call the `GetConfigurationPackage` function on `activation_context` with `config_package_name`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_018: [** `configuration_reader_get_uint32_t` shall call `GetValue` on the configuration package with `section_name` and `parameter_name`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_019: [** `configuration_reader_get_uint32_t` shall convert the value to `uint32_t` and store it in `value`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_020: [** If the value is outside the range of representable values then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_021: [** If there are any other failures then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_022: [** `configuration_reader_get_uint32_t` shall succeed and return 0. **]**
|
||||
|
||||
### configuration_reader_get_uint64_t
|
||||
|
||||
```c
|
||||
|
@ -50,37 +112,6 @@ MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint64_t, IFabric
|
|||
|
||||
**SRS_CONFIGURATION_READER_42_011: [** `configuration_reader_get_uint64_t` shall succeed and return 0. **]**
|
||||
|
||||
|
||||
### configuration_reader_get_uint32_t
|
||||
|
||||
```c
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint32_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint32_t*, value)(0, MU_FAILURE);
|
||||
```
|
||||
|
||||
`configuration_reader_get_uint32_t` reads a configuration value from the code package and returns it as `uint32_t`.
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_012: [** If `activation_context` is `NULL` then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_013: [** If `config_package_name` is `NULL` or empty then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_014: [** If `section_name` is `NULL` or empty then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_015: [** If `parameter_name` is `NULL` or empty then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_016: [** If `value` is `NULL` then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_017: [** `configuration_reader_get_uint32_t` shall call the `GetConfigurationPackage` function on `activation_context` with `config_package_name`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_018: [** `configuration_reader_get_uint32_t` shall call `GetValue` on the configuration package with `section_name` and `parameter_name`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_019: [** `configuration_reader_get_uint32_t` shall convert the value to `uint32_t` and store it in `value`. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_020: [** If the value is outside the range of representable values then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_021: [** If there are any other failures then `configuration_reader_get_uint32_t` shall fail and return a non-zero value. **]**
|
||||
|
||||
**SRS_CONFIGURATION_READER_42_022: [** `configuration_reader_get_uint32_t` shall succeed and return 0. **]**
|
||||
|
||||
### configuration_reader_get_char_string
|
||||
|
||||
```c
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
The following types are supported:
|
||||
- `bool` (must be the string "True" for `true` or "False" or empty for `false`, any other value will fail to parse)
|
||||
- `uint8_t`
|
||||
- `uint32_t`
|
||||
- `uint64_t`
|
||||
- `char*` (`char_ptr`)
|
||||
|
@ -166,6 +167,12 @@ THANDLE(SF_SERVICE_CONFIG(name)) SF_SERVICE_CONFIG_CREATE(name)(IFabricCodePacka
|
|||
|
||||
- **SRS_SF_SERVICE_CONFIG_42_015: [** `SF_SERVICE_CONFIG_CREATE(name)` shall call `configuration_reader_get_bool` with the `activation_context`, `sf_config_name`, `sf_parameters_section_name`, and `SF_SERVICE_CONFIG_PARAMETER_NAME_config_name`. **]**
|
||||
|
||||
- **SRS_SF_SERVICE_CONFIG_01_001: [** If the type is `uint8_t` then: **]**
|
||||
|
||||
- **SRS_SF_SERVICE_CONFIG_01_002: [** `SF_SERVICE_CONFIG_CREATE(name)` shall call `configuration_reader_get_uint8_t` with the `activation_context`, `sf_config_name`, `sf_parameters_section_name`, and `SF_SERVICE_CONFIG_PARAMETER_NAME_config_name`. **]**
|
||||
|
||||
- **SRS_SF_SERVICE_CONFIG_01_003: [** If the result is `UINT8_MAX` then `SF_SERVICE_CONFIG_CREATE(name)` shall fail and return `NULL`. **]**
|
||||
|
||||
- **SRS_SF_SERVICE_CONFIG_42_016: [** If the type is `uint32_t` then: **]**
|
||||
|
||||
- **SRS_SF_SERVICE_CONFIG_42_017: [** `SF_SERVICE_CONFIG_CREATE(name)` shall call `configuration_reader_get_uint32_t` with the `activation_context`, `sf_config_name`, `sf_parameters_section_name`, and `SF_SERVICE_CONFIG_PARAMETER_NAME_config_name`. **]**
|
||||
|
@ -242,6 +249,8 @@ Each getter function returns the value read from the config. The integer values
|
|||
|
||||
- **SRS_SF_SERVICE_CONFIG_42_045: [** ...`false` if the type is `bool` **]**
|
||||
|
||||
- **SRS_SF_SERVICE_CONFIG_01_004: [** ...`UINT8_MAX` if the type is `uint8_t` **]**
|
||||
|
||||
- **SRS_SF_SERVICE_CONFIG_42_046: [** ...`UINT32_MAX` if the type is `uint32_t` **]**
|
||||
|
||||
- **SRS_SF_SERVICE_CONFIG_42_047: [** ...`UINT64_MAX` if the type is `uint64_t` **]**
|
||||
|
|
|
@ -24,10 +24,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint64_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint64_t*, value)(0, MU_FAILURE);
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint8_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint8_t*, value)(0, MU_FAILURE);
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint32_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint32_t*, value)(0, MU_FAILURE);
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_uint64_t, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, uint64_t*, value)(0, MU_FAILURE);
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_char_string, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, char**, value)(0, MU_FAILURE);
|
||||
|
||||
MOCKABLE_FUNCTION_WITH_RETURNS(, int, configuration_reader_get_thandle_rc_string, IFabricCodePackageActivationContext*, activation_context, const wchar_t*, config_package_name, const wchar_t*, section_name, const wchar_t*, parameter_name, THANDLE(RC_STRING)*, value)(0, MU_FAILURE);
|
||||
|
|
|
@ -36,6 +36,7 @@ extern "C" {
|
|||
/*
|
||||
Currently supports the following types:
|
||||
bool
|
||||
uint8_t
|
||||
uint32_t
|
||||
uint64_t
|
||||
char* (char_ptr)
|
||||
|
@ -146,6 +147,7 @@ typedef THANDLE(RC_STRING) thandle_rc_string;
|
|||
|
||||
// Type helpers
|
||||
|
||||
#define PRI_uint8_t PRIu8
|
||||
#define PRI_uint32_t PRIu32
|
||||
#define PRI_uint64_t PRIu64
|
||||
|
||||
|
@ -202,6 +204,7 @@ typedef THANDLE(RC_STRING) thandle_rc_string;
|
|||
#define SF_SERVICE_CONFIG_DO_READ_integer_type(type, max_value, config, parameter_string, result_value, error_occurred_flag) \
|
||||
if (!error_occurred_flag) \
|
||||
{ \
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_01_002: [ SF_SERVICE_CONFIG_CREATE(name) shall call configuration_reader_get_uint8_t with the activation_context, sf_config_name, sf_parameters_section_name, and SF_SERVICE_CONFIG_PARAMETER_NAME_config_name. ]*/ \
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_42_017: [ SF_SERVICE_CONFIG_CREATE(name) shall call configuration_reader_get_uint32_t with the activation_context, sf_config_name, sf_parameters_section_name, and SF_SERVICE_CONFIG_PARAMETER_NAME_config_name. ]*/ \
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_42_020: [ SF_SERVICE_CONFIG_CREATE(name) shall call configuration_reader_get_uint64_t with the activation_context, sf_config_name, sf_parameters_section_name, and SF_SERVICE_CONFIG_PARAMETER_NAME_config_name. ]*/ \
|
||||
if (MU_C2(configuration_reader_get_, type)(config->activation_context, config->sf_config_name_string, config->sf_parameters_section_name_string, parameter_string, &result_value) != 0) \
|
||||
|
@ -213,6 +216,7 @@ typedef THANDLE(RC_STRING) thandle_rc_string;
|
|||
} \
|
||||
else if (result_value == max_value) \
|
||||
{ \
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_01_003: [ If the result is UINT8_MAX then SF_SERVICE_CONFIG_CREATE(name) shall fail and return NULL. ]*/ \
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_42_018: [ If the result is UINT32_MAX then SF_SERVICE_CONFIG_CREATE(name) shall fail and return NULL. ]*/ \
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_42_021: [ If the result is UINT64_MAX then SF_SERVICE_CONFIG_CREATE(name) shall fail and return NULL. ]*/ \
|
||||
LogError("Invalid %ls=%" MU_C2(PRI_, type), parameter_string, result_value); \
|
||||
|
@ -224,6 +228,10 @@ typedef THANDLE(RC_STRING) thandle_rc_string;
|
|||
} \
|
||||
}
|
||||
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_01_001: [ If the type is uint8_t then: ]*/
|
||||
#define SF_SERVICE_CONFIG_DO_READ_uint8_t(config, field_name, parameter_string, result_value, error_occurred_flag, fail_if_null) \
|
||||
SF_SERVICE_CONFIG_DO_READ_integer_type(uint8_t, UINT8_MAX, config, parameter_string, result_value, error_occurred_flag)
|
||||
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_42_016: [ If the type is uint32_t then: ]*/
|
||||
#define SF_SERVICE_CONFIG_DO_READ_uint32_t(config, field_name, parameter_string, result_value, error_occurred_flag, fail_if_null) \
|
||||
SF_SERVICE_CONFIG_DO_READ_integer_type(uint32_t, UINT32_MAX, config, parameter_string, result_value, error_occurred_flag)
|
||||
|
@ -428,6 +436,7 @@ typedef THANDLE(RC_STRING) thandle_rc_string;
|
|||
// Getters
|
||||
|
||||
#define SF_SERVICE_CONFIG_RETURN_TYPE__Bool bool
|
||||
#define SF_SERVICE_CONFIG_RETURN_TYPE_uint8_t uint8_t
|
||||
#define SF_SERVICE_CONFIG_RETURN_TYPE_uint32_t uint32_t
|
||||
#define SF_SERVICE_CONFIG_RETURN_TYPE_uint64_t uint64_t
|
||||
#define SF_SERVICE_CONFIG_RETURN_TYPE_char_ptr const char*
|
||||
|
@ -437,6 +446,7 @@ typedef THANDLE(RC_STRING) thandle_rc_string;
|
|||
#define SF_SERVICE_CONFIG_RETURN_TYPE(type) MU_C2A(SF_SERVICE_CONFIG_RETURN_TYPE_, type)
|
||||
|
||||
#define SF_SERVICE_CONFIG_INIT_RETURN__Bool
|
||||
#define SF_SERVICE_CONFIG_INIT_RETURN_uint8_t
|
||||
#define SF_SERVICE_CONFIG_INIT_RETURN_uint32_t
|
||||
#define SF_SERVICE_CONFIG_INIT_RETURN_uint64_t
|
||||
#define SF_SERVICE_CONFIG_INIT_RETURN_char_ptr
|
||||
|
@ -447,6 +457,8 @@ typedef THANDLE(RC_STRING) thandle_rc_string;
|
|||
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_42_045: [ ...false if the type is bool ]*/
|
||||
#define SF_SERVICE_CONFIG_GETTER_ERROR__Bool false
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_01_004: [ ...UINT8_MAX if the type is uint8_t ]*/
|
||||
#define SF_SERVICE_CONFIG_GETTER_ERROR_uint8_t UINT8_MAX
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_42_046: [ ...UINT32_MAX if the type is uint32_t ]*/
|
||||
#define SF_SERVICE_CONFIG_GETTER_ERROR_uint32_t UINT32_MAX
|
||||
/*Codes_SRS_SF_SERVICE_CONFIG_42_047: [ ...UINT64_MAX if the type is uint64_t ]*/
|
||||
|
@ -459,6 +471,7 @@ typedef THANDLE(RC_STRING) thandle_rc_string;
|
|||
#define SF_SERVICE_CONFIG_GETTER_ERROR(type) MU_C2(SF_SERVICE_CONFIG_GETTER_ERROR_, type)
|
||||
|
||||
#define SF_SERVICE_CONFIG_GETTER_DO_ASSIGN__Bool(lval, rval) lval = rval
|
||||
#define SF_SERVICE_CONFIG_GETTER_DO_ASSIGN_uint8_t(lval, rval) lval = rval
|
||||
#define SF_SERVICE_CONFIG_GETTER_DO_ASSIGN_uint32_t(lval, rval) lval = rval
|
||||
#define SF_SERVICE_CONFIG_GETTER_DO_ASSIGN_uint64_t(lval, rval) lval = rval
|
||||
#define SF_SERVICE_CONFIG_GETTER_DO_ASSIGN_char_ptr(lval, rval) lval = rval
|
||||
|
|
|
@ -28,16 +28,18 @@ static int get_string_value_from_package(IFabricCodePackageActivationContext* ac
|
|||
int result;
|
||||
HRESULT hr;
|
||||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_006: [ configuration_reader_get_uint64_t shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_006: [ configuration_reader_get_uint8_t shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_017: [ configuration_reader_get_uint32_t shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_006: [ configuration_reader_get_uint64_t shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_028: [ configuration_reader_get_char_string shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_038: [ configuration_reader_get_wchar_string shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_048: [ configuration_reader_get_thandle_rc_string shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
hr = activation_context->lpVtbl->GetConfigurationPackage(activation_context, config_package_name, fabric_configuration_package);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_010: [ If there are any other failures then configuration_reader_get_uint64_t shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_010: [ If there are any other failures then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_021: [ If there are any other failures then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_010: [ If there are any other failures then configuration_reader_get_uint64_t shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_031: [ If there are any other failures then configuration_reader_get_char_string shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_041: [ If there are any other failures then configuration_reader_get_wchar_string shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_052: [ If there are any other failures then configuration_reader_get_thandle_rc_string shall fail and return a non-zero value. ]*/
|
||||
|
@ -47,16 +49,18 @@ static int get_string_value_from_package(IFabricCodePackageActivationContext* ac
|
|||
else
|
||||
{
|
||||
BOOLEAN is_encrypted = FALSE;
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_007: [ configuration_reader_get_uint64_t shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_007: [ configuration_reader_get_uint8_t shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_018: [ configuration_reader_get_uint32_t shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_007: [ configuration_reader_get_uint64_t shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_029: [ configuration_reader_get_char_string shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_039: [ configuration_reader_get_wchar_string shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_049: [ configuration_reader_get_thandle_rc_string shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
hr = (*fabric_configuration_package)->lpVtbl->GetValue((*fabric_configuration_package), section_name, parameter_name, &is_encrypted, wchar_value);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_010: [ If there are any other failures then configuration_reader_get_uint64_t shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_010: [ If there are any other failures then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_021: [ If there are any other failures then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_010: [ If there are any other failures then configuration_reader_get_uint64_t shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_031: [ If there are any other failures then configuration_reader_get_char_string shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_041: [ If there are any other failures then configuration_reader_get_wchar_string shall fail and return a non-zero value. ]*/
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_052: [ If there are any other failures then configuration_reader_get_thandle_rc_string shall fail and return a non-zero value. ]*/
|
||||
|
@ -76,6 +80,149 @@ all_ok:
|
|||
return result;
|
||||
}
|
||||
|
||||
int configuration_reader_get_uint8_t(IFabricCodePackageActivationContext* activation_context, const wchar_t* config_package_name, const wchar_t* section_name, const wchar_t* parameter_name, uint8_t* value)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_001: [ If activation_context is NULL then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
activation_context == NULL ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_002: [ If config_package_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
(config_package_name == NULL || config_package_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_003: [ If section_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
(section_name == NULL || section_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_004: [ If parameter_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
(parameter_name == NULL || parameter_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_005: [ If value is NULL then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
(value == NULL)
|
||||
)
|
||||
{
|
||||
LogError("Invalid args: IFabricCodePackageActivationContext* activation_context = %p, const wchar_t* config_package_name = %ls, const wchar_t* section_name = %ls, const wchar_t* parameter_name = %ls, uint8_t* value = %p",
|
||||
activation_context, MU_WP_OR_NULL(config_package_name), MU_WP_OR_NULL(section_name), MU_WP_OR_NULL(parameter_name), value);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IFabricConfigurationPackage* fabric_configuration_package;
|
||||
const wchar_t* wchar_value;
|
||||
if (get_string_value_from_package(activation_context, config_package_name, section_name, parameter_name, &fabric_configuration_package, &wchar_value) != 0)
|
||||
{
|
||||
// already logged error
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_008: [ configuration_reader_get_uint8_t shall convert the value to uint8_t and store it in value. ]*/
|
||||
wchar_t* end_ptr;
|
||||
uint64_t temp = wcstoull(wchar_value, &end_ptr, 10);
|
||||
if (end_ptr == wchar_value)
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_021: [ If there are any other failures then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
LogError("failure in wcstoull(%ls): subject sequence is empty or does not have the expected form (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
wchar_value, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((temp == ULLONG_MAX) && (errno == ERANGE))
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_009: [ If the value is outside the range of representable values then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
LogError("ULLONGMAX was returned for wcstoull(%ls), indicating the correct value is outside the range of representable values (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
wchar_value, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else if (temp > UINT8_MAX)
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_009: [ If the value is outside the range of representable values then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
LogError("The value %" PRIu64 " is too large for uint8_t (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
temp, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_01_011: [ configuration_reader_get_uint8_t shall succeed and return 0. ]*/
|
||||
*value = (uint8_t)temp;
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
(void)fabric_configuration_package->lpVtbl->Release(fabric_configuration_package);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int configuration_reader_get_uint32_t(IFabricCodePackageActivationContext* activation_context, const wchar_t* config_package_name, const wchar_t* section_name, const wchar_t* parameter_name, uint32_t* value)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_012: [ If activation_context is NULL then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
activation_context == NULL ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_013: [ If config_package_name is NULL or empty then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
(config_package_name == NULL || config_package_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_014: [ If section_name is NULL or empty then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
(section_name == NULL || section_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_015: [ If parameter_name is NULL or empty then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
(parameter_name == NULL || parameter_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_016: [ If value is NULL then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
(value == NULL)
|
||||
)
|
||||
{
|
||||
LogError("Invalid args: IFabricCodePackageActivationContext* activation_context = %p, const wchar_t* config_package_name = %ls, const wchar_t* section_name = %ls, const wchar_t* parameter_name = %ls, uint32_t* value = %p",
|
||||
activation_context, MU_WP_OR_NULL(config_package_name), MU_WP_OR_NULL(section_name), MU_WP_OR_NULL(parameter_name), value);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IFabricConfigurationPackage* fabric_configuration_package;
|
||||
const wchar_t* wchar_value;
|
||||
if (get_string_value_from_package(activation_context, config_package_name, section_name, parameter_name, &fabric_configuration_package, &wchar_value) != 0)
|
||||
{
|
||||
// already logged error
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_019: [ configuration_reader_get_uint32_t shall convert the value to uint32_t and store it in value. ]*/
|
||||
wchar_t* end_ptr;
|
||||
uint64_t temp = wcstoull(wchar_value, &end_ptr, 10);
|
||||
if (end_ptr == wchar_value)
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_021: [ If there are any other failures then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
LogError("failure in wcstoull(%ls): subject sequence is empty or does not have the expected form (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
wchar_value, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((temp == ULLONG_MAX) && (errno == ERANGE))
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_020: [ If the value is outside the range of representable values then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
LogError("ULLONGMAX was returned for wcstoull(%ls), indicating the correct value is outside the range of representable values (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
wchar_value, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else if (temp > UINT32_MAX)
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_020: [ If the value is outside the range of representable values then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
LogError("The value %" PRIu64 " is too large for uint32_t (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
temp, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_022: [ configuration_reader_get_uint32_t shall succeed and return 0. ]*/
|
||||
*value = (uint32_t)temp;
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
(void)fabric_configuration_package->lpVtbl->Release(fabric_configuration_package);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int configuration_reader_get_uint64_t(IFabricCodePackageActivationContext* activation_context, const wchar_t* config_package_name, const wchar_t* section_name, const wchar_t* parameter_name, uint64_t* value)
|
||||
{
|
||||
|
@ -212,78 +359,6 @@ int configuration_reader_get_bool(IFabricCodePackageActivationContext* activatio
|
|||
return result;
|
||||
}
|
||||
|
||||
int configuration_reader_get_uint32_t(IFabricCodePackageActivationContext* activation_context, const wchar_t* config_package_name, const wchar_t* section_name, const wchar_t* parameter_name, uint32_t* value)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_012: [ If activation_context is NULL then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
activation_context == NULL ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_013: [ If config_package_name is NULL or empty then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
(config_package_name == NULL || config_package_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_014: [ If section_name is NULL or empty then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
(section_name == NULL || section_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_015: [ If parameter_name is NULL or empty then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
(parameter_name == NULL || parameter_name[0] == L'\0') ||
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_016: [ If value is NULL then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
(value == NULL)
|
||||
)
|
||||
{
|
||||
LogError("Invalid args: IFabricCodePackageActivationContext* activation_context = %p, const wchar_t* config_package_name = %ls, const wchar_t* section_name = %ls, const wchar_t* parameter_name = %ls, uint32_t* value = %p",
|
||||
activation_context, MU_WP_OR_NULL(config_package_name), MU_WP_OR_NULL(section_name), MU_WP_OR_NULL(parameter_name), value);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IFabricConfigurationPackage* fabric_configuration_package;
|
||||
const wchar_t* wchar_value;
|
||||
if (get_string_value_from_package(activation_context, config_package_name, section_name, parameter_name, &fabric_configuration_package, &wchar_value) != 0)
|
||||
{
|
||||
// already logged error
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_019: [ configuration_reader_get_uint32_t shall convert the value to uint32_t and store it in value. ]*/
|
||||
wchar_t* end_ptr;
|
||||
uint64_t temp = wcstoull(wchar_value, &end_ptr, 10);
|
||||
if (end_ptr == wchar_value)
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_021: [ If there are any other failures then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
LogError("failure in wcstoull(%ls): subject sequence is empty or does not have the expected form (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
wchar_value, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((temp == ULLONG_MAX) && (errno == ERANGE))
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_020: [ If the value is outside the range of representable values then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
LogError("ULLONGMAX was returned for wcstoull(%ls), indicating the correct value is outside the range of representable values (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
wchar_value, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else if (temp > UINT32_MAX)
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_020: [ If the value is outside the range of representable values then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
LogError("The value %" PRIu64 " is too large for uint32_t (config_package_name:%ls, section_name:%ls, parameter_name:%ls)",
|
||||
temp, config_package_name, section_name, parameter_name);
|
||||
result = MU_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Codes_SRS_CONFIGURATION_READER_42_022: [ configuration_reader_get_uint32_t shall succeed and return 0. ]*/
|
||||
*value = (uint32_t)temp;
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
(void)fabric_configuration_package->lpVtbl->Release(fabric_configuration_package);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int configuration_reader_get_char_string(IFabricCodePackageActivationContext* activation_context, const wchar_t* config_package_name, const wchar_t* section_name, const wchar_t* parameter_name, char** value)
|
||||
{
|
||||
int result;
|
||||
|
|
|
@ -442,6 +442,232 @@ TEST_FUNCTION(configuration_reader_get_uint64_t_fails_when_underlying_functions_
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// configuration_reader_get_uint8_t
|
||||
//
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_001: [ If activation_context is NULL then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_null_activation_context_fails)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(NULL, test_config_package_name, test_section_name, test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_002: [ If config_package_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_null_config_package_name_fails)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, NULL, test_section_name, test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_002: [ If config_package_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_empty_config_package_name_fails)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, L"", test_section_name, test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_003: [ If section_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_null_section_name_fails)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, NULL, test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_003: [ If section_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_empty_section_name_fails)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, L"", test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_004: [ If parameter_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_null_parameter_name_fails)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, NULL, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_004: [ If parameter_name is NULL or empty then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_empty_parameter_name_fails)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, L"", &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_005: [ If value is NULL then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_null_value_fails)
|
||||
{
|
||||
///arrange
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, test_parameter_name, NULL);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_006: [ configuration_reader_get_uint8_t shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_007: [ configuration_reader_get_uint8_t shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_008: [ configuration_reader_get_uint8_t shall convert the value to uint8_t and store it in value. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_011: [ configuration_reader_get_uint8_t shall succeed and return 0. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_succeeds)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
test_value_to_return = L"42";
|
||||
|
||||
setup_expectation_read_uint_values();
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_EQUAL(uint8_t, 42, value);
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_006: [ configuration_reader_get_uint8_t shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_007: [ configuration_reader_get_uint8_t shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_008: [ configuration_reader_get_uint8_t shall convert the value to uint8_t and store it in value. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_011: [ configuration_reader_get_uint8_t shall succeed and return 0. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_max_succeeds)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
test_value_to_return = L"255"; // UINT8_MAX as decimal
|
||||
|
||||
setup_expectation_read_uint_values();
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_EQUAL(uint8_t, 255, value);
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_006: [ configuration_reader_get_uint8_t shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_007: [ configuration_reader_get_uint8_t shall call GetValue on the configuration package with section_name and parameter_name. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_008: [ configuration_reader_get_uint8_t shall convert the value to uint8_t and store it in value. ]*/
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_011: [ configuration_reader_get_uint8_t shall succeed and return 0. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_with_0_succeeds)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
test_value_to_return = L"0"; // UINT32_MAX as decimal
|
||||
|
||||
setup_expectation_read_uint_values();
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_EQUAL(uint8_t, 0, value);
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_009: [ If the value is outside the range of representable values then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_too_large_fails)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
test_value_to_return = L"256";
|
||||
|
||||
setup_expectation_read_uint_values();
|
||||
|
||||
///act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, test_parameter_name, &value);
|
||||
|
||||
///assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_01_010: [ If there are any other failures then configuration_reader_get_uint8_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint8_t_fails_when_underlying_functions_fail)
|
||||
{
|
||||
/// arrange
|
||||
uint8_t value;
|
||||
|
||||
test_value_to_return = L"42";
|
||||
|
||||
setup_expectation_read_uint_values();
|
||||
|
||||
umock_c_negative_tests_snapshot();
|
||||
|
||||
for (uint8_t i = 0; i < umock_c_negative_tests_call_count(); i++)
|
||||
{
|
||||
if (umock_c_negative_tests_can_call_fail(i))
|
||||
{
|
||||
umock_c_negative_tests_reset();
|
||||
umock_c_negative_tests_fail_call(i);
|
||||
|
||||
/// act
|
||||
int result = configuration_reader_get_uint8_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, test_parameter_name, &value);
|
||||
|
||||
/// assert
|
||||
ASSERT_ARE_NOT_EQUAL(int, 0, result, "On failed call %" PRIu32, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// configuration_reader_get_uint32_t
|
||||
//
|
||||
|
@ -547,6 +773,7 @@ TEST_FUNCTION(configuration_reader_get_uint32_t_with_empty_parameter_name_fails)
|
|||
/*Tests_SRS_CONFIGURATION_READER_42_016: [ If value is NULL then configuration_reader_get_uint32_t shall fail and return a non-zero value. ]*/
|
||||
TEST_FUNCTION(configuration_reader_get_uint32_t_with_null_value_fails)
|
||||
{
|
||||
///arrange
|
||||
///act
|
||||
int result = configuration_reader_get_uint32_t(&test_fabric_code_package_activation_context, test_config_package_name, test_section_name, test_parameter_name, NULL);
|
||||
|
||||
|
@ -574,7 +801,7 @@ TEST_FUNCTION(configuration_reader_get_uint32_t_succeeds)
|
|||
///assert
|
||||
ASSERT_ARE_EQUAL(int, 0, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
ASSERT_ARE_EQUAL(uint64_t, 42, value);
|
||||
ASSERT_ARE_EQUAL(uint32_t, 42, value);
|
||||
}
|
||||
|
||||
/*Tests_SRS_CONFIGURATION_READER_42_017: [ configuration_reader_get_uint32_t shall call the GetConfigurationPackage function on activation_context with config_package_name. ]*/
|
||||
|
|
|
@ -77,6 +77,7 @@ TEST_SF_SERVICE_CONFIG_DEFINE_EXPECTED_CALL_HELPERS(my_config, expected_config_p
|
|||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_mocked_parameter_1 L"Parameter1"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_mocked_parameter_2 L"Parameter2"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_mocked_parameter_3 L"Parameter3WithLongerName"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_mocked_parameter_4 L"Parameter4"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_mocked_some_flag L"SomeFlag"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_mocked_string_option_in_thandle L"StringOptionThandle"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_mocked_string_option L"MyString"
|
||||
|
@ -90,6 +91,7 @@ TEST_SF_SERVICE_CONFIG_DEFINE_EXPECTED_CALL_HELPERS(my_config, expected_config_p
|
|||
CONFIG_REQUIRED(uint64_t, mocked_parameter_1), \
|
||||
CONFIG_REQUIRED(uint64_t, mocked_parameter_2), \
|
||||
CONFIG_REQUIRED(uint32_t, mocked_parameter_3), \
|
||||
CONFIG_REQUIRED(uint8_t, mocked_parameter_4), \
|
||||
CONFIG_REQUIRED(bool, mocked_some_flag), \
|
||||
CONFIG_REQUIRED(thandle_rc_string, mocked_string_option_in_thandle), \
|
||||
CONFIG_REQUIRED(char_ptr, mocked_string_option), \
|
||||
|
@ -249,6 +251,8 @@ TEST_FUNCTION(SF_SERVICE_CONFIG_CREATE_with_NULL_activation_context_fails)
|
|||
/*Tests_SRS_SF_SERVICE_CONFIG_42_013: [ For each configuration value with name config_name: ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_014: [ If the type is bool then: ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_015: [ SF_SERVICE_CONFIG_CREATE(name) shall call configuration_reader_get_bool with the activation_context, sf_config_name, sf_parameters_section_name, and SF_SERVICE_CONFIG_PARAMETER_NAME_config_name. ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_01_001: [ If the type is uint8_t then: ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_01_002: [ SF_SERVICE_CONFIG_CREATE(name) shall call configuration_reader_get_uint8_t with the activation_context, sf_config_name, sf_parameters_section_name, and SF_SERVICE_CONFIG_PARAMETER_NAME_config_name. ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_016: [ If the type is uint32_t then: ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_017: [ SF_SERVICE_CONFIG_CREATE(name) shall call configuration_reader_get_uint32_t with the activation_context, sf_config_name, sf_parameters_section_name, and SF_SERVICE_CONFIG_PARAMETER_NAME_config_name. ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_019: [ If the type is uint64_t then: ]*/
|
||||
|
@ -299,6 +303,23 @@ TEST_FUNCTION(SF_SERVICE_CONFIG_CREATE_fails_when_underlying_functions_fail)
|
|||
}
|
||||
}
|
||||
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_01_001: [ If the type is uint8_t then: ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_01_002: [ SF_SERVICE_CONFIG_CREATE(name) shall call configuration_reader_get_uint8_t with the activation_context, sf_config_name, sf_parameters_section_name, and SF_SERVICE_CONFIG_PARAMETER_NAME_config_name. ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_01_003: [ If the result is UINT8_MAX then SF_SERVICE_CONFIG_CREATE(name) shall fail and return NULL. ]*/
|
||||
TEST_FUNCTION(SF_SERVICE_CONFIG_CREATE_fails_when_uint8_t_value_is_UINT8_MAX)
|
||||
{
|
||||
// arrange
|
||||
TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(parameter_4) = UINT8_MAX;
|
||||
TEST_SF_SERVICE_CONFIG_EXPECT_READ_UP_TO(my_config)(TEST_SF_SERVICE_CONFIG_INDEX_OF_CONFIG(my_config, parameter_4));
|
||||
|
||||
// act
|
||||
THANDLE(SF_SERVICE_CONFIG(my_config)) result = SF_SERVICE_CONFIG_CREATE(my_config)(TEST_SF_SERVICE_CONFIG_ACTIVATION_CONTEXT(my_config));
|
||||
|
||||
// assert
|
||||
ASSERT_IS_NULL(result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_016: [ If the type is uint32_t then: ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_017: [ SF_SERVICE_CONFIG_CREATE(name) shall call configuration_reader_get_uint32_t with the activation_context, sf_config_name, sf_parameters_section_name, and SF_SERVICE_CONFIG_PARAMETER_NAME_config_name. ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_018: [ If the result is UINT32_MAX then SF_SERVICE_CONFIG_CREATE(name) shall fail and return NULL. ]*/
|
||||
|
@ -580,6 +601,26 @@ TEST_FUNCTION(SF_SERVICE_CONFIG_GETTER_for_bool_with_NULL_handle_returns_false)
|
|||
THANDLE_ASSIGN(SF_SERVICE_CONFIG(my_config))(&config, NULL);
|
||||
}
|
||||
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_044: [ If handle is NULL then SF_SERVICE_CONFIG_GETTER(name, field_name) shall fail and return... ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_01_004: [ ...UINT8_MAX if the type is uint8_t ]*/
|
||||
TEST_FUNCTION(SF_SERVICE_CONFIG_GETTER_for_uint8_t_with_NULL_handle_returns_UINT8_MAX)
|
||||
{
|
||||
// arrange
|
||||
TEST_SF_SERVICE_CONFIG_EXPECT_ALL_READ(my_config)();
|
||||
THANDLE(SF_SERVICE_CONFIG(my_config)) config = SF_SERVICE_CONFIG_CREATE(my_config)(TEST_SF_SERVICE_CONFIG_ACTIVATION_CONTEXT(my_config));
|
||||
ASSERT_IS_NOT_NULL(config);
|
||||
|
||||
// act
|
||||
uint32_t result = SF_SERVICE_CONFIG_GETTER(my_config, parameter_4)(NULL);
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(uint8_t, UINT8_MAX, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
|
||||
// cleanup
|
||||
THANDLE_ASSIGN(SF_SERVICE_CONFIG(my_config))(&config, NULL);
|
||||
}
|
||||
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_044: [ If handle is NULL then SF_SERVICE_CONFIG_GETTER(name, field_name) shall fail and return... ]*/
|
||||
/*Tests_SRS_SF_SERVICE_CONFIG_42_046: [ ...UINT32_MAX if the type is uint32_t ]*/
|
||||
TEST_FUNCTION(SF_SERVICE_CONFIG_GETTER_for_uint32_t_with_NULL_handle_returns_UINT32_MAX)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
/* This expands to the configuration reader mock hooks */ \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_CONFIGURATION_READER_HOOK(uint64_t, config_name, __VA_ARGS__) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_CONFIGURATION_READER_HOOK(uint32_t, config_name, __VA_ARGS__) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_CONFIGURATION_READER_HOOK(uint8_t, config_name, __VA_ARGS__) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_CONFIGURATION_READER_HOOK(wchar_ptr, config_name, __VA_ARGS__) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_CONFIGURATION_READER_HOOK(char_ptr, config_name, __VA_ARGS__) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_CONFIGURATION_READER_HOOK(thandle_rc_string, config_name, __VA_ARGS__) \
|
||||
|
@ -53,6 +54,7 @@
|
|||
#define TEST_SF_SERVICE_CONFIG_HOOK_CONFIGURATION_READER(config_name) \
|
||||
REGISTER_GLOBAL_MOCK_HOOK(configuration_reader_get_uint64_t, MU_C3(hook_, config_name, _configuration_reader_get_uint64_t)); \
|
||||
REGISTER_GLOBAL_MOCK_HOOK(configuration_reader_get_uint32_t, MU_C3(hook_, config_name, _configuration_reader_get_uint32_t)); \
|
||||
REGISTER_GLOBAL_MOCK_HOOK(configuration_reader_get_uint8_t, MU_C3(hook_, config_name, _configuration_reader_get_uint8_t)); \
|
||||
REGISTER_GLOBAL_MOCK_HOOK(configuration_reader_get_char_string, MU_C3(hook_, config_name, _configuration_reader_get_char_ptr)); \
|
||||
REGISTER_GLOBAL_MOCK_HOOK(configuration_reader_get_thandle_rc_string, MU_C3(hook_, config_name, _configuration_reader_get_thandle_rc_string)); \
|
||||
REGISTER_GLOBAL_MOCK_HOOK(configuration_reader_get_wchar_string, MU_C3(hook_, config_name, _configuration_reader_get_wchar_ptr)); \
|
||||
|
@ -99,6 +101,7 @@
|
|||
MOCK_FUNCTION_END(0); \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_EXPECT_READ(name, sf_config_name, sf_parameters_section_name, uint64_t) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_EXPECT_READ(name, sf_config_name, sf_parameters_section_name, uint32_t) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_EXPECT_READ(name, sf_config_name, sf_parameters_section_name, uint8_t) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_EXPECT_READ(name, sf_config_name, sf_parameters_section_name, wchar_ptr) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_EXPECT_READ(name, sf_config_name, sf_parameters_section_name, char_ptr) \
|
||||
TEST_SF_SERVICE_CONFIG_DEFINE_EXPECT_READ(name, sf_config_name, sf_parameters_section_name, bool) \
|
||||
|
@ -208,6 +211,10 @@
|
|||
#define TEST_SF_SERVICE_CONFIG_TYPE_IS_bool(type) MU_IF(MU_C2(TEST_SF_SERVICE_CONFIG_TYPE_IS_bool_,type), 0, 1)
|
||||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGN_IF_MATCH__Bool(type, name) MU_IF(TEST_SF_SERVICE_CONFIG_TYPE_IS_bool(type), TEST_SF_SERVICE_CONFIG_DO_ASSIGN_IF_MATCH(name), )
|
||||
|
||||
#define TEST_SF_SERVICE_CONFIG_TYPE_IS_UINT8_uint8_t 0
|
||||
#define TEST_SF_SERVICE_CONFIG_TYPE_IS_UINT8(type) MU_IF(MU_C2(TEST_SF_SERVICE_CONFIG_TYPE_IS_UINT8_,type), 0, 1)
|
||||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGN_IF_MATCH_uint8_t(type, name) MU_IF(TEST_SF_SERVICE_CONFIG_TYPE_IS_UINT8(type), TEST_SF_SERVICE_CONFIG_DO_ASSIGN_IF_MATCH(name), )
|
||||
|
||||
#define TEST_SF_SERVICE_CONFIG_TYPE_IS_UINT32_uint32_t 0
|
||||
#define TEST_SF_SERVICE_CONFIG_TYPE_IS_UINT32(type) MU_IF(MU_C2(TEST_SF_SERVICE_CONFIG_TYPE_IS_UINT32_,type), 0, 1)
|
||||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGN_IF_MATCH_uint32_t(type, name) MU_IF(TEST_SF_SERVICE_CONFIG_TYPE_IS_UINT32(type), TEST_SF_SERVICE_CONFIG_DO_ASSIGN_IF_MATCH(name), )
|
||||
|
@ -239,6 +246,7 @@
|
|||
TEST_SF_SERVICE_CONFIG_THANDLE_MEMBER_DECL(type, member); \
|
||||
} name;
|
||||
|
||||
#define TEST_SF_SERVICE_CONFIG_TYPE_FOR_ASSERT_uint8_t uint8_t
|
||||
#define TEST_SF_SERVICE_CONFIG_TYPE_FOR_ASSERT_uint32_t uint32_t
|
||||
#define TEST_SF_SERVICE_CONFIG_TYPE_FOR_ASSERT_uint64_t uint64_t
|
||||
#define TEST_SF_SERVICE_CONFIG_TYPE_FOR_ASSERT_char_ptr char_ptr
|
||||
|
@ -252,6 +260,7 @@
|
|||
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE__Bool TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_bool TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_uint8_t TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_uint32_t TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_uint64_t TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_char_ptr TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_DEFINE_DEFAULT
|
||||
|
@ -262,6 +271,7 @@
|
|||
|
||||
#define TEST_SF_SERVICE_CONFIG_DEFAULT_DEFINE__Bool(type, name) static const bool TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name) = true;
|
||||
#define TEST_SF_SERVICE_CONFIG_DEFAULT_DEFINE_bool(type, name) static const bool TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name) = true;
|
||||
#define TEST_SF_SERVICE_CONFIG_DEFAULT_DEFINE_uint8_t(type, name) static const uint8_t TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name) = 42;
|
||||
#define TEST_SF_SERVICE_CONFIG_DEFAULT_DEFINE_uint32_t(type, name) static const uint32_t TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name) = 42;
|
||||
#define TEST_SF_SERVICE_CONFIG_DEFAULT_DEFINE_uint64_t(type, name) static const uint64_t TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name) = 4242;
|
||||
#define TEST_SF_SERVICE_CONFIG_DEFAULT_DEFINE_char_ptr(type, name) static const char* TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name) = MU_TOSTRING(name);
|
||||
|
@ -274,6 +284,7 @@
|
|||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_THANDLE(lval, rval) THANDLE_ASSIGN(real_RC_STRING)(&lval, rval);
|
||||
|
||||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT__Bool TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_uint8_t TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_uint32_t TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_uint64_t TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_DEFAULT
|
||||
#define TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_char_ptr TEST_SF_SERVICE_CONFIG_DO_ASSIGNMENT_DEFAULT
|
||||
|
@ -295,6 +306,7 @@
|
|||
// Causes all mock calls to return the defaults (defined above)
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT_bool(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name);
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT__Bool(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name);
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT_uint8_t(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name);
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT_uint32_t(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name);
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT_uint64_t(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name);
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT_char_ptr(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = (char*)TEST_SF_SERVICE_CONFIG_DEFAULT_VALUE(name);
|
||||
|
@ -308,6 +320,7 @@
|
|||
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_MAX_bool(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = false;
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_MAX__Bool(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = false;
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_MAX_uint8_t(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = UINT8_MAX - 1;
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_MAX_uint32_t(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = UINT32_MAX - 1;
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_MAX_uint64_t(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN(name) = UINT64_MAX - 1;
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_MAX_char_ptr(name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT(char_ptr, name)
|
||||
|
@ -320,6 +333,7 @@
|
|||
// Cleanup defaults
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_CLEANUP_bool(type, name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT(type, name)
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_CLEANUP__Bool(type, name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT(type, name)
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_CLEANUP_uint8_t(type, name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT(type, name)
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_CLEANUP_uint32_t(type, name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT(type, name)
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_CLEANUP_uint64_t(type, name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT(type, name)
|
||||
#define TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_CLEANUP_char_ptr(type, name) TEST_SF_SERVICE_CONFIG_VALUE_TO_RETURN_INIT_DEFAULT(type, name)
|
||||
|
@ -351,6 +365,7 @@
|
|||
|
||||
#define TEST_SF_SERVICE_CONFIG_EXPECT_FREE_bool(name)
|
||||
#define TEST_SF_SERVICE_CONFIG_EXPECT_FREE__Bool(name)
|
||||
#define TEST_SF_SERVICE_CONFIG_EXPECT_FREE_uint8_t(name)
|
||||
#define TEST_SF_SERVICE_CONFIG_EXPECT_FREE_uint32_t(name)
|
||||
#define TEST_SF_SERVICE_CONFIG_EXPECT_FREE_uint64_t(name)
|
||||
#define TEST_SF_SERVICE_CONFIG_EXPECT_FREE_char_ptr(name) \
|
||||
|
@ -383,6 +398,7 @@
|
|||
MU_IF(TEST_SF_SERVICE_CONFIG_TYPE_IS_THANDLE(field_type), TEST_SF_SERVICE_CONFIG_EXPECT_FREE_IF_EMPTY_THANDLE_RC_STRING(field_name), )
|
||||
|
||||
|
||||
#define TEST_SF_SERVICE_CONFIG_CONFIGURATION_READER_GET_FUNCTION_uint8_t configuration_reader_get_uint8_t
|
||||
#define TEST_SF_SERVICE_CONFIG_CONFIGURATION_READER_GET_FUNCTION_uint32_t configuration_reader_get_uint32_t
|
||||
#define TEST_SF_SERVICE_CONFIG_CONFIGURATION_READER_GET_FUNCTION_uint64_t configuration_reader_get_uint64_t
|
||||
#define TEST_SF_SERVICE_CONFIG_CONFIGURATION_READER_GET_FUNCTION__Bool configuration_reader_get_bool
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_parameter_1 L"Parameter1"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_parameter_2 L"Parameter2"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_parameter_3 L"Parameter3WithLongerName"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_parameter_4 L"Parameter4uint8_t"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_some_flag L"SomeFlag"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_string_option_in_thandle L"StringOptionThandle"
|
||||
#define SF_SERVICE_CONFIG_PARAMETER_NAME_string_option L"MyString"
|
||||
|
@ -28,6 +29,7 @@
|
|||
CONFIG_REQUIRED(uint64_t, parameter_1), \
|
||||
CONFIG_REQUIRED(uint64_t, parameter_2), \
|
||||
CONFIG_REQUIRED(uint32_t, parameter_3), \
|
||||
CONFIG_REQUIRED(uint8_t, parameter_4), \
|
||||
CONFIG_REQUIRED(bool, some_flag), \
|
||||
CONFIG_REQUIRED(thandle_rc_string, string_option_in_thandle), \
|
||||
CONFIG_REQUIRED(char_ptr, string_option), \
|
||||
|
|
Загрузка…
Ссылка в новой задаче