@@ -9,6 +9,36 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
99{
1010 public class Bgr565Tests
1111 {
12+ /// <summary>
13+ /// Tests the equality operators for equality.
14+ /// </summary>
15+ [ Fact ]
16+ public void AreEqual ( )
17+ {
18+ var color1 = new Bgr565 ( 0.0f , 0.0f , 0.0f ) ;
19+ var color2 = new Bgr565 ( new Vector3 ( 0.0f ) ) ;
20+ var color3 = new Bgr565 ( new Vector3 ( 1.0f , 0.0f , 1.0f ) ) ;
21+ var color4 = new Bgr565 ( 1.0f , 0.0f , 1.0f ) ;
22+
23+ Assert . Equal ( color1 , color2 ) ;
24+ Assert . Equal ( color3 , color4 ) ;
25+ }
26+
27+ /// <summary>
28+ /// Tests the equality operators for inequality.
29+ /// </summary>
30+ [ Fact ]
31+ public void AreNotEqual ( )
32+ {
33+ var color1 = new Bgr565 ( 0.0f , 0.0f , 0.0f ) ;
34+ var color2 = new Bgr565 ( new Vector3 ( 1.0f ) ) ;
35+ var color3 = new Bgr565 ( new Vector3 ( 1.0f , 0.0f , 0.0f ) ) ;
36+ var color4 = new Bgr565 ( 1.0f , 1.0f , 0.0f ) ;
37+
38+ Assert . NotEqual ( color1 , color2 ) ;
39+ Assert . NotEqual ( color3 , color4 ) ;
40+ }
41+
1242 [ Fact ]
1343 public void Bgr565_PackedValue ( )
1444 {
@@ -77,6 +107,140 @@ public void Bgr565_FromBgra5551()
77107 Assert . Equal ( expected , bgr . PackedValue ) ;
78108 }
79109
110+ [ Fact ]
111+ public void Bgr565_FromArgb32 ( )
112+ {
113+ // arrange
114+ var bgr1 = default ( Bgr565 ) ;
115+ var bgr2 = default ( Bgr565 ) ;
116+ ushort expected1 = ushort . MaxValue ;
117+ ushort expected2 = ushort . MaxValue ;
118+
119+ // act
120+ bgr1 . FromArgb32 ( new Argb32 ( 1.0f , 1.0f , 1.0f , 1.0f ) ) ;
121+ bgr2 . FromArgb32 ( new Argb32 ( 1.0f , 1.0f , 1.0f , 0.0f ) ) ;
122+
123+ // assert
124+ Assert . Equal ( expected1 , bgr1 . PackedValue ) ;
125+ Assert . Equal ( expected2 , bgr2 . PackedValue ) ;
126+ }
127+
128+ [ Fact ]
129+ public void Bgr565_FromRgba32 ( )
130+ {
131+ // arrange
132+ var bgr1 = default ( Bgr565 ) ;
133+ var bgr2 = default ( Bgr565 ) ;
134+ ushort expected1 = ushort . MaxValue ;
135+ ushort expected2 = ushort . MaxValue ;
136+
137+ // act
138+ bgr1 . FromRgba32 ( new Rgba32 ( 1.0f , 1.0f , 1.0f , 1.0f ) ) ;
139+ bgr2 . FromRgba32 ( new Rgba32 ( 1.0f , 1.0f , 1.0f , 0.0f ) ) ;
140+
141+ // assert
142+ Assert . Equal ( expected1 , bgr1 . PackedValue ) ;
143+ Assert . Equal ( expected2 , bgr2 . PackedValue ) ;
144+ }
145+
146+ [ Fact ]
147+ public void Bgr565_ToRgba32 ( )
148+ {
149+ // arrange
150+ var bgra = new Bgr565 ( Vector3 . One ) ;
151+ var expected = new Rgba32 ( Vector4 . One ) ;
152+ var actual = default ( Rgba32 ) ;
153+
154+ // act
155+ bgra . ToRgba32 ( ref actual ) ;
156+
157+ Assert . Equal ( expected , actual ) ;
158+ }
159+
160+ [ Fact ]
161+ public void Bgra565_FromRgb48 ( )
162+ {
163+ // arrange
164+ var bgr = default ( Bgr565 ) ;
165+ ushort expectedPackedValue = ushort . MaxValue ;
166+
167+ // act
168+ bgr . FromRgb48 ( new Rgb48 ( ushort . MaxValue , ushort . MaxValue , ushort . MaxValue ) ) ;
169+
170+ // assert
171+ Assert . Equal ( expectedPackedValue , bgr . PackedValue ) ;
172+ }
173+
174+ [ Fact ]
175+ public void Bgra565_FromRgba64 ( )
176+ {
177+ // arrange
178+ var bgr = default ( Bgr565 ) ;
179+ ushort expectedPackedValue = ushort . MaxValue ;
180+
181+ // act
182+ bgr . FromRgba64 ( new Rgba64 ( ushort . MaxValue , ushort . MaxValue , ushort . MaxValue , ushort . MaxValue ) ) ;
183+
184+ // assert
185+ Assert . Equal ( expectedPackedValue , bgr . PackedValue ) ;
186+ }
187+
188+ [ Fact ]
189+ public void Bgr565_FromBgr24 ( )
190+ {
191+ // arrange
192+ var bgr = default ( Bgr565 ) ;
193+ ushort expected = ushort . MaxValue ;
194+
195+ // act
196+ bgr . FromBgr24 ( new Bgr24 ( byte . MaxValue , byte . MaxValue , byte . MaxValue ) ) ;
197+
198+ // assert
199+ Assert . Equal ( expected , bgr . PackedValue ) ;
200+ }
201+
202+ [ Fact ]
203+ public void Bgr565_FromRgb24 ( )
204+ {
205+ // arrange
206+ var bgr = default ( Bgr565 ) ;
207+ ushort expected = ushort . MaxValue ;
208+
209+ // act
210+ bgr . FromRgb24 ( new Rgb24 ( byte . MaxValue , byte . MaxValue , byte . MaxValue ) ) ;
211+
212+ // assert
213+ Assert . Equal ( expected , bgr . PackedValue ) ;
214+ }
215+
216+ [ Fact ]
217+ public void Bgr565_FromGrey8 ( )
218+ {
219+ // arrange
220+ var bgr = default ( Bgr565 ) ;
221+ ushort expected = ushort . MaxValue ;
222+
223+ // act
224+ bgr . FromGray8 ( new Gray8 ( byte . MaxValue ) ) ;
225+
226+ // assert
227+ Assert . Equal ( expected , bgr . PackedValue ) ;
228+ }
229+
230+ [ Fact ]
231+ public void Bgr565_FromGrey16 ( )
232+ {
233+ // arrange
234+ var bgr = default ( Bgr565 ) ;
235+ ushort expected = ushort . MaxValue ;
236+
237+ // act
238+ bgr . FromGray16 ( new Gray16 ( ushort . MaxValue ) ) ;
239+
240+ // assert
241+ Assert . Equal ( expected , bgr . PackedValue ) ;
242+ }
243+
80244 [ Fact ]
81245 public void Bgr565_Clamping ( )
82246 {
0 commit comments