Commit b207087a authored by Boris Mühmer's avatar Boris Mühmer
Browse files

expanded types and added unit tests

parent 9c1fad01
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -3,9 +3,18 @@ package cross
// Cross ...
type Cross struct{}

const (
	symbolCross = "×"
)

// NewCross creates a new cross.
func NewCross() *Cross {
	return &Cross{}
}

// Symbol ...
func (c *Cross) Symbol() string {
	return "×"
	return symbolCross
}

// IsEmpty ...
+20 −0
Original line number Diff line number Diff line
package cross

import (
	"testing"
)

func TestCross(t *testing.T) {
	c := NewCross()
	if s := c.Symbol(); s != symbolCross {
		t.Errorf("c.Symbol() is \"%s\", expected \"%s\"", s, symbolCross)
	}
	if f := c.IsEmpty(); f != false {
		t.Errorf("c.IsEmpty() is %t, expected %t", f, false)
	}
	if f := c.IsNought(); f != false {
		t.Errorf("c.IsNought() is %t, expected %t", f, false)
	}
	if f := c.IsCross(); f != true {
		t.Errorf("c.IsCross() is %t, expected %t", f, true)
	}
}
+10 −1
Original line number Diff line number Diff line
@@ -3,9 +3,18 @@ package empty
// Empty ...
type Empty struct{}

const (
	symbolEmpty = " "
)

// NewEmpty ...
func NewEmpty() *Empty {
	return &Empty{}
}

// Symbol ...
func (e *Empty) Symbol() string {
	return " "
	return symbolEmpty
}

// IsEmpty ...
+20 −0
Original line number Diff line number Diff line
package empty

import (
	"testing"
)

func TestEmpty(t *testing.T) {
	c := NewEmpty()
	if s := c.Symbol(); s != symbolEmpty {
		t.Errorf("c.Symbol() is \"%s\", expected \"%s\"", s, symbolEmpty)
	}
	if f := c.IsEmpty(); f != true {
		t.Errorf("c.IsEmpty() is %t, expected %t", f, true)
	}
	if f := c.IsNought(); f != false {
		t.Errorf("c.IsNought() is %t, expected %t", f, false)
	}
	if f := c.IsCross(); f != false {
		t.Errorf("c.IsCross() is %t, expected %t", f, false)
	}
}
+10 −1
Original line number Diff line number Diff line
@@ -3,9 +3,18 @@ package nought
// Nought ...
type Nought struct{}

const (
	symbolNought = "○"
)

// NewNought ...
func NewNought() *Nought {
	return &Nought{}
}

// Symbol ...
func (n *Nought) Symbol() string {
	return "○"
	return symbolNought
}

// IsEmpty ...
Loading