Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 1, 2022
1 parent 62bf14a commit 90613a3
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 74 deletions.
5 changes: 5 additions & 0 deletions tests/projects/c++/shared_library/src/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "foo.h"

int add(int a, int b) {
return a + b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 0 additions & 6 deletions tests/projects/c++/shared_library/src/interface.cpp

This file was deleted.

7 changes: 3 additions & 4 deletions tests/projects/c++/shared_library/src/main.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 3 additions & 3 deletions tests/projects/c++/shared_library/xmake.lua
Original file line number Diff line number Diff line change
@@ -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")


5 changes: 5 additions & 0 deletions tests/projects/c++/static_library/src/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "foo.h"

int add(int a, int b) {
return a + b;
}
9 changes: 9 additions & 0 deletions tests/projects/c++/static_library/src/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef __cplusplus
extern "C" {
#endif

int add(int a, int b);

#ifdef __cplusplus
}
#endif
6 changes: 0 additions & 6 deletions tests/projects/c++/static_library/src/interface.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions tests/projects/c++/static_library/src/interface.h

This file was deleted.

7 changes: 3 additions & 4 deletions tests/projects/c++/static_library/src/main.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 3 additions & 3 deletions tests/projects/c++/static_library/xmake.lua
Original file line number Diff line number Diff line change
@@ -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")


5 changes: 5 additions & 0 deletions tests/projects/c/static_library/src/foo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "foo.h"

int add(int a, int b) {
return a + b;
}
2 changes: 2 additions & 0 deletions tests/projects/c/static_library/src/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int add(int a, int b);

6 changes: 0 additions & 6 deletions tests/projects/c/static_library/src/interface.c

This file was deleted.

9 changes: 0 additions & 9 deletions tests/projects/c/static_library/src/interface.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "interface.h"
#include "foo.h"
#include <stdio.h>

int main(int argc, char** argv)
{

int main(int argc, char** argv) {
printf("add(1, 2) = %d\n", add(1, 2));
return 0;
}
10 changes: 5 additions & 5 deletions tests/projects/c/static_library/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
add_rules("mode.release", "mode.debug")

target("static_library_c")
target("foo")
set_kind("static")
add_files("src/interface.c")
add_files("src/foo.c")

target("test")
target("demo")
set_kind("binary")
add_deps("static_library_c")
add_files("src/test.c")
add_deps("foo")
add_files("src/main.c")


0 comments on commit 90613a3

Please sign in to comment.