- all RAN code, CI code, configuration files, dockerfiles, in CSSL v1.0
- all deployment code (openshift, charts, ancillary files like shell
scripts), in MIT
- documentation in CC-BY-4.0
- exceptions might apply and are listed in NOTICE
- there is a new LICENSES folder with all licenses
- CONTRIBUTIONS.md has been updated accordingly
For automated changes based on OAI PL v1.1:
perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.{c,h,cpp}
perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.ts
perl -i~ -0pe 's/<!--.*Licensed to the OpenAirInterface.*openairinterface.org\n.*-->/<!-- SPDX-License-Identifier: LicenseRef-CSSL-1.0 -->/s' **/*.xml
The rest (cmake, files with missing license, cmake) manually.
90 lines
2.7 KiB
C++
90 lines
2.7 KiB
C++
/*
|
|
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
|
*/
|
|
|
|
#include <gtest/gtest.h>
|
|
extern "C" {
|
|
#include "hashtable.h"
|
|
}
|
|
|
|
TEST(hashtable, test_insert_remove) {
|
|
hash_table_t* table = hashtable_create(250, NULL, NULL);
|
|
int* a = (int*)calloc(1, sizeof(*a));
|
|
EXPECT_EQ(hashtable_insert(table, 1, a), HASH_TABLE_OK);
|
|
EXPECT_EQ(hashtable_remove(table, 1), HASH_TABLE_OK);
|
|
EXPECT_EQ(hashtable_destroy(&table), HASH_TABLE_OK);
|
|
}
|
|
|
|
TEST(hashtable, test_insert_iterate_remove) {
|
|
hash_table_t* table = hashtable_create(250, NULL, NULL);
|
|
int* a = (int*)calloc(1, sizeof(*a));
|
|
EXPECT_EQ(hashtable_insert(table, 1, a), HASH_TABLE_OK);
|
|
auto iterator = hashtable_get_iterator(table);
|
|
void* ptr;
|
|
int num_items = 0;
|
|
while(hashtable_iterator_getnext(&iterator, &ptr)) {
|
|
num_items++;
|
|
}
|
|
EXPECT_EQ(num_items, 1);
|
|
EXPECT_EQ(hashtable_remove(table, 1), HASH_TABLE_OK);
|
|
num_items = 0;
|
|
|
|
auto iterator2 = hashtable_get_iterator(table);
|
|
while(hashtable_iterator_getnext(&iterator2, &ptr)) {
|
|
num_items++;
|
|
}
|
|
EXPECT_EQ(num_items, 0);
|
|
EXPECT_EQ(hashtable_destroy(&table), HASH_TABLE_OK);
|
|
}
|
|
|
|
TEST(hashtable, test_insert_three_iterate_remove) {
|
|
hash_table_t* table = hashtable_create(250, NULL, NULL);
|
|
int* a1 = (int*)calloc(1, sizeof(*a1));
|
|
int* a2 = (int*)calloc(1, sizeof(*a2));
|
|
int* a3 = (int*)calloc(1, sizeof(*a3));
|
|
EXPECT_EQ(hashtable_insert(table, 1, a1), HASH_TABLE_OK);
|
|
EXPECT_EQ(hashtable_insert(table, 2, a2), HASH_TABLE_OK);
|
|
EXPECT_EQ(hashtable_insert(table, 3, a3), HASH_TABLE_OK);
|
|
auto iterator = hashtable_get_iterator(table);
|
|
void* ptr;
|
|
int num_items = 0;
|
|
while(hashtable_iterator_getnext(&iterator, &ptr)) {
|
|
num_items++;
|
|
}
|
|
EXPECT_EQ(num_items, 3);
|
|
EXPECT_EQ(hashtable_remove(table, 1), HASH_TABLE_OK);
|
|
num_items = 0;
|
|
|
|
auto iterator2 = hashtable_get_iterator(table);
|
|
while(hashtable_iterator_getnext(&iterator2, &ptr)) {
|
|
num_items++;
|
|
}
|
|
EXPECT_EQ(num_items, 2);
|
|
EXPECT_EQ(hashtable_destroy(&table), HASH_TABLE_OK);
|
|
}
|
|
|
|
TEST(hashtable, test_insert_empty_insert_interate) {
|
|
hash_table_t* table = hashtable_create(250, NULL, NULL);
|
|
int* a = (int*)calloc(1, sizeof(*a));
|
|
EXPECT_EQ(hashtable_insert(table, 1, a), HASH_TABLE_OK);
|
|
EXPECT_EQ(hashtable_remove(table, 1), HASH_TABLE_OK);
|
|
|
|
int* a2 = (int*)calloc(1, sizeof(*a2));
|
|
EXPECT_EQ(hashtable_insert(table, 1, a2), HASH_TABLE_OK);
|
|
auto iterator3 = hashtable_get_iterator(table);
|
|
int num_items = 0;
|
|
void* ptr;
|
|
while(hashtable_iterator_getnext(&iterator3, &ptr)) {
|
|
num_items++;
|
|
}
|
|
EXPECT_EQ(num_items, 1);
|
|
|
|
EXPECT_EQ(hashtable_destroy(&table), HASH_TABLE_OK);
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|