Skip to content

Commit

Permalink
add unit tests for energy saver
Browse files Browse the repository at this point in the history
  • Loading branch information
jamali005 committed Sep 14, 2022
1 parent 9d0e425 commit ecdca63
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 260 deletions.
33 changes: 33 additions & 0 deletions test/unit_test_sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,36 @@ void test_os_auth_failure_response( void )

TEST_ASSERT_EQUAL_INT( os_auth( &osNetwork, &nceKey ), NCE_SDK_PARSING_ERROR );
}


/**
* @brief Test 4 ( successful binary conversion ).
*/
void test_os_energy_save_success( void )
{
Element2byte_gen_t battery_level = { .type = E_INTEGER, .value.i = 99, .template_length = 1 };
Element2byte_gen_t signal_strength = { .type = E_INTEGER, .value.i = 84, .template_length = 1 };
Element2byte_gen_t software_version = { .type = E_STRING, .value.s = "2.2.1", .template_length = 5 };
uint8_t selector = 1;
char pcTransmittedString[ 50 ];

memset( pcTransmittedString, '\0', 50 );
int expected_location = 8;

TEST_ASSERT_EQUAL_INT( os_energy_save( pcTransmittedString, selector, 3, battery_level, signal_strength, software_version ), expected_location );
}

/**
* @brief Test 5 ( invalid binary conversion - the provided string size is not equal to the template length - ).
*/
void test_os_energy_save_failure( void )
{
Element2byte_gen_t software_version = { .type = E_STRING, .value.s = "1.1", .template_length = 5 };

uint8_t selector = 1;
char pcTransmittedString[ 50 ];

memset( pcTransmittedString, '\0', 50 );

TEST_ASSERT_EQUAL_INT( os_energy_save( pcTransmittedString, selector, 2, software_version ), NCE_SDK_BINARY_PAYLOAD_ERROR );
}
69 changes: 0 additions & 69 deletions tools/cmock/coverage.cmake

This file was deleted.

166 changes: 0 additions & 166 deletions tools/cmock/create_test.cmake

This file was deleted.

25 changes: 0 additions & 25 deletions tools/cmock/project.yml

This file was deleted.

0 comments on commit ecdca63

Please sign in to comment.