2 * BongoDB, an embedded document-based engine
3 * Copyright (C) 2015 by Javier Sancho Fernandez <jsf at jsancho dot org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 bongo_client_t *bongo_client;
29 bongo_database_t *bongo_database;
30 bongo_collection_t *bongo_collection;
32 bongo_client = bongo_client_new();
33 printf("Databases: %d\n", bongo_client->n_databases);
34 bongo_database = bongo_client_get_database(bongo_client, "db_test");
35 printf("Databases: %d\n", bongo_client->n_databases);
37 printf("Collections: %d\n", bongo_database->database_node->n_collections);
38 bongo_collection = bongo_client_get_collection(bongo_client, "db_test", "col_test");
39 printf("Collections: %d\n", bongo_database->database_node->n_collections);
41 bongo_collection_destroy(bongo_collection);
42 bongo_database_destroy(bongo_database);
43 bongo_client_destroy(bongo_client);
45 printf("test_bongodb: PASSED\n");
54 const char *js = "{\"name\": \"Jack\", \"age\": 27, \"list\": [1, 2, 3]}";
57 n_tokens = jsmn_parse(&parser, js, strlen(js), NULL, 1);
58 tokens = malloc(sizeof(jsmntok_t) * n_tokens);
60 n_tokens = jsmn_parse(&parser, js, strlen(js), tokens, n_tokens);
61 printf("Tokens: %d\n", n_tokens);
63 for (int i = 0; i < n_tokens; i++)
65 printf(" %d, %d, %d, %d: %.*s\n", tokens[i].type, tokens[i].start, tokens[i].end, tokens[i].size, tokens[i].end - tokens[i].start, js + tokens[i].start);
70 printf("test_jsmn: PASSED\n");