mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
test(old): move memfile_test.c to test/old/ (#22567)
This commit is contained in:
@@ -598,6 +598,7 @@ _set_missing_vimpatches() {
|
|||||||
declare -a git_log_args
|
declare -a git_log_args
|
||||||
|
|
||||||
local extended_format=$1; shift
|
local extended_format=$1; shift
|
||||||
|
if [[ "$extended_format" == 1 ]]; then
|
||||||
git_log_args=("--format=%H %s")
|
git_log_args=("--format=%H %s")
|
||||||
else
|
else
|
||||||
git_log_args=("--format=%H")
|
git_log_args=("--format=%H")
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
// This is an open source non-commercial project. Dear PVS-Studio, please check
|
// This is an open source non-commercial project. Dear PVS-Studio, please check
|
||||||
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
|
|
||||||
// uncrustify:off
|
|
||||||
|
|
||||||
/* vi:set ts=8 sts=4 sw=4 noet:
|
/* vi:set ts=8 sts=4 sw=4 noet:
|
||||||
*
|
*
|
||||||
* VIM - Vi IMproved by Bram Moolenaar
|
* VIM - Vi IMproved by Bram Moolenaar
|
||||||
@@ -20,11 +18,11 @@
|
|||||||
#undef NDEBUG
|
#undef NDEBUG
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/* Must include main.c because it contains much more than just main() */
|
// Must include main.c because it contains much more than just main()
|
||||||
#define NO_VIM_MAIN
|
#define NO_VIM_MAIN
|
||||||
#include "main.c"
|
#include "main.c"
|
||||||
|
|
||||||
/* This file has to be included because the tested functions are static */
|
// This file has to be included because the tested functions are static
|
||||||
#include "memfile.c"
|
#include "memfile.c"
|
||||||
|
|
||||||
#define index_to_key(i) ((i) ^ 15167)
|
#define index_to_key(i) ((i) ^ 15167)
|
||||||
@@ -39,26 +37,26 @@ test_mf_hash(void)
|
|||||||
mf_hashtab_T ht;
|
mf_hashtab_T ht;
|
||||||
mf_hashitem_T *item;
|
mf_hashitem_T *item;
|
||||||
blocknr_T key;
|
blocknr_T key;
|
||||||
size_t i;
|
long_u i;
|
||||||
size_t num_buckets;
|
long_u num_buckets;
|
||||||
|
|
||||||
mf_hash_init(&ht);
|
mf_hash_init(&ht);
|
||||||
|
|
||||||
/* insert some items and check invariants */
|
// insert some items and check invariants
|
||||||
for (i = 0; i < TEST_COUNT; i++)
|
for (i = 0; i < TEST_COUNT; i++)
|
||||||
{
|
{
|
||||||
assert(ht.mht_count == i);
|
assert(ht.mht_count == i);
|
||||||
|
|
||||||
/* check that number of buckets is a power of 2 */
|
// check that number of buckets is a power of 2
|
||||||
num_buckets = ht.mht_mask + 1;
|
num_buckets = ht.mht_mask + 1;
|
||||||
assert(num_buckets > 0 && (num_buckets & (num_buckets - 1)) == 0);
|
assert(num_buckets > 0 && (num_buckets & (num_buckets - 1)) == 0);
|
||||||
|
|
||||||
/* check load factor */
|
// check load factor
|
||||||
assert(ht.mht_count <= (num_buckets << MHT_LOG_LOAD_FACTOR));
|
assert(ht.mht_count <= (num_buckets << MHT_LOG_LOAD_FACTOR));
|
||||||
|
|
||||||
if (i < (MHT_INIT_SIZE << MHT_LOG_LOAD_FACTOR))
|
if (i < (MHT_INIT_SIZE << MHT_LOG_LOAD_FACTOR))
|
||||||
{
|
{
|
||||||
/* first expansion shouldn't have occurred yet */
|
// first expansion shouldn't have occurred yet
|
||||||
assert(num_buckets == MHT_INIT_SIZE);
|
assert(num_buckets == MHT_INIT_SIZE);
|
||||||
assert(ht.mht_buckets == ht.mht_small_buckets);
|
assert(ht.mht_buckets == ht.mht_small_buckets);
|
||||||
}
|
}
|
||||||
@@ -71,8 +69,8 @@ test_mf_hash(void)
|
|||||||
key = index_to_key(i);
|
key = index_to_key(i);
|
||||||
assert(mf_hash_find(&ht, key) == NULL);
|
assert(mf_hash_find(&ht, key) == NULL);
|
||||||
|
|
||||||
/* allocate and add new item */
|
// allocate and add new item
|
||||||
item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);
|
item = LALLOC_CLEAR_ONE(mf_hashitem_T);
|
||||||
assert(item != NULL);
|
assert(item != NULL);
|
||||||
item->mhi_key = key;
|
item->mhi_key = key;
|
||||||
mf_hash_add_item(&ht, item);
|
mf_hash_add_item(&ht, item);
|
||||||
@@ -81,13 +79,13 @@ test_mf_hash(void)
|
|||||||
|
|
||||||
if (ht.mht_mask + 1 != num_buckets)
|
if (ht.mht_mask + 1 != num_buckets)
|
||||||
{
|
{
|
||||||
/* hash table was expanded */
|
// hash table was expanded
|
||||||
assert(ht.mht_mask + 1 == num_buckets * MHT_GROWTH_FACTOR);
|
assert(ht.mht_mask + 1 == num_buckets * MHT_GROWTH_FACTOR);
|
||||||
assert(i + 1 == (num_buckets << MHT_LOG_LOAD_FACTOR));
|
assert(i + 1 == (num_buckets << MHT_LOG_LOAD_FACTOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check presence of inserted items */
|
// check presence of inserted items
|
||||||
for (i = 0; i < TEST_COUNT; i++)
|
for (i = 0; i < TEST_COUNT; i++)
|
||||||
{
|
{
|
||||||
key = index_to_key(i);
|
key = index_to_key(i);
|
||||||
@@ -96,7 +94,7 @@ test_mf_hash(void)
|
|||||||
assert(item->mhi_key == key);
|
assert(item->mhi_key == key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delete some items */
|
// delete some items
|
||||||
for (i = 0; i < TEST_COUNT; i++)
|
for (i = 0; i < TEST_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (i % 100 < 70)
|
if (i % 100 < 70)
|
||||||
@@ -119,7 +117,7 @@ test_mf_hash(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check again */
|
// check again
|
||||||
for (i = 0; i < TEST_COUNT; i++)
|
for (i = 0; i < TEST_COUNT; i++)
|
||||||
{
|
{
|
||||||
key = index_to_key(i);
|
key = index_to_key(i);
|
||||||
@@ -136,7 +134,7 @@ test_mf_hash(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free hash table and all remaining items */
|
// free hash table and all remaining items
|
||||||
mf_hash_free_all(&ht);
|
mf_hash_free_all(&ht);
|
||||||
}
|
}
|
||||||
|
|
@@ -116,7 +116,7 @@ func Test_syntime()
|
|||||||
let a = execute('syntime clear')
|
let a = execute('syntime clear')
|
||||||
call assert_equal("\nNo Syntax items defined for this buffer", a)
|
call assert_equal("\nNo Syntax items defined for this buffer", a)
|
||||||
|
|
||||||
view samples/memfile_test.c
|
view ../memfile_test.c
|
||||||
setfiletype cpp
|
setfiletype cpp
|
||||||
redraw
|
redraw
|
||||||
let a = execute('syntime report')
|
let a = execute('syntime report')
|
||||||
|
Reference in New Issue
Block a user