summaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2023-02-17 12:14:21 +0600
committerGrail Finder <wohilas@gmail.com>2023-02-17 12:14:21 +0600
commitdf498c756b1cb0e3f045bc88396223272b713a4c (patch)
tree9f7725adfdd87c592aac10a03e516f0f88087404 /main_test.go
parent520aae362ecdac0b60c9aca19b83cac1061813de (diff)
Feat: add time check and test
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go67
1 files changed, 67 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
new file mode 100644
index 0000000..e494dc6
--- /dev/null
+++ b/main_test.go
@@ -0,0 +1,67 @@
+package main
+
+import (
+ "fmt"
+ "testing"
+)
+
+func TestFullyIncludes(t *testing.T) {
+ cases := []struct {
+ LeftTime string
+ RightTime string
+ Want bool
+ Description string
+ }{
+ {
+ LeftTime: "06:12.240",
+ RightTime: "06:16.040",
+ Want: true,
+ Description: "right time is bigger",
+ },
+ {
+ LeftTime: "06:18.240",
+ RightTime: "06:16.040",
+ Want: false,
+ Description: "left time is bigger: inadequate",
+ },
+ {
+ LeftTime: "06:18.240",
+ RightTime: "06:18.240",
+ Want: false,
+ Description: "left == right: inadequate",
+ },
+ {
+ LeftTime: "01:00:08.000",
+ RightTime: "59:37.800",
+ Want: false,
+ Description: "with hours: left time is bigger: inadequate",
+ },
+ {
+ LeftTime: "59:37.800",
+ RightTime: "01:00:08.000",
+ Want: true,
+ Description: "with hours: right time is bigger",
+ },
+ {
+ LeftTime: "01:00:04.900",
+ RightTime: "01:02:08.000",
+ Want: true,
+ Description: "with hours: right time is bigger",
+ },
+ {
+ LeftTime: "01:02:08.000",
+ RightTime: "01:00:04.900",
+ Want: false,
+ Description: "with hours: left time is bigger",
+ },
+ }
+ for i, tc := range cases {
+ t.Run(fmt.Sprintf("run: #%d; %q", i, tc.Description), func(t *testing.T) {
+ got := adequateTimes(tc.LeftTime, tc.RightTime)
+ if got != tc.Want {
+ t.Errorf("want: %v; got: %v", tc.Want, got)
+ }
+ })
+ }
+
+}