Skip to content

Commit

Permalink
Add some sample test codes to allow unit testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed Sep 16, 2015
1 parent b27e6e1 commit 7be9c29
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/embedded_c/main.go
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions tests/embedded_cpp/main.go
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions tests/embedded_cpp/snippet.cpp
Original file line number Diff line number Diff line change
@@ -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 changes: 14 additions & 0 deletions tests/embedded_cpp/snippet.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7be9c29

Please sign in to comment.