Skip to content

Commit 03231db

Browse files
committed
Add color serialization unit tests.
1 parent 3716158 commit 03231db

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/tests.rs

+21
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,27 @@ fn serializer() {
275275
}
276276

277277

278+
#[test]
279+
fn serialize_current_color() {
280+
let c = CurrentColor;
281+
assert!(format!("{}", c).as_slice() == "currentColor");
282+
}
283+
284+
285+
#[test]
286+
fn serialize_rgb_full_alpha() {
287+
let c = RGBAColor(RGBA { red: 1.0, green: 0.9, blue: 0.8, alpha: 1.0 });
288+
assert!(format!("{}", c).as_slice() == "rgb(255, 230, 204)");
289+
}
290+
291+
292+
#[test]
293+
fn serialize_rgba() {
294+
let c = RGBAColor(RGBA { red: 0.1, green: 0.2, blue: 0.3, alpha: 0.5 });
295+
assert!(format!("{}", c).as_slice() == "rgba(26, 51, 77, 0.5)");
296+
}
297+
298+
278299
impl ToJson for Result<Rule, SyntaxError> {
279300
fn to_json(&self) -> json::Json {
280301
match *self {

0 commit comments

Comments
 (0)