summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2018-03-02 19:31:23 +0100
committerChristoph Schlosser <christophschlosser@users.noreply.github.com>2018-03-02 20:24:28 +0100
commitef2e8c5d451188bceaeaa262b49d86081f775098 (patch)
tree87c674ef463909303025bd153c5223754f803d15
parent23ae26f33b60244ce19e8a49d43c022bc41fd719 (diff)
downloaddoxdocgen-ef2e8c5d451188bceaeaa262b49d86081f775098.tar.gz
Add tests for new smart text
-rw-r--r--src/test/CppTests/Config.test.ts25
-rw-r--r--src/test/CppTests/SmartText.test.ts100
2 files changed, 123 insertions, 2 deletions
diff --git a/src/test/CppTests/Config.test.ts b/src/test/CppTests/Config.test.ts
index d37f93d..ee6a90f 100644
--- a/src/test/CppTests/Config.test.ts
+++ b/src/test/CppTests/Config.test.ts
@@ -114,4 +114,29 @@ suite("C++ - Configuration Tests", () => {
const result = testSetup.SetLine("~Foo();").GetResult();
assert.equal("/**\n * @brief Test Foo\n * \n */", result);
});
+
+ test("Custom smart text getter", () => {
+ testSetup.cfg.C.getterText = "Test {name}";
+ const result = testSetup.SetLine("int getFoo();").GetResult();
+ assert.equal("/**\n * @brief Test Foo\n * \n * @return int \n */", result);
+ });
+
+ test("Custom smart text setter", () => {
+ testSetup.cfg.C.setterText = "Test {name}";
+ const result = testSetup.SetLine("void setFoo(int foo);").GetResult();
+ assert.equal("/**\n * @brief Test Foo\n * \n * @param foo \n */", result);
+ });
+
+ test("Custom smart text factory method", () => {
+ testSetup.cfg.C.factoryMethodText = "Test {name}";
+ const result = testSetup.SetLine("int createFoo();").GetResult();
+ assert.equal("/**\n * @brief Test Foo\n * \n * @return int \n */", result);
+ });
+
+ test("Don't split casing for smart text", () => {
+ testSetup.cfg.C.factoryMethodText = "Test {name}";
+ testSetup.cfg.Generic.splitCasingSmartText = false;
+ const result = testSetup.SetLine("int createFooObject();").GetResult();
+ assert.equal("/**\n * @brief Test FooObject\n * \n * @return int \n */", result);
+ });
});
diff --git a/src/test/CppTests/SmartText.test.ts b/src/test/CppTests/SmartText.test.ts
index 23ecaba..bcfb6c8 100644
--- a/src/test/CppTests/SmartText.test.ts
+++ b/src/test/CppTests/SmartText.test.ts
@@ -20,23 +20,119 @@ suite("Smart Text Tests", () => {
testSetup.cfg.Generic.generateSmartText = false;
const result = testSetup.SetLine("Foo();").GetResult();
assert.equal("/**\n * @brief \n * \n */", result);
- testSetup.cfg.Generic.generateSmartText = true; // for later tests
});
test("Disable smart text Dtor", () => {
testSetup.cfg.Generic.generateSmartText = false;
const result = testSetup.SetLine("~Foo();").GetResult();
assert.equal("/**\n * @brief \n * \n */", result);
- testSetup.cfg.Generic.generateSmartText = true; // for later tests
+ });
+
+ test("Disable smart text getter", () => {
+ testSetup.cfg.Generic.generateSmartText = false;
+ const result = testSetup.SetLine("int getFoo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("Disable smart text setter", () => {
+ testSetup.cfg.Generic.generateSmartText = false;
+ const result = testSetup.SetLine("void setFoo(int foo);").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @param foo \n */", result);
+ });
+
+ test("Disable smart text factory method", () => {
+ testSetup.cfg.Generic.generateSmartText = false;
+ const result = testSetup.SetLine("int createFoo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
});
test("Standard smart text Ctor", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
const result = testSetup.SetLine("Foo();").GetResult();
assert.equal("/**\n * @brief Construct a new Foo object\n * \n */", result);
});
test("Standard smart text Dtor", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
const result = testSetup.SetLine("~Foo();").GetResult();
assert.equal("/**\n * @brief Destroy the Foo object\n * \n */", result);
});
+
+ test("Standard smart text getter", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("int getFoo();").GetResult();
+ assert.equal("/**\n * @brief Get the Foo object\n * \n * @return int \n */", result);
+ });
+
+ test("Standard smart text setter", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("void setFoo(int foo);").GetResult();
+ assert.equal("/**\n * @brief Set the Foo object\n * \n * @param foo \n */", result);
+ });
+
+ test("Standard smart text factory method", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("int createFoo();").GetResult();
+ assert.equal("/**\n * @brief Create a Foo object\n * \n * @return int \n */", result);
+ });
+
+ test("Casing text split: SCREAMING_SNAKE", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("int CREATE_FOO();").GetResult();
+ assert.equal("/**\n * @brief Create a foo object\n * \n * @return int \n */", result);
+ });
+
+ test("Casing text split: snake_case", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("int create_foo();").GetResult();
+ assert.equal("/**\n * @brief Create a foo object\n * \n * @return int \n */", result);
+ });
+
+ test("Casing text split: PascalCase", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("int CreateFoo();").GetResult();
+ assert.equal("/**\n * @brief Create a Foo object\n * \n * @return int \n */", result);
+ });
+
+ test("Casing text split: camelCase", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("int createFoo();").GetResult();
+ assert.equal("/**\n * @brief Create a Foo object\n * \n * @return int \n */", result);
+ });
+
+ test("Casing text split: UPPERCASE", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("int CREATEFOO();").GetResult();
+ assert.equal("/**\n * @brief Create a FOO object\n * \n * @return int \n */", result);
+ });
+
+ test("Casing text split: UnCertain_CASE", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+ const result = testSetup.SetLine("int Create_FOO();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
+
+ test("Casing text split: unidentifieable", () => {
+ testSetup.cfg.Generic.generateSmartText = true;
+
+ // SCREAMING_SNAKE
+ let result = testSetup.SetLine("int CREATE_foo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+
+ // snake_case
+ result = testSetup.SetLine("int create_FOO();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+
+ // Pascal
+ result = testSetup.SetLine("int Createfoo();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+
+ // camel
+ result = testSetup.SetLine("int createFOO();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+
+ // UPPER???
+ result = testSetup.SetLine("int CREATE_();").GetResult();
+ assert.equal("/**\n * @brief \n * \n * @return int \n */", result);
+ });
});