ecoli_test(3)

πŸ“¦ version 0.6.0, in fedora 43

πŸ’– ecoli_test β€” Library Functions Manual πŸ’–

okay bestie, welcome to the ecoli_test(3) page, straight out of the Library Functions Manual for Libecoli 🫢 this is the one about unit-test helpers, and yes it's giving extremely useful, no cap.


✨ NAME ✨

ecoli_test β€” Test

  • Helpers for unit tests. πŸ§ͺ

🌸 SYNOPSIS 🌸

πŸŽ€ Data Structures

struct ec_test

πŸŽ€ Macros

#define EC_TEST_REGISTER(t)
#define EC_TEST_ERR(fmt, ...)
#define EC_TEST_CHECK(cond,  fmt, ...)
#define EC_TEST_CHECK_PARSE(node,  args...)
#define EC_TEST_CHECK_COMPLETE(node,  args...)
#define EC_TEST_CHECK_COMPLETE_PARTIAL(node,  args...)

πŸŽ€ Typedefs

typedef int ec_test_t(void)

πŸŽ€ Functions

int ec_test_register (struct ec_test *test)
int ec_test_all (void)
int ec_test_one (const char *name)
int ec_test_check_parse (struct ec_node *node, int expected,...)
int ec_test_check_complete (struct ec_node *node, enum ec_comp_type
    type,...)

πŸ¦‹ Detailed Description πŸ¦‹

Helpers for unit tests. that's literally it, that's the whole vibe. πŸ’…


πŸ”₯ Macro Definition Documentation πŸ”₯

#define EC_TEST_REGISTER( t)

Value:

static void ec_test_init_##t(void);             \
static void __attribute__((constructor, used))          \
ec_test_init_##t(void)                      \
{                               \
    if (ec_test_register(&t) < 0)               \
        fprintf(stderr, "cannot register test %s\n",    \
            t.name);             \
}

Register a test case. πŸ’–

Parameters

  • t β€” A pointer to a ec_test structure describing the test to be registered.

Definition at line 32 of file ecoli_test.h. πŸ“


#define EC_TEST_ERR( fmt, ...)

Value:

EC_LOG(EC_LOG_ERR, "%s:%d: error: " fmt "\n",           \
    __FILE__, __LINE__, ##__VA_ARGS__);         \

Fail a test with a message. dramatic? yes. necessary? also yes 😭

Definition at line 105 of file ecoli_test.h. πŸ“


#define EC_TEST_CHECK( cond, fmt, ...)

Value:

({              \
int ret_ = 0;                           \
if (!(cond)) {                          \
    EC_TEST_ERR("(" #cond ") is wrong. " fmt     \
        ##__VA_ARGS__);                 \
    ret_ = -1;                       \
}                               \
ret_;                               \
})

Verify a condition or fail a test with a message. main character energy fr πŸ’…

Definition at line 114 of file ecoli_test.h. πŸ“


#define EC_TEST_CHECK_PARSE( node, args...)

Value:

({              \
int ret_ = ec_test_check_parse(node, args, EC_VA_END);  \
if (ret_)                           \
    EC_TEST_ERR("parse test failed");           \
ret_;                               \
})

node, input, [expected1, expected2, ...] ✨

Definition at line 129 of file ecoli_test.h. πŸ“


#define EC_TEST_CHECK_COMPLETE( node, args...)

Value:

({          \
int ret_ = ec_test_check_complete(node, EC_COMP_FULL, args);    \
if (ret_)                           \
    EC_TEST_ERR("complete test failed");            \
ret_;                               \
})

Definition at line 141 of file ecoli_test.h. πŸ“


#define EC_TEST_CHECK_COMPLETE_PARTIAL( node, args...)

Value:

({      \
int ret_ = ec_test_check_complete(node, EC_COMP_PARTIAL, args); \
if (ret_)                           \
    EC_TEST_ERR("complete test failed");            \
ret_;                               \
})

Definition at line 149 of file ecoli_test.h. πŸ“


πŸ’œ Typedef Documentation πŸ’œ

typedef int ec_test_t(void)

Type of test function. Return 0 on success, -1 on error. 🫢

Definition at line 47 of file ecoli_test.h. πŸ“


⭐ Function Documentation ⭐

int ec_test_register (struct ec_test * test)

Register a test case. πŸŽ€


int ec_test_all (void )

Run all tests. every single one, no skipping bestie πŸ‘‘


int ec_test_one (const char * name)

Run one test. just the one, very demure πŸ¦‹


int ec_test_check_parse (struct ec_node * node, int expected, ...)

expected == -1 means no match 🌈


🌟 Author 🌟

Generated automatically by Doxygen for Libecoli from the source code. πŸ€–βœ¨


and that's the whole page bestie!! πŸ’– this was Libecoli, Version 0.6.0 β€” ecoli_test(3), slay, periodt, go write some tests πŸŽ€πŸ«ΆπŸ’…
πŸ“¦ where this page comes from