File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -4,18 +4,29 @@ const (
44 PriorityUrgent string = "URGENT"
55 PriorityImportant string = "IMPORTANT"
66 PriorityInformational string = "INFORMATIONAL"
7+ PriorityUnknown string = "UNKNOWN"
78)
89
910var priorityToInt = map [string ]int {
10- PriorityInformational : 0 ,
11- PriorityImportant : 1 ,
12- PriorityUrgent : 2 ,
11+ PriorityUnknown : 0 ,
12+ PriorityInformational : 1 ,
13+ PriorityImportant : 2 ,
14+ PriorityUrgent : 3 ,
1315}
1416
1517func ComparePriority (priority1 , priority2 string ) int {
1618 val1 , ok1 := priorityToInt [priority1 ]
1719 val2 , ok2 := priorityToInt [priority2 ]
1820
21+ // If priority1 is NONE and priority2 is not in the map, treat them as equal
22+ if priority1 == PriorityUnknown && ! ok2 {
23+ return 0
24+ }
25+ // If priority2 is NONE and priority1 is not in the map, treat them as equal
26+ if priority2 == PriorityUnknown && ! ok1 {
27+ return 0
28+ }
29+
1930 if ! ok1 && ! ok2 {
2031 return 0
2132 } else if ! ok1 {
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ func TestComparePriority(t *testing.T) {
2020 {"INFORMATIONAL" , "INFORMATIONAL" , 0 },
2121 {"IMPORTANT" , "IMPORTANT" , 0 },
2222 {"URGENT" , "URGENT" , 0 },
23+ {"NONE" , "INVALID" , 0 },
24+ {"NONE" , "UNKNOWN" , 0 },
25+ {"UNKNOWN" , "" , 0 },
26+ {"" , "UNKNOWN" , 0 },
2327 }
2428
2529 for _ , test := range tests {
You can’t perform that action at this time.
0 commit comments