add unit test
This commit is contained in:
@@ -18,7 +18,7 @@ go_binary(
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "test_test",
|
||||
name = "hello_test",
|
||||
srcs = ["hello_test.go"],
|
||||
embed = [":test_lib"],
|
||||
embed = [":hello_lib"],
|
||||
)
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
)
|
||||
|
||||
// #include <stdio.h>
|
||||
// char* hello() { return "hello, world\n"; }
|
||||
// void printhello() { printf(hello()); }
|
||||
// char* hello() { return "hello, world"; }
|
||||
// void printhello() { printf("%s\n", hello()); }
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
|
||||
11
test/hello_test.go
Normal file
11
test/hello_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHello(t *testing.T) {
|
||||
want := "hello, world"
|
||||
got := chello()
|
||||
if got != want {
|
||||
t.Errorf("expected %q, got %q", want, got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user