diff --git a/.gitignore b/.gitignore index 65b934e..e1a4ae2 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ Module.symvers Mkfile.old dkms.conf +.variant diff --git a/include/ut_kvp_profile.h b/include/ut_kvp_profile.h index b880a70..2dfe979 100644 --- a/include/ut_kvp_profile.h +++ b/include/ut_kvp_profile.h @@ -62,6 +62,10 @@ extern "C" #define UT_KVP_PROFILE_GET_UINT16(key) ut_kvp_getUInt16Field(ut_kvp_profile_getInstance(), key) #define UT_KVP_PROFILE_GET_UINT32(key) ut_kvp_getUInt32Field(ut_kvp_profile_getInstance(), key) #define UT_KVP_PROFILE_GET_UINT64(key) ut_kvp_getUInt64Field(ut_kvp_profile_getInstance(), key) +#define UT_KVP_PROFILE_GET_INT8(key) ut_kvp_getInt8Field(ut_kvp_profile_getInstance(), key) +#define UT_KVP_PROFILE_GET_INT16(key) ut_kvp_getInt16Field(ut_kvp_profile_getInstance(), key) +#define UT_KVP_PROFILE_GET_INT32(key) ut_kvp_getInt32Field(ut_kvp_profile_getInstance(), key) +#define UT_KVP_PROFILE_GET_INT64(key) ut_kvp_getInt64Field(ut_kvp_profile_getInstance(), key) #define UT_KVP_PROFILE_GET_LIST_COUNT(key) ut_kvp_getListCount(ut_kvp_profile_getInstance(), key) #define UT_KVP_PROFILE_GET_STRING(key, pszReturnedString ) \ { \ @@ -85,6 +89,18 @@ extern "C" /**! Asserts that a UINT64 KVP field matches the expected value. */ #define UT_ASSERT_KVP_EQUAL_PROFILE_UINT64(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_UINT64(key), checkValue); +/**! Asserts that an INT8 KVP field matches the expected value. */ +#define UT_ASSERT_KVP_EQUAL_PROFILE_INT8(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT8(key), checkValue); + +/**! Asserts that an INT16 KVP field matches the expected value. */ +#define UT_ASSERT_KVP_EQUAL_PROFILE_INT16(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT16(key), checkValue); + +/**! Asserts that an INT32 KVP field matches the expected value. */ +#define UT_ASSERT_KVP_EQUAL_PROFILE_INT32(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT32(key), checkValue); + +/**! Asserts that an INT64 KVP field matches the expected value. */ +#define UT_ASSERT_KVP_EQUAL_PROFILE_INT64(checkValue, key) UT_ASSERT(UT_KVP_PROFILE_GET_INT64(key) == (checkValue)); + /**! Asserts that a KVP list field matches the expected value. */ #define UT_ASSERT_KVP_EQUAL_PROFILE_LIST_COUNT(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_LIST_COUNT(key), checkValue); diff --git a/tests/src/assets/test_kvp.json b/tests/src/assets/test_kvp.json index 543eb20..174812f 100644 --- a/tests/src/assets/test_kvp.json +++ b/tests/src/assets/test_kvp.json @@ -26,6 +26,14 @@ 720, 800, 1080 - ] + ], + "checkInt8Positive": 120, + "checkInt8Negative": -120, + "checkInt16Positive": 30000, + "checkInt16Negative": -30000, + "checkInt32Positive": 2000000000, + "checkInt32Negative": -2000000000, + "checkInt64Positive": 9000000000000000000, + "checkInt64Negative": -9000000000000000000 } } diff --git a/tests/src/assets/test_kvp.yaml b/tests/src/assets/test_kvp.yaml index 6b098e2..d78fac8 100644 --- a/tests/src/assets/test_kvp.yaml +++ b/tests/src/assets/test_kvp.yaml @@ -24,4 +24,12 @@ decodeTest: checkUint32List: - 720 - 800 - - 1080 \ No newline at end of file + - 1080 + checkInt8Positive: 120 + checkInt8Negative: -120 + checkInt16Positive: 30000 + checkInt16Negative: -30000 + checkInt32Positive: 2000000000 + checkInt32Negative: -2000000000 + checkInt64Positive: 9000000000000000000 + checkInt64Negative: -9000000000000000000 diff --git a/tests/src/c_source/ut_test_kvp_profile.c b/tests/src/c_source/ut_test_kvp_profile.c index 8da9ecb..262e984 100644 --- a/tests/src/c_source/ut_test_kvp_profile.c +++ b/tests/src/c_source/ut_test_kvp_profile.c @@ -165,6 +165,74 @@ void test_ut_kvp_profile_list_count(void) UT_LOG_STEP( "test_ut_kvp_profile_list_count - end" ); } +void test_ut_kvp_profile_int8(void) +{ + int8_t checkFieldPositive = 120; + int8_t checkFieldNegative = -120; + int8_t result; + UT_LOG_STEP("test_ut_kvp_profile_int8 - start"); + UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldPositive, "decodeTest/checkInt8Positive" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldPositive, "decodeTest.checkInt8Positive" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldNegative, "decodeTest/checkInt8Negative" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldNegative, "decodeTest.checkInt8Negative" ); + + result = UT_KVP_PROFILE_GET_INT8("decodeTest.checkInt8Positive"); + UT_ASSERT_EQUAL(result, checkFieldPositive); + + UT_LOG_STEP( "test_ut_kvp_profile_int8 - end" ); +} + +void test_ut_kvp_profile_int16(void) +{ + int16_t checkFieldPositive = 30000; + int16_t checkFieldNegative = -30000; + int16_t result; + UT_LOG_STEP("test_ut_kvp_profile_int16 - start"); + UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldPositive, "decodeTest/checkInt16Positive" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldPositive, "decodeTest.checkInt16Positive" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldNegative, "decodeTest/checkInt16Negative" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldNegative, "decodeTest.checkInt16Negative" ); + + result = UT_KVP_PROFILE_GET_INT16("decodeTest.checkInt16Positive"); + UT_ASSERT_EQUAL(result, checkFieldPositive); + + UT_LOG_STEP( "test_ut_kvp_profile_int16 - end" ); +} + +void test_ut_kvp_profile_int32(void) +{ + int32_t checkFieldPositive = 2000000000; + int32_t checkFieldNegative = -2000000000; + int32_t result; + UT_LOG_STEP("test_ut_kvp_profile_int32 - start"); + UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldPositive, "decodeTest/checkInt32Positive" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldPositive, "decodeTest.checkInt32Positive" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldNegative, "decodeTest/checkInt32Negative" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldNegative, "decodeTest.checkInt32Negative" ); + + result = UT_KVP_PROFILE_GET_INT32("decodeTest.checkInt32Positive"); + UT_ASSERT_EQUAL(result, checkFieldPositive); + + UT_LOG_STEP("test_ut_kvp_profile_int32 - end"); +} + +void test_ut_kvp_profile_int64(void) +{ + int64_t checkFieldPositive = 9000000000000000000LL; + int64_t checkFieldNegative = -9000000000000000000LL; + int64_t result; + UT_LOG_STEP("test_ut_kvp_profile_int64 - start"); + UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldPositive, "decodeTest/checkInt64Positive" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldPositive, "decodeTest.checkInt64Positive" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldNegative, "decodeTest/checkInt64Negative" ); + UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldNegative, "decodeTest.checkInt64Negative" ); + + result = UT_KVP_PROFILE_GET_INT64("decodeTest.checkInt64Positive"); + UT_ASSERT(result == checkFieldPositive); + + UT_LOG_STEP("test_ut_kvp_profile_int64 - end"); +} + void test_ut_kvp_profile_open( void ) { UT_LOG_STEP( "test_ut_kvp_profile_open - start" ); @@ -251,6 +319,10 @@ void register_kvp_profile_testing_functions(void) UT_add_test(gpAssertSuite2, "kvp profile uint16", test_ut_kvp_profile_uint16); UT_add_test(gpAssertSuite2, "kvp profile uint32", test_ut_kvp_profile_uint32); UT_add_test(gpAssertSuite2, "kvp profile uint64", test_ut_kvp_profile_uint64); + UT_add_test(gpAssertSuite2, "kvp profile int8", test_ut_kvp_profile_int8); + UT_add_test(gpAssertSuite2, "kvp profile int16", test_ut_kvp_profile_int16); + UT_add_test(gpAssertSuite2, "kvp profile int32", test_ut_kvp_profile_int32); + UT_add_test(gpAssertSuite2, "kvp profile int64", test_ut_kvp_profile_int64); UT_add_test(gpAssertSuite2, "kvp profile string", test_ut_kvp_profile_string); UT_add_test(gpAssertSuite2, "kvp profile bool", test_ut_kvp_profile_bool); UT_add_test(gpAssertSuite2, "kvp profile list count", test_ut_kvp_profile_list_count); @@ -264,6 +336,10 @@ void register_kvp_profile_testing_functions(void) UT_add_test(gpAssertSuite3, "kvp profile uint16", test_ut_kvp_profile_uint16); UT_add_test(gpAssertSuite3, "kvp profile uint32", test_ut_kvp_profile_uint32); UT_add_test(gpAssertSuite3, "kvp profile uint64", test_ut_kvp_profile_uint64); + UT_add_test(gpAssertSuite3, "kvp profile int8", test_ut_kvp_profile_int8); + UT_add_test(gpAssertSuite3, "kvp profile int16", test_ut_kvp_profile_int16); + UT_add_test(gpAssertSuite3, "kvp profile int32", test_ut_kvp_profile_int32); + UT_add_test(gpAssertSuite3, "kvp profile int64", test_ut_kvp_profile_int64); UT_add_test(gpAssertSuite3, "kvp profile string", test_ut_kvp_profile_string); UT_add_test(gpAssertSuite3, "kvp profile bool", test_ut_kvp_profile_bool); UT_add_test(gpAssertSuite3, "kvp profile list count", test_ut_kvp_profile_list_count); diff --git a/tests/src_weak/ut_test_weak_kvp.c b/tests/src_weak/ut_test_weak_kvp.c index 591709a..01c6568 100644 --- a/tests/src_weak/ut_test_weak_kvp.c +++ b/tests/src_weak/ut_test_weak_kvp.c @@ -174,6 +174,74 @@ uint64_t __attribute__((weak)) ut_kvp_getUInt64Field(ut_kvp_instance_t *pInstanc return 0; } +/** + * @brief Weak implementation of ut_kvp_getInt8Field. + * + * Always returns 0. + * + * @param[in] pInstance - Handle to the KVP instance. + * @param[in] pszKey - Key to search for. + * @returns 0. + */ +int8_t __attribute__((weak)) ut_kvp_getInt8Field(ut_kvp_instance_t *pInstance, const char *pszKey) +{ + (void)pInstance; + (void)pszKey; + printf("Weak implementation of [%s]", __func__); + return 0; +} + +/** + * @brief Weak implementation of ut_kvp_getInt16Field. + * + * Always returns 0. + * + * @param[in] pInstance - Handle to the KVP instance. + * @param[in] pszKey - Key to search for. + * @returns 0. + */ +int16_t __attribute__((weak)) ut_kvp_getInt16Field(ut_kvp_instance_t *pInstance, const char *pszKey) +{ + (void)pInstance; + (void)pszKey; + printf("Weak implementation of [%s]", __func__); + return 0; +} + +/** + * @brief Weak implementation of ut_kvp_getInt32Field. + * + * Always returns 0. + * + * @param[in] pInstance - Handle to the KVP instance. + * @param[in] pszKey - Key to search for. + * @returns 0. + */ +int32_t __attribute__((weak)) ut_kvp_getInt32Field(ut_kvp_instance_t *pInstance, const char *pszKey) +{ + (void)pInstance; + (void)pszKey; + printf("Weak implementation of [%s]", __func__); + return 0; +} + +/** + * @brief Weak implementation of ut_kvp_getInt64Field. + * + * Always returns 0. + * + * @param[in] pInstance - Handle to the KVP instance. + * @param[in] pszKey - Key to search for. + * @returns 0. + */ +int64_t __attribute__((weak)) ut_kvp_getInt64Field(ut_kvp_instance_t *pInstance, const char *pszKey) +{ + (void)pInstance; + (void)pszKey; + printf("Weak implementation of [%s]", __func__); + return 0; +} + /** * @brief Weak implementation of ut_kvp_getStringField. *