nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | README | LICENSE

commit a39f1f4f5a1adea15deeafcfdf307a0012e3c965
parent 3f84a586c02b811c7d0cc1a05df021a2dc7bb01e
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 24 Jul 2023 16:04:34 -0700

test: add test that make sure string functions work before finalization

Diffstat:
Mtest.c | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/test.c b/test.c @@ -225,9 +225,25 @@ static void test_parse_json() { assert(!strcmp(ndb_iter_tag_str(it, 2).str, "w")); } +static void test_strings_work_before_finalization() { + struct ndb_builder builder, *b = &builder; + struct ndb_note *note; + int ok; + unsigned char buf[1024]; + + ok = ndb_builder_init(b, buf, sizeof(buf)); assert(ok); + ndb_builder_set_content(b, "hello", 5); + + assert(!strcmp(ndb_note_str(b->note, &b->note->content).str, "hello")); + assert(ndb_builder_finalize(b, &note)); + + assert(!strcmp(ndb_note_str(b->note, &b->note->content).str, "hello")); +} + int main(int argc, const char *argv[]) { test_basic_event(); test_empty_tags(); test_parse_json(); test_parse_contact_list(); + test_strings_work_before_finalization(); }