Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  rounded-rect.c

  Sprache: C
 

/*
 * Copyright © 2020 Benjamin Otte
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Benjamin Otte <otte@gnome.org>
 */


#include "config.h"

#include <gtk/gtk.h>
#include <gsk/gskroundedrectprivate.h>
#include <gsk/gskrectprivate.h>

static void
test_contains_rect (void)
{
  static double points[] = { -5051015859095100105 };
#define LAST (G_N_ELEMENTS(points) - 1)
  GskRoundedRect rounded;
  guint x1, x2, y1, y2;

  gsk_rounded_rect_init_from_rect (&rounded, &GRAPHENE_RECT_INIT (00100100), 10);

  for (x1 = 0; x1 < G_N_ELEMENTS (points); x1++)
    for (x2 = x1 + 1; x2 < G_N_ELEMENTS (points); x2++)
      for (y1 = 0; y1 < G_N_ELEMENTS (points); y1++)
        for (y2 = y1 + 1; y2 < G_N_ELEMENTS (points); y2++)
          {
            graphene_rect_t rect;
            gboolean inside;

            /* check all points are in the bounding box */
            inside = x1 > 0 && y1 > 0 && x2 < LAST && y2 < LAST;
            /* now check all the corners */
            inside &= x1 > 2 || y1 > 2 || (x1 == 2 && y1 == 2);
            inside &= x2 < LAST - 2 || y1 > 2 || (x2 == LAST - 2 && y1 == 2);
            inside &= x2 < LAST - 2 || y2 < LAST - 2 || (x2 == LAST - 2 && y2 == LAST - 2);
            inside &= x1 > 2 || y2 < LAST - 2 || (x1 == 2 && y2 == LAST - 2);

            graphene_rect_init (&rect, points[x1], points[y1], points[x2] - points[x1], points[y2] - points[y1]);
            if (inside)
              g_assert_true (gsk_rounded_rect_contains_rect (&rounded, &rect));
            else
              g_assert_false (gsk_rounded_rect_contains_rect (&rounded, &rect));
          }
#undef LAST
}

static void
test_intersects_rect (void)
{
  static double points[] = { -10199100101 };
#define ALL_THE_POINTS (G_N_ELEMENTS(points))
#define HALF_THE_POINTS (ALL_THE_POINTS / 2)
  GskRoundedRect rounded;
  guint x1, x2, y1, y2;

  gsk_rounded_rect_init_from_rect (&rounded, &GRAPHENE_RECT_INIT (00100100), 10);

  for (x1 = 0; x1 < ALL_THE_POINTS; x1++)
    for (x2 = x1 + 1; x2 < ALL_THE_POINTS; x2++)
      for (y1 = 0; y1 < ALL_THE_POINTS; y1++)
        for (y2 = y1 + 1; y2 < ALL_THE_POINTS; y2++)
          {
            graphene_rect_t rect;
            gboolean should_contain_x, should_contain_y;

            graphene_rect_init (&rect, points[x1], points[y1], points[x2] - points[x1], points[y2] - points[y1]);
            should_contain_x = x1 < HALF_THE_POINTS && x2 >= HALF_THE_POINTS && y2 > 1 && y1 < ALL_THE_POINTS - 2;
            should_contain_y = y1 < HALF_THE_POINTS && y2 >= HALF_THE_POINTS && x2 > 1 && x1 < ALL_THE_POINTS - 2;
            if (should_contain_x || should_contain_y)
              g_assert_true (gsk_rounded_rect_intersects_rect (&rounded, &rect));
            else
              g_assert_false (gsk_rounded_rect_intersects_rect (&rounded, &rect));
          }
#undef ALL_THE_POINTS
#undef HALF_THE_POINTS
}

static void
test_contains_point (void)
{
  GskRoundedRect rect;

  gsk_rounded_rect_init (&rect,
                         &GRAPHENE_RECT_INIT (00100100),
                         &GRAPHENE_SIZE_INIT (00),
                         &GRAPHENE_SIZE_INIT (1010),
                         &GRAPHENE_SIZE_INIT (1020),
                         &GRAPHENE_SIZE_INIT (2010));

  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (5050)));
  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (00)));
  g_assert_false (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (1000)));
  g_assert_false (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (100100)));
  g_assert_false (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (0100)));
  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (050)));
  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (500)));
  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (50100)));
  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (10050)));

  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (955)));
  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (9590)));
  g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (1095)));
}

