Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

sapin_test.gno

2.13 Kb · 132 lines
  1package sapin
  2
  3import (
  4	"fmt"
  5	"testing"
  6)
  7
  8func TestSapin(t *testing.T) {
  9	tt := []struct {
 10		size int
 11		want string
 12	}{
 13		{1, `
 14   *
 15  ***
 16 *****
 17*******
 18  |||
 19`},
 20		{2, `
 21      *
 22     ***
 23    *****
 24   *******
 25    *****
 26   *******
 27  *********
 28 ***********
 29*************
 30     |||
 31     |||
 32`},
 33		{3, `
 34         *
 35        ***
 36       *****
 37      *******
 38       *****
 39      *******
 40     *********
 41    ***********
 42   *************
 43     *********
 44    ***********
 45   *************
 46  ***************
 47 *****************
 48*******************
 49        |||
 50        |||
 51        |||
 52`},
 53		{4, `
 54            *
 55           ***
 56          *****
 57         *******
 58          *****
 59         *******
 60        *********
 61       ***********
 62      *************
 63        *********
 64       ***********
 65      *************
 66     ***************
 67    *****************
 68   *******************
 69      *************
 70     ***************
 71    *****************
 72   *******************
 73  *********************
 74 ***********************
 75*************************
 76           |||
 77           |||
 78           |||
 79           |||
 80`},
 81		{5, `
 82               *
 83              ***
 84             *****
 85            *******
 86             *****
 87            *******
 88           *********
 89          ***********
 90         *************
 91           *********
 92          ***********
 93         *************
 94        ***************
 95       *****************
 96      *******************
 97         *************
 98        ***************
 99       *****************
100      *******************
101     *********************
102    ***********************
103   *************************
104       *****************
105      *******************
106     *********************
107    ***********************
108   *************************
109  ***************************
110 *****************************
111*******************************
112              |||
113              |||
114              |||
115              |||
116              |||
117`},
118		// {50, ``},
119		// {51, ``},
120	}
121
122	for _, tc := range tt {
123		name := fmt.Sprintf("%d", tc.size)
124		t.Run(name, func(t *testing.T) {
125			got := Sapin(tc.size)
126			want := tc.want[1:]
127			if got != want {
128				t.Errorf("expected \n%s\n, got \n%s\n.", want, got)
129			}
130		})
131	}
132}