2 * Copyright © 2012 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 #include "wayland-private.h"
27 #include "test-runner.h"
29 TEST(fixed_double_conversions)
35 f = wl_fixed_from_double(d);
36 fprintf(stderr, "double %lf to fixed %x\n", d, f);
40 f = wl_fixed_from_double(d);
41 fprintf(stderr, "double %lf to fixed %x\n", d, f);
42 assert(f == -0x4b0a0);
45 d = wl_fixed_to_double(f);
46 fprintf(stderr, "fixed %x to double %lf\n", f, d);
47 assert(d == f / 256.0);
50 d = wl_fixed_to_double(f);
51 fprintf(stderr, "fixed %x to double %lf\n", f, d);
52 assert(d == 288.1875);
55 d = wl_fixed_to_double(f);
56 fprintf(stderr, "fixed %x to double %lf\n", f, d);
60 d = wl_fixed_to_double(f);
61 fprintf(stderr, "fixed %x to double %lf\n", f, d);
62 assert(d == -288.1875);
65 d = wl_fixed_to_double(f);
66 fprintf(stderr, "fixed %x to double %lf\n", f, d);
70 TEST(fixed_int_conversions)
76 f = wl_fixed_from_int(i);
77 assert(f == 62 * 256);
80 f = wl_fixed_from_int(i);
81 assert(f == -2080 * 256);
84 i = wl_fixed_to_int(f);
88 i = wl_fixed_to_int(f);