diff options
| author | ruki <[email protected]> | 2022-12-01 22:38:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-12-01 22:38:41 +0800 |
| commit | 90613a344570916a4a7d197dc20d3af31a38be51 (patch) | |
| tree | a2f05adfd49d82915b86749a39fcbae662b9f3d5 /tests/projects/c++ | |
| parent | 62bf14a330904ea37496d5da5bfe3a66ec3d02ec (diff) | |
improve tests
Diffstat (limited to 'tests/projects/c++')
| -rw-r--r-- | tests/projects/c++/shared_library/src/foo.cpp | 5 | ||||
| -rw-r--r-- | tests/projects/c++/shared_library/src/foo.h (renamed from tests/projects/c++/shared_library/src/interface.h) | 9 | ||||
| -rw-r--r-- | tests/projects/c++/shared_library/src/interface.cpp | 6 | ||||
| -rw-r--r-- | tests/projects/c++/shared_library/src/main.cpp | 7 | ||||
| -rw-r--r-- | tests/projects/c++/shared_library/xmake.lua | 6 | ||||
| -rw-r--r-- | tests/projects/c++/static_library/src/foo.cpp | 5 | ||||
| -rw-r--r-- | tests/projects/c++/static_library/src/foo.h | 9 | ||||
| -rw-r--r-- | tests/projects/c++/static_library/src/interface.cpp | 6 | ||||
| -rw-r--r-- | tests/projects/c++/static_library/src/interface.h | 16 | ||||
| -rw-r--r-- | tests/projects/c++/static_library/src/main.cpp | 7 | ||||
| -rw-r--r-- | tests/projects/c++/static_library/xmake.lua | 6 |
11 files changed, 32 insertions, 50 deletions
diff --git a/tests/projects/c++/shared_library/src/foo.cpp b/tests/projects/c++/shared_library/src/foo.cpp new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/tests/projects/c++/shared_library/src/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/tests/projects/c++/shared_library/src/interface.h b/tests/projects/c++/shared_library/src/foo.h index 57b6194de..20df0baa4 100644 --- a/tests/projects/c++/shared_library/src/interface.h +++ b/tests/projects/c++/shared_library/src/foo.h @@ -10,14 +10,7 @@ extern "C" { # define __export #endif -/*! calculate add(a, b) - * - * @param a the first argument - * @param b the second argument - * - * @return the result - */ -__export int add(int a, int b); +__export int add(int a, int b); #ifdef __cplusplus } diff --git a/tests/projects/c++/shared_library/src/interface.cpp b/tests/projects/c++/shared_library/src/interface.cpp deleted file mode 100644 index 598d07560..000000000 --- a/tests/projects/c++/shared_library/src/interface.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "interface.h" - -int add(int a, int b) -{ - return a + b; -} diff --git a/tests/projects/c++/shared_library/src/main.cpp b/tests/projects/c++/shared_library/src/main.cpp index 72e03272b..ed1924789 100644 --- a/tests/projects/c++/shared_library/src/main.cpp +++ b/tests/projects/c++/shared_library/src/main.cpp @@ -1,10 +1,9 @@ -#include "interface.h" +#include "foo.h" #include <iostream> using namespace std; -int main(int argc, char** argv) -{ - cout << "add(1, 2) = " << add(1, 2) << endl; +int main(int argc, char** argv) { + cout << "add(1, 2) = " << add(1, 2) << endl; return 0; } diff --git a/tests/projects/c++/shared_library/xmake.lua b/tests/projects/c++/shared_library/xmake.lua index 49641ced1..f2e0a1d3d 100644 --- a/tests/projects/c++/shared_library/xmake.lua +++ b/tests/projects/c++/shared_library/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.debug", "mode.release") -target("test") +target("foo") set_kind("shared") - add_files("src/interface.cpp") + add_files("src/foo.cpp") target("demo") set_kind("binary") - add_deps("test") + add_deps("foo") add_files("src/main.cpp") diff --git a/tests/projects/c++/static_library/src/foo.cpp b/tests/projects/c++/static_library/src/foo.cpp new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/tests/projects/c++/static_library/src/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/tests/projects/c++/static_library/src/foo.h b/tests/projects/c++/static_library/src/foo.h new file mode 100644 index 000000000..d2506bca9 --- /dev/null +++ b/tests/projects/c++/static_library/src/foo.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif + +int add(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/tests/projects/c++/static_library/src/interface.cpp b/tests/projects/c++/static_library/src/interface.cpp deleted file mode 100644 index 598d07560..000000000 --- a/tests/projects/c++/static_library/src/interface.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "interface.h" - -int add(int a, int b) -{ - return a + b; -} diff --git a/tests/projects/c++/static_library/src/interface.h b/tests/projects/c++/static_library/src/interface.h deleted file mode 100644 index 4a41e9597..000000000 --- a/tests/projects/c++/static_library/src/interface.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -/*! calculate add(a, b) - * - * @param a the first argument - * @param b the second argument - * - * @return the result - */ -int add(int a, int b); - -#ifdef __cplusplus -} -#endif diff --git a/tests/projects/c++/static_library/src/main.cpp b/tests/projects/c++/static_library/src/main.cpp index 72e03272b..ed1924789 100644 --- a/tests/projects/c++/static_library/src/main.cpp +++ b/tests/projects/c++/static_library/src/main.cpp @@ -1,10 +1,9 @@ -#include "interface.h" +#include "foo.h" #include <iostream> using namespace std; -int main(int argc, char** argv) -{ - cout << "add(1, 2) = " << add(1, 2) << endl; +int main(int argc, char** argv) { + cout << "add(1, 2) = " << add(1, 2) << endl; return 0; } diff --git a/tests/projects/c++/static_library/xmake.lua b/tests/projects/c++/static_library/xmake.lua index 184a33d51..f31e08530 100644 --- a/tests/projects/c++/static_library/xmake.lua +++ b/tests/projects/c++/static_library/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.debug", "mode.release") -target("test") +target("foo") set_kind("static") - add_files("src/interface.cpp") + add_files("src/foo.cpp") target("demo") set_kind("binary") - add_deps("test") + add_deps("foo") add_files("src/main.cpp") |
