mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #2793 from kushalsingh007/hash_string
Tests: Creating unittests for the hash_string module
This commit is contained in:
commit
1af6126000
40
tests/unittests/tests-hash_string/tests-hash_string.c
Normal file
40
tests/unittests/tests-hash_string/tests-hash_string.c
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kushal Singh <kushal.spiderman.singh@gmail.com>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
#include "tests-hash_string.h"
|
||||
#include "hash_string.h"
|
||||
|
||||
static void test_hash_value(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_INT(177621, hash_string("0"));
|
||||
TEST_ASSERT_EQUAL_INT(6555485335635392041, hash_string("0123456789abcde-"
|
||||
"0123456789abcde-0123"
|
||||
"456789abcde-01234567"
|
||||
"89abcde-"));
|
||||
TEST_ASSERT_EQUAL_INT(210674770391, hash_string("Frank jagt im komplett"
|
||||
" verwahrlosten Taxi q"
|
||||
"uer durch Bayern"));
|
||||
TEST_ASSERT_EQUAL_INT(249811328611268156, hash_string("12A5B6cd_"));
|
||||
TEST_ASSERT_EQUAL_INT(5381, hash_string(""));
|
||||
}
|
||||
|
||||
Test *tests_hash_string_tests(void)
|
||||
{
|
||||
EMB_UNIT_TESTFIXTURES(fixtures) {
|
||||
new_TestFixture(test_hash_value),
|
||||
};
|
||||
|
||||
EMB_UNIT_TESTCALLER(hash_string_tests, NULL, NULL, fixtures);
|
||||
|
||||
return (Test *)&hash_string_tests;
|
||||
}
|
||||
|
||||
void tests_hash_string(void)
|
||||
{
|
||||
TESTS_RUN(tests_hash_string_tests());
|
||||
}
|
44
tests/unittests/tests-hash_string/tests-hash_string.h
Normal file
44
tests/unittests/tests-hash_string/tests-hash_string.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kushal Singh <kushal.spiderman.singh@gmail.com>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup unittests
|
||||
* @{
|
||||
*
|
||||
* @file tests-hash_string.h
|
||||
* @brief Unittests for the ``hash_string`` module
|
||||
*
|
||||
* @author Kushal Singh <kushal.spiderman.singh@gmail.com>
|
||||
*/
|
||||
#ifndef TESTS_HASH_STRING_H_
|
||||
#define TESTS_HASH_STRING_H_
|
||||
|
||||
#include "embUnit.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The entry point of this test suite.
|
||||
*/
|
||||
void tests_hash_string(void);
|
||||
|
||||
/**
|
||||
* @brief Generates tests for hash_string
|
||||
*
|
||||
* @return embUnit tests if successful, NULL if not.
|
||||
*/
|
||||
Test *tests_hash_string_tests(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TESTS_HASH_STRING_H_ */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user