Skip to content

Check unit tests with vera++ & fix reported issues #951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions tests/unit/test-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ static bool foreach (const jerry_api_string_t *name,
const jerry_api_value_t *value, void *user_data)
{
char str_buf_p[128];
jerry_api_size_t sz = jerry_api_string_to_char_buffer (name, (jerry_api_char_t *)str_buf_p, 128);
jerry_api_size_t sz = jerry_api_string_to_char_buffer (name, (jerry_api_char_t *) str_buf_p, 128);
str_buf_p[sz] = '\0';

if (!strncmp (str_buf_p, "alpha", (size_t)sz))
if (!strncmp (str_buf_p, "alpha", (size_t) sz))
{
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_FLOAT32);
Expand All @@ -252,16 +252,16 @@ static bool foreach (const jerry_api_string_t *name,
JERRY_ASSERT (value->u.v_float64 == 32.0);
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */
}
else if (!strncmp (str_buf_p, "bravo", (size_t)sz))
else if (!strncmp (str_buf_p, "bravo", (size_t) sz))
{
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_BOOLEAN);
JERRY_ASSERT (value->u.v_bool == false);
}
else if (!strncmp (str_buf_p, "charlie", (size_t)sz))
else if (!strncmp (str_buf_p, "charlie", (size_t) sz))
{
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_OBJECT);
}
else if (!strncmp (str_buf_p, "delta", (size_t)sz))
else if (!strncmp (str_buf_p, "delta", (size_t) sz))
{
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_FLOAT32);
Expand All @@ -271,19 +271,19 @@ static bool foreach (const jerry_api_string_t *name,
JERRY_ASSERT (value->u.v_float64 == 123.45);
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */
}
else if (!strncmp (str_buf_p, "echo", (size_t)sz))
else if (!strncmp (str_buf_p, "echo", (size_t) sz))
{
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_STRING);
jerry_api_size_t echo_sz = jerry_api_string_to_char_buffer (value->u.v_string, (jerry_api_char_t *)str_buf_p, 128);
jerry_api_size_t echo_sz = jerry_api_string_to_char_buffer (value->u.v_string, (jerry_api_char_t *) str_buf_p, 128);
str_buf_p[echo_sz] = '\0';
JERRY_ASSERT (!strncmp (str_buf_p, "foobar", (size_t)echo_sz));
JERRY_ASSERT (!strncmp (str_buf_p, "foobar", (size_t) echo_sz));
}
else
{
JERRY_ASSERT (false);
}

JERRY_ASSERT (!strncmp ((const char*)user_data, "user_data", 9));
JERRY_ASSERT (!strncmp ((const char *) user_data, "user_data", 9));
return true;
} /* foreach */

Expand Down Expand Up @@ -440,7 +440,7 @@ main (void)

// foreach properties
jerry_api_get_object_field_value (global_obj_p, (jerry_api_char_t *) "p", &val_p);
is_ok = jerry_api_foreach_object_field (val_p.u.v_object, foreach, (void*)"user_data");
is_ok = jerry_api_foreach_object_field (val_p.u.v_object, foreach, (void *) "user_data");
JERRY_ASSERT (is_ok);

// break foreach at third element
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test-heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ main (int __attr_unused___ argc,
for (uint32_t j = 0; j < test_sub_iters; j++)
{
size_t size = (size_t) rand () % test_threshold_block_size;
ptrs[j] = (uint8_t*) mem_heap_alloc_block_store_size (size);
ptrs[j] = (uint8_t *) mem_heap_alloc_block_store_size (size);
sizes[j] = size;

JERRY_ASSERT (sizes[j] == 0 || ptrs[j] != NULL);
Expand Down
9 changes: 5 additions & 4 deletions tools/check-vera.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

JERRY_CORE_FILES=`find ./jerry-core -name "*.c" -or -name "*.cpp" -or -name "*.h"`
JERRY_LIBC_FILES=`find ./jerry-libc -name "*.c" -or -name "*.cpp" -or -name "*.h"`
JERRY_MAIN_FILES=`find . -maxdepth 1 -name "*.c" -or -name "*.cpp" -or -name "*.h"`
JERRY_CORE_FILES=`find ./jerry-core -name "*.c" -or -name "*.h"`
JERRY_LIBC_FILES=`find ./jerry-libc -name "*.c" -or -name "*.h"`
JERRY_MAIN_FILES=`find . -maxdepth 1 -name "*.c" -or -name "*.h"`
UNIT_TEST_FILES=`find ./tests/unit -name "*.c" -or -name "*.h"`

vera++ -r tools/vera++ -p jerry \
-e --no-duplicate \
$JERRY_CORE_FILES $JERRY_LIBC_FILES $JERRY_MAIN_FILES
$JERRY_CORE_FILES $JERRY_LIBC_FILES $JERRY_MAIN_FILES $UNIT_TEST_FILES