1
Fork 0

add unit test

nix
Motiejus Jakštys 2022-01-28 15:49:24 +02:00
parent 47f1b10370
commit 3d8cc9c38c
4 changed files with 18 additions and 4 deletions

View File

@ -19,6 +19,9 @@ tasks:
shellcheck -x $(awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(git ls-files))
bazel run //:buildifier
git diff --exit-code
- test_native: |
cd bazel-zig-cc; . .envrc
bazel test //...
- test_list_toolchains: |
cd bazel-zig-cc; . .envrc; echo "Available toolchains:"
bazel query @zig_sdk//... | sed -En '/.*_toolchain$/ s/.*:(.*)_toolchain$/\1/p'

View File

@ -18,7 +18,7 @@ go_binary(
)
go_test(
name = "test_test",
name = "hello_test",
srcs = ["hello_test.go"],
embed = [":test_lib"],
embed = [":hello_lib"],
)

View File

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