Skip to content

Commit 7be9c29

Browse files
committed
Add some sample test codes to allow unit testing.
1 parent b27e6e1 commit 7be9c29

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

tests/embedded_c/main.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Go cross compiler (xgo): Test file for embedded C snippets.
2+
// Copyright (c) 2015 Péter Szilágyi. All rights reserved.
3+
//
4+
// Released under the MIT license.
5+
6+
package main
7+
8+
// #include <stdio.h>
9+
//
10+
// void sayHi() {
11+
// printf("Hello, embedded C!\n");
12+
// }
13+
import "C"
14+
15+
func main() {
16+
C.sayHi()
17+
}

tests/embedded_cpp/main.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Go cross compiler (xgo): Test file for embedded C++ snippets.
2+
// Copyright (c) 2015 Péter Szilágyi. All rights reserved.
3+
//
4+
// Released under the MIT license.
5+
6+
package main
7+
8+
// #include "snippet.h"
9+
import "C"
10+
11+
func main() {
12+
C.sayHi()
13+
}

tests/embedded_cpp/snippet.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Go cross compiler (xgo): Test implementation for embedded C++ snippets.
2+
// Copyright (c) 2015 Péter Szilágyi. All rights reserved.
3+
//
4+
// Released under the MIT license.
5+
6+
#include <iostream>
7+
#include "snippet.h"
8+
9+
void sayHi() {
10+
std::cout << "Hello, embedded C++!" << std::endl;
11+
}

tests/embedded_cpp/snippet.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Go cross compiler (xgo): Test header for embedded C++ snippets.
2+
// Copyright (c) 2015 Péter Szilágyi. All rights reserved.
3+
//
4+
// Released under the MIT license.
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
void sayHi();
11+
12+
#ifdef __cplusplus
13+
}
14+
#endif

0 commit comments

Comments
 (0)