* [Theme] First move to double internal calculations. * [Theme] Allow float numbers. * [Theme] Fix unary - and tighten the grammar parser. * [Theme] Rename % to modulo to fix compiler. * [Theme] Dump right modulo syntax. * [Test] add missing end_test * [Grammar] Allow negative numbers as property value
This commit is contained in:
@@ -1456,7 +1456,7 @@ START_TEST(test_prepare_math_modulo) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 255 % 4 % 3 % );}");
|
||||
rofi_theme_parse_string("window { width: calc( 255 modulo 4 modulo 5 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
@@ -1499,6 +1499,143 @@ START_TEST(test_prepare_math_max) {
|
||||
ck_assert_int_eq(dist, 256);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_prepare_math_failure) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( 1/2 * 500 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 250);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_prepare_math_failure2) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc( -16/2 * 1.5 );}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, -12);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_failure3) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc(10+3);}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 13);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_failure4) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc(10.0+3.2);}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 13);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_failure5) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc(10-3);}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 7);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_failure6) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc(10.0-3.2);}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, 6);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_failure7) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc(-10--3);}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, -7);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_failure8) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: calc(-10.0--3.2);}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, -6);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_math_failure9) {
|
||||
widget wid;
|
||||
wid.name = "window";
|
||||
wid.state = "";
|
||||
rofi_theme_parse_string("window { width: -128;}");
|
||||
ck_assert_ptr_nonnull(rofi_theme);
|
||||
// ck_assert_ptr_null ( rofi_theme->widgets );
|
||||
ck_assert_ptr_null(rofi_theme->properties);
|
||||
ck_assert_ptr_null(rofi_theme->parent);
|
||||
ck_assert_str_eq(rofi_theme->name, "Root");
|
||||
RofiDistance l = rofi_theme_get_distance(&wid, "width", 0);
|
||||
int dist = distance_get_pixel(l, ROFI_ORIENTATION_HORIZONTAL);
|
||||
ck_assert_int_eq(dist, -128);
|
||||
}
|
||||
END_TEST
|
||||
START_TEST(test_prepare_default) {
|
||||
rofi_theme_parse_string("@import \"default\"");
|
||||
|
||||
@@ -1739,6 +1876,15 @@ static Suite *theme_parser_suite(void) {
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_round);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_min);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_max);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure2);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure3);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure4);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure5);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure6);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure7);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure8);
|
||||
tcase_add_test(tc_prepare_math, test_prepare_math_failure9);
|
||||
suite_add_tcase(s, tc_prepare_math);
|
||||
}
|
||||
return s;
|
||||
|
Reference in New Issue
Block a user