aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/test
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-19 10:44:43 +0200
committermarha <marha@users.sourceforge.net>2011-10-19 10:44:43 +0200
commit9f986778bd4393c5a9108426969d45aa7f10f334 (patch)
tree27d7bd08dac54a54a923e76dccf2b8e388be2a03 /xorg-server/test
parentafbd3947071a33f59dda122f1ac396442a02c128 (diff)
downloadvcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.tar.gz
vcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.tar.bz2
vcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.zip
libX11 libXext libXft mesa libxcb mkfontscale pixman xserver
xkeyboard-config git update 19 oct 2011
Diffstat (limited to 'xorg-server/test')
-rw-r--r--xorg-server/test/input.c150
1 files changed, 139 insertions, 11 deletions
diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c
index afc4d4d99..bc41c226d 100644
--- a/xorg-server/test/input.c
+++ b/xorg-server/test/input.c
@@ -1309,17 +1309,17 @@ static void dix_get_master(void)
SpriteInfoRec ptr_sprite, kbd_sprite;
SpriteInfoRec floating_sprite;
- memset(&vcp, 0, sizeof(DeviceIntRec));
- memset(&vck, 0, sizeof(DeviceIntRec));
- memset(&ptr, 0, sizeof(DeviceIntRec));
- memset(&kbd, 0, sizeof(DeviceIntRec));
- memset(&floating, 0, sizeof(DeviceIntRec));
-
- memset(&vcp_sprite, 0, sizeof(DeviceIntRec));
- memset(&vck_sprite, 0, sizeof(DeviceIntRec));
- memset(&ptr_sprite, 0, sizeof(DeviceIntRec));
- memset(&kbd_sprite, 0, sizeof(DeviceIntRec));
- memset(&floating_sprite, 0, sizeof(DeviceIntRec));
+ memset(&vcp, 0, sizeof(vcp));
+ memset(&vck, 0, sizeof(vck));
+ memset(&ptr, 0, sizeof(ptr));
+ memset(&kbd, 0, sizeof(kbd));
+ memset(&floating, 0, sizeof(floating));
+
+ memset(&vcp_sprite, 0, sizeof(vcp_sprite));
+ memset(&vck_sprite, 0, sizeof(vck_sprite));
+ memset(&ptr_sprite, 0, sizeof(ptr_sprite));
+ memset(&kbd_sprite, 0, sizeof(kbd_sprite));
+ memset(&floating_sprite, 0, sizeof(floating_sprite));
vcp.type = MASTER_POINTER;
vck.type = MASTER_KEYBOARD;
@@ -1462,9 +1462,137 @@ static void input_option_test(void)
assert(list == NULL);
}
+static void
+_test_double_fp16_values(double orig_d)
+{
+ FP1616 first_fp16, final_fp16;
+ double final_d;
+ char first_fp16_s[64];
+ char final_fp16_s[64];
+
+ if (orig_d > 0x7FFF) {
+ printf("Test out of range\n");
+ assert(0);
+ }
+
+ first_fp16 = double_to_fp1616(orig_d);
+ final_d = fp1616_to_double(first_fp16);
+ final_fp16 = double_to_fp1616(final_d);
+
+ snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff);
+ snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff);
+
+ printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s);
+
+ /* since we lose precision, we only do rough range testing */
+ assert(final_d > orig_d - 0.1);
+ assert(final_d < orig_d + 0.1);
+
+ assert(memcmp(&first_fp16, &final_fp16, sizeof(FP1616)) == 0);
+
+ if (orig_d > 0)
+ _test_double_fp16_values(-orig_d);
+}
+
+static void
+_test_double_fp32_values(double orig_d)
+{
+ FP3232 first_fp32, final_fp32;
+ double final_d;
+
+ if (orig_d > 0x7FFFFFFF) {
+ printf("Test out of range\n");
+ assert(0);
+ }
+
+ first_fp32 = double_to_fp3232(orig_d);
+ final_d = fp3232_to_double(first_fp32);
+ final_fp32 = double_to_fp3232(final_d);
+
+ /* {
+ * char first_fp32_s[64];
+ * char final_fp32_s[64];
+ * snprintf(first_fp32_s, sizeof(first_fp32_s), "%d + %u * 2^-32", first_fp32.integral, first_fp32.frac);
+ * snprintf(final_fp32_s, sizeof(final_fp32_s), "%d + %u * 2^-32", first_fp32.integral, final_fp32.frac);
+ *
+ * printf("FP32: original double: %f first fp32: %s, re-encoded double: %f, final fp32: %s\n", orig_d, first_fp32_s, final_d, final_fp32_s);
+ * }
+ */
+
+ /* since we lose precision, we only do rough range testing */
+ assert(final_d > orig_d - 0.1);
+ assert(final_d < orig_d + 0.1);
+
+ assert(memcmp(&first_fp32, &final_fp32, sizeof(FP3232)) == 0);
+
+ if (orig_d > 0)
+ _test_double_fp32_values(-orig_d);
+}
+
+static void
+dix_double_fp_conversion(void)
+{
+ uint32_t i;
+ printf("Testing double to FP1616/FP3232 conversions\n");
+
+ _test_double_fp16_values(0);
+ for (i = 1; i < 0x7FFF; i <<= 1) {
+ double val;
+
+ val = i;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+
+ /* and some pseudo-random floating points */
+ val = i - 0.00382;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+
+ val = i + 0.00382;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+
+ val = i + 0.05234;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+
+ val = i + 0.12342;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+
+ val = i + 0.27583;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+
+ val = i + 0.50535;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+
+ val = i + 0.72342;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+
+ val = i + 0.80408;
+ _test_double_fp16_values(val);
+ _test_double_fp32_values(val);
+ }
+
+ for (i = 0x7FFFF; i < 0x7FFFFFFF; i <<= 1) {
+ _test_double_fp32_values(i);
+ /* and a few more random floating points, obtained
+ * by faceplanting into the numpad repeatedly */
+ _test_double_fp32_values(i + 0.010177);
+ _test_double_fp32_values(i + 0.213841);
+ _test_double_fp32_values(i + 0.348720);
+ _test_double_fp32_values(i + 0.472020);
+ _test_double_fp32_values(i + 0.572020);
+ _test_double_fp32_values(i + 0.892929);
+ }
+}
int main(int argc, char** argv)
{
+ dix_double_fp_conversion();
dix_input_valuator_masks();
dix_input_attributes();
dix_init_valuators();