aboutsummaryrefslogtreecommitdiff
path: root/object/id/algorithm_test.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-05-24 11:07:16 +0000
committerGravatar Runxi Yu2026-05-24 11:09:59 +0000
commit36340918040627d93808c09dea8d9bd7b7457f82 (patch)
treedab5fa0edbf2f2bf315d1fda73c0f7ac5c8fc6d9 /object/id/algorithm_test.go
parentinternal/testgit: Add Algorithm method (diff)
signatureNo signature
object/id: Rename algorithm to object format
Diffstat (limited to 'object/id/algorithm_test.go')
-rw-r--r--object/id/algorithm_test.go43
1 files changed, 0 insertions, 43 deletions
diff --git a/object/id/algorithm_test.go b/object/id/algorithm_test.go
deleted file mode 100644
index a596236a..00000000
--- a/object/id/algorithm_test.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package id_test
-
-import (
- "testing"
-
- "codeberg.org/lindenii/furgit/object/id"
-)
-
-func TestParseAlgorithm(t *testing.T) {
- t.Parallel()
-
- algo, ok := id.ParseAlgorithm("sha1")
- if !ok || algo != id.AlgorithmSHA1 {
- t.Fatalf("ParseAlgorithm(sha1) = (%v,%v)", algo, ok)
- }
-
- algo, ok = id.ParseAlgorithm("sha256")
- if !ok || algo != id.AlgorithmSHA256 {
- t.Fatalf("ParseAlgorithm(sha256) = (%v,%v)", algo, ok)
- }
-
- if _, ok := id.ParseAlgorithm("md5"); ok {
- t.Fatalf("ParseAlgorithm(md5) should fail")
- }
-}
-
-func TestAlgorithmSum(t *testing.T) {
- t.Parallel()
-
- id1 := id.AlgorithmSHA1.Sum([]byte("hello"))
- if id1.Algorithm() != id.AlgorithmSHA1 || id1.Algorithm().Size() != id.AlgorithmSHA1.Size() {
- t.Fatalf("sha1 sum produced invalid object id")
- }
-
- id2 := id.AlgorithmSHA256.Sum([]byte("hello"))
- if id2.Algorithm() != id.AlgorithmSHA256 || id2.Algorithm().Size() != id.AlgorithmSHA256.Size() {
- t.Fatalf("sha256 sum produced invalid object id")
- }
-
- if id1.String() == id2.String() {
- t.Fatalf("sha1 and sha256 should differ")
- }
-}