Skip to content

Commit a19f63f

Browse files
committed
Check unit tests with vera++ & fix reported issues
Cppcheck has already been used for checking unit test sources statically but vera++ style-checking of unit tests was left out, most probably only by mistake. This patch adds unit tests to the set of style-checked sources and also fixes the stlye issues that were present in the test code. (Extra: since the project is pure C now, not trying to collect *.cpp files anymore.) JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent 21e2951 commit a19f63f

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

tests/unit/test-api.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ static bool foreach (const jerry_api_string_t *name,
239239
const jerry_api_value_t *value, void *user_data)
240240
{
241241
char str_buf_p[128];
242-
jerry_api_size_t sz = jerry_api_string_to_char_buffer (name, (jerry_api_char_t *)str_buf_p, 128);
242+
jerry_api_size_t sz = jerry_api_string_to_char_buffer (name, (jerry_api_char_t *) str_buf_p, 128);
243243
str_buf_p[sz] = '\0';
244244

245-
if (!strncmp (str_buf_p, "alpha", (size_t)sz))
245+
if (!strncmp (str_buf_p, "alpha", (size_t) sz))
246246
{
247247
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
248248
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_FLOAT32);
@@ -252,16 +252,16 @@ static bool foreach (const jerry_api_string_t *name,
252252
JERRY_ASSERT (value->u.v_float64 == 32.0);
253253
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */
254254
}
255-
else if (!strncmp (str_buf_p, "bravo", (size_t)sz))
255+
else if (!strncmp (str_buf_p, "bravo", (size_t) sz))
256256
{
257257
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_BOOLEAN);
258258
JERRY_ASSERT (value->u.v_bool == false);
259259
}
260-
else if (!strncmp (str_buf_p, "charlie", (size_t)sz))
260+
else if (!strncmp (str_buf_p, "charlie", (size_t) sz))
261261
{
262262
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_OBJECT);
263263
}
264-
else if (!strncmp (str_buf_p, "delta", (size_t)sz))
264+
else if (!strncmp (str_buf_p, "delta", (size_t) sz))
265265
{
266266
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
267267
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_FLOAT32);
@@ -271,19 +271,19 @@ static bool foreach (const jerry_api_string_t *name,
271271
JERRY_ASSERT (value->u.v_float64 == 123.45);
272272
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */
273273
}
274-
else if (!strncmp (str_buf_p, "echo", (size_t)sz))
274+
else if (!strncmp (str_buf_p, "echo", (size_t) sz))
275275
{
276276
JERRY_ASSERT (value->type == JERRY_API_DATA_TYPE_STRING);
277-
jerry_api_size_t echo_sz = jerry_api_string_to_char_buffer (value->u.v_string, (jerry_api_char_t *)str_buf_p, 128);
277+
jerry_api_size_t echo_sz = jerry_api_string_to_char_buffer (value->u.v_string, (jerry_api_char_t *) str_buf_p, 128);
278278
str_buf_p[echo_sz] = '\0';
279-
JERRY_ASSERT (!strncmp (str_buf_p, "foobar", (size_t)echo_sz));
279+
JERRY_ASSERT (!strncmp (str_buf_p, "foobar", (size_t) echo_sz));
280280
}
281281
else
282282
{
283283
JERRY_ASSERT (false);
284284
}
285285

286-
JERRY_ASSERT (!strncmp ((const char*)user_data, "user_data", 9));
286+
JERRY_ASSERT (!strncmp ((const char *) user_data, "user_data", 9));
287287
return true;
288288
} /* foreach */
289289

@@ -440,7 +440,7 @@ main (void)
440440

441441
// foreach properties
442442
jerry_api_get_object_field_value (global_obj_p, (jerry_api_char_t *) "p", &val_p);
443-
is_ok = jerry_api_foreach_object_field (val_p.u.v_object, foreach, (void*)"user_data");
443+
is_ok = jerry_api_foreach_object_field (val_p.u.v_object, foreach, (void *) "user_data");
444444
JERRY_ASSERT (is_ok);
445445

446446
// break foreach at third element

tests/unit/test-heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ main (int __attr_unused___ argc,
8585
for (uint32_t j = 0; j < test_sub_iters; j++)
8686
{
8787
size_t size = (size_t) rand () % test_threshold_block_size;
88-
ptrs[j] = (uint8_t*) mem_heap_alloc_block_store_size (size);
88+
ptrs[j] = (uint8_t *) mem_heap_alloc_block_store_size (size);
8989
sizes[j] = size;
9090

9191
JERRY_ASSERT (sizes[j] == 0 || ptrs[j] != NULL);

tools/check-vera.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

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

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

0 commit comments

Comments
 (0)