summaryrefslogtreecommitdiffstats
path: root/src/test/CppTests
diff options
context:
space:
mode:
authorRowan Goemans <RB.Goemans@student.han.nl>2017-12-31 04:07:55 +0100
committerChristoph Schlosser <christophschlosser@users.noreply.github.com>2018-02-20 22:02:22 +0100
commit31f6517aa5d8d3ccdd0b39880337c000943d08c1 (patch)
tree2c3c5240470a592f4c0bd134d779f4f3c25d6b2b /src/test/CppTests
parent10aac7196a3a701860525d0f466896efe182d39a (diff)
downloaddoxdocgen-31f6517aa5d8d3ccdd0b39880337c000943d08c1.tar.gz
-- Completed unit tests for operators. Conversion operators aren't working yet.
-- Renamed all C things to Cpp since that is really what they are. -- Made empty files for the remaining unit tests.
Diffstat (limited to 'src/test/CppTests')
-rw-r--r--src/test/CppTests/Attributes.test.ts62
-rw-r--r--src/test/CppTests/Con-AndDestructor.test.ts63
-rw-r--r--src/test/CppTests/Config.tests.ts20
-rw-r--r--src/test/CppTests/FunctionPointer.test.ts42
-rw-r--r--src/test/CppTests/Operators.test.ts300
-rw-r--r--src/test/CppTests/Parameters.test.ts20
-rw-r--r--src/test/CppTests/ReturnTypes.test.ts102
-rw-r--r--src/test/CppTests/Templates.test.ts51
-rw-r--r--src/test/CppTests/TestSetup.ts52
-rw-r--r--src/test/CppTests/TrailingReturns.test.ts39
10 files changed, 751 insertions, 0 deletions
diff --git a/src/test/CppTests/Attributes.test.ts b/src/test/CppTests/Attributes.test.ts
new file mode 100644
index 0000000..bfeaef1
--- /dev/null
+++ b/src/test/CppTests/Attributes.test.ts
@@ -0,0 +1,62 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Attributes Tests", () => {
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // Tests
+ test("Attributes on parameter", () => {
+ const result = testSetup.SetLine("int foo([[maybe_unused]] int a, [[maybe_unused]]double& b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return int \n */", result);
+ });
+
+ test("Attributes on function", () => {
+ const result = testSetup.SetLine("[[nodiscard]] int foo(int a, double& b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return int \n */", result);
+ });
+
+ test("Multiple attributes on parameter", () => {
+ const result = testSetup.SetLine("int foo([[maybe_unused]] [[carries_dependency]]"
+ + " int a, double& b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return int \n */", result);
+ });
+
+ test("Multiple attributes on function", () => {
+ const result = testSetup.SetLine("[[nodiscard]][[deprecated(\"old\")]] int foo(int a, double& b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return int \n */", result);
+ });
+
+ test("Specifier and attribute on class", () => {
+ const result = testSetup.SetLine("class [[nodiscard]] alignas(8) Matrix {").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+
+ test("Specifier and attribute on struct", () => {
+ const result = testSetup.SetLine("struct [[nodiscard]] alignas(8) Matrix {").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+
+ test("Noexcept on function", () => {
+ let result = testSetup.SetLine("constexpr int foo(int a, double& b) noexcept(true);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return constexpr int \n */", result);
+
+ result = testSetup.SetLine("constexpr int foo(int a, double& b) noexcept;").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return constexpr int \n */", result);
+ });
+
+ test("Throw on function", () => {
+ const result = testSetup.SetLine("constexpr int foo(int a, double& b) throw(std::except);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return constexpr int \n */", result);
+ });
+});
diff --git a/src/test/CppTests/Con-AndDestructor.test.ts b/src/test/CppTests/Con-AndDestructor.test.ts
new file mode 100644
index 0000000..6bf3242
--- /dev/null
+++ b/src/test/CppTests/Con-AndDestructor.test.ts
@@ -0,0 +1,63 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Con- and Destructor Tests", () => {
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // Tests
+ test("Normal Constructor", () => {
+ const result = testSetup.SetLine("Foo(int a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+ });
+
+ test("Constructor with initializer list", () => {
+ const result = testSetup.SetLine("Foo(int a) : m_a(a) {").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+ });
+
+ test("Explicit Constructor", () => {
+ const result = testSetup.SetLine("explicit Foo(int a);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+ });
+
+ test("Deleted Constructor", () => {
+ const result = testSetup.SetLine("Foo(int a) = delete;").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n */", result);
+ });
+
+ test("Default Constructor", () => {
+ const result = testSetup.SetLine("Foo() = default;").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+
+ test("Destructor", () => {
+ const result = testSetup.SetLine("~Foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+
+ test("Virtual Destructor", () => {
+ const result = testSetup.SetLine("virtual ~Foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+
+ test("Deleted Destructor", () => {
+ const result = testSetup.SetLine("virtual ~Foo() = 0").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+
+ test("Default Destructor", () => {
+ const result = testSetup.SetLine("~Foo() = default;").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+});
diff --git a/src/test/CppTests/Config.tests.ts b/src/test/CppTests/Config.tests.ts
new file mode 100644
index 0000000..3d5fc0a
--- /dev/null
+++ b/src/test/CppTests/Config.tests.ts
@@ -0,0 +1,20 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Configuration Tests", () => {
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // Tests
+
+});
diff --git a/src/test/CppTests/FunctionPointer.test.ts b/src/test/CppTests/FunctionPointer.test.ts
new file mode 100644
index 0000000..a353380
--- /dev/null
+++ b/src/test/CppTests/FunctionPointer.test.ts
@@ -0,0 +1,42 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Function pointer Tests", () => {
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // Tests
+ test("Function pointer return", () => {
+ const result = testSetup.SetLine("int (*idputs(int a, int b))(char *);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return int(*)(char*) \n */", result);
+ });
+
+ test("Nested function pointer return", () => {
+ const result = testSetup.SetLine("int (*(*(*foo(int a, int b))(int))(double))(float);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n"
+ + " * @return int(*(*(*)(int))(double))(float) \n */", result);
+ });
+
+ test("Function pointer parameter", () => {
+ const result = testSetup.SetLine("int foo(int (*puts)(const char *));").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param puts \n * @return int \n */", result);
+ });
+
+ test("Struct function pointer return with struct FP parameters and keywords", () => {
+ const result = testSetup.SetLine("const struct foo (*idputs(int (*puts)(const char *), const"
+ + " struct test(*str)(int *, const struct test(*str2))))(const char *);").GetResult();
+
+ assert.equal("/**\n * @brief \n * \n * @param puts \n * @param str "
+ + "\n * @return const struct foo(*)(const char*) \n */", result);
+ });
+});
diff --git a/src/test/CppTests/Operators.test.ts b/src/test/CppTests/Operators.test.ts
new file mode 100644
index 0000000..09f5dd4
--- /dev/null
+++ b/src/test/CppTests/Operators.test.ts
@@ -0,0 +1,300 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Operators Tests", () => {
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // Tests
+ test("+ operator", () => {
+ const result = testSetup.SetLine("T operator +(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("- operator", () => {
+ const result = testSetup.SetLine("T operator- (const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("* operator with params", () => {
+ const result = testSetup.SetLine("T operator*(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("/ operator", () => {
+ const result = testSetup.SetLine("T operator/(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("% operator", () => {
+ const result = testSetup.SetLine("T operator%(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("^ operator", () => {
+ const result = testSetup.SetLine("T operator^(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("& operator with params", () => {
+ const result = testSetup.SetLine("T operator&(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("| operator", () => {
+ const result = testSetup.SetLine("T operator|(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("~ operator", () => {
+ const result = testSetup.SetLine("T operator~(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T \n */", result);
+ });
+
+ test("<< operator", () => {
+ const result = testSetup.SetLine("T operator<<(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test(">> operator", () => {
+ const result = testSetup.SetLine("T operator>>(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return T \n */", result);
+ });
+
+ test("! operator", () => {
+ const result = testSetup.SetLine("bool operator!(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return true \n * @return false \n */", result);
+ });
+
+ test("&& operator", () => {
+ const result = testSetup.SetLine("bool operator&&(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return true \n"
+ + " * @return false \n */", result);
+ });
+
+ test("|| operator", () => {
+ const result = testSetup.SetLine("bool operator||(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return true \n"
+ + " * @return false \n */", result);
+ });
+
+ test("!= operator", () => {
+ const result = testSetup.SetLine("bool operator!=(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return true \n"
+ + " * @return false \n */", result);
+ });
+
+ test("== operator", () => {
+ const result = testSetup.SetLine("bool operator==(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return true \n"
+ + " * @return false \n */", result);
+ });
+
+ test("<= operator", () => {
+ const result = testSetup.SetLine("bool operator<=(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return true \n"
+ + " * @return false \n */", result);
+ });
+
+ test(">= operator", () => {
+ const result = testSetup.SetLine("bool operator>=(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return true \n"
+ + " * @return false \n */", result);
+ });
+
+ test("< operator", () => {
+ const result = testSetup.SetLine("bool operator<(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return true \n"
+ + " * @return false \n */", result);
+ });
+
+ test("> operator", () => {
+ const result = testSetup.SetLine("bool operator>(const T& lhs, const T2& rhs);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param lhs \n * @param rhs \n * @return true \n"
+ + " * @return false \n */", result);
+ });
+
+ test("= operator", () => {
+ const result = testSetup.SetLine("T& operator=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("+= operator", () => {
+ const result = testSetup.SetLine("T& operator+=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("-= operator", () => {
+ const result = testSetup.SetLine("T& operator-=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("*= operator", () => {
+ const result = testSetup.SetLine("T& operator*=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("/= operator", () => {
+ const result = testSetup.SetLine("T& operator/=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("%= operator", () => {
+ const result = testSetup.SetLine("T& operator%=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("^= operator", () => {
+ const result = testSetup.SetLine("T& operator^=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("&= operator", () => {
+ const result = testSetup.SetLine("T& operator&=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("|= operator", () => {
+ const result = testSetup.SetLine("T& operator|=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test(">>= operator", () => {
+ const result = testSetup.SetLine("T& operator>>=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("<<= operator", () => {
+ const result = testSetup.SetLine("T& operator<<=(const T& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T& \n */", result);
+ });
+
+ test("prefix ++ operator", () => {
+ const result = testSetup.SetLine("T& operator++();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return T& \n */", result);
+ });
+
+ test("prefix -- operator", () => {
+ const result = testSetup.SetLine("T& operator--();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return T& \n */", result);
+ });
+
+ test("postfix ++ operator", () => {
+ const result = testSetup.SetLine("T operator++(int);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return T \n */", result);
+ });
+
+ test("postfix -- operator", () => {
+ const result = testSetup.SetLine("T operator--(int);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return T \n */", result);
+ });
+
+ test("() operator", () => {
+ let result = testSetup.SetLine("R operator()(const T& a, const T2& b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return R \n */", result);
+
+ result = testSetup.SetLine("R operator( )(const T& a, const T2& b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return R \n */", result);
+ });
+
+ test(", operator", () => {
+ const result = testSetup.SetLine("T2& operator , (const T2& t);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param t \n * @return T2& \n */", result);
+ });
+
+ test("* operator without params", () => {
+ const result = testSetup.SetLine("R& operator*();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return R& \n */", result);
+ });
+
+ test("& operator without params", () => {
+ const result = testSetup.SetLine("R* operator&();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return R* \n */", result);
+ });
+
+ test("->* operator", () => {
+ const result = testSetup.SetLine("R& operator->*();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return R& \n */", result);
+ });
+
+ test("-> operator", () => {
+ const result = testSetup.SetLine("R* operator->();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return R* \n */", result);
+ });
+
+ test("[] operator", () => {
+ let result = testSetup.SetLine("R operator[](S b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param b \n * @return R \n */", result);
+
+ result = testSetup.SetLine("R operator[ ](S b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param b \n * @return R \n */", result);
+ });
+
+ test("new operator", () => {
+ const result = testSetup.SetLine("void* operator new ( std::size_t count );").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param count \n * @return void* \n */", result);
+ });
+
+ test("new[] operator", () => {
+ let result = testSetup.SetLine("void* operator new[]( std::size_t count, std::align_val_t al);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param count \n * @param al \n * @return void* \n */", result);
+
+ result = testSetup.SetLine("void* operator new[ ]( std::size_t count, std::align_val_t al);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param count \n * @param al \n * @return void* \n */", result);
+ });
+
+ test("delete operator", () => {
+ const result = testSetup.SetLine("void operator delete(void* ptr, std::size_t sz, std::align_val_t al);")
+ .GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param ptr \n * @param sz \n * @param al \n */", result);
+ });
+
+ test("delete[] operator", () => {
+ let result = testSetup.SetLine("void operator delete[] (void* ptr);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param ptr \n */", result);
+
+ result = testSetup.SetLine("void operator delete [ ] (void* ptr);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param ptr \n */", result);
+ });
+
+ test("user literal operator", () => {
+ let result = testSetup.SetLine("long double operator\"\"_My_C00l_Conversion(const char * str);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param str \n * @return long double \n */", result);
+
+ result = testSetup.SetLine("long double operator \"\"_My_C00l_Conversion(const char * str);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param str \n * @return long double \n */", result);
+
+ result = testSetup.SetLine("long double operator\"\"_My_C00l_Conversion (const char * str);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param str \n * @return long double \n */", result);
+ });
+
+ test("Implicit conversion operator", () => {
+ const result = testSetup.SetLine("operator int() const").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("Explicit conversion operator", () => {
+ const result = testSetup.SetLine("explicit operator int() const").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("conversion operator to struct", () => {
+ const result = testSetup.SetLine("explicit operator struct foo() const").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return struct foo \n */", result);
+ });
+
+ test("conversion operator to struct pointer", () => {
+ const result = testSetup.SetLine("explicit operator struct foo*() const").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return struct foo* \n */", result);
+ });
+});
diff --git a/src/test/CppTests/Parameters.test.ts b/src/test/CppTests/Parameters.test.ts
new file mode 100644
index 0000000..02d3773
--- /dev/null
+++ b/src/test/CppTests/Parameters.test.ts
@@ -0,0 +1,20 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Parameters Tests", () => {
+
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // Tests
+});
diff --git a/src/test/CppTests/ReturnTypes.test.ts b/src/test/CppTests/ReturnTypes.test.ts
new file mode 100644
index 0000000..1a59878
--- /dev/null
+++ b/src/test/CppTests/ReturnTypes.test.ts
@@ -0,0 +1,102 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Return type Tests", () => {
+
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // Tests
+ test("Void return", () => {
+ const result = testSetup.SetLine("void foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n */", result);
+ });
+
+ test("Void pointer return", () => {
+ const result = testSetup.SetLine("void* foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return void* \n */", result);
+ });
+
+ test("Reference return", () => {
+ const result = testSetup.SetLine("int& foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int& \n */", result);
+ });
+
+ test("Simple type return", () => {
+ const result = testSetup.SetLine("int foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("Bool return type", () => {
+ const result = testSetup.SetLine("bool foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return true \n * @return false \n */", result);
+ });
+
+ test("Pointer return type", () => {
+ const result = testSetup.SetLine("int* foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int* \n */", result);
+ });
+
+ test("Bool pointer return type", () => {
+ const result = testSetup.SetLine("bool* foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return true \n * @return false \n */", result);
+ });
+
+ test("Struct pointer return type", () => {
+ const result = testSetup.SetLine("struct foo* foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return struct foo* \n */", result);
+ });
+
+ test("Struct return type", () => {
+ const result = testSetup.SetLine("struct Bar* foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return struct Bar* \n */", result);
+ });
+
+ test("Return type with keywords and noexcept", () => {
+ const result = testSetup.SetLine("static constexpr inline struct Bar* foo() "
+ + "const noexcept(false);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return constexpr struct Bar* \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);
+
+ result = testSetup.SetLine("unsigned short int foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return unsigned short int \n */", result);
+
+ result = testSetup.SetLine("signed short foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return signed short \n */", result);
+
+ result = testSetup.SetLine("long foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return long \n */", result);
+
+ result = testSetup.SetLine("unsigned long long int foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return unsigned long long int \n */", result);
+
+ result = testSetup.SetLine("signed foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return signed \n */", result);
+
+ result = testSetup.SetLine("unsigned foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return unsigned \n */", result);
+
+ result = testSetup.SetLine("unsigned char foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return unsigned char \n */", result);
+
+ result = testSetup.SetLine("long double foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return long double \n */", result);
+
+ result = testSetup.SetLine("long unsigned unsigned_foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return long unsigned \n */", result);
+ });
+});
diff --git a/src/test/CppTests/Templates.test.ts b/src/test/CppTests/Templates.test.ts
new file mode 100644
index 0000000..07a2144
--- /dev/null
+++ b/src/test/CppTests/Templates.test.ts
@@ -0,0 +1,51 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Template tests", () => {
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // Tests
+ test("Template class", () => {
+ const result = testSetup.SetLine("template<typename T, std::size_t M, std::size_t N,"
+ + "typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>"
+ + "class matrix {").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @tparam T \n * @tparam M \n * @tparam N \n * "
+ + "@tparam std::enable_if<std::is_arithmetic<T>::value, T>::type \n */", result);
+ });
+
+ test("Template function", () => {
+ const result = testSetup.SetLine("template<typename T, typename S>\nT f(T a, S b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @tparam T \n * @tparam S \n * @param a \n * "
+ + "@param b \n * @return T \n */", result);
+ });
+
+ test("Double template", () => {
+ const result = testSetup.SetLine("template<typename T>\ntemplate<typename S>\nT f(T a, S b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @tparam T \n * @tparam S \n * @param a \n * "
+ + "@param b \n * @return T \n */", result);
+ });
+
+ test("Template struct", () => {
+ const result = testSetup.SetLine("template<typename T, std::size_t m, std::size_t n>\n"
+ + "struct myStruct {").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @tparam T \n * @tparam m \n * @tparam n \n */", result);
+ });
+
+ test("Variadic template", () => {
+ const result = testSetup.SetLine("template<typename T, typename... Args>"
+ + "\nT adder(T first, Args... args);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @tparam T \n * @tparam Args \n *"
+ + " @param first \n * @param args \n * @return T \n */", result);
+ });
+});
diff --git a/src/test/CppTests/TestSetup.ts b/src/test/CppTests/TestSetup.ts
new file mode 100644
index 0000000..068cff2
--- /dev/null
+++ b/src/test/CppTests/TestSetup.ts
@@ -0,0 +1,52 @@
+import * as vscode from "vscode";
+
+import CodeParser from "../../Common/ICodeParser";
+import { IDocGen } from "../../Common/IDocGen";
+import { Config } from "../../Config";
+import * as myExtension from "../../extension";
+import CppParser from "../../Lang/Cpp/CppParser";
+import MockDocument from "../tools/MockDocument";
+import MockEditor from "../tools/MockEditor";
+import MockLine from "../tools/MockLine";
+import MockPosition from "../tools/MockPosition";
+import MockSelection from "../tools/MockSelection";
+
+export default class TestSetup {
+ public cfg: Config;
+
+ private editor: MockEditor;
+
+ constructor(method: string) {
+ this.SetLine(method);
+ }
+
+ public SetLine(method: string): TestSetup {
+ this.cfg = new Config();
+
+ let position: MockPosition;
+ position = new MockPosition(0, 0);
+
+ let selection: MockSelection;
+ selection = new MockSelection(position);
+
+ let line: MockLine;
+ line = new MockLine(method);
+
+ let doc: MockDocument;
+ doc = new MockDocument(line);
+
+ this.editor = new MockEditor(selection, doc);
+
+ return this;
+ }
+
+ public GetResult(): string {
+ let parser: CodeParser;
+ parser = new CppParser(new Config());
+
+ const gen: IDocGen = parser.Parse(this.editor);
+ gen.GenerateDoc(new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)));
+
+ return this.editor.editBuilder.text;
+ }
+}
diff --git a/src/test/CppTests/TrailingReturns.test.ts b/src/test/CppTests/TrailingReturns.test.ts
new file mode 100644
index 0000000..11b7937
--- /dev/null
+++ b/src/test/CppTests/TrailingReturns.test.ts
@@ -0,0 +1,39 @@
+//
+// Note: This example test is leveraging the Mocha test framework.
+// Please refer to their documentation on https://mochajs.org/ for help.
+//
+
+// The module 'assert' provides assertion methods from node
+import * as assert from "assert";
+
+// You can import and use all API from the 'vscode' module
+// as well as import your extension to test it
+import * as vscode from "vscode";
+import TestSetup from "./TestSetup";
+
+// Defines a Mocha test suite to group tests of similar kind together
+suite("C++ - Trailing returns tests", () => {
+ const testSetup: TestSetup = new TestSetup("void foo();");
+
+ // tests
+ test("Trailing return", () => {
+ const result = testSetup.SetLine("auto foo() -> int;").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("Trailing return with decltype", () => {
+ const result = testSetup.SetLine("auto foo(int a, double b) -> decltype(a + b);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @r