mirror of
https://github.com/status-im/xgo.git
synced 2025-02-27 09:30:37 +00:00
Add some sample test codes to allow unit testing.
This commit is contained in:
parent
b27e6e194e
commit
7be9c29ba2
17
tests/embedded_c/main.go
Normal file
17
tests/embedded_c/main.go
Normal file
@ -0,0 +1,17 @@
|
||||
// Go cross compiler (xgo): Test file for embedded C snippets.
|
||||
// Copyright (c) 2015 Péter Szilágyi. All rights reserved.
|
||||
//
|
||||
// Released under the MIT license.
|
||||
|
||||
package main
|
||||
|
||||
// #include <stdio.h>
|
||||
//
|
||||
// void sayHi() {
|
||||
// printf("Hello, embedded C!\n");
|
||||
// }
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
C.sayHi()
|
||||
}
|
13
tests/embedded_cpp/main.go
Normal file
13
tests/embedded_cpp/main.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Go cross compiler (xgo): Test file for embedded C++ snippets.
|
||||
// Copyright (c) 2015 Péter Szilágyi. All rights reserved.
|
||||
//
|
||||
// Released under the MIT license.
|
||||
|
||||
package main
|
||||
|
||||
// #include "snippet.h"
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
C.sayHi()
|
||||
}
|
11
tests/embedded_cpp/snippet.cpp
Normal file
11
tests/embedded_cpp/snippet.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
// Go cross compiler (xgo): Test implementation for embedded C++ snippets.
|
||||
// Copyright (c) 2015 Péter Szilágyi. All rights reserved.
|
||||
//
|
||||
// Released under the MIT license.
|
||||
|
||||
#include <iostream>
|
||||
#include "snippet.h"
|
||||
|
||||
void sayHi() {
|
||||
std::cout << "Hello, embedded C++!" << std::endl;
|
||||
}
|
14
tests/embedded_cpp/snippet.h
Normal file
14
tests/embedded_cpp/snippet.h
Normal file
@ -0,0 +1,14 @@
|
||||
// Go cross compiler (xgo): Test header for embedded C++ snippets.
|
||||
// Copyright (c) 2015 Péter Szilágyi. All rights reserved.
|
||||
//
|
||||
// Released under the MIT license.
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void sayHi();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user