Added some guides and examples for mangle naming problem
authorYoonki Park <yoonki.park@samsung.com>
Tue, 22 Mar 2016 09:33:23 +0000 (18:33 +0900)
committerYoonki Park <yoonki.park@samsung.com>
Tue, 22 Mar 2016 09:33:23 +0000 (18:33 +0900)
Change-Id: Id8825c637a41afba5e0e2028a69e58b37e0244a6
Signed-off-by: Yoonki Park <yoonki.park@samsung.com>
org.tizen.devtools/html/images/unit_test_create.png
org.tizen.devtools/html/native_tools/unit_test_n.htm

index cda9719..b125a0e 100644 (file)
Binary files a/org.tizen.devtools/html/images/unit_test_create.png and b/org.tizen.devtools/html/images/unit_test_create.png differ
index 6006f18..2c8e1eb 100644 (file)
 <p>The unit test tool supports basic assertions, binary comparison, and string comparison in gtest. For more information, see <a href="https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md" target="_blank">https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md</a>.</p></li>
 </ol>
 
+<p><strong>Note:</strong>To test your project written in C code</p>
+  We provide a unit test project written in C++ language. So the function which you want to test should be qualified as extern "C" to avoid the error, "undefined reference" as demangled symbols in the error message.
+  There are two forms of the extern "C" declaration.
+<li><p>Declare with extern "C" linkage specification in C header file:</p>
+<pre class="prettyprint">
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int foo;
+void bar();
+
+#ifdef __cplusplus
+}
+#endif
+</pre></li>
+<li><p>Include C headers in C++ Code:</p>
+<pre class="prettyprint">
+extern "C" {
+    #include "header.h"
+}
+</pre></li>
+
+<p>Here is a detail example with calculator sample project:</p>
+We will write a test case for <span style="font-family: Courier New, Courier, monospace">utils_round</span> function declared in utils/utils.h.
+<ol>
+<li>Create a calculator project named "Calculator" and a unit test project for calculator project named "CalculatorTest".</li>
+<li>Append the test method to the end of CalculatorTest/src/CalculatorTestTestCase.cpp file.</li>
+<pre class="prettyprint">
+TEST_F(TestSuite, utils_round)
+{
+    double var = 3.5;
+    // long long utils_round(double value);
+
+    EXPECT_EQ(utils_round(var), (long long)4);
+}
+</pre>
+<li>Change the line including "utils/utils.h" such as:</li>
+<pre class="prettyprint">
+#include "view/window.h"
+#include "view/main-view.h"
+extern "C" {
+#include "utils/utils.h"
+}
+#include "utils/ui-utils.h"
+</pre>
+If you do not want to change source codes to the calculator project, you can declare with extern "C" linkage specifications in the test project as the example.
+</ol>
 <h2 id="run">Running a Test Project</h2>
 
 <p>You can run a test project on the Emulator or a target device.</p>