Skip to content

Commit

Permalink
vaev-style: Changed the order of Insets parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Sep 28, 2024
1 parent b4f72ac commit 663fca5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"extern": {
"skift-org/karm": {
"git": "https://github.com/skift-org/karm.git",
"tag": "v0.1.1"
"tag": "v0.1.2"
},
"cute-engineering/cat": {
"git": "https://github.com/cute-engineering/cat.git",
Expand Down
47 changes: 31 additions & 16 deletions src/vaev-style/tests/test-parse-value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,37 @@ test$("vaev-css-build-margin") {
return Ok();
};

try$(testCase("margin: 30px;", Margin{Width{Length{Px{30}}}}));
try$(testCase("margin: 1px 2px;", Margin{
Width{Length{Px{1}}},
Width{Length{Px{2}}},
}));
try$(testCase("margin: 1px 2px 3px;", Margin{
Width{Length{Px{1}}},
Width{Length{Px{2}}},
Width{Length{Px{3}}},
}));
try$(testCase("margin: 1px 2px 3px 4px;", Margin{
Width{Length{Px{4}}},
Width{Length{Px{1}}},
Width{Length{Px{2}}},
Width{Length{Px{3}}},
}));
try$(testCase(
"margin: 30px;",
Margin{Width{Px{30}}}
));

try$(testCase(
"margin: 1px 2px;",
Margin{
Width{Px{1}},
Width{Px{2}},
}
));

try$(testCase(
"margin: 1px 2px 3px;",
Margin{
Width{Px{1}},
Width{Px{2}},
Width{Px{3}},
}
));

try$(testCase(
"margin: 1px 2px 3px 4px;",
Margin{
Width{Px{1}},
Width{Px{2}},
Width{Px{3}},
Width{Px{4}},
}
));

return Ok();
}
Expand Down
16 changes: 12 additions & 4 deletions src/vaev-style/values.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,25 @@ struct ValueParser<Math::Insets<T>> {

auto right = parseValue<T>(c);
if (not right)
return Ok(Math::Insets<T>{top.take()});
return Ok(Math::Insets<T>{
top.take()
});

auto bottom = parseValue<T>(c);
if (not bottom)
return Ok(Math::Insets<T>{top.take(), right.take()});
return Ok(Math::Insets<T>{
top.take(), right.take()
});

auto left = parseValue<T>(c);
if (not left)
return Ok(Math::Insets<T>{top.take(), right.take(), bottom.take()});
return Ok(Math::Insets<T>{
top.take(), right.take(), bottom.take()
});

return Ok(Math::Insets<T>{left.take(), top.take(), right.take(), bottom.take()});
return Ok(Math::Insets<T>{
top.take(), right.take(), bottom.take(), left.take()
});
}
};

Expand Down

0 comments on commit 663fca5

Please sign in to comment.