Skip to content

Commit

Permalink
Make CELLULAR_AT_MAX_STRING_SIZE configurable (#140)
Browse files Browse the repository at this point in the history
* Make CELLULAR_AT_MAX_STRING_SIZE configurable

* Add large string test in Cellular_ATStrStartWith
  • Loading branch information
ActoryOu authored Jul 4, 2023
1 parent 4bc022e commit bfe3f48
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
12 changes: 12 additions & 0 deletions source/include/cellular_config_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,18 @@
( !( CELLULAR_CHECK_IS_PREFIX_LEADING_CHAR( inputChar ) ) ) )
#endif

/**
* @brief Cellular AT string length.<br>
*
* The maximum length of an AT string.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 256
*/
#ifndef CELLULAR_AT_MAX_STRING_SIZE
#define CELLULAR_AT_MAX_STRING_SIZE ( 256U )
#endif

/**
* @brief Macro that is called in the cellular library for logging "Error" level
* messages.
Expand Down
17 changes: 7 additions & 10 deletions source/include/common/cellular_at_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,14 @@
/* Standard includes. */
#include <stdint.h>

/*-----------------------------------------------------------*/

/**
* @brief Maximum size of an AT string.
*/
#define CELLULAR_AT_MAX_STRING_SIZE ( 256U )
/* Cellular includes. */
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
/* Include custom config file before other headers. */
#include "cellular_config.h"
#endif
#include "cellular_config_defaults.h"

/**
* @brief Maximum size of an AT prefix.
*/
#define CELLULAR_AT_MAX_PREFIX_SIZE ( 32 )
/*-----------------------------------------------------------*/

/**
* @brief The array size of an array.
Expand Down
14 changes: 14 additions & 0 deletions test/unit-test/cellular_at_core_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,20 @@ void test_Cellular_ATStrStartWith_Empty_Prefix( void )
TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus );
}

/**
* @brief Test the long string case for Cellular_ATStrStartWith to return CELLULAR_AT_BAD_PARAMETER.
*/
void test_Cellular_ATStrStartWith_ATStringTooLong( void )
{
CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS;
bool result;
char * pPrefix = "";
char pStringSuccess[] = CELLULAR_SAMPLE_PREFIX_STRING_LARGE_INPUT;

cellularStatus = Cellular_ATStrStartWith( pStringSuccess, pPrefix, &result );
TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus );
}

/**
* @brief Test that any NULL parameter causes Cellular_ATStrtoi to return CELLULAR_AT_BAD_PARAMETER.
*/
Expand Down

0 comments on commit bfe3f48

Please sign in to comment.