gitlab.com/evatix-go/core@v1.3.55/tests/testwrappers/coredynamictestwrappers/ReflectSetFromToValidTestCases.go (about)

     1  package coredynamictestwrappers
     2  
     3  import (
     4  	"gitlab.com/evatix-go/core/coretests"
     5  )
     6  
     7  var (
     8  	ReflectSetFromToTestCasesDraftTypeInput = coretests.DraftType{
     9  		SampleString1: "Same data",
    10  		SampleString2: "",
    11  		SampleInteger: 0,
    12  	}
    13  	ReflectSetFromToTestCasesDraftTypeExpected = coretests.DraftType{
    14  		SampleString1: "Expected",
    15  		SampleString2: "",
    16  		SampleInteger: 0,
    17  	}
    18  
    19  	nilBytes        []byte  = nil
    20  	nilBytesPointer *[]byte = nil
    21  
    22  	ReflectSetFromToValidTestCases = []ReflectSetFromToTestWrapper{
    23  		{
    24  			Header: "(null, null) -- do nothing -- " +
    25  				"From `Null` to `Null` -- does nothing -- no error",
    26  		},
    27  		{
    28  			Header: "(sameTypePointer, sameTypePointer) -- try reflection -- " +
    29  				"From `*ReflectSetFromToTestWrapper{Expected}` " +
    30  				"to   `*ReflectSetFromToTestWrapper{Sample data}` should set to Expected. ",
    31  			From: &ReflectSetFromToTestCasesDraftTypeExpected,
    32  			To: &coretests.DraftType{
    33  				SampleString1: "Same data",
    34  			},
    35  			ExpectedValue: &ReflectSetFromToTestCasesDraftTypeExpected,
    36  		},
    37  		{
    38  			Header: "(sameTypeNonPointer, sameTypePointer) -- try reflection -- " +
    39  				"From `ReflectSetFromToTestWrapper{Expected}` " +
    40  				"to   `*ReflectSetFromToTestWrapper{Sample data}` should set to Expected.",
    41  			From: ReflectSetFromToTestCasesDraftTypeExpected,
    42  			To: &coretests.DraftType{
    43  				SampleString1: "Sample data",
    44  			},
    45  			ExpectedValue: &ReflectSetFromToTestCasesDraftTypeExpected,
    46  		},
    47  		{
    48  			Header: "(*[]byte, otherType) -- try unmarshal, reflect -- " +
    49  				"From `*[]bytes(ReflectSetFromToTestWrapper{Expected}` " +
    50  				"to   `*ReflectSetFromToTestWrapper{Sample data}` should set to Expected.",
    51  			From: ReflectSetFromToTestCasesDraftTypeExpected.JsonBytesPtr(),
    52  			To: &coretests.DraftType{
    53  				SampleString1: "Sample data",
    54  			},
    55  			ExpectedValue: &ReflectSetFromToTestCasesDraftTypeExpected,
    56  		},
    57  		{
    58  			Header: "(otherType, *[]byte) -- try marshal, reflect -- " +
    59  				"From `ReflectSetFromToTestWrapper{Expected}` " +
    60  				"to   `*[]byte{}` should set to Expected.",
    61  			From:          ReflectSetFromToTestCasesDraftTypeExpected.JsonBytesPtr(),
    62  			To:            &[]byte{},
    63  			ExpectedValue: ReflectSetFromToTestCasesDraftTypeExpected.JsonBytesPtr(),
    64  		},
    65  	}
    66  )