diff options
| author | Yuichi Watanabe <[email protected]> | 2020-07-30 21:07:05 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-07-30 05:07:05 -0700 |
| commit | 462ebd83e0ccba9cd93c05ec12dc3d98064e3d5c (patch) | |
| tree | 8dffde8f4ee95359aa8a03b10840da9598f06029 /blob_test.go | |
| parent | d8f9990d4d0af1f80c13aa3ff256b004c7cadc46 (diff) | |
Add support for git_blob_is_binary (#625)
This adds IsBinary() func to Blob struct, which simply returns the result of git_blob_is_binary function.
Refs: https://libgit2.org/libgit2/#HEAD/group/blob/git_blob_is_binary
Issue: Add support for git_blob_is_binary #426
Fixes: #426
Diffstat (limited to 'blob_test.go')
| -rw-r--r-- | blob_test.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/blob_test.go b/blob_test.go index 815ab3d..2ab1291 100644 --- a/blob_test.go +++ b/blob_test.go @@ -28,7 +28,21 @@ func TestCreateBlobFromBuffer(t *testing.T) { t.Fatal("Empty buffer did not deliver empty blob id") } - for _, data := range []([]byte){[]byte("hello there"), doublePointerBytes()} { + tests := []struct { + data []byte + isBinary bool + }{ + { + data: []byte("hello there"), + isBinary: false, + }, + { + data: doublePointerBytes(), + isBinary: true, + }, + } + for _, tt := range tests { + data := tt.data id, err = repo.CreateBlobFromBuffer(data) checkFatal(t, err) @@ -38,5 +52,9 @@ func TestCreateBlobFromBuffer(t *testing.T) { t.Fatal("Loaded bytes don't match original bytes:", blob.Contents(), "!=", data) } + want := tt.isBinary + if got := blob.IsBinary(); got != want { + t.Fatalf("IsBinary() = %v, want %v", got, want) + } } } |
