gitlab.com/evatix-go/core@v1.3.55/tests/integratedtests/enumimpltests/Enum_test.go (about) 1 package enumimpltests 2 3 import ( 4 "testing" 5 6 . "github.com/smartystreets/goconvey/convey" 7 "gitlab.com/evatix-go/core/coreimpl/enumimpl/enumtype" 8 ) 9 10 func Test_Enum(t *testing.T) { 11 for _, testCase := range enumTestCases { 12 Convey(testCase.Header, t, func() { 13 switch testCase.EnumType { 14 case enumtype.Byte: 15 assertBasicByte(testCase) 16 case enumtype.Integer8: 17 assertBasicInteger8(testCase) 18 case enumtype.Integer16: 19 assertBasicInteger16(testCase) 20 case enumtype.Integer32: 21 assertBasicInteger32(testCase) 22 case enumtype.UnsignedInteger16: 23 assertBasicUnsignedInteger16(testCase) 24 case enumtype.String: 25 assertBasicString(testCase) 26 } 27 }) 28 } 29 } 30 31 func assertBasicString(testCase TestWrapper) { 32 // Arrange 33 enumImpl := testCase.EnumMap.BasicString("unknown type") 34 actualMin := enumImpl.Min() 35 actualMax := enumImpl.Max() 36 37 // Assert 38 So(actualMin, ShouldEqual, "") 39 So(actualMax, ShouldEqual, "Something2") // it depends on string max than number max 40 } 41 42 func assertBasicUnsignedInteger16(testCase TestWrapper) { 43 // Arrange 44 enumImpl := testCase.EnumMap.BasicUInt16("unknown type") 45 actualMin := enumImpl.Min() 46 actualMax := enumImpl.Max() 47 48 // Assert 49 So(actualMin, ShouldEqual, testCase.ExpectedMinMax.Min) 50 So(actualMax, ShouldEqual, testCase.ExpectedMinMax.Max) 51 } 52 53 func assertBasicInteger32(testCase TestWrapper) { 54 // Arrange 55 enumImplementation := testCase.EnumMap.BasicInt32("unknown type") 56 actualMin := enumImplementation.Min() 57 actualMax := enumImplementation.Max() 58 59 // Assert 60 So(actualMin, ShouldEqual, testCase.ExpectedMinMax.Min) 61 So(actualMax, ShouldEqual, testCase.ExpectedMinMax.Max) 62 } 63 64 func assertBasicInteger16(testCase TestWrapper) { 65 // Arrange 66 enumImplementation := testCase.EnumMap.BasicInt16("unknown type") 67 actualMin := enumImplementation.Min() 68 actualMax := enumImplementation.Max() 69 70 // Assert 71 So(actualMin, ShouldEqual, testCase.ExpectedMinMax.Min) 72 So(actualMax, ShouldEqual, testCase.ExpectedMinMax.Max) 73 } 74 75 func assertBasicInteger8(testCase TestWrapper) { 76 // Arrange 77 enumImplementation := testCase.EnumMap.BasicInt8("unknown type") 78 actualMin := enumImplementation.Min() 79 actualMax := enumImplementation.Max() 80 81 // Assert 82 So(actualMin, ShouldEqual, testCase.ExpectedMinMax.Min) 83 So(actualMax, ShouldEqual, testCase.ExpectedMinMax.Max) 84 } 85 86 func assertBasicByte(testCase TestWrapper) { 87 // Arrange 88 enumImplementation := testCase.EnumMap.BasicByte("unknown type") 89 actualMin := enumImplementation.Min() 90 actualMax := enumImplementation.Max() 91 92 // Assert 93 So(actualMin, ShouldEqual, testCase.ExpectedMinMax.Min) 94 So(actualMax, ShouldEqual, testCase.ExpectedMinMax.Max) 95 }