mirror of
https://github.com/RubyMetric/chsrc
synced 2025-09-09 02:26:43 +08:00
测试 map
This commit is contained in:
parent
560a47f358
commit
51b6ece5b7
22
test/xy.c
22
test/xy.c
@ -13,11 +13,17 @@
|
||||
#include "xy.h"
|
||||
|
||||
void
|
||||
print_str (void *str)
|
||||
print_str_for_seq (void *str)
|
||||
{
|
||||
print ((char *) str);
|
||||
}
|
||||
|
||||
void
|
||||
print_str_for_map (const char *key, void *value)
|
||||
{
|
||||
println (xy_strcat (4, " ", key, " => ", (char *) value));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char const *argv[])
|
||||
@ -144,11 +150,23 @@ main (int argc, char const *argv[])
|
||||
xy_seq_push (seq, "World");
|
||||
assert_str ("Hello", xy_seq_at (seq, 1));
|
||||
assert_str ("World", xy_seq_at (seq, 2));
|
||||
xy_seq_each (seq, print_str);
|
||||
xy_seq_each (seq, print_str_for_seq); br();
|
||||
xy_seq_pop (seq);
|
||||
assert (1 == xy_seq_len (seq));
|
||||
|
||||
|
||||
XyMap_t *map = xy_map_new ();
|
||||
xy_map_set (map, "Hello", "World");
|
||||
xy_map_set (map, "你好", "世界");
|
||||
assert_str ("World", xy_map_get (map, "Hello"));
|
||||
assert_str ("世界", xy_map_get (map, "你好"));
|
||||
xy_map_set (map, "Hello", "chsrc");
|
||||
assert_str ("chsrc", xy_map_get (map, "Hello"));
|
||||
assert (2 == xy_map_len (map));
|
||||
echo ("{");
|
||||
xy_map_each (map, print_str_for_map);
|
||||
echo ("}");
|
||||
|
||||
xy_succ ("测试完成", "xy.h 测试全部通过");
|
||||
|
||||
// xy_unimplemented();
|
||||
|
Loading…
x
Reference in New Issue
Block a user