build: re-enable namespace-specific tests

This commit is contained in:
2026-05-05 21:17:21 +01:00
parent 4b20f8ca0e
commit c29465a97d
27 changed files with 273 additions and 447 deletions
+31 -13
View File
@@ -1,4 +1,4 @@
#include <fx/core/error.h>
#include <fx/error.h>
#include <fx/term/print.h>
#include <stdio.h>
@@ -17,21 +17,28 @@ static const fx_error_definition sample_errors[] = {
FX_ERROR_DEFINITION(SAMPLE_OK, "OK", "Success"),
FX_ERROR_DEFINITION(SAMPLE_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
FX_ERROR_DEFINITION_TEMPLATE(
SAMPLE_ERR_FILE_READ_FAILED, "FILE_READ_FAILED",
SAMPLE_ERR_FILE_READ_FAILED,
"FILE_READ_FAILED",
"Failed to read file @i[filepath]",
FX_ERROR_TEMPLATE_PARAM(
"filepath", FX_ERROR_TEMPLATE_PARAM_STRING, "%s")),
"filepath",
FX_ERROR_TEMPLATE_PARAM_STRING,
"%s")),
};
static const fx_error_msg sample_error_msg[] = {
FX_ERROR_MSG_TEMPLATE(
SAMPLE_MSG_A_TEMPLATED_MSG, "A templated message: @e[param1]",
SAMPLE_MSG_A_TEMPLATED_MSG,
"A templated message: @e[param1]",
FX_ERROR_TEMPLATE_PARAM(
"param1", FX_ERROR_TEMPLATE_PARAM_STRING, "%s")),
"param1",
FX_ERROR_TEMPLATE_PARAM_STRING,
"%s")),
};
static const char *sample_code_to_string(
const struct fx_error_vendor *vendor, fx_error_status_code code)
const struct fx_error_vendor *vendor,
fx_error_status_code code)
{
switch (code) {
case SAMPLE_OK:
@@ -56,15 +63,22 @@ static fx_error_vendor sample_vendor = {
static fx_result error_return_3(void)
{
fx_result err = fx_error_with_string(
&sample_vendor, SAMPLE_ERR_IO_FAILURE,
&sample_vendor,
SAMPLE_ERR_IO_FAILURE,
"I/O failure while reading file");
fx_error_add_submsg_string(
err, FX_ERROR_SUBMSG_ERROR, "An @e{error} message");
err,
FX_ERROR_SUBMSG_ERROR,
"An @e{error} message");
fx_error_add_submsg_string(
err, FX_ERROR_SUBMSG_WARNING, "A @w{warning} message");
err,
FX_ERROR_SUBMSG_WARNING,
"A @w{warning} message");
fx_error_add_submsg_template(
err, FX_ERROR_SUBMSG_WARNING, SAMPLE_MSG_A_TEMPLATED_MSG,
err,
FX_ERROR_SUBMSG_WARNING,
SAMPLE_MSG_A_TEMPLATED_MSG,
FX_ERROR_PARAM("param1", "Hello!"));
return err;
@@ -105,10 +119,12 @@ static fx_result some_operation(void)
fx_result result = error_return_2();
if (fx_result_is_error(result)) {
fx_result err = fx_error_with_template(
&sample_vendor, SAMPLE_ERR_FILE_READ_FAILED,
&sample_vendor,
SAMPLE_ERR_FILE_READ_FAILED,
FX_ERROR_PARAM("filepath", "src/Manifest.json"));
fx_error_add_submsg_string(
err, FX_ERROR_SUBMSG_INFO,
err,
FX_ERROR_SUBMSG_INFO,
"An @i{informational} message");
fx_error_caused_by_fx_status(result, FX_ERR_IO_FAILURE);
@@ -122,7 +138,9 @@ static fx_result some_operation(void)
int main(void)
{
fx_set_error_report_function(fx_enhanced_error_reporter, FX_ERROR_REPORT_ALL);
fx_set_error_report_function(
fx_enhanced_error_reporter,
FX_ERROR_REPORT_ALL);
test(PARAM("Hello", 1), PARAM("Goodbye", 2));