github.com/google/trillian-examples@v0.0.0-20240520080811-0d40d35cef0e/binary_transparency/firmware/api/http_test.go (about)

     1  // Copyright 2020 Google LLC. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package api_test
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/google/trillian-examples/binary_transparency/firmware/api"
    21  	"github.com/transparency-dev/formats/log"
    22  )
    23  
    24  func TestLogCheckpointString(t *testing.T) {
    25  	for _, test := range []struct {
    26  		cp   api.LogCheckpoint
    27  		want string
    28  	}{
    29  		{
    30  			cp:   api.LogCheckpoint{},
    31  			want: "{size 0 @ 0 root: 0x}",
    32  		}, {
    33  			cp: api.LogCheckpoint{
    34  				Checkpoint: log.Checkpoint{
    35  					Size: 10,
    36  					Hash: []byte{0x12, 0x34, 0x56},
    37  				},
    38  				TimestampNanos: 234,
    39  			},
    40  			want: "{size 10 @ 234 root: 0x123456}",
    41  		},
    42  	} {
    43  		if got, want := test.cp.String(), test.want; got != want {
    44  			t.Errorf("got %q, want %q", got, want)
    45  		}
    46  	}
    47  }