From f9f34844b49e357605d1a497651d532658d7e313 Mon Sep 17 00:00:00 2001 From: Suyash Kumar Date: Sun, 29 Sep 2024 17:16:10 -0400 Subject: [PATCH] Ensure #190 fixed --- write_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/write_test.go b/write_test.go index 56ca954..997b860 100644 --- a/write_test.go +++ b/write_test.go @@ -1,6 +1,7 @@ package dicom import ( + "fmt" "bytes" "encoding/binary" "errors" @@ -964,3 +965,33 @@ func TestWrite_OverrideMissingTransferSyntax(t *testing.T) { }) } } + +func MustNewValue(data interface{}) Value { + value, err := NewValue(data) + if err != nil { + panic(err) + } + + return value +} + +func ExampleIssue190() { + dataset := Dataset{ + Elements: []*Element{ + &Element{ + Tag: tag.SmallestImagePixelValue, + ValueRepresentation: tag.VRUInt16List, + RawValueRepresentation: "US", + ValueLength: 0, + Value: MustNewValue([]int{1}), + }, + }, + } + + buffer := new(bytes.Buffer) + err := Write(buffer, dataset, DefaultMissingTransferSyntax()) + if err != nil { + fmt.Printf("err: %v", err) + } + // Output: +}