File: test-easing.c

package info (click to toggle)
libadwaita-1 1.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,252 kB
  • sloc: ansic: 86,011; xml: 189; python: 60; sh: 30; makefile: 23; javascript: 9
file content (44 lines) | stat: -rw-r--r-- 950 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (C) 2021 Purism SPC
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 *
 * Author: Alice Mikhaylenko <alice.mikhaylenko@puri.sm>
 */

#include <adwaita.h>

static void
test_easing_ease (gconstpointer data)
{
  AdwEasing easing = GPOINTER_TO_INT (data);

  g_assert_cmpfloat_with_epsilon (adw_easing_ease (easing, 0), 0, 0.005);
  g_assert_cmpfloat_with_epsilon (adw_easing_ease (easing, 1), 1, 0.005);
}

int
main (int   argc,
      char *argv[])
{
  GEnumClass *enum_class;
  guint i;

  gtk_test_init (&argc, &argv, NULL);
  adw_init ();

  enum_class = g_type_class_ref (ADW_TYPE_EASING);

  for (i = 0; i < enum_class->n_values; i++) {
    GEnumValue *value = &enum_class->values[i];
    char *path = g_strdup_printf ("/Adwaita/Easing/%s", value->value_nick);

    g_test_add_data_func (path, GINT_TO_POINTER (value->value), test_easing_ease);

    g_free (path);
  }

  g_type_class_unref (enum_class);

  return g_test_run();
}