Commits

Miki Tebeka  committed b75445c

Start of demo

  • Participants
  • Parent commits 6d89f25

Comments (0)

Files changed (4)

 
 go2xunit
 README.html
+demo/gotest.out
+demo/jenkins.war
+demo/tests.xml

File demo/jenkins.sh

+#!/bin/bash
+# Test script run by jenkins
+
+outfile=gotest.out
+
+go test -v | tee $outfile
+go2xunit -fail -input $outfile -output tests.xml

File demo/mmath.go

+package mmath
+
+func Add(x, y int) int {
+	return x + y
+}
+
+func Sub(x, y int) int {
+	return x - y
+}
+
+func Mul(x, y int) int {
+	return x * y
+}
+
+func Div(x, y int) int {
+	return x / y
+}

File demo/mmath_test.go

+package mmath
+
+import (
+	"testing"
+)
+
+func TestAdd(t *testing.T) {
+	x, y := 1, 2
+	z := Add(x, y)
+	if z != x+y {
+		t.Fatalf("%d + %d != %d\n", x, y, x+y)
+	}
+}
+
+func TestSub(t *testing.T) {
+	x, y := 1, 2
+	z := Sub(x, y)
+	if z != x-y {
+		t.Fatalf("%d-%d != %d\n", x, y, x-y)
+	}
+}
+
+func TestMul(t *testing.T) {
+	x, y := 2, 3
+	z := Mul(x, y)
+	if z != x*y {
+		t.Fatalf("%d*%d != %d\n", x, y, x*y)
+	}
+}
+
+func TestDiv(t *testing.T) {
+	x, y := 2, 3
+	z := Div(x, y)
+	if float64(z) != float64(x)/float64(y) {
+		t.Fatalf("%d/%d != %f\n", x, y, float64(x)/float64(y))
+	}
+}