diff --git a/test/BUILD b/test/BUILD index 9a6de2e..00c2c02 100644 --- a/test/BUILD +++ b/test/BUILD @@ -1,5 +1,5 @@ load("//rules:rules_go.bzl", "go_binary") -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "hello_lib", @@ -16,3 +16,9 @@ go_binary( static = "on", visibility = ["//visibility:public"], ) + +go_test( + name = "test_test", + srcs = ["hello_test.go"], + embed = [":test_lib"], +) diff --git a/test/hello.go b/test/hello.go index c6489b9..6d042bd 100644 --- a/test/hello.go +++ b/test/hello.go @@ -5,9 +5,14 @@ import ( ) // #include -// void helloworld() { printf("hello, world\n"); } +// char* hello() { return "hello, world\n"; } +// void printhello() { printf(hello()); } import "C" func main() { - C.helloworld() + C.printhello() +} + +func chello() string { + return C.GoString(C.hello()) }