|
| 1 | +package models |
| 2 | + |
| 3 | +import "testing" |
| 4 | + |
| 5 | +func TestComparePriority(t *testing.T) { |
| 6 | + tests := []struct { |
| 7 | + priority1 string |
| 8 | + priority2 string |
| 9 | + expected int |
| 10 | + }{ |
| 11 | + {"INVALID", "URGENT", -1}, |
| 12 | + {"UNKNOWN", "IMPORTANT", -1}, |
| 13 | + {"INFORMATIONAL", "URGENT", -1}, |
| 14 | + {"IMPORTANT", "URGENT", -1}, |
| 15 | + {"URGENT", "IMPORTANT", 1}, |
| 16 | + {"IMPORTANT", "INFORMATIONAL", 1}, |
| 17 | + {"URGENT", "UNKNOWN", 1}, |
| 18 | + {"IMPORTANT", "INVALID", 1}, |
| 19 | + {"UNKNOWN", "UNKNOWN", 0}, |
| 20 | + {"INFORMATIONAL", "INFORMATIONAL", 0}, |
| 21 | + {"IMPORTANT", "IMPORTANT", 0}, |
| 22 | + {"URGENT", "URGENT", 0}, |
| 23 | + } |
| 24 | + |
| 25 | + for _, test := range tests { |
| 26 | + result := ComparePriority(test.priority1, test.priority2) |
| 27 | + if result != test.expected { |
| 28 | + t.Errorf("ComparePriority(%s, %s) = %d; want %d", |
| 29 | + test.priority1, test.priority2, result, test.expected) |
| 30 | + } |
| 31 | + } |
| 32 | +} |
0 commit comments