Skip to content

Commit

Permalink
hide capacity by default
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrre committed Jan 30, 2025
1 parent 0c880a1 commit dc0189a
Show file tree
Hide file tree
Showing 33 changed files with 140 additions and 31 deletions.
2 changes: 1 addition & 1 deletion _assertauto/Test/BytesHexDump/Default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]uint8] (len=400 cap=400)\n\t00000000 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000010 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000020 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000030 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000040 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000050 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000060 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000070 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000080 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000090 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000a0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000b0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000c0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000d0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000e0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000f0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000100 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000110 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000120 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000130 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000140 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000150 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000160 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000170 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000180 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n"
"value": "[[]uint8] (len=400)\n\t00000000 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000010 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000020 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000030 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000040 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000050 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000060 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000070 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000080 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000090 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000a0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000b0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000c0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000d0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000e0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000f0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000100 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000110 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000120 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000130 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000140 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000150 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000160 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000170 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000180 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/BytesHexDump/Disabled.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]uint8] (len=4 cap=4) {\n\t116,\n\t101,\n\t115,\n\t116,\n}"
"value": "[[]uint8] (len=4) {\n\t116,\n\t101,\n\t115,\n\t116,\n}"
}
},
{
Expand Down
18 changes: 18 additions & 0 deletions _assertauto/Test/BytesHexDump/ShowCap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"entries": [
{
"name": "result",
"equal": {
"type": "string",
"value": "[[]uint8] (len=4 cap=4)\n\t00000000 74 65 73 74 |test|\n"
}
},
{
"name": "allocs",
"allocs_per_run": {
"runs": 100,
"allocs": 0
}
}
]
}
2 changes: 1 addition & 1 deletion _assertauto/Test/BytesHexDump/Truncated.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]uint8] (len=4 cap=4)\n\t00000000 74 65 |te|\n\t<truncated>"
"value": "[[]uint8] (len=4)\n\t00000000 74 65 |te|\n\t<truncated>"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/BytesableHexDump/Default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[*pretty_test.testBytesable] => .Bytes() => (len=400 cap=400)\n\t00000000 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000010 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000020 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000030 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000040 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000050 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000060 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000070 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000080 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000090 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000a0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000b0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000c0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000d0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000e0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000f0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000100 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000110 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000120 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000130 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000140 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000150 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000160 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000170 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000180 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n"
"value": "[*pretty_test.testBytesable] => .Bytes() => (len=400)\n\t00000000 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000010 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000020 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000030 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000040 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000050 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000060 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000070 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000080 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000090 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000a0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000b0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000c0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000d0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000e0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t000000f0 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000100 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000110 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000120 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000130 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000140 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000150 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000160 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000170 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n\t00000180 74 65 73 74 74 65 73 74 74 65 73 74 74 65 73 74 |testtesttesttest|\n"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/BytesableHexDump/Disabled.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[*pretty_test.testBytesable] => {\n\tb: [[]uint8] (len=4 cap=4)\n\t\t00000000 74 65 73 74 |test|\n,\n}"
"value": "[*pretty_test.testBytesable] => {\n\tb: [[]uint8] (len=4)\n\t\t00000000 74 65 73 74 |test|\n,\n}"
}
},
{
Expand Down
18 changes: 18 additions & 0 deletions _assertauto/Test/BytesableHexDump/ShowCap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"entries": [
{
"name": "result",
"equal": {
"type": "string",
"value": "[*pretty_test.testBytesable] => .Bytes() => (len=4 cap=4)\n\t00000000 74 65 73 74 |test|\n"
}
},
{
"name": "allocs",
"allocs_per_run": {
"runs": 100,
"allocs": 0
}
}
]
}
2 changes: 1 addition & 1 deletion _assertauto/Test/BytesableHexDump/Truncated.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[*pretty_test.testBytesable] => .Bytes() => (len=4 cap=4)\n\t00000000 74 65 |te|\n\t<truncated>"
"value": "[*pretty_test.testBytesable] => .Bytes() => (len=4)\n\t00000000 74 65 |te|\n\t<truncated>"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Chan/Default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[chan int] (len=1 cap=5) "
"value": "[chan int] (len=1) "
}
},
{
Expand Down
18 changes: 18 additions & 0 deletions _assertauto/Test/Chan/ShowCap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"entries": [
{
"name": "result",
"equal": {
"type": "string",
"value": "[chan int] (len=1 cap=5) "
}
},
{
"name": "allocs",
"allocs_per_run": {
"runs": 100,
"allocs": 0
}
}
]
}
2 changes: 1 addition & 1 deletion _assertauto/Test/Chan/ShowElems.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[chan string] (len=3 cap=5) {\n\t(len=1) \"a\",\n\t(len=1) \"b\",\n\t(len=1) \"c\",\n}"
"value": "[chan string] (len=3) {\n\t(len=1) \"a\",\n\t(len=1) \"b\",\n\t(len=1) \"c\",\n}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Chan/ShowElemsClosed.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[chan string] (len=3 cap=5) {\n\t(len=1) \"a\",\n\t(len=1) \"b\",\n\t(len=1) \"c\",\n}"
"value": "[chan string] (len=3) {\n\t(len=1) \"a\",\n\t(len=1) \"b\",\n\t(len=1) \"c\",\n}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Chan/ShowElemsIndexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[chan string] (len=3 cap=5) {\n\t0: (len=1) \"a\",\n\t1: (len=1) \"b\",\n\t2: (len=1) \"c\",\n}"
"value": "[chan string] (len=3) {\n\t0: (len=1) \"a\",\n\t1: (len=1) \"b\",\n\t2: (len=1) \"c\",\n}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Chan/ShowElemsReadOnly.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[<-chan string] (len=3 cap=5) "
"value": "[<-chan string] (len=3) "
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Chan/ShowElemsTruncated.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[chan string] (len=3 cap=5) {\n\t(len=1) \"a\",\n\t(len=1) \"b\",\n\t<truncated>\n}"
"value": "[chan string] (len=3) {\n\t(len=1) \"a\",\n\t(len=1) \"b\",\n\t<truncated>\n}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Chan/ShowElemsWriteOnly.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[chan<- string] (len=3 cap=5) "
"value": "[chan<- string] (len=3) "
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Recursion/Slice.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]interface {}] (len=1 cap=1) {\n\t<recursion>,\n}"
"value": "[[]interface {}] (len=1) {\n\t<recursion>,\n}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Slice/Default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]int] (len=3 cap=3) {\n\t1,\n\t2,\n\t3,\n}"
"value": "[[]int] (len=3) {\n\t1,\n\t2,\n\t3,\n}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Slice/Empty.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]int] (len=0 cap=0) {}"
"value": "[[]int] (len=0) {}"
}
},
{
Expand Down
18 changes: 18 additions & 0 deletions _assertauto/Test/Slice/ShowCap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"entries": [
{
"name": "result",
"equal": {
"type": "string",
"value": "[[]int] (len=3 cap=3) {\n\t1,\n\t2,\n\t3,\n}"
}
},
{
"name": "allocs",
"allocs_per_run": {
"runs": 100,
"allocs": 0
}
}
]
}
2 changes: 1 addition & 1 deletion _assertauto/Test/Slice/ShowIndexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]int] (len=3 cap=3) {\n\t0: 1,\n\t1: 2,\n\t2: 3,\n}"
"value": "[[]int] (len=3) {\n\t0: 1,\n\t1: 2,\n\t2: 3,\n}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Slice/ShowKnownTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]int] (len=3 cap=3) {\n\t[int] 1,\n\t[int] 2,\n\t[int] 3,\n}"
"value": "[[]int] (len=3) {\n\t[int] 1,\n\t[int] 2,\n\t[int] 3,\n}"
}
},
{
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion _assertauto/Test/Slice/Truncated.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]int] (len=3 cap=3) {\n\t1,\n\t2,\n\t<truncated>\n}"
"value": "[[]int] (len=3) {\n\t1,\n\t2,\n\t<truncated>\n}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion _assertauto/Test/Slice/UnknownType.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "result",
"equal": {
"type": "string",
"value": "[[]interface {}] (len=3 cap=3) {\n\t[int] 1,\n\t[int] 2,\n\t[int] 3,\n}"
"value": "[[]interface {}] (len=3) {\n\t[int] 1,\n\t[int] 2,\n\t[int] 3,\n}"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type BytesHexDumpValueWriter struct {
// Default: true.
ShowLen bool
// ShowCap shows the cap.
// Default: true.
// Default: false.
ShowCap bool
// ShowAddr shows the address.
// Default: false.
Expand All @@ -35,7 +35,7 @@ type BytesHexDumpValueWriter struct {
func NewBytesHexDumpValueWriter() *BytesHexDumpValueWriter {
return &BytesHexDumpValueWriter{
ShowLen: true,
ShowCap: true,
ShowCap: false,
ShowAddr: false,
MaxLen: 0,
}
Expand Down Expand Up @@ -69,7 +69,7 @@ type BytesableHexDumpValueWriter struct {
// Default: true.
ShowLen bool
// ShowCap shows the cap.
// Default: true.
// Default: false.
ShowCap bool
// ShowAddr shows the address.
// Default: false.
Expand All @@ -83,7 +83,7 @@ type BytesableHexDumpValueWriter struct {
func NewBytesableHexDumpValueWriter() *BytesableHexDumpValueWriter {
return &BytesableHexDumpValueWriter{
ShowLen: true,
ShowCap: true,
ShowCap: false,
ShowAddr: false,
MaxLen: 0,
}
Expand Down
16 changes: 16 additions & 0 deletions bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ func init() {
},
ignoreBenchmark: true,
},
{
name: "ShowCap",
value: []byte("test"),
configure: func(vw *CommonValueWriter) {
vw.BytesHexDump.ShowCap = true
},
ignoreBenchmark: true,
},
{
name: "ShowAddr",
value: []byte("test"),
Expand Down Expand Up @@ -103,6 +111,14 @@ func init() {
},
ignoreBenchmark: true,
},
{
name: "ShowCap",
value: &testBytesable{b: []byte("test")},
configure: func(vw *CommonValueWriter) {
vw.BytesableHexDump.ShowCap = true
},
ignoreBenchmark: true,
},
{
name: "ShowAddr",
value: &testBytesable{b: []byte("test")},
Expand Down
4 changes: 2 additions & 2 deletions chan.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ChanValueWriter struct {
// Default: true.
ShowLen bool
// ShowCap shows the cap.
// Default: true.
// Default: false.
ShowCap bool
// ShowAddr shows the address.
// Default: false.
Expand All @@ -41,7 +41,7 @@ func NewChanValueWriter(vw ValueWriter) *ChanValueWriter {
return &ChanValueWriter{
ValueWriter: vw,
ShowLen: true,
ShowCap: true,
ShowCap: false,
ShowAddr: false,
ShowElems: false,
ShowIndexes: false,
Expand Down
12 changes: 12 additions & 0 deletions chan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ func init() {
value: chan int(nil),
ignoreBenchmark: true,
},
{
name: "ShowCap",
value: func() chan int {
c := make(chan int, 5)
c <- 123
return c
}(),
configure: func(vw *CommonValueWriter) {
vw.Kind.BaseChan.ShowCap = true
},
ignoreBenchmark: true,
},
{
name: "ShowAddr",
value: func() chan int {
Expand Down
3 changes: 2 additions & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ func (vw *CommonValueWriter) SetShowAddr(show bool) {
// ConfigureTest configures the [CommonValueWriter] for testing.
//
// It makes the result deterministic.
// It sorts the keys of maps and disables the address.
// It sorts the keys of maps and disables the address/capacity.
func (vw *CommonValueWriter) ConfigureTest() {
vw.Kind.BaseMap.SortKeys = true
vw.SetShowAddr(false)
vw.SetShowCap(false)
}

// WriteValue implements [ValueWriter].
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Example() {
// "bar": 2,
// "foo": 1,
// },
// Slice: [[]int] (len=3 cap=3) {
// Slice: [[]int] (len=3) {
// 1,
// 2,
// 3,
Expand Down
4 changes: 2 additions & 2 deletions slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type SliceValueWriter struct {
// Default: true.
ShowLen bool
// ShowCap shows the cap.
// Default: true.
// Default: false.
ShowCap bool
// ShowAddr shows the address.
// Default: false.
Expand All @@ -31,7 +31,7 @@ func NewSliceValueWriter(vw ValueWriter) *SliceValueWriter {
return &SliceValueWriter{
ValueWriter: vw,
ShowLen: true,
ShowCap: true,
ShowCap: false,
ShowAddr: false,
ShowIndexes: false,
MaxLen: 0,
Expand Down
Loading

0 comments on commit dc0189a

Please sign in to comment.