MCPcopy Create free account
hub / github.com/OpenPrinting/goipp / TestValuesCopy

Function TestValuesCopy

value_test.go:957–1007  ·  view source on GitHub ↗

TestValuesCopy tests Values.Clone and Values.DeepCopy methods

(t *testing.T)

Source from the content-addressed store, hash-verified

955
956// TestValuesCopy tests Values.Clone and Values.DeepCopy methods
957func TestValuesCopy(t *testing.T) {
958 values := Values{}
959 values.Add(TagBoolean, Boolean(true))
960 values.Add(TagExtension, Binary{})
961 values.Add(TagString, Binary{1, 2, 3})
962 values.Add(TagInteger, Integer(123))
963 values.Add(TagEnum, Integer(-321))
964 values.Add(TagRange, Range{-100, 200})
965 values.Add(TagRange, Range{-100, -50})
966 values.Add(TagResolution, Resolution{150, 300, UnitsDpi})
967 values.Add(TagResolution, Resolution{100, 200, UnitsDpcm})
968 values.Add(TagResolution, Resolution{75, 150, 10})
969 values.Add(TagString, String("hello"))
970 values.Add(TagTextLang, TextWithLang{"en-US", "hello"})
971 values.Add(TagDateTime, Time{time.Now()})
972 values.Add(TagNoValue, Void{})
973 values.Add(TagBeginCollection,
974 Collection{MakeAttribute("test", TagString, String(""))})
975
976 type testData struct {
977 values Values
978 }
979
980 tests := []testData{
981 {nil},
982 {Values{}},
983 {values},
984 }
985
986 for _, test := range tests {
987 clone := test.values.Clone()
988 if !test.values.Equal(clone) {
989 t.Errorf("testing Attributes.Clone\n"+
990 "expected: %#v\n"+
991 "present: %#v\n",
992 test.values,
993 clone,
994 )
995 }
996
997 copy := test.values.DeepCopy()
998 if !test.values.Equal(copy) {
999 t.Errorf("testing Attributes.DeepCopy\n"+
1000 "expected: %#v\n"+
1001 "present: %#v\n",
1002 test.values,
1003 copy,
1004 )
1005 }
1006 }
1007}
1008
1009// TestIntegerOrRange tests IntegerOrRange interface implementation
1010// by Integer and Range types

Callers

nothing calls this directly

Calls 8

AddMethod · 0.95
BooleanTypeAlias · 0.85
IntegerTypeAlias · 0.85
StringTypeAlias · 0.85
MakeAttributeFunction · 0.85
DeepCopyMethod · 0.65
CloneMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected