view src/atom_test.c @ 145:7887550c61c6

atom: Allow freeing atoms table
author Lewin Bormann <lbo@spheniscida.de>
date Tue, 03 Sep 2019 12:15:21 +0200
parents cf95c6716512
children
line wrap: on
line source

#include "atom.h"

#include <assert.h>
#include <string.h>

void test_atom_table(void) {
    yatom_t first = yatom_get_or_add("first");
    yatom_t second = yatom_get_or_add("second");
    yatom_t firstagain = yatom_get_or_add("first");

    assert(first == firstagain);
    assert(first != second);
}

void test_atom_name(void) {
    yatom_t a = yatom_get_or_add("a");
    yatom_t abc = yatom_get_or_add("abc");

    assert(0 == strcmp(yatom_name(a), "a"));
    assert(0 == strcmp(yatom_name(abc), "abc"));
}

int main(void) {
    test_atom_table();
    test_atom_name();
    yatom_free_all();
    return 0;
}