-
-
Notifications
You must be signed in to change notification settings - Fork 156
feat(parser): support transfer syntax inference when parsing small DICOM fragments (<100 bytes) #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mlibanori
wants to merge
6
commits into
suyashkumar:main
Choose a base branch
from
mlibanori:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(parser): support transfer syntax inference when parsing small DICOM fragments (<100 bytes) #347
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fad79ea
feat(parser): support parsing DICOM messages with less than 100 bytes
mlibanori 2082411
fix(dicomio/reader.go) ensure error is returned when no bytes are rea…
mlibanori 6cb4d9d
test: add unit tests for PeekAtMost
mlibanori ae3563d
test: improve readability of TestParse_CEchoRQ
mlibanori 5f39697
doc: Improve documentation for TestParse_CEchoRQ test
mlibanori e3e37e1
refact: Adjust tests to conform to project standards
mlibanori File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package dicomio | ||
|
|
||
| import ( | ||
| "bufio" | ||
| "encoding/binary" | ||
| "errors" | ||
| "io" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestReader_PeekAtMost(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| data string | ||
| peekCount int | ||
| wantData string | ||
| wantErr error | ||
| }{ | ||
| { | ||
| name: "peek_valid_count_within_buffer", | ||
| data: "abcdefghijklmnop", | ||
| peekCount: 3, | ||
| wantData: "abc", | ||
| wantErr: nil, | ||
| }, | ||
| { | ||
| name: "peek_zero_bytes", | ||
| data: "abcdefghijklmnop", | ||
| peekCount: 0, | ||
| wantData: "", | ||
| wantErr: nil, | ||
| }, | ||
| { | ||
| name: "peek_negative_count_returns_error", | ||
| data: "abcdefghijklmnop", | ||
| peekCount: -1, | ||
| wantData: "", | ||
| wantErr: bufio.ErrNegativeCount, | ||
| }, | ||
| { | ||
| name: "peek_count_larger_than_available_data", | ||
| data: "abcdefghijklmnop", | ||
| peekCount: 32, | ||
| wantData: "abcdefghijklmnop", | ||
| wantErr: nil, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| buf := bufio.NewReaderSize(strings.NewReader(tt.data), 16) | ||
| r := NewReader(buf, binary.LittleEndian, 0) | ||
|
|
||
| data, err := r.PeekAtMost(tt.peekCount) | ||
|
|
||
| if !errors.Is(err, tt.wantErr) { | ||
| t.Errorf("got error %v, want %v", err, tt.wantErr) | ||
| } | ||
|
|
||
| if string(data) != tt.wantData { | ||
| t.Errorf("got data %q, want %q", string(data), tt.wantData) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestReader_PeekAtMost_AfterConsumingAllData(t *testing.T) { | ||
| buf := bufio.NewReaderSize(strings.NewReader("abcdefghijklmnop"), 16) | ||
| r := NewReader(buf, binary.LittleEndian, 0) | ||
|
|
||
| // Consume all data | ||
| n, err := r.in.Read(make([]byte, 16)) | ||
| if n != 16 || err != nil { | ||
| t.Fatalf("failed to consume all data: got %d bytes, err=%v", n, err) | ||
| } | ||
| // Now try to peek - should return empty slice with EOF error | ||
| data, err := r.PeekAtMost(1) | ||
| if len(data) != 0 || !errors.Is(err, io.EOF) { | ||
| t.Errorf("got len=%d, err=%v, want len=0, err=EOF", len(data), err) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.