Skip to content

jsonpb: unexpected output for small negative google.protobuf.Duration (again) #1219

Closed
@AlekSi

Description

@AlekSi

What version of protobuf and what language are you using?
Version: v1.4.2

What did you do?
https://github.com/AlekSi/go-bug/tree/master/jsonpb

func TestDuration(t *testing.T) {
	d := -time.Nanosecond
	dp := ptypes.DurationProto(d)
	m := &jsonpb.Marshaler{}
	s, err := m.MarshalToString(dp)
	if err != nil {
		t.Fatal(err)
	}
	if s != `"-0.000000001s"` {
		t.Errorf("Unexpected result: %s", s)
	}
}

What did you expect to see?
"-0.000000001s"

What did you see instead?
Unexpected result: "0.-00000001s"

Anything else we should know about your project / environment?
Issue #883 is back for 1.4.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions