diff options
| author | Rowan Goemans <RB.Goemans@student.han.nl> | 2017-12-31 04:07:55 +0100 |
|---|---|---|
| committer | Christoph Schlosser <christophschlosser@users.noreply.github.com> | 2018-02-20 22:02:22 +0100 |
| commit | 31f6517aa5d8d3ccdd0b39880337c000943d08c1 (patch) | |
| tree | 2c3c5240470a592f4c0bd134d779f4f3c25d6b2b /src/test/CTests | |
| parent | 10aac7196a3a701860525d0f466896efe182d39a (diff) | |
| download | doxdocgen-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/CTests')
| -rw-r--r-- | src/test/CTests/Attributes.test.ts | 62 | ||||
| -rw-r--r-- | src/test/CTests/Con-AndDestructor.test.ts | 63 | ||||
| -rw-r--r-- | src/test/CTests/FunctionPointer.test.ts | 42 | ||||
| -rw-r--r-- | src/test/CTests/Operators.test.ts | 279 | ||||
| -rw-r--r-- | src/test/CTests/ReturnTypes.test.ts | 102 | ||||
| -rw-r--r-- | src/test/CTests/Templates.test.ts | 51 | ||||
| -rw-r--r-- | src/test/CTests/TestSetup.ts | 52 | ||||
| -rw-r--r-- | src/test/CTests/TrailingReturns.test.ts | 39 |
8 files changed, 0 insertions, 690 deletions
diff --git a/src/test/CTests/Attributes.test.ts b/src/test/CTests/Attributes.test.ts deleted file mode 100644 index bfeaef1..0000000 --- a/src/test/CTests/Attributes.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -// -// 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/CTests/Con-AndDestructor.test.ts b/src/test/CTests/Con-AndDestructor.test.ts deleted file mode 100644 index 6bf3242..0000000 --- a/src/test/CTests/Con-AndDestructor.test.ts +++ /dev/null @@ -1,63 +0,0 @@ -// -// 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/CTests/FunctionPointer.test.ts b/src/test/CTests/FunctionPointer.test.ts deleted file mode 100644 index a353380..0000000 --- a/src/test/CTests/FunctionPointer.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -// -// 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/CTests/Operators.test.ts b/src/test/CTests/Operators.test.ts deleted file mode 100644 index 32d097c..0000000 --- a/src/test/CTests/Operators.test.ts +++ /dev/null @@ -1,279 +0,0 @@ -// -// 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", () => { - 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("conversion 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); - }); -}); diff --git a/src/test/CTests/ReturnTypes.test.ts b/src/test/CTests/ReturnTypes.test.ts deleted file mode 100644 index 1a59878..0000000 --- a/src/test/CTests/ReturnTypes.test.ts +++ /dev/null @@ -1,102 +0,0 @@ -// -// 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/CTests/Templates.test.ts b/src/test/CTests/Templates.test.ts deleted file mode 100644 index 07a2144..0000000 --- a/src/test/CTests/Templates.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -// -// 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/CTests/TestSetup.ts b/src/test/CTests/TestSetup.ts deleted file mode 100644 index 1eb9c86..0000000 --- a/src/test/CTests/TestSetup.ts +++ /dev/null @@ -1,52 +0,0 @@ -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 CParser from "../../Lang/C/CParser"; -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 CParser(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/CTests/TrailingReturns.test.ts b/src/test/CTests/TrailingReturns.test.ts deleted file mode 100644 index 11b7937..0000000 --- a/src/test/CTests/TrailingReturns.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -// -// 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 * @return decltype(a + b) \n */", result); - }); - - test("Multiple trailing returns", () => { - const result = testSetup.SetLine("auto foo() -> auto(*)() -> tmp<int>(*)();").GetResult(); - assert.equal("/**\n * @brief \n * \n * @return auto(*)() -> tmp<int>(*)() \n */", result); - }); - - test("Trailing return with keywords", () => { - const result = testSetup.SetLine("auto foo(const int& a, const double* b) const noexcept -> const double&;") - .GetResult(); - assert.equal("/**\n * @brief \n * \n * @param a \n * @param b \n * @return const double& \n */", result); - }); -}); |