You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.2 KiB
54 lines
1.2 KiB
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <json/json.h>
|
|
|
|
#include "../bigpoint_cclass.h"
|
|
#include "../bigpoint_dyntype.h"
|
|
#include "../bigpoint_hash.h"
|
|
|
|
|
|
#define TEST_KEY1 "key1"
|
|
#define TEST_KEY2 "key2"
|
|
|
|
|
|
int
|
|
main(int argc, char * argv[])
|
|
{
|
|
struct BIGPOINT_DYNTYPE * dyn;
|
|
struct BIGPOINT_HASH * hash = new(BIGPOINT_HASH);
|
|
struct json_object * json;
|
|
|
|
dyn = new(BIGPOINT_DYNTYPE, BIGPOINT_DYNTYPE_INT, sizeof(int), 123);
|
|
bigpoint_hash_set(hash, TEST_KEY1, dyn);
|
|
|
|
dyn = new(BIGPOINT_DYNTYPE, BIGPOINT_DYNTYPE_INT, sizeof(int), 321);
|
|
bigpoint_hash_set(hash, TEST_KEY2, dyn);
|
|
|
|
dyn = bigpoint_hash_get(hash, TEST_KEY1);
|
|
printf("%d\n", (dyn->data)._int);
|
|
delete(dyn);
|
|
|
|
dyn = bigpoint_hash_get(hash, TEST_KEY2);
|
|
printf("%d\n", (dyn->data)._int);
|
|
delete(dyn);
|
|
|
|
delete(hash);
|
|
|
|
json = json_tokener_parse("{\"key1\":123,\"key2\":321}");
|
|
hash = newFromJson(BIGPOINT_HASH, json);
|
|
json_object_put(json);
|
|
|
|
dyn = bigpoint_hash_get(hash, TEST_KEY1);
|
|
printf("%d\n", (dyn->data)._int);
|
|
delete(dyn);
|
|
|
|
dyn = bigpoint_hash_get(hash, TEST_KEY2);
|
|
printf("%d\n", (dyn->data)._int);
|
|
delete(dyn);
|
|
|
|
delete(hash);
|
|
|
|
return 0;
|
|
}
|
|
|
|
// vim: set et ts=4 sw=4:
|