forked from chaos-mesh/chaos-mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automatically calculate duration (chaos-mesh#375)
- Loading branch information
Showing
9 changed files
with
66 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package timechaos | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
type SecAndNSecFromDurationTestCase struct { | ||
Duration time.Duration | ||
Sec int64 | ||
NSec int64 | ||
} | ||
|
||
func TestSecAndNSecFromDuration(t *testing.T) { | ||
g := NewGomegaWithT(t) | ||
cases := []SecAndNSecFromDurationTestCase{ | ||
{time.Second * 100, 100, 0}, | ||
{time.Second * -100, -100, 0}, | ||
{time.Second*-100 + time.Microsecond*-20, -100, -20000}, | ||
{time.Second*-100 + time.Microsecond*20, -99, -999980000}, | ||
{time.Second*100 + time.Microsecond*20, 100, 20000}, | ||
{time.Second*100 + time.Microsecond*-20, 99, 999980000}, | ||
} | ||
|
||
for _, c := range cases { | ||
sec, nsec := secAndNSecFromDuration(c.Duration) | ||
g.Expect(sec).Should(Equal(c.Sec)) | ||
g.Expect(nsec).Should(Equal(c.NSec)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters