Skip to content

Commit 8989fa5

Browse files
Modified output format of values.TagID
1 parent 050a75a commit 8989fa5

File tree

7 files changed

+27
-36
lines changed

7 files changed

+27
-36
lines changed

cli/gpgpdump/facade/facade_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ T1ZprZqwRPOjiLJg9AwA/ArTwCPz7c2vmxlv7sRlRLUI6CdsOqhuO1KfYXrq7idI
2323

2424
var (
2525
resdataFromBindata1 = `[[Packet]]
26-
name = "Packet"
27-
value = "Marker Packet (Obsolete Literal Packet) (tag 10)"
26+
name = "Marker Packet (Obsolete Literal Packet) (tag 10)"
2827
note = "3 bytes"
2928
3029
[[Packet.Item]]
3130
name = "Literal data"
3231
note = "3 bytes"
3332
3433
[[Packet]]
35-
name = "Packet"
36-
value = "Symmetric-Key Encrypted Session Key Packet (tag 3)"
34+
name = "Symmetric-Key Encrypted Session Key Packet (tag 3)"
3735
note = "4 bytes"
3836
3937
[[Packet.Item]]
@@ -54,8 +52,7 @@ var (
5452
value = "MD5 (hash 1)"
5553
5654
[[Packet]]
57-
name = "Packet"
58-
value = "Symmetrically Encrypted Data Packet (tag 9)"
55+
name = "Symmetrically Encrypted Data Packet (tag 9)"
5956
note = "56 bytes"
6057
6158
[[Packet.Item]]
@@ -67,8 +64,7 @@ var (
6764
note = "55 bytes"
6865
`
6966
resdataFromAscdata1 = `[[Packet]]
70-
name = "Packet"
71-
value = "Signature Packet (tag 2)"
67+
name = "Signature Packet (tag 2)"
7268
note = "94 bytes"
7369
7470
[[Packet.Item]]

cli/gpgpdump/facade/json_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import (
1010
var resJSON = `{
1111
"Packet": [
1212
{
13-
"name": "Packet",
14-
"value": "Marker Packet (Obsolete Literal Packet) (tag 10)",
13+
"name": "Marker Packet (Obsolete Literal Packet) (tag 10)",
1514
"note": "3 bytes",
1615
"Item": [
1716
{
@@ -21,8 +20,7 @@ var resJSON = `{
2120
]
2221
},
2322
{
24-
"name": "Packet",
25-
"value": "Symmetric-Key Encrypted Session Key Packet (tag 3)",
23+
"name": "Symmetric-Key Encrypted Session Key Packet (tag 3)",
2624
"note": "4 bytes",
2725
"Item": [
2826
{
@@ -47,8 +45,7 @@ var resJSON = `{
4745
]
4846
},
4947
{
50-
"name": "Packet",
51-
"value": "Symmetrically Encrypted Data Packet (tag 9)",
48+
"name": "Symmetrically Encrypted Data Packet (tag 9)",
5249
"note": "56 bytes",
5350
"Item": [
5451
{

packet/parser_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ const (
2525
result2 = `{
2626
"Packet": [
2727
{
28-
"name": "Packet",
29-
"value": "Signature Packet (tag 2)",
28+
"name": "Signature Packet (tag 2)",
3029
"dump": "04 01 13 08 00 06 05 02 54 c3 08 df 00 0a 09 10 31 fb fd a9 5f bb fa 18 36 1f 01 00 ea 1d a2 14 5b 82 06 fd d5 ae c4 9f d8 14 44 41 a4 f5 4f 56 69 ad 9a b0 44 f3 a3 88 b2 60 f4 0c 00 fc 0a d3 c0 23 f3 ed cd af 9b 19 6f ee c4 65 44 b5 08 e8 27 6c 3a a8 6e 3b 52 9f 61 7a ea ee 27 48",
3130
"note": "94 bytes",
3231
"Item": [

packet/tags/tags_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ func TestTag01(t *testing.T) {
2727
t.Errorf("NewTag() = %v, want nil error.", err)
2828
return
2929
}
30-
if i.Name != "Packet" {
31-
t.Errorf("Tag.Name = \"%s\", want \"Packet\".", i.Name)
30+
if i.Name != tag01Name {
31+
t.Errorf("Tag.Value = \"%s\", want \"%s\".", i.Name, tag01Name)
3232
}
33-
if i.Value != tag01Name {
34-
t.Errorf("Tag.Value = \"%s\", want \"%s\".", i.Value, tag01Name)
33+
if i.Value != "" {
34+
t.Errorf("Tag.Name = \"%s\", want \"\".", i.Value)
3535
}
3636
if i.Note != "126 bytes" {
3737
t.Errorf("Tag.Note = \"%s\", want \"126 bytes\"", i.Note)
@@ -49,11 +49,11 @@ func TestTag02(t *testing.T) {
4949
t.Errorf("NewTag() = %v, want nil error.", err)
5050
return
5151
}
52-
if i.Name != "Packet" {
53-
t.Errorf("Tag.Name = \"%s\", want \"Packet\".", i.Name)
52+
if i.Name != tag02Name {
53+
t.Errorf("Tag.Value = \"%s\", want \"%s\".", i.Name, tag02Name)
5454
}
55-
if i.Value != tag02Name {
56-
t.Errorf("Tag.Value = \"%s\", want \"%s\".", i.Value, tag02Name)
55+
if i.Value != "" {
56+
t.Errorf("Tag.Name = \"%s\", want \"\".", i.Value)
5757
}
5858
if i.Note != "94 bytes" {
5959
t.Errorf("Tag.Note = \"%s\", want \"94 bytes\"", i.Note)
@@ -74,11 +74,11 @@ func TestTagUnknown(t *testing.T) {
7474
t.Errorf("NewTag() = %v, want nil error.", err)
7575
return
7676
}
77-
if i.Name != "Packet" {
78-
t.Errorf("Tag.Name = \"%s\", want \"Packet\".", i.Name)
77+
if i.Name != name {
78+
t.Errorf("Tag.Name = \"%s\", want \"%s\".", i.Name, name)
7979
}
80-
if i.Value != name {
81-
t.Errorf("Tag.Value = \"%s\", want \"%s\".", i.Value, name)
80+
if i.Value != "" {
81+
t.Errorf("Tag.Value = \"%s\", want \"\".", i.Value)
8282
}
8383
if i.Note != "4 bytes" {
8484
t.Errorf("Tag.Note = \"%s\", want \"4 bytes\"", i.Note)

packet/values/tagid.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ type TagID int
3838
// ToItem returns Item instance
3939
func (t TagID) ToItem(r *reader.Reader, dumpFlag bool) *info.Item {
4040
return info.NewItem(
41-
info.Name("Packet"),
42-
info.Value(t.String()),
41+
info.Name(t.String()),
4342
info.Note(fmt.Sprintf("%d bytes", r.Len())),
4443
info.DumpStr(Dump(r, dumpFlag).String()),
4544
)

packet/values/tagid_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ func TestTagID(t *testing.T) {
7878
var body = []byte{0x01, 0x02, 0x03, 0x04}
7979
for tag := 0; tag <= 64; tag++ {
8080
i := TagID(tag).ToItem(reader.New(body), true)
81-
if i.Name != "Packet" {
82-
t.Errorf("Tag.Name = \"%s\", want \"Packet\".", i.Name)
81+
if i.Name != testTagNames[tag] {
82+
t.Errorf("Tag.Name = \"%s\", want \"%s\".", i.Name, testTagNames[tag])
8383
}
84-
if i.Value != testTagNames[tag] {
85-
t.Errorf("Tag.Value = \"%s\", want \"%s\".", i.Value, testTagNames[tag])
84+
if i.Value != "" {
85+
t.Errorf("Tag.Value = \"%s\", want \"\".", i.Name)
8686
}
8787
if i.Note != "4 bytes" {
8888
t.Errorf("Tag.Note = \"%s\", want \"4 bytes\"", i.Note)

parse_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func ExampleParse() {
3030
if err != nil {
3131
return
3232
}
33-
fmt.Println(info.Packets[0].Value)
33+
fmt.Println(info.Packets[0].Name)
3434
// Output:
3535
// Signature Packet (tag 2)
3636
}
@@ -40,7 +40,7 @@ func ExampleParseByte() {
4040
if err != nil {
4141
return
4242
}
43-
fmt.Println(info.Packets[0].Value)
43+
fmt.Println(info.Packets[0].Name)
4444
// Output:
4545
// Signature Packet (tag 2)
4646
}

0 commit comments

Comments
 (0)