Skip to content

Commit

Permalink
fixed test output formmating
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjoshuak committed Aug 21, 2018
1 parent 8036fc6 commit 56a3cf0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -8,7 +8,7 @@


_**Note:** The C4 ID package has recently moved from `github.com/Avalanche-io/c4/id` to `github.com/Avalanche-io/c4`, and the API has been cleaned up considerably to perform better and and be easier to use. While deprecated the previous C4 ID API will continue to work and remain unchanged at the current `c4/id` path to give users time to switch._ _**Note:** The C4 ID package has recently moved from `github.com/Avalanche-io/c4/id` to `github.com/Avalanche-io/c4`, and the API has been cleaned up considerably to perform better and and be easier to use. While deprecated the previous C4 ID API will continue to work and remain unchanged at the current `c4/id` path to give users time to switch._


This is a Go package that implements the C4 ID system **SMPTE standard ST 2114:2017**. C4 IDs are a universally unique and consistent identifiers standardize the derivation and formatting of data identification so that all users independently agree on the identification of any given block or set of blocks of data. This is a Go package that implements the C4 ID system **SMPTE standard ST 2114:2017**. C4 IDs are universally unique and consistent identifiers that standardize the derivation and formatting of data identification so that all users independently agree on the identification of any block or set of blocks of data.


C4 IDs are 90 character long strings suitable for use in filenames, URLs, database fields, or anywhere else that a string identifier might normally be used. In ram C4 IDs are represented in a 64 byte "digest" format. C4 IDs are 90 character long strings suitable for use in filenames, URLs, database fields, or anywhere else that a string identifier might normally be used. In ram C4 IDs are represented in a 64 byte "digest" format.


Expand Down
2 changes: 1 addition & 1 deletion db/db_test.go
Expand Up @@ -138,7 +138,7 @@ func TestKeyApi(t *testing.T) {
count++ count++
} }
if count != len(sorted_keys) { if count != len(sorted_keys) {
t.Error("wrong number of keys returned %d of %d", count, len(sorted_keys)) t.Errorf("wrong number of keys returned %d of %d", count, len(sorted_keys))
} }


// We pick an arbitrary key, and trim it to create a prefix // We pick an arbitrary key, and trim it to create a prefix
Expand Down
24 changes: 12 additions & 12 deletions id/digest_test.go
Expand Up @@ -59,7 +59,7 @@ func TestIdentification(t *testing.T) {
for i, test := range test_vectors { for i, test := range test_vectors {
c4id := c4.Identify(bytes.NewReader([]byte(test))) c4id := c4.Identify(bytes.NewReader([]byte(test)))
if c4id.String() != test_vector_ids[0][i] { if c4id.String() != test_vector_ids[0][i] {
t.Error("IDs don't match, got %q expected %q", c4id.String(), test_vector_ids[0][i]) t.Errorf("IDs don't match, got %q expected %q", c4id.String(), test_vector_ids[0][i])
} }


} }
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestDigestSum(t *testing.T) {
} }


if id.String() != test_vector_ids[0][i] { if id.String() != test_vector_ids[0][i] {
t.Error("IDs don't match, got %q expected %q", id.String(), test_vector_ids[0][i]) t.Errorf("IDs don't match, got %q expected %q", id.String(), test_vector_ids[0][i])
} }


test_data = append(test_data, testDataType{s, id, test_vector_ids[0][i], dig}) test_data = append(test_data, testDataType{s, id, test_vector_ids[0][i], dig})
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestDigestSum(t *testing.T) {
// Check Sum produces the expected ID // Check Sum produces the expected ID


if bytes.Compare(testsum1, sum) != 0 { if bytes.Compare(testsum1, sum) != 0 {
t.Error("Digests don't match, got %q expected %q", testsum1, sum) t.Errorf("Digests don't match, got %q expected %q", testsum1, sum)
} }
// Check that Sum did not alter l, or r // Check that Sum did not alter l, or r
if bytes.Compare([]byte(r), rbytes) != 0 { if bytes.Compare([]byte(r), rbytes) != 0 {
Expand All @@ -178,7 +178,7 @@ func TestDigestSum(t *testing.T) {
testsum2 := c4.Digest(pair[:64]).Sum(pair[64:]) testsum2 := c4.Digest(pair[:64]).Sum(pair[64:])


if bytes.Compare(testsum2, sum) != 0 { if bytes.Compare(testsum2, sum) != 0 {
t.Error("IDs don't match, got %q expected %q", testsum2, sum) t.Errorf("IDs don't match, got %q expected %q", testsum2, sum)
} }


pair = pair[:0] pair = pair[:0]
Expand All @@ -203,20 +203,20 @@ func TestDigestSlice(t *testing.T) {
} }
t.Run("Order", func(t *testing.T) { t.Run("Order", func(t *testing.T) {
if len(digests) != len(test_vectors) { if len(digests) != len(test_vectors) {
t.Error("lengths do not match got %d, expected %d", len(digests), len(test_vectors)) t.Errorf("lengths do not match got %d, expected %d", len(digests), len(test_vectors))
} }
sorted_test_vector_ids := make([]string, len(test_vector_ids[0])) sorted_test_vector_ids := make([]string, len(test_vector_ids[0]))
copy(sorted_test_vector_ids, test_vector_ids[0]) copy(sorted_test_vector_ids, test_vector_ids[0])
sort.Strings(sorted_test_vector_ids) sort.Strings(sorted_test_vector_ids)
for i, idstring := range sorted_test_vector_ids { for i, idstring := range sorted_test_vector_ids {
if idstring != digests[i].ID().String() { if idstring != digests[i].ID().String() {
t.Error("IDs don't match, got %q expected %q", idstring, digests[i].ID().String()) t.Errorf("IDs don't match, got %q expected %q", idstring, digests[i].ID().String())
} }
} }


c4id := digests.Digest().ID() c4id := digests.Digest().ID()
if c4id.String() != "c435RzTWWsjWD1Fi7dxS3idJ7vFgPVR96oE95RfDDT5ue7hRSPENePDjPDJdnV46g7emDzWK8LzJUjGESMG5qzuXqq" { if c4id.String() != "c435RzTWWsjWD1Fi7dxS3idJ7vFgPVR96oE95RfDDT5ue7hRSPENePDjPDJdnV46g7emDzWK8LzJUjGESMG5qzuXqq" {
t.Error("IDs don't match, got %q expected %q", c4id.String(), "c435RzTWWsjWD1Fi7dxS3idJ7vFgPVR96oE95RfDDT5ue7hRSPENePDjPDJdnV46g7emDzWK8LzJUjGESMG5qzuXqq") t.Errorf("IDs don't match, got %q expected %q", c4id.String(), "c435RzTWWsjWD1Fi7dxS3idJ7vFgPVR96oE95RfDDT5ue7hRSPENePDjPDJdnV46g7emDzWK8LzJUjGESMG5qzuXqq")
} }
}) })


Expand All @@ -226,7 +226,7 @@ func TestDigestSlice(t *testing.T) {
copy(data[s*64:], []byte(digest)) copy(data[s*64:], []byte(digest))
} }
if len(data) != len(digests)*64 { if len(data) != len(digests)*64 {
t.Error("lengths do not match got %d, expected %d", len(data), len(digests)*64) t.Errorf("lengths do not match got %d, expected %d", len(data), len(digests)*64)
} }
test_data := make([]byte, len(digests)*64) test_data := make([]byte, len(digests)*64)
n, err := digests.Read(test_data) n, err := digests.Read(test_data)
Expand All @@ -235,7 +235,7 @@ func TestDigestSlice(t *testing.T) {
} }


if n != len(data) { if n != len(data) {
t.Error("lengths do not match got %d, expected %d", n, len(data)) t.Errorf("lengths do not match got %d, expected %d", n, len(data))
} }
if bytes.Compare(data, test_data) != 0 { if bytes.Compare(data, test_data) != 0 {
t.Errorf("data doesn't match") t.Errorf("data doesn't match")
Expand All @@ -247,10 +247,10 @@ func TestDigestSlice(t *testing.T) {
t.Errorf("unexpected error %q", err) t.Errorf("unexpected error %q", err)
} }
if n != len(data) { if n != len(data) {
t.Error("lengths do not match got %d, expected %d", n, len(data)) t.Errorf("lengths do not match got %d, expected %d", n, len(data))
} }
if len(digests) != len(digests2) { if len(digests) != len(digests2) {
t.Error("lengths do not match got %d, expected %d", len(digests), len(digests2)) t.Errorf("lengths do not match got %d, expected %d", len(digests), len(digests2))
} }
for i, digest := range digests { for i, digest := range digests {
if digest.ID().String() != digests2[i].ID().String() { if digest.ID().String() != digests2[i].ID().String() {
Expand All @@ -269,7 +269,7 @@ func TestDigest(t *testing.T) {
id := c4.Digest(b).ID() id := c4.Digest(b).ID()


if id.String() != `c467rpwLCuS5DGA8KGZXKsVQ7dnPb9goRLoKfgGbLfQg9WoLUgNY77E2jT11fem3coV9nAkguBACzrU1iyZM4B8roQ` { if id.String() != `c467rpwLCuS5DGA8KGZXKsVQ7dnPb9goRLoKfgGbLfQg9WoLUgNY77E2jT11fem3coV9nAkguBACzrU1iyZM4B8roQ` {
t.Error("IDs don't match, got %q expected %q", id.String(), `c467rpwLCuS5DGA8KGZXKsVQ7dnPb9goRLoKfgGbLfQg9WoLUgNY77E2jT11fem3coV9nAkguBACzrU1iyZM4B8roQ`) t.Errorf("IDs don't match, got %q expected %q", id.String(), `c467rpwLCuS5DGA8KGZXKsVQ7dnPb9goRLoKfgGbLfQg9WoLUgNY77E2jT11fem3coV9nAkguBACzrU1iyZM4B8roQ`)
} }


id2, err := c4.Parse(`c41111111111111111111111111111111111111111111111111111111111111111111111111111111111111121`) id2, err := c4.Parse(`c41111111111111111111111111111111111111111111111111111111111111111111111111111111111111121`)
Expand Down
2 changes: 1 addition & 1 deletion id/encoder_test.go
Expand Up @@ -73,7 +73,7 @@ func TestIDEncoderReset(t *testing.T) {
id1 := e.ID() id1 := e.ID()
id2 := e2.ID() id2 := e2.ID()
if id1.String() != id2.String() { if id1.String() != id2.String() {
t.Error("IDs don't match, got %q expected %q", id1.String(), id2.String()) t.Errorf("IDs don't match, got %q expected %q", id1.String(), id2.String())
} }
e.Reset() e.Reset()
} }
Expand Down

0 comments on commit 56a3cf0

Please sign in to comment.