static void
test_is_circular (void)
{
  GskRoundedRect rect;

  gsk_rounded_rect_init (&rect,
                         &GRAPHENE_RECT_INIT (00100100),
                         &GRAPHENE_SIZE_INIT (00),
                         &GRAPHENE_SIZE_INIT (1010),
                         &GRAPHENE_SIZE_INIT (1020),
                         &GRAPHENE_SIZE_INIT (2010));

  g_assert_false (gsk_rounded_rect_is_circular (&rect));

  gsk_rounded_rect_init (&rect,
                         &GRAPHENE_RECT_INIT (00100100),
                         &GRAPHENE_SIZE_INIT (00),
                         &GRAPHENE_SIZE_INIT (1010),
                         &GRAPHENE_SIZE_INIT (2020),
                         &GRAPHENE_SIZE_INIT (3030));

  g_assert_true (gsk_rounded_rect_is_circular (&rect));
}

static void
test_to_float (void)
{
  GskRoundedRect rect;
  float flt[12];

  gsk_rounded_rect_init (&rect,
                         &GRAPHENE_RECT_INIT (0112233),
                         &GRAPHENE_SIZE_INIT (45),
                         &GRAPHENE_SIZE_INIT (67),
                         &GRAPHENE_SIZE_INIT (89),
                         &GRAPHENE_SIZE_INIT (1011));

  gsk_rounded_rect_to_float (&rect, &GRAPHENE_POINT_INIT(00), flt);
  g_assert_true (flt[0] == 0. && flt[1] == 11. && flt[2] == 22. && flt[3] == 33.);
  g_assert_true (flt[4] == 4. && flt[5] == 6.);
  g_assert_true (flt[6] == 8. && flt[7] == 10.);
  g_assert_true (flt[8] == 5. && flt[9] == 7.);
  g_assert_true (flt[10] == 9. && flt[11] == 11.);

  gsk_rounded_rect_to_float (&rect, &GRAPHENE_POINT_INIT(100200), flt);
  g_assert_true (flt[0] == 100. && flt[1] == 211. && flt[2] == 22. && flt[3] == 33.);
  g_assert_true (flt[4] == 4. && flt[5] == 6.);
  g_assert_true (flt[6] == 8. && flt[7] == 10.);
  g_assert_true (flt[8] == 5. && flt[9] == 7.);
  g_assert_true (flt[10] == 9. && flt[11] == 11.);
}

#define ROUNDED_RECT_INIT_FULL(x,y,w,h,w0,h0,w1,h1,w2,h2,w3,h3) \
  (GskRoundedRect) { .bounds = GRAPHENE_RECT_INIT (x, y, w, h), \
                     .corner = { \
                       GRAPHENE_SIZE_INIT (w0, h0), \
                       GRAPHENE_SIZE_INIT (w1, h1), \
                       GRAPHENE_SIZE_INIT (w2, h2), \
                       GRAPHENE_SIZE_INIT (w3, h3), \
                   }}

#define ROUNDED_RECT_INIT(x,y,w,h,r) \
  ROUNDED_RECT_INIT_FULL (x, y, w, h, r, r, r, r, r, r, r, r)

#define ROUNDED_RECT_INIT_UNIFORM(x,y,w,h,r1,r2,r3,r4) \
  ROUNDED_RECT_INIT_FULL (x, y, w, h, r1, r1, r2, r2, r3, r3, r4, r4)


