-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for C++ namespace support
This combines some test input from Stephan Lachnit and myself. Some of the results are likely not what's desired. Not everything appears to get the namespace prefix, for example variables. It's not clear that everything that appears to be missing a namespace prefix should get a prefix either; for example class/struct/union members, or enumerators, as they're nested within a parent that does have the namespace prefix. More than anything, the test documents the status quo, and provides a way to make incremental improvements on top.
- Loading branch information
Showing
3 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
namespace A { | ||
namespace B { | ||
|
||
/** | ||
* Test fct A | ||
*/ | ||
int testa(int a) { return a; } | ||
|
||
/** | ||
* Test cls B | ||
*/ | ||
class TestB { | ||
public: | ||
/** | ||
* Test fct B | ||
*/ | ||
int testb(int b) { return b; } | ||
|
||
private: | ||
/** Not constant */ | ||
double b; | ||
}; | ||
|
||
|
||
/** Some constant */ | ||
constexpr double CONSTANT = 5.; | ||
|
||
} // namespace B | ||
|
||
/** | ||
* Test cls D | ||
*/ | ||
class TestD : public B::TestB { | ||
public: | ||
/** | ||
* Test fct D | ||
*/ | ||
int testd() const { return d; } | ||
private: | ||
static double d; | ||
}; | ||
|
||
/** | ||
* Test fct C | ||
*/ | ||
template<typename T> | ||
int testc(int c) { return c; } | ||
|
||
/** | ||
* Test enum E | ||
*/ | ||
enum class TestE { | ||
/** enum member A */ | ||
A, | ||
/** enum member B */ | ||
B, | ||
}; | ||
|
||
} // namespace A | ||
|
||
|
||
namespace foo { | ||
/** | ||
* foo_class | ||
*/ | ||
class foo_class { | ||
/** member */ | ||
int m; | ||
}; | ||
|
||
/** | ||
* foo_struct | ||
*/ | ||
struct foo_struct { | ||
/** member */ | ||
int m; | ||
}; | ||
|
||
/** | ||
* foo_union | ||
*/ | ||
union foo_union { | ||
/** member1 */ | ||
int m1; | ||
/** member2 */ | ||
int m2; | ||
}; | ||
|
||
/** | ||
* Const. | ||
*/ | ||
const int GLOBAL = 5; | ||
|
||
/** enum */ | ||
enum foo_enum { | ||
/** enumerator */ | ||
FOO_ENUMERATOR, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
|
||
.. cpp:function:: int A::B::testa(int a) | ||
|
||
Test fct A | ||
|
||
|
||
.. cpp:class:: A::B::TestB | ||
|
||
Test cls B | ||
|
||
|
||
.. cpp:function:: public int testb(int b) | ||
|
||
Test fct B | ||
|
||
|
||
.. cpp:member:: private double b | ||
|
||
Not constant | ||
|
||
|
||
.. cpp:var:: constexpr double CONSTANT | ||
|
||
Some constant | ||
|
||
|
||
.. cpp:class:: A::TestD: public A::B::TestB | ||
|
||
Test cls D | ||
|
||
|
||
.. cpp:function:: public int testd(void) const | ||
|
||
Test fct D | ||
|
||
|
||
.. cpp:function:: template<typename T> int A::testc(int c) | ||
|
||
Test fct C | ||
|
||
|
||
.. cpp:enum-class:: A::TestE | ||
|
||
Test enum E | ||
|
||
|
||
.. cpp:enumerator:: A | ||
|
||
enum member A | ||
|
||
|
||
.. cpp:enumerator:: B | ||
|
||
enum member B | ||
|
||
|
||
.. cpp:class:: foo::foo_class | ||
|
||
foo_class | ||
|
||
|
||
.. cpp:member:: private int m | ||
|
||
member | ||
|
||
|
||
.. cpp:struct:: foo::foo_struct | ||
|
||
foo_struct | ||
|
||
|
||
.. cpp:member:: public int m | ||
|
||
member | ||
|
||
|
||
.. cpp:union:: foo::foo_union | ||
|
||
foo_union | ||
|
||
|
||
.. cpp:member:: int m1 | ||
|
||
member1 | ||
|
||
|
||
.. cpp:member:: int m2 | ||
|
||
member2 | ||
|
||
|
||
.. cpp:var:: const int GLOBAL | ||
|
||
Const. | ||
|
||
|
||
.. cpp:enum:: foo::foo_enum | ||
|
||
enum | ||
|
||
|
||
.. cpp:enumerator:: FOO_ENUMERATOR | ||
|
||
enumerator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
directives: | ||
- domain: cpp | ||
directive: autodoc | ||
arguments: | ||
- namespace.cpp | ||
expected: namespace.rst |