summaryrefslogtreecommitdiffstats
path: root/src/test/CppTests
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/CppTests')
-rw-r--r--src/test/CppTests/Config.tests.ts1
-rw-r--r--src/test/CppTests/Parameters.test.ts235
-rw-r--r--src/test/CppTests/ReturnTypes.test.ts53
3 files changed, 286 insertions, 3 deletions
diff --git a/src/test/CppTests/Config.tests.ts b/src/test/CppTests/Config.tests.ts
index 3d5fc0a..0143341 100644
--- a/src/test/CppTests/Config.tests.ts
+++ b/src/test/CppTests/Config.tests.ts
@@ -16,5 +16,4 @@ suite("C++ - Configuration Tests", () => {
const testSetup: TestSetup = new TestSetup("void foo();");
// Tests
-
});
diff --git a/src/test/CppTests/Parameters.test.ts b/src/test/CppTests/Parameters.test.ts
index 02d3773..8505826 100644
--- a/src/test/CppTests/Parameters.test.ts
+++ b/src/test/CppTests/Parameters.test.ts
@@ -17,4 +17,239 @@ suite("C++ - Parameters Tests", () => {
const testSetup: TestSetup = new TestSetup("void foo();");
// Tests
+ test("No parameters", () => {
+ const result = testSetup.SetLine("void foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+
+ test("Single parameter", () => {
+ const result = testSetup.SetLine("void foo(int a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+ });
+
+ test("Multiple parameters", () => {
+ const result = testSetup.SetLine("void foo(int a, int b, int c);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @param c \n */", result);
+ });
+
+ test("Parameters with numbers in them", () => {
+ const result = testSetup.SetLine("void foo(int a1, int b23);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b23 \n */", result);
+ });
+
+ test("Reference parameter", () => {
+ const result = testSetup.SetLine("void foo(int& a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+ });
+
+ test("Pointer parameter", () => {
+ const result = testSetup.SetLine("void foo(int* a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+ });
+
+ test("Const parameter", () => {
+ let result = testSetup.SetLine("void foo(const int a1);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n */", result);
+
+ result = testSetup.SetLine("void foo(int const a1);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n */", result);
+ });
+
+ test("Struct parameter", () => {
+ const result = testSetup.SetLine("void foo(int a1, int b23);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b23 \n */", result);
+ });
+
+ test("Template parameter", () => {
+ const result = testSetup.SetLine("void foo(Matrix<T, N, M> mat);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param mat \n */", result);
+ });
+
+ test("Const parameter with const pointer to const pointer", () => {
+ let result = testSetup.SetLine("void foo(const int * const * const a1);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n */", result);
+
+ result = testSetup.SetLine("void foo(int const * const * const a1);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n */", result);
+ });
+
+ test("Fundamental return type with modifiers", () => {
+ let result = testSetup.SetLine("void foo(unsigned int a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(unsigned short int a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(signed short a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(long a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(unsigned long long int a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(signed a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(unsigned a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(unsigned char a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(long double a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+
+ result = testSetup.SetLine("void foo(long unsigned unsigned_a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param unsigned_a \n */", result);
+ });
+
+ test("Parameter type in namespace", () => {
+ const result = testSetup.SetLine("void foo(MyNamespace::Foo a1);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n */", result);
+ });
+
+ test("Parameter template type in namespace", () => {
+ const result = testSetup.SetLine("void foo(Math::Matrix<A, B, C> mat);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param mat \n */", result);
+ });
+
+ test("Parameter template type within templated namespace", () => {
+ const result = testSetup.SetLine("void foo(Matrix<A, B, C>::Matrix<A, B, C> mat);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param mat \n */", result);
+ });
+
+ test("Parameter type in nested namespacee", () => {
+ const result = testSetup.SetLine("void foo( Math::LA::Matrix<A, B, C> mat);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param mat \n */", result);
+ });
+
+ test("Parameter with default char literal", () => {
+ let result = testSetup.SetLine("void foo(char a1 = 'a', int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(char a1 = u'b', int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(char a1 = u8'b', int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(char a1 = U'a', int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(char a1 = l',', int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(int a1 = 'ab', int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+ });
+
+ test("Parameter with default string literal", () => {
+ let result = testSetup.SetLine("void foo(std::string a1 = \"bar\", int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(std::string a1 = u\"bar, test\", int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(std::string a1 = u8\"bar\", int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(std::string a1 = U\"bar\", int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(std::string a1 = l\"bar\", int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(std::string a1 = R\"(bar\\t\\\")\", int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+ });
+
+ test("Parameter with default integer literal", () => {
+ let result = testSetup.SetLine("void foo(int a1 = 1337, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(int a1 = 01337, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(int a1 = 1337, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(int a1 = 0x0FAB, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(int a1 = 0X0FAB, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(std::uint8_t a1 = 0b110011, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(std::byte a1 = 0B11111, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(long a1 = 1337l, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(long long a1 = 1337ll, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(unsigned long long a1 = 1337ull, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(long a1 = 1337L, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(long long a1 = 1337LL, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(unsigned long long a1 = 1337ULL, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+ });
+
+ test("Parameter with default floating point literal", () => {
+ let result = testSetup.SetLine("void foo(double a1 = 1e10, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(double a1 = 1., int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(double a1 = .1, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(double a1 = 0.1e-1, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(float a1 = 1.0f, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(float a1 = 1.0F, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(long double a1 = 1.0lf, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(long double a1 = 1.0LF, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(double a1 = 0xa.bp10, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+
+ result = testSetup.SetLine("void foo(double a1 = 0xa.bp10l, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+ });
+
+ test("Parameter with default compound literal", () => {
+ const result = testSetup.SetLine("void foo(struct Bar a1 = {2, 3}, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+ });
+
+ test("Parameter with default template function call", () => {
+ const result = testSetup.SetLine("void foo(struct Bar a1 = test::baz<3, 2, 5>(23), int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+ });
+
+ test("Parameter with default user defined literal.", () => {
+ const result = testSetup.SetLine("void foo(double a1 = 0xa.bp10l_deg_test, int b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a1 \n * @param b \n */", result);
+ });
});
diff --git a/src/test/CppTests/ReturnTypes.test.ts b/src/test/CppTests/ReturnTypes.test.ts
index 1a59878..caefa48 100644
--- a/src/test/CppTests/ReturnTypes.test.ts
+++ b/src/test/CppTests/ReturnTypes.test.ts
@@ -62,12 +62,26 @@ suite("C++ - Return type Tests", () => {
assert.equal("/**\n * @brief \n * \n * @return struct Bar* \n */", result);
});
- test("Return type with keywords and noexcept", () => {
+ test("Return type with keywords", () => {
+ const result = testSetup.SetLine("static constexpr inline Bar* const foo() "
+ + "const;").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return constexpr Bar* const \n */", result);
+ });
+
+ test("Return type struct with keywords", () => {
const result = testSetup.SetLine("static constexpr inline struct Bar* foo() "
- + "const noexcept(false);").GetResult();
+ + "const;").GetResult();
assert.equal("/**\n * @brief \n * \n * @return constexpr struct Bar* \n */", result);
});
+ test("Const with const pointer to const pointer return type", () => {
+ let result = testSetup.SetLine("const int* const* const foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return const int* const* const \n */", result);
+
+ result = testSetup.SetLine("int const* const* const foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int const* const* const \n */", result);
+ });
+
test("Fundamental return type with modifiers", () => {
let result = testSetup.SetLine("unsigned int foo();").GetResult();
assert.equal("/**\n * @brief \n * \n * @return unsigned int \n */", result);
@@ -99,4 +113,39 @@ suite("C++ - Return type Tests", () => {
result = testSetup.SetLine("long unsigned unsigned_foo();").GetResult();
assert.equal("/**\n * @brief \n * \n * @return long unsigned \n */", result);
});
+
+ test("Function in namespace", () => {
+ const result = testSetup.SetLine("int MyClass::foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("Return Type in namespace", () => {
+ const result = testSetup.SetLine("MyNamespace::Foo CreateFoo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return MyNamespace::Foo \n */", result);
+ });
+
+ test("Template return type", () => {
+ const result = testSetup.SetLine("Matrix<A, B, C> foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return Matrix<A, B, C> \n */", result);
+ });
+
+ test("Template return type within templated namespace", () => {
+ const result = testSetup.SetLine("Matrix<A, B, C>::Matrix<A, B, C> foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return Matrix<A, B, C>::Matrix<A, B, C> \n */", result);
+ });
+
+ test("Function in templated namespace", () => {
+ const result = testSetup.SetLine("int Matrix<A, B, C>::foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("Function with nested namespacee", () => {
+ const result = testSetup.SetLine("int Math::LA::Matrix<A, B, C>::foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("Return Type in nested namespace", () => {
+ const result = testSetup.SetLine("Math::LA::Matrix<A, B, C> foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return Math::LA::Matrix<A, B, C> \n */", result);
+ });
});