From 6491f45cfd5671ffff53068444aa3a3f9dba94d6 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 19 Apr 2016 16:38:15 +0200 Subject: Naming convention --- stack.go | 4 ++-- stack_test.go | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/stack.go b/stack.go index 1b7eb11..3c54937 100644 --- a/stack.go +++ b/stack.go @@ -4,8 +4,8 @@ package stack // Stack contains generic values type Stack []interface{} -// NewStack allocates a new Stack -func NewStack() Stack { +// New allocates a new Stack +func New() Stack { return Stack{} } diff --git a/stack_test.go b/stack_test.go index bdb5c0e..32637fa 100644 --- a/stack_test.go +++ b/stack_test.go @@ -3,7 +3,7 @@ package stack import "testing" func TestInt(t *testing.T) { - s := NewStack() + s := New() s.Push(1) i := s.Pop() if i != 1 { @@ -12,16 +12,16 @@ func TestInt(t *testing.T) { } func TestComplex(t *testing.T) { - s := NewStack() - s.Push(1+1i) + s := New() + s.Push(1 + 1i) i := s.Pop() if i != 1+1i { t.Error("Expected 1+1i, got ", i) } } -func TestMeny(t *testing.T) { - s := NewStack() +func TestMany(t *testing.T) { + s := New() s.Push(1) s.Push(2) i := s.Pop() @@ -35,7 +35,7 @@ func TestMeny(t *testing.T) { } func TestSwap(t *testing.T) { - s := NewStack() + s := New() s.Push(1) s.Push(2) s.Swap() @@ -53,7 +53,7 @@ func TestSwap(t *testing.T) { } func TestInsert(t *testing.T) { - s := NewStack() + s := New() s.Push(1) s.Insert(2) if s.Depth() != 2 { @@ -70,7 +70,7 @@ func TestInsert(t *testing.T) { } func BenchmarkPushPopSingle(b *testing.B) { - s := NewStack() + s := New() for i := 0; i < b.N; i++ { s.Push(1) s.Pop() @@ -78,7 +78,7 @@ func BenchmarkPushPopSingle(b *testing.B) { } func BenchmarkPushPopAlot(b *testing.B) { - s := NewStack() + s := New() for i := 0; i < b.N; i++ { s.Push(i) } @@ -88,7 +88,7 @@ func BenchmarkPushPopAlot(b *testing.B) { } func BenchmarkInsetPopSingle(b *testing.B) { - s := NewStack() + s := New() for i := 0; i < b.N; i++ { s.Insert(1) s.Pop() @@ -96,7 +96,7 @@ func BenchmarkInsetPopSingle(b *testing.B) { } func BenchmarkInsetPopAlot(b *testing.B) { - s := NewStack() + s := New() for i := 0; i < b.N; i++ { s.Insert(i) } -- cgit v1.2.3