Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
01526fb2
Commit
01526fb2
authored
12 years ago
by
Roman Tsisyk
Browse files
Options
Downloads
Patches
Plain Diff
Update mhash unit test
parent
d4640dd1
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/unit/CMakeLists.txt
+2
-2
2 additions, 2 deletions
test/unit/CMakeLists.txt
test/unit/mhash.c
+46
-17
46 additions, 17 deletions
test/unit/mhash.c
test/unit/mhash_body.c
+16
-12
16 additions, 12 deletions
test/unit/mhash_body.c
with
64 additions
and
31 deletions
test/unit/CMakeLists.txt
+
2
−
2
View file @
01526fb2
add_executable
(
rlist rlist.c test.c
)
add_executable
(
rlist rlist.c test.c
)
add_executable
(
queue queue.c
)
add_executable
(
queue queue.c
)
#
add_executable(mhash mhash.c)
add_executable
(
mhash mhash.c
)
add_executable
(
rope_basic rope_basic.c
${
CMAKE_SOURCE_DIR
}
/src/rope.c
)
add_executable
(
rope_basic rope_basic.c
${
CMAKE_SOURCE_DIR
}
/src/rope.c
)
add_executable
(
rope_avl rope_avl.c
${
CMAKE_SOURCE_DIR
}
/src/rope.c
)
add_executable
(
rope_avl rope_avl.c
${
CMAKE_SOURCE_DIR
}
/src/rope.c
)
add_executable
(
rope_stress rope_stress.c
${
CMAKE_SOURCE_DIR
}
/src/rope.c
)
add_executable
(
rope_stress rope_stress.c
${
CMAKE_SOURCE_DIR
}
/src/rope.c
)
...
@@ -9,7 +9,7 @@ add_executable(objc_finally objc_finally.m)
...
@@ -9,7 +9,7 @@ add_executable(objc_finally objc_finally.m)
add_executable
(
objc_catchcxx objc_catchcxx.m
)
add_executable
(
objc_catchcxx objc_catchcxx.m
)
add_dependencies
(
objc_finally build_bundled_libs
)
add_dependencies
(
objc_finally build_bundled_libs
)
add_dependencies
(
objc_catchcxx build_bundled_libs
)
add_dependencies
(
objc_catchcxx build_bundled_libs
)
#
set_target_properties(mhash PROPERTIES COMPILE_FLAGS "-std=c99")
set_target_properties
(
mhash PROPERTIES COMPILE_FLAGS
"-std=c99"
)
target_link_libraries
(
objc_finally
${
LIBOBJC_LIB
}
-lm -pthread
)
target_link_libraries
(
objc_finally
${
LIBOBJC_LIB
}
-lm -pthread
)
target_link_libraries
(
objc_catchcxx
${
LIBOBJC_LIB
}
${
LUAJIT_LIB
}
-lm -pthread
)
target_link_libraries
(
objc_catchcxx
${
LIBOBJC_LIB
}
${
LUAJIT_LIB
}
-lm -pthread
)
if
(
TARGET_OS_LINUX OR TARGET_OS_DEBIAN_FREEBSD
)
if
(
TARGET_OS_LINUX OR TARGET_OS_DEBIAN_FREEBSD
)
...
...
This diff is collapsed.
Click to expand it.
test/unit/mhash.c
+
46
−
17
View file @
01526fb2
...
@@ -5,18 +5,27 @@
...
@@ -5,18 +5,27 @@
#define MH_SOURCE 1
#define MH_SOURCE 1
#define mh_name _i32
#define mh_name _i32
#define mh_key_t int32_t
struct
mh_i32_node_t
{
#define mh_val_t int32_t
int32_t
key
;
#define mh_hash(a) (a)
int32_t
val
;
#define mh_eq(a, b) ((a) == (b))
};
#define mh_node_t struct mh_i32_node_t
#define mh_hash_arg_t void *
#define mh_hash(a, arg) (a->key)
#define mh_eq_arg_t void *
#define mh_eq(a, b, arg) ((a->key) == (b->key))
#include
"mhash.h"
#include
"mhash.h"
#define mh_name _i32_collision
#define mh_name _i32_collision
#define mh_key_t int32_t
struct
mh_i32_collision_node_t
{
#define mh_val_t int32_t
int32_t
key
;
#define mh_hash(a) 42
int32_t
val
;
#define mh_eq(a, b) ((a) == (b))
};
#define mh_node_t struct mh_i32_collision_node_t
#define mh_hash_arg_t void *
#define mh_hash(a, arg) 42
#define mh_eq_arg_t void *
#define mh_eq(a, b, arg) ((a->key) == (b->key))
#include
"mhash.h"
#include
"mhash.h"
...
@@ -30,9 +39,19 @@ static void mhash_int32_id_test()
...
@@ -30,9 +39,19 @@ static void mhash_int32_id_test()
#define init() ({ mh_i32_init(); })
#define init() ({ mh_i32_init(); })
#define clear(x) ({ mh_i32_clear((x)); })
#define clear(x) ({ mh_i32_clear((x)); })
#define destroy(x) ({ mh_i32_destroy((x)); })
#define destroy(x) ({ mh_i32_destroy((x)); })
#define get(x) ({ mh_i32_get(h, (x)); })
#define get(x) ({ \
#define put(x) ({ mh_i32_put(h, (x), 0, &ret); })
const struct mh_i32_node_t _node = { .key = (x) }; \
#define del(x) ({ mh_i32_del(h, (x)); })
mh_i32_get(h, &_node, NULL, NULL); \
})
#define put(x) ({ \
const struct mh_i32_node_t _node = { .key = (x) }; \
mh_i32_put(h, &_node, NULL, NULL, &ret); \
})
#define key(k) (mh_i32_node(h, k)->key)
#define val(k) (mh_i32_node(h, k)->val)
#define del(k) ({ \
mh_i32_del(h, k, NULL, NULL); \
})
#include
"mhash_body.c"
#include
"mhash_body.c"
footer
();
footer
();
...
@@ -45,11 +64,21 @@ static void mhash_int32_collision_test()
...
@@ -45,11 +64,21 @@ static void mhash_int32_collision_test()
int
ret
,
k
;
int
ret
,
k
;
struct
mh_i32_collision_t
*
h
;
struct
mh_i32_collision_t
*
h
;
#define init() ({ mh_i32_collision_init(); })
#define init() ({ mh_i32_collision_init(); })
#define clear(x) ({ mh_i32_collision_clear((x)); })
#define clear(x) ({ mh_i32_collision_clear((x)); })
#define destroy(x) ({ mh_i32_collision_destroy((x)); })
#define destroy(x) ({ mh_i32_collision_destroy((x)); })
#define get(x) ({ mh_i32_collision_get(h, (x)); })
#define get(x) ({ \
#define put(x) ({ mh_i32_collision_put(h, (x), 0, &ret); })
const struct mh_i32_collision_node_t _node = { .key = (x) }; \
#define del(x) ({ mh_i32_collision_del(h, (x)); })
mh_i32_collision_get(h, &_node, NULL, NULL); \
})
#define put(x) ({ \
const struct mh_i32_collision_node_t _node = { .key = (x) }; \
mh_i32_collision_put(h, &_node, NULL, NULL, &ret); \
})
#define key(k) (mh_i32_collision_node(h, k)->key)
#define val(k) (mh_i32_collision_node(h, k)->val)
#define del(k) ({ \
mh_i32_collision_del(h, k, NULL, NULL); \
})
#include
"mhash_body.c"
#include
"mhash_body.c"
footer
();
footer
();
...
...
This diff is collapsed.
Click to expand it.
test/unit/mhash_body.c
+
16
−
12
View file @
01526fb2
#define set(x) ({ \
#define set(x) ({
\
k = put(x); \
k = put(x);
\
mh_value(h,
k) = (x) << 1; \
val(
k) = (x) << 1;
\
})
})
#define rm(x) ({ \
k = get(x); \
#define rm(x) ({ \
del(k); \
mh_int_t k = get(x); \
})
del(k); \
})
#define tst(x) ({ \
#define tst(x) ({ \
k = get(x); \
mh_int_t k = get((x)); \
fail_unless(k != mh_end(h)); \
fail_unless(k != mh_end(h)); \
fail_unless(mh_value(h, k) == (x) << 1);\
fail_unless(val(k) == ((x) << 1)); \
})
})
#define clr(x) fail_unless(get(x) == mh_end(h))
#define clr(x) fail_unless(get(x) == mh_end(h))
#define usd(x) fail_unless(get(x) != mh_end(h))
#define usd(x) fail_unless(get(x) != mh_end(h))
...
@@ -174,3 +176,5 @@ destroy(h);
...
@@ -174,3 +176,5 @@ destroy(h);
#undef get
#undef get
#undef put
#undef put
#undef del
#undef del
#undef key
#undef val
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment