Add some sample test codes to allow unit testing.

This commit is contained in:
Péter Szilágyi 2015-09-16 11:29:40 +03:00
parent b27e6e194e
commit 7be9c29ba2
4 changed files with 55 additions and 0 deletions

17
tests/embedded_c/main.go Normal file
View 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()
}

View 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()
}

View 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;
}

View 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