infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
008_registry_introspection.c File Reference

Unit test for the registry introspection and serialization APIs. More...

#include "common/double_tap.h"
#include "common/infix_internals.h"
#include <infix/infix.h>
#include <string.h>
Include dependency graph for 008_registry_introspection.c:

Macros

#define DBLTAP_IMPLEMENTATION
 

Functions

 if (!registry) bail_out("Failed to create registry for testing.")
 
 if (infix_register_types(registry, definitions) !=INFIX_SUCCESS)
 
 subtest ("`infix_registry_print` serialization")
 
 subtest ("Registry Iterator API")
 
 subtest ("Lookup by Name API")
 
 infix_registry_destroy (registry)
 

Variables

 TEST
 
infix_registry_tregistry = infix_registry_create()
 
const char * definitions
 

Detailed Description

Unit test for the registry introspection and serialization APIs.

This test file validates the new APIs for inspecting and dumping the contents of a named type registry. It ensures that developers can accurately debug and serialize the types they have defined.

The test covers:

  1. **infix_registry_print:**
    • Verifies that all defined types are serialized into a single string.
    • Confirms that undefined forward declarations are correctly omitted from the output.
    • Checks that the function returns an error when the provided buffer is too small.
  2. **Registry Iterator (infix_registry_iterator_*)**:
    • Verifies that the iterator correctly traverses all defined types in the registry.
    • Confirms that the correct number of types are found.
    • Checks that the get_name and get_type accessors return the correct data for each type.
    • Ensures that the iterator correctly skips over undefined forward declarations.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Function Documentation

◆ if() [1/2]

if ( registry)

◆ if() [2/2]

◆ infix_registry_destroy()

infix_registry_destroy ( registry  )

◆ subtest() [1/3]

subtest ( "`infix_registry_print` serialization"  )

◆ subtest() [2/3]

subtest ( "Lookup by Name API"  )

◆ subtest() [3/3]

subtest ( "Registry Iterator API"  )

Variable Documentation

◆ definitions

const char* definitions
Initial value:
=
"@MyInt = int64;"
"@Point = { x: double, y: double };"
"@FwdOnly;"
"@Node = { value: int, next: *@Node };"

◆ registry

◆ TEST

TEST
Initial value:
{
plan(3)
#define plan(count)
Definition double_tap.h:163