Skip to content

Commit

Permalink
Merge pull request #1 from dreamer-coding/main
Browse files Browse the repository at this point in the history
Updated Fossil Test to the latest
  • Loading branch information
dreamer-coding authored Nov 26, 2024
2 parents e686ccb + 211eadc commit d931eee
Show file tree
Hide file tree
Showing 16 changed files with 855 additions and 118 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/meson_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ on:
paths:
- "**.c"
- "**.h"
- "**.kt"
- "**.cpp"
- "**.hpp"
- "**.rs"
- "**.py"
- "meson.**"
- "**.build"
- "**.options"
pull_request:
paths:
- "**.c"
- "**.h"
- "**.kt"
- "**.cpp"
- "**.hpp"
- "**.rs"
- "**.py"
- "meson.**"
- "**.build"
- "**.options"

jobs:
build_msvc:
Expand Down Expand Up @@ -211,7 +217,7 @@ jobs:

strategy:
matrix:
distro: [ubuntu, debian, fedora, archlinux]
distro: [ubuntu, fedora, archlinux, debian]

steps:
- name: Checkout code
Expand Down Expand Up @@ -243,7 +249,8 @@ jobs:
-w /workspace \
${GITHUB_REPOSITORY}:${{ matrix.distro }} \
/bin/bash -c "
meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3 -Dc_std=c17 -Dfossil-test:c_std=c17
apt-get update
meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3
meson compile -C builddir
meson test -C builddir -v"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Before using Fossil Lib, ensure you have the following:
# ======================
[wrap-git]
url = https://github.com/fossillogic/fossil-lib.git
revision = v0.1.0
revision = v0.1.1

[provide]
fossil-lib = fossil_lib_dep
Expand Down
39 changes: 32 additions & 7 deletions code/tests/test_arguments.c → code/tests/cases/test_arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,39 @@
* Copyright (C) 2024 Fossil Logic. All rights reserved.
* -----------------------------------------------------------------------------
*/
#include <fossil/unittest/framework.h>
#include <fossil/xassume.h>
#include <fossil/test/framework.h>

#include "fossil/lib/framework.h"

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test
// * Fossil Logic Test Utilities
// * * * * * * * * * * * * * * * * * * * * * * * *
// Setup steps for things like test fixtures and
// mock objects are set here.
// * * * * * * * * * * * * * * * * * * * * * * * *

// Define the test suite and add test cases
FOSSIL_TEST_SUITE(c_args_suite);

// Setup function for the test suite
FOSSIL_SETUP(c_args_suite) {
// Setup code here
}

// Teardown function for the test suite
FOSSIL_TEARDOWN(c_args_suite) {
// Teardown code here
}

FOSSIL_TEST(test_fossil_arg_parse_has) {
// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Cases
// * * * * * * * * * * * * * * * * * * * * * * * *
// The test cases below are provided as samples, inspired
// by the Meson build system's approach of using test cases
// as samples for library usage.
// * * * * * * * * * * * * * * * * * * * * * * * *

FOSSIL_TEST_CASE(c_test_arg_parse_has) {
// Test fossil_arg_parse_has function
fossil_option_t options[] = {
{"option1", COPTION_TYPE_BOOL, {.bool_val = 0}, cnull, 0, 0},
Expand All @@ -32,7 +55,7 @@ FOSSIL_TEST(test_fossil_arg_parse_has) {
ASSUME_ITS_EQUAL_I32(0, fossil_arg_parse_has(options, num_options, "option1"));
}

FOSSIL_TEST(test_fossil_arg_parse) {
FOSSIL_TEST_CASE(c_test_arg_parse) {
// Test fossil_arg_parse function
const char* argv[] = {"program", "-number", "42", "-name", "John", "-flag", "-choice", "choice2", "-feature", "enable"};
const int argc = sizeof(argv) / sizeof(argv[0]);
Expand All @@ -57,6 +80,8 @@ FOSSIL_TEST(test_fossil_arg_parse) {
// * * * * * * * * * * * * * * * * * * * * * * * *

FOSSIL_TEST_GROUP(c_commandline_tests) {
ADD_TEST(test_fossil_arg_parse_has);
ADD_TEST(test_fossil_arg_parse);
FOSSIL_TEST_ADD(c_args_suite, c_test_arg_parse_has);
FOSSIL_TEST_ADD(c_args_suite, c_test_arg_parse);

FOSSIL_TEST_REGISTER(c_args_suite);
}
113 changes: 113 additions & 0 deletions code/tests/cases/test_arguments.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* -----------------------------------------------------------------------------
* Project: Fossil Logic
*
* This file is part of the Fossil Logic project, which aims to develop high-
* performance, cross-platform applications and libraries. The code contained
* herein is subject to the terms and conditions defined in the project license.
*
* Author: Michael Gene Brockus (Dreamer)
*
* Copyright (C) 2024 Fossil Logic. All rights reserved.
* -----------------------------------------------------------------------------
*/
#include <fossil/test/framework.h>

#include "fossil/lib/framework.h"

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Utilities
// * * * * * * * * * * * * * * * * * * * * * * * *
// Setup steps for things like test fixtures and
// mock objects are set here.
// * * * * * * * * * * * * * * * * * * * * * * * *

// Define the test suite and add test cases
FOSSIL_TEST_SUITE(cpp_args_suite);

// Setup function for the test suite
FOSSIL_SETUP(cpp_args_suite) {
// Setup code here
}

// Teardown function for the test suite
FOSSIL_TEARDOWN(cpp_args_suite) {
// Teardown code here
}

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Cases
// * * * * * * * * * * * * * * * * * * * * * * * *
// The test cases below are provided as samples, inspired
// by the Meson build system's approach of using test cases
// as samples for library usage.
// * * * * * * * * * * * * * * * * * * * * * * * *

FOSSIL_TEST_CASE(cpp_test_arg_parse_has) {
// Test fossil_arg_parse_has function
fossil_option_t option1;
option1.name = "option1";
option1.type = COPTION_TYPE_BOOL;
option1.num_choices = 0;
option1.value.bool_val = 0;
option1.extra_data = cnull;
option1.parsed = 0;

fossil_option_t option2;
option2.name = "option2";
option2.type = COPTION_TYPE_INT;
option2.num_choices = 0;
option2.value.int_val = 42;
option2.extra_data = cnull;
option2.parsed = 0;

fossil_option_t options[] = {option1, option2};
int num_options = sizeof(options) / sizeof(options[0]);

// Assuming fossil_arg_parse_has returns 1 for the existing option
ASSUME_ITS_EQUAL_I32(0, fossil_arg_parse_has(options, num_options, "option1"));
}

FOSSIL_TEST_CASE(cpp_test_arg_parse) {
// Test fossil_arg_parse function
const char* argv[] = {"program", "-number", "42", "-name", "John", "-flag", "-choice", "choice2", "-feature", "enable"};
const int argc = sizeof(argv) / sizeof(argv[0]);

fossil_command_line_t cmd = {argc, (char **)argv};

fossil_option_t option1;
option1.name = "option1";
option1.type = COPTION_TYPE_INT;
option1.value.int_val = 0;
option1.num_choices = 0;
option1.extra_data = cnull;
option1.parsed = 0;

fossil_option_t option2;
option2.name = "option2";
option2.type = COPTION_TYPE_BOOL;
option2.num_choices = 0;
option2.value.bool_val = 0;
option2.extra_data = cnull;
option2.parsed = 0;

fossil_option_t options[] = {option1, option2};
int num_options = sizeof(options) / sizeof(options[0]);

// Assuming fossil_arg_parse modifies the options array
fossil_arg_parse(&cmd, options, num_options);

ASSUME_ITS_EQUAL_I32(0, options[0].value.int_val);
ASSUME_ITS_EQUAL_I32(0, options[1].value.bool_val);
}

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Pool
// * * * * * * * * * * * * * * * * * * * * * * * *

FOSSIL_TEST_GROUP(cpp_commandline_tests) {
FOSSIL_TEST_ADD(cpp_args_suite, cpp_test_arg_parse_has);
FOSSIL_TEST_ADD(cpp_args_suite, cpp_test_arg_parse);

FOSSIL_TEST_REGISTER(cpp_args_suite);
}
59 changes: 44 additions & 15 deletions code/tests/test_cnullptr.c → code/tests/cases/test_cnullptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
* -----------------------------------------------------------------------------
* Project: Fossil Logic
*
* This file is part of the Fossil Logic project, which aims to develop high-
* performance, cross-platform applications and libraries. The code contained
* This file is part of the Fossil Logic project, which aims to develop high-
* herein is subject to the terms and conditions defined in the project license.
*
* Author: Michael Gene Brockus (Dreamer)
*
* Copyright (C) 2024 Fossil Logic. All rights reserved.
* -----------------------------------------------------------------------------
*/
#include <fossil/unittest/framework.h>
#include <fossil/xassume.h>
#include <fossil/test/framework.h>

#include "fossil/lib/framework.h"

Expand All @@ -25,11 +24,35 @@
#endif

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test
// * Fossil Logic Test Utilities
// * * * * * * * * * * * * * * * * * * * * * * * *
// Setup steps for things like test fixtures and
// mock objects are set here.
// * * * * * * * * * * * * * * * * * * * * * * * *

// Define the test suite and add test cases
FOSSIL_TEST_SUITE(c_null_suite);

// Setup function for the test suite
FOSSIL_SETUP(c_null_suite) {
// Setup code here
}

// Teardown function for the test suite
FOSSIL_TEARDOWN(c_null_suite) {
// Teardown code here
}

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Cases
// * * * * * * * * * * * * * * * * * * * * * * * *
// The test cases below are provided as samples, inspired
// by the Meson build system's approach of using test cases
// as samples for library usage.
// * * * * * * * * * * * * * * * * * * * * * * * *

// Test cases for cnull
FOSSIL_TEST(test_cnull_definition) {
FOSSIL_TEST_CASE(c_test_cnull_definition) {
// Test cnull definition
#if __cplusplus >= 201103L || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
// C++11 or later, C23 or later
Expand All @@ -49,20 +72,26 @@ FOSSIL_TEST(test_cnull_definition) {
#endif
}

// Test cases for cterminator and related constants
FOSSIL_TEST(test_cterminator_definition) {
// Check if the terminator constants are defined correctly
ASSUME_ITS_EQUAL_CHAR(cterminator, '\0');
ASSUME_ITS_EQUAL_WCHAR(wterminator, L'\0');
ASSUME_ITS_EQUAL_CHAR(cterm, '\0');
ASSUME_ITS_EQUAL_WCHAR(wterm, L'\0');
FOSSIL_TEST_CASE(c_test_cnull_assignment) {
// Test cnull assignment
void *ptr = cnull;
ASSUME_ITS_EQUAL_PTR(ptr, cnull);
}

FOSSIL_TEST_CASE(c_test_cnull_comparison) {
// Test cnull comparison
void *ptr = cnull;
ASSUME_ITS_TRUE(ptr == cnull);
ASSUME_ITS_FALSE(ptr != cnull);
}

// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Pool
// * * * * * * * * * * * * * * * * * * * * * * * *
FOSSIL_TEST_GROUP(c_null_tests) {
FOSSIL_TEST_ADD(c_null_suite, c_test_cnull_definition);
FOSSIL_TEST_ADD(c_null_suite, c_test_cnull_assignment);
FOSSIL_TEST_ADD(c_null_suite, c_test_cnull_comparison);

FOSSIL_TEST_GROUP(cnull_tests) {
ADD_TEST(test_cnull_definition);
ADD_TEST(test_cterminator_definition);
FOSSIL_TEST_REGISTER(c_null_suite);
}
Loading

0 comments on commit d931eee

Please sign in to comment.