static void
test_intersect_with_rect (void)
{
  struct {
    GskRoundedRect rounded;
    graphene_rect_t rect;
    GskRoundedRect expected;
    GskRoundedRectIntersection result;
  } test[] = {
    { ROUNDED_RECT_INIT (205010010050), GRAPHENE_RECT_INIT (60806070),
      ROUNDED_RECT_INIT (00000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT (0010010010), GRAPHENE_RECT_INIT (00100100),
      ROUNDED_RECT_INIT (0010010010), GSK_INTERSECTION_NONEMPTY },
    { ROUNDED_RECT_INIT (0010010010), GRAPHENE_RECT_INIT (008080),
      ROUNDED_RECT_INIT_UNIFORM (00808010000), GSK_INTERSECTION_NONEMPTY },
    { ROUNDED_RECT_INIT (0010010010), GRAPHENE_RECT_INIT (10108080),
      ROUNDED_RECT_INIT (101080800), GSK_INTERSECTION_NONEMPTY },
    { ROUNDED_RECT_INIT (0010010010), GRAPHENE_RECT_INIT (101510070),
      ROUNDED_RECT_INIT (101590700), GSK_INTERSECTION_NONEMPTY },
    { ROUNDED_RECT_INIT (0010010010), GRAPHENE_RECT_INIT (11001010),
      ROUNDED_RECT_INIT (00000), GSK_INTERSECTION_EMPTY },
    { ROUNDED_RECT_INIT (0010010010), GRAPHENE_RECT_INIT (559090),
      ROUNDED_RECT_INIT (5590900), GSK_INTERSECTION_NONEMPTY },
    { ROUNDED_RECT_INIT (0010010010), GRAPHENE_RECT_INIT (1111),
      ROUNDED_RECT_INIT (00000), GSK_INTERSECTION_EMPTY },
    { ROUNDED_RECT_INIT (0010010010), GRAPHENE_RECT_INIT (5, -51020),
      ROUNDED_RECT_INIT (00000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT_UNIFORM (-200020010000040), GRAPHENE_RECT_INIT (-2000160100),
      ROUNDED_RECT_INIT_UNIFORM (-200016010000040), GSK_INTERSECTION_NONEMPTY },

    { ROUNDED_RECT_INIT_UNIFORM (005050500500), GRAPHENE_RECT_INIT (004949),
      ROUNDED_RECT_INIT_UNIFORM (00000000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT_UNIFORM (005050500500), GRAPHENE_RECT_INIT (104949),
      ROUNDED_RECT_INIT_UNIFORM (00000000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT_UNIFORM (005050500500), GRAPHENE_RECT_INIT (014949),
      ROUNDED_RECT_INIT_UNIFORM (00000000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT_UNIFORM (005050500500), GRAPHENE_RECT_INIT (114949),
      ROUNDED_RECT_INIT_UNIFORM (00000000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT_UNIFORM (005050050050), GRAPHENE_RECT_INIT (004949),
      ROUNDED_RECT_INIT_UNIFORM (00000000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT_UNIFORM (005050050050), GRAPHENE_RECT_INIT (104949),
      ROUNDED_RECT_INIT_UNIFORM (00000000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT_UNIFORM (005050050050), GRAPHENE_RECT_INIT (014949),
      ROUNDED_RECT_INIT_UNIFORM (00000000), GSK_INTERSECTION_NOT_REPRESENTABLE },
    { ROUNDED_RECT_INIT_UNIFORM (005050050050), GRAPHENE_RECT_INIT (114949),
      ROUNDED_RECT_INIT_UNIFORM (00000000), GSK_INTERSECTION_NOT_REPRESENTABLE },
  };

  for (unsigned int i = 0; i < G_N_ELEMENTS (test); i++)
    {
      GskRoundedRect out;
      GskRoundedRectIntersection res;

      if (g_test_verbose ())
        g_test_message ("intersection test %u", i);

      memset (&out, 0sizeof (GskRoundedRect));

      res = gsk_rounded_rect_intersect_with_rect (&test[i].rounded, &test[i].rect, &out);
      g_assert_true (res == test[i].result);
      if (res == GSK_INTERSECTION_NONEMPTY)
        {
          if (!gsk_rounded_rect_equal (&out, &test[i].expected))
            {
              char *s = gsk_rounded_rect_to_string (&test[i].expected);
              char *s2 = gsk_rounded_rect_to_string (&out);
              g_test_message ("expected %s, got %s\n", s, s2);
            }
          g_assert_true (gsk_rounded_rect_equal (&out, &test[i].expected));
        }

      g_assert_true ((res != GSK_INTERSECTION_EMPTY) == gsk_rounded_rect_intersects_rect (&test[i].rounded,&nbsp;&test[i].rect));
    }
}

static void
test_intersect (void)
{
  struct {
    GskRoundedRect a;
    GskRoundedRect b;
    GskRoundedRectIntersection result;
    GskRoundedRect expected;
  } test[] = {
    {
      ROUNDED_RECT_INIT(001001000),
      ROUNDED_RECT_INIT(0010010020),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT(0010010020),
    },
    {
      ROUNDED_RECT_INIT(0010010020),
      ROUNDED_RECT_INIT(505010010020),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT_UNIFORM(50505050200200),
    },
    {
      ROUNDED_RECT_INIT(0010010020),
      ROUNDED_RECT_INIT(50010010020),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT(5005010020),
    },
    {
      ROUNDED_RECT_INIT(0010010020),
      ROUNDED_RECT_INIT(05010010020),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT(0501005020),
    },
    {
      ROUNDED_RECT_INIT(0010010020),
      ROUNDED_RECT_INIT(-50, -5010010020),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT_UNIFORM(005050200200),
    },
    {
      ROUNDED_RECT_INIT(0010010020),
      ROUNDED_RECT_INIT(0, -5010010020),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT(001005020),
    },
    {
      ROUNDED_RECT_INIT(0010010020),
      ROUNDED_RECT_INIT(-50010010020),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT(005010020),
    },
    {
      ROUNDED_RECT_INIT(0010010020),
      ROUNDED_RECT_INIT(1010808020),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT(1010808020),
    },
    {
      ROUNDED_RECT_INIT(0010010020),
      ROUNDED_RECT_INIT(1010808010),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT(1010808010),
    },
    {
      ROUNDED_RECT_INIT(0010010040),
      ROUNDED_RECT_INIT(101080800),
      GSK_INTERSECTION_NOT_REPRESENTABLE,
    },
    {
      ROUNDED_RECT_INIT(101010010040),
      ROUNDED_RECT_INIT(30040400),
      GSK_INTERSECTION_NOT_REPRESENTABLE,
    },
    {
      ROUNDED_RECT_INIT(101010010040),
      ROUNDED_RECT_INIT(00100200),
      GSK_INTERSECTION_NOT_REPRESENTABLE,
    },
    {
      ROUNDED_RECT_INIT_UNIFORM(64718133355005),
      ROUNDED_RECT_INIT_UNIFORM(141216668898800),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT_UNIFORM(64718133355005),
    },
    {
      ROUNDED_RECT_INIT_UNIFORM(00100100100000),
      ROUNDED_RECT_INIT_UNIFORM(00100100001000),
      GSK_INTERSECTION_NONEMPTY,
      ROUNDED_RECT_INIT_UNIFORM(0010010010001000),
    },
    {
      ROUNDED_RECT_INIT_UNIFORM(00100100100000),
      ROUNDED_RECT_INIT_UNIFORM(-20, -20100100001000),
      GSK_INTERSECTION_NOT_REPRESENTABLE,
    },
    {
      ROUNDED_RECT_INIT_UNIFORM(00505000500),
      ROUNDED_RECT_INIT_UNIFORM(00202020000),
      GSK_INTERSECTION_NOT_REPRESENTABLE, /* FIXME: should be empty */
    },
    {
      ROUNDED_RECT_INIT_UNIFORM(00505000500),
      ROUNDED_RECT_INIT_UNIFORM(00212121000),
      GSK_INTERSECTION_NOT_REPRESENTABLE,
    },
    {
      ROUNDED_RECT_INIT_UNIFORM(005050500500),
      ROUNDED_RECT_INIT_UNIFORM(005050050050),
      GSK_INTERSECTION_NOT_REPRESENTABLE,
    },
  };
  gsize i;

  for (i = 0; i < G_N_ELEMENTS (test); i++)
    {
      GskRoundedRect out;
      GskRoundedRectIntersection res;

      if (g_test_verbose ())
        g_test_message ("intersection test %zu", i);

      memset (&out, 0sizeof (GskRoundedRect));

      res = gsk_rounded_rect_intersection (&test[i].a, &test[i].b, &out);
      g_assert_cmpint (res, ==, test[i].result);
      if (res == GSK_INTERSECTION_NONEMPTY)
        {
          if (!gsk_rounded_rect_equal (&out, &test[i].expected))
            {
              char *a = gsk_rounded_rect_to_string (&test[i].a);
              char *b = gsk_rounded_rect_to_string (&test[i].b);
              char *expected = gsk_rounded_rect_to_string (&test[i].expected);
              char *result = gsk_rounded_rect_to_string (&out);
              g_test_message ("     A = %s\n"
                              "     B = %s\n"
                              "expected %s\n"
                              "     got %s\n",
                              a, b, expected, result);
            }
          g_assert_true (gsk_rounded_rect_equal (&out, &test[i].expected));
        }
    }
}

static void
test_rounded_rect_dihedral (void)
{
  struct {
    GdkDihedral dihedral;
    GskRoundedRect in;
    GskRoundedRect expected;
  } test[] = {
    {
      GDK_DIHEDRAL_NORMAL,
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
    },
    {
      GDK_DIHEDRAL_90,
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
      ROUNDED_RECT_INIT_FULL(-50, -5010010076103254),
    },
    {
      GDK_DIHEDRAL_180,
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
      ROUNDED_RECT_INIT_FULL(-50, -5010010045670123),
    },
    {
      GDK_DIHEDRAL_270,
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
      ROUNDED_RECT_INIT_FULL(-50, -5010010032547610),
    },
    {
      GDK_DIHEDRAL_FLIPPED,
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
      ROUNDED_RECT_INIT_FULL(-50, -5010010023016745),
    },
    {
      GDK_DIHEDRAL_FLIPPED_90,
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
      ROUNDED_RECT_INIT_FULL(-50, -5010010010765432),
    },
    {
      GDK_DIHEDRAL_FLIPPED_180,
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
      ROUNDED_RECT_INIT_FULL(-50, -5010010067452301),
    },
    {
      GDK_DIHEDRAL_FLIPPED_270,
      ROUNDED_RECT_INIT_FULL(-50, -5010010001234567),
      ROUNDED_RECT_INIT_FULL(-50, -5010010054321076),
    },
  };

  g_test_summary ("Verifies the results of gsk_rounded_rect_dihedral");

  for (gsize i = 0; i < G_N_ELEMENTS (test); i++)
    {
      GskRoundedRect out;

      gsk_rounded_rect_dihedral (&out, &test[i].in, test[i].dihedral);
      if (!gsk_rounded_rect_equal (&out, &test[i].expected))
        {
          char *b = gsk_rounded_rect_to_string (&out);
          char *expected = gsk_rounded_rect_to_string (&test[i].expected);
          g_test_message ("rounded rect %s\n"
                          "expected: %s\n"
                          "got: %s\n",
                          gdk_dihedral_get_name (i), expected, b);
        }
      g_assert_true (gsk_rounded_rect_equal (&out, &test[i].expected));
    }
}

static void
test_rect_dihedral (void)
{
  struct {
    GdkDihedral dihedral;
    graphene_rect_t in;
    graphene_rect_t expected;
  } test[] = {
    {
      GDK_DIHEDRAL_NORMAL,
      GRAPHENE_RECT_INIT (0050100),
      GRAPHENE_RECT_INIT (0050100),
    },
    {
      GDK_DIHEDRAL_90,
      GRAPHENE_RECT_INIT (0050100),
      GRAPHENE_RECT_INIT (-100010050),
    },
    {
      GDK_DIHEDRAL_180,
      GRAPHENE_RECT_INIT (0050100),
      GRAPHENE_RECT_INIT (-50, -10050100),
    },
    {
      GDK_DIHEDRAL_270,
      GRAPHENE_RECT_INIT (0050100),
      GRAPHENE_RECT_INIT (0, -5010050),
    },
    {
      GDK_DIHEDRAL_FLIPPED,
      GRAPHENE_RECT_INIT (0050100),
      GRAPHENE_RECT_INIT (-50050100),
    },
    {
      GDK_DIHEDRAL_FLIPPED_90,
      GRAPHENE_RECT_INIT (0050100),
      GRAPHENE_RECT_INIT (0010050),
    },
    {
      GDK_DIHEDRAL_FLIPPED_180,
      GRAPHENE_RECT_INIT (0050100),
      GRAPHENE_RECT_INIT (0, -10050100),
    },
    {
      GDK_DIHEDRAL_FLIPPED_270,
      GRAPHENE_RECT_INIT (0050100),
      GRAPHENE_RECT_INIT (-100, -5010050),
    },
  };

  g_test_summary ("Verifies the results of gsk_rect_dihedral");

  for (gsize i = 0; i < G_N_ELEMENTS (test); i++)
    {
      graphene_rect_t out;

      gsk_rect_dihedral (&test[i].in, test[i].dihedral, &out);
      if (!gsk_rect_equal (&out, &test[i].expected))
        {
          graphene_rect_t a = test[i].expected;
          graphene_rect_t b = out;
          g_test_message ("rect %s\n"
                          "expected: %f %f %f %f\n"
                          "got: %f %f %f %f\n",
                          gdk_dihedral_get_name (test[i].dihedral),
                          a.origin.x, a.origin.y, a.size.width, a.size.height,
                          b.origin.x, b.origin.y, b.size.width, b.size.height);
        }
      g_assert_true (gsk_rect_equal (&out, &test[i].expected));
    }
}

int
main (int   argc,
      char *argv[])
{
  gtk_test_init (&argc, &argv, NULL);
  g_test_set_nonfatal_assertions ();

  g_test_add_func ("/rounded-rect/contains-rect", test_contains_rect);
  g_test_add_func ("/rounded-rect/intersects-rect", test_intersects_rect);
  g_test_add_func ("/rounded-rect/contains-point", test_contains_point);
  g_test_add_func ("/rounded-rect/is-circular", test_is_circular);
  g_test_add_func ("/rounded-rect/to-float", test_to_float);
  g_test_add_func ("/rounded-rect/intersect-with-rect", test_intersect_with_rect);
  g_test_add_func ("/rounded-rect/intersect", test_intersect);
  g_test_add_func ("/rounded-rect/dihedral", test_rounded_rect_dihedral);
  g_test_add_func ("/rect/dihedral", test_rect_dihedral);

  return g_test_run ();
}

Messung V0.5 in Prozent
C=99 H=92 G=95

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-07-02) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik