Skip to content

Commit

Permalink
test: split out _Bool/bool tests to C only
Browse files Browse the repository at this point in the history
Split out the _Bool/bool tests and run them in C only. They're
problematic in C++ because they depend on stdbool.h, and specifically on
GCC version of it which defines _Bool bool for C++. This is problematic
on Alpine Linux which uses musl, as well as on macOS.

Annoyingly the anonymous struct names also change.
  • Loading branch information
jnikula committed Sep 11, 2024
1 parent bfb981f commit ee79b6c
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 87 deletions.
4 changes: 2 additions & 2 deletions test/c/autostruct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Named struct.


.. c:struct:: @anonymous_0a4d6f0b47cde0e9872b6dbde2ad1c1a
.. c:struct:: @anonymous_a63d10331be1a527625db63b8ace540f
Anonymous sub-struct.

Expand All @@ -39,7 +39,7 @@
Member foo.


.. c:union:: @anonymous_22cf17aa0fa6d83246282a58013db249
.. c:union:: @anonymous_69382278a84175c1cbff40d522114b38
Anonymous sub-union.

Expand Down
32 changes: 32 additions & 0 deletions test/c/bool.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <stdbool.h>

/**
* Retain bool instead of using _Bool.
*/
static bool convert_bool;

/**
* Also convert _Bool to bool.
*/
static _Bool convert_Bool;

/**
* Bool function.
*/
bool boolean(bool bar, _Bool baz);

/**
* This is a sample struct
*
* Woohoo.
*/
struct sample_struct {
/**
* bool member
*/
bool bool_member;
/**
* _Bool member
*/
_Bool _Bool_member;
};
32 changes: 32 additions & 0 deletions test/c/bool.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

.. c:var:: static bool convert_bool
Retain bool instead of using _Bool.


.. c:var:: static bool convert_Bool
Also convert _Bool to bool.


.. c:function:: bool boolean(bool bar, bool baz)
Bool function.
.. c:struct:: sample_struct
This is a sample struct
Woohoo.
.. c:member:: bool bool_member
bool member
.. c:member:: bool _Bool_member
_Bool member
6 changes: 6 additions & 0 deletions test/c/bool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
directives:
- domain: c
directive: autodoc
arguments:
- bool.c
expected: bool.rst
7 changes: 0 additions & 7 deletions test/c/function.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#include <stdbool.h>

/**
* Foo function.
*/
static inline int foo(int bar, int baz);

/**
* Bool function.
*/
bool boolean(bool bar, _Bool baz);

/**
* No parameters.
*/
Expand Down
5 changes: 0 additions & 5 deletions test/c/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
Foo function.
.. c:function:: bool boolean(bool bar, bool baz)
Bool function.
.. c:function:: int no_parameters(void)
No parameters.
Expand Down
10 changes: 0 additions & 10 deletions test/c/struct.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <stdbool.h>

/**
* This is a sample struct
*
Expand All @@ -10,14 +8,6 @@ struct sample_struct {
* member
*/
int jesh;
/**
* bool member
*/
bool bool_member;
/**
* _Bool member
*/
_Bool _Bool_member;
/**
* array member
*/
Expand Down
16 changes: 3 additions & 13 deletions test/c/struct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@
member


.. c:member:: bool bool_member
bool member


.. c:member:: bool _Bool_member
_Bool member


.. c:member:: int array_member[5]
array member
Expand Down Expand Up @@ -49,7 +39,7 @@
foo next


.. c:struct:: @anonymous_a6168a23d6840e8919ade5661a307607
.. c:struct:: @anonymous_7bf120438d254a91e1275b973de6a0eb
Anonymous struct documentation.

Expand All @@ -64,7 +54,7 @@
Named struct.


.. c:struct:: @anonymous_0a4d6f0b47cde0e9872b6dbde2ad1c1a
.. c:struct:: @anonymous_a63d10331be1a527625db63b8ace540f
Anonymous sub-struct.

Expand All @@ -74,7 +64,7 @@
Member foo.


.. c:union:: @anonymous_22cf17aa0fa6d83246282a58013db249
.. c:union:: @anonymous_69382278a84175c1cbff40d522114b38
Anonymous sub-union.

Expand Down
12 changes: 0 additions & 12 deletions test/c/variable.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
#include <stdbool.h>

/**
* This is a variable document.
*/
static int sheesh;

/**
* Retain bool instead of using _Bool.
*/
static bool convert_bool;

/**
* Also convert _Bool to bool.
*/
static _Bool convert_Bool;

/**
* function pointer variable
*/
Expand Down
10 changes: 0 additions & 10 deletions test/c/variable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
This is a variable document.


.. c:var:: static bool convert_bool
Retain bool instead of using _Bool.


.. c:var:: static bool convert_Bool
Also convert _Bool to bool.


.. c:var:: int (*function_pointer_variable)(int *param_name_ignored)
function pointer variable
Expand Down
5 changes: 0 additions & 5 deletions test/cpp/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
Foo function.


.. cpp:function:: bool boolean(bool bar, bool baz)

Bool function.


.. cpp:function:: int no_parameters(void)

No parameters.
Expand Down
16 changes: 3 additions & 13 deletions test/cpp/struct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@
member


.. cpp:member:: public bool bool_member

bool member


.. cpp:member:: public bool _Bool_member

_Bool member


.. cpp:member:: public int array_member[5]

array member
Expand Down Expand Up @@ -49,7 +39,7 @@
foo next


.. cpp:struct:: @anonymous_a6168a23d6840e8919ade5661a307607
.. cpp:struct:: @anonymous_7bf120438d254a91e1275b973de6a0eb

Anonymous struct documentation.

Expand All @@ -64,7 +54,7 @@
Named struct.


.. cpp:struct:: @anonymous_0a4d6f0b47cde0e9872b6dbde2ad1c1a
.. cpp:struct:: @anonymous_a63d10331be1a527625db63b8ace540f

Anonymous sub-struct.

Expand All @@ -74,7 +64,7 @@
Member foo.


.. cpp:union:: @anonymous_22cf17aa0fa6d83246282a58013db249
.. cpp:union:: @anonymous_69382278a84175c1cbff40d522114b38

Anonymous sub-union.

Expand Down
10 changes: 0 additions & 10 deletions test/cpp/variable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
This is a variable document.


.. cpp:var:: static bool convert_bool

Retain bool instead of using _Bool.


.. cpp:var:: static bool convert_Bool

Also convert _Bool to bool.


.. cpp:var:: int (*function_pointer_variable)(int *param_name_ignored)

function pointer variable
Expand Down

0 comments on commit ee79b6c

Please sign in to comment.