提交 e254c7a7 编写于 作者: L liaogang

add go unit test

上级 4dcb9f1c
......@@ -9,6 +9,10 @@ add_subdirectory(pserver)
add_subdirectory(trainer)
add_subdirectory(scripts)
if(${CMAKE_Go_COMPILER})
add_subdirectory(go)
endif()
find_package(Boost QUIET)
if(Boost_FOUND)
......
include_directories(${CMAKE_CURRENT_BINARY_DIR})
go_library(adder SRCS adder.go)
# cc_test(cgo_test
# SRCS
# cgo_test.cc
# DEPS
# adder)
add_executable(cgo_test cgo_test.cc)
add_dependencies(cgo_test adder)
target_link_libraries(cgo_test ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} adder)
add_test(cgo_test cgo_test)
package main
import "C"
//export GoAdder
func GoAdder(x, y int) int {
return x + y
}
func main() {} // Required but ignored
#include "libadder.h"
#include <iostream>
#include "gtest/gtest.h"
TEST(Cgo, Invoke) {
EXPECT_EQ(GoAdder(30, 12), 42);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册