Skip to content

Commit

Permalink
Merge pull request #22 from yassinebenaid/add-uintptr-support
Browse files Browse the repository at this point in the history
added support for uintptr
  • Loading branch information
yassinebenaid authored Jun 11, 2024
2 parents ce8edc1 + 464cd82 commit eccca31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type pointer struct {
pos int
tagged bool
}

type dumper struct {
buf []byte
theme theme
Expand Down Expand Up @@ -58,7 +59,9 @@ func (d *dumper) dump(v any, ignore_depth ...bool) {
d.write(d.theme.Number.apply(v.(string)))
case reflect.Invalid:
d.write(d.theme.Nil.apply("nil"))

case reflect.Uintptr:
v = fmt.Sprint(reflect.ValueOf(v).Uint())
d.write(d.theme.Number.apply(v.(string)))
}
}

Expand Down
4 changes: 2 additions & 2 deletions dumper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ func TestDumperWithComplexDataStructure(t *testing.T) {
for i, line := range e_lines {
if len(line) != len(r_lines[i]) {
t.Fatalf(`mismatche at line %d:
- "%s"
+ "%s"`, i, line, r_lines[i])
--- "%s"
+++ "%s"`, i+1, line, r_lines[i])
}

for j, ch := range line {
Expand Down
14 changes: 7 additions & 7 deletions testdata/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Uint16Field: 300,
Uint32Field: 400,
Uint64Field: 500,
UintptrField: ,
UintptrField: 600,
Float32Field: 123.45600128173828,
Float64Field: 789.012,
Complex64Field: (1+2i),
Expand All @@ -28,7 +28,7 @@
Uint16Field: 1300,
Uint32Field: 1400,
Uint64Field: 1500,
UintptrField: ,
UintptrField: 1600,
Float32Field: 223.45599365234375,
Float64Field: 1789.012,
Complex64Field: (2+3i),
Expand Down Expand Up @@ -109,7 +109,7 @@
Uint16Field: 2300,
Uint32Field: 2400,
Uint64Field: 2500,
UintptrField: ,
UintptrField: 2600,
Float32Field: 323.45599365234375,
Float64Field: 2789.012,
Complex64Field: (3+4i),
Expand Down Expand Up @@ -211,7 +211,7 @@
Uint16Field: 3300,
Uint32Field: 3400,
Uint64Field: 3500,
UintptrField: ,
UintptrField: 3600,
Float32Field: 423.45599365234375,
Float64Field: 3789.012,
Complex64Field: (4+5i),
Expand All @@ -230,7 +230,7 @@
Uint16Field: 4300,
Uint32Field: 4400,
Uint64Field: 4500,
UintptrField: ,
UintptrField: 4600,
Float32Field: 523.4559936523438,
Float64Field: 4789.012,
Complex64Field: (5+6i),
Expand Down Expand Up @@ -299,7 +299,7 @@
Uint16Field: 5300,
Uint32Field: 5400,
Uint64Field: 5500,
UintptrField: ,
UintptrField: 5600,
Float32Field: 623.4559936523438,
Float64Field: 5789.012,
Complex64Field: (6+7i),
Expand All @@ -318,7 +318,7 @@
Uint16Field: 6300,
Uint32Field: 6400,
Uint64Field: 6500,
UintptrField: ,
UintptrField: 6600,
Float32Field: 723.4559936523438,
Float64Field: 6789.012,
Complex64Field: (7+8i),
Expand Down

0 comments on commit eccca31

Please sign in to comment.