File tree Expand file tree Collapse file tree 1 file changed +40
-9
lines changed Expand file tree Collapse file tree 1 file changed +40
-9
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,7 @@ impl Hash for Model {
48
48
49
49
impl PartialOrd for Model {
50
50
fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
51
- match self
52
- . frontend_question_id
53
- . parse :: < i32 > ( )
54
- . unwrap ( )
55
- . partial_cmp ( & other. frontend_question_id . parse :: < i32 > ( ) . unwrap ( ) )
56
- {
57
- Some ( core:: cmp:: Ordering :: Equal ) => Some ( core:: cmp:: Ordering :: Equal ) ,
58
- ord => ord,
59
- }
51
+ Some ( self . cmp ( other) )
60
52
}
61
53
}
62
54
@@ -82,3 +74,42 @@ impl Related<super::topic_tag::Entity> for Entity {
82
74
}
83
75
84
76
impl ActiveModelBehavior for ActiveModel { }
77
+
78
+ #[ cfg( test) ]
79
+ mod tests {
80
+ use super :: * ;
81
+
82
+ #[ test]
83
+ fn test ( ) {
84
+ let m1 = Model {
85
+ ac_rate : None ,
86
+ difficulty : None ,
87
+ freq_bar : None ,
88
+ frontend_question_id : "1" . to_string ( ) ,
89
+ is_favor : None ,
90
+ paid_only : None ,
91
+ status : None ,
92
+ title : None ,
93
+ title_slug : None ,
94
+ has_solution : None ,
95
+ has_video_solution : None ,
96
+ } ;
97
+
98
+ let m2 = Model {
99
+ ac_rate : None ,
100
+ difficulty : None ,
101
+ freq_bar : None ,
102
+ frontend_question_id : "2" . to_string ( ) ,
103
+ is_favor : None ,
104
+ paid_only : None ,
105
+ status : None ,
106
+ title : None ,
107
+ title_slug : None ,
108
+ has_solution : None ,
109
+ has_video_solution : None ,
110
+ } ;
111
+
112
+ assert ! ( m1 < m2) ;
113
+ assert ! ( m1 == m1) ;
114
+ }
115
+ }
You can’t perform that action at this time.
0 commit comments