From unknown Wed Aug 20 05:15:52 2025 X-Loop: help-debbugs@gnu.org Subject: bug#28386: [PATCH] Add tests for color.el Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Sep 2017 19:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28386 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 28386@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.150481235012099 (code B ref -1); Thu, 07 Sep 2017 19:26:01 +0000 Received: (at submit) by debbugs.gnu.org; 7 Sep 2017 19:25:50 +0000 Received: from localhost ([127.0.0.1]:54691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dq2Qw-000394-21 for submit@debbugs.gnu.org; Thu, 07 Sep 2017 15:25:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51319) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dq2Qu-00038p-Fy for submit@debbugs.gnu.org; Thu, 07 Sep 2017 15:25:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq2Qj-0004yb-EX for submit@debbugs.gnu.org; Thu, 07 Sep 2017 15:25:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42621) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dq2Qj-0004yC-1k for submit@debbugs.gnu.org; Thu, 07 Sep 2017 15:25:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq2Qc-0007Mt-MS for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 15:25:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq2QW-0004oz-Ol for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 15:25:30 -0400 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]:33613) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dq2QW-0004my-BM for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 15:25:24 -0400 Received: by mail-lf0-x22a.google.com with SMTP id c80so1300864lfh.0 for ; Thu, 07 Sep 2017 12:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:message-id:mime-version; bh=frDFNDUa6s60LlxTjOYeRto7+75+RIo/UT9OhToMYF8=; b=Sqr4NmHhWy6ShrQrmMK7XWA/rTFbIOBJfhw8hPoEKgPZuM/nosWTCscJCXEnHpCcMk Pfq8eTcp7sxqMbRKNmqS6V/Ycib4Bn1vGFl6Zq+aWfyJ/F6/7ZXfC1/+q2l+MsJ5o73a kczqQzlKcHp2TxccnblCaM3AtBW2qoBSELgYxbnFJj/AhyYmOf4qMpzb8UqTDCzf/E8q YkiWdvM3n3KnDKvtMuD+o9M72Xj/h525j+2exmQVoQzVI9znihF1apfJzbFTQ50Khunn ttU+krYUBqDf3Szxvkz9h3QJmYYsPV8cvl/EVvNrucdMD11fWJc9TlQtTl+CuDtmcn0X plkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:message-id:mime-version; bh=frDFNDUa6s60LlxTjOYeRto7+75+RIo/UT9OhToMYF8=; b=VjJHXqPBTDadBr3PT7wUJHGZFpRX6QtdBjT/E+9UqezINCPrd84E+U8CXIQF50dyvd MZB2ge2O8Azbuc9ZUw2NTSJi6kGikyEH+RkVMiW/7REAQgm0PDQfiXOTIM09Imdd+EYz 0OVFMdRZPmQUflSpwpLOBCG+/i9B6y5TFu87rT5zluZmP4TgHfLOXg8XEytI6PHBhh+L h0vZM1JypgrfLr1v6PnVsudJfP3ptXqTHglMBfO4DKdG8OB5yORXU3K80WXiIqDQ+B/m IKGPoBjKXGZMFCHRRsy3mprhrrOXl0wz8pNaiZImpcx4Ek6rPC/2wLX+UdpURZw8+x40 t9tA== X-Gm-Message-State: AHPjjUheOnAaDuuhWxK2siu2D0InK87CYaZjo0y82PBzavz2k8fcWPx+ zpIj8YQkJ3hzUEtq X-Google-Smtp-Source: AOwi7QDwUecp8eDQcyETqRB98JeQyoXZPUDMhaRgUAU8j2K7dQEBJrnf3PLUnf7XHxGwCWtx0VZA2w== X-Received: by 10.46.68.66 with SMTP id r63mr103632lja.145.1504812321565; Thu, 07 Sep 2017 12:25:21 -0700 (PDT) Received: from [192.168.100.3] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id l18sm13802ljb.41.2017.09.07.12.25.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 12:25:20 -0700 (PDT) Date: Thu, 07 Sep 2017 21:25:18 +0200 From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Message-Id: <1504812318.20485.0@smtp.gmail.com> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-j682YigBcsA2WpiLTvak" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-j682YigBcsA2WpiLTvak Content-Type: text/plain; charset=utf-8; format=flowed Hi, I've written some initial tests for color.el. Unless there are any objections I'll install the patch in a couple of days. -- Simen --=-j682YigBcsA2WpiLTvak Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-tests-for-color.el.patch Content-Transfer-Encoding: quoted-printable >From 27e9b944c196ac4110c82bdf5c53efaf469a2f49 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D Date: Thu, 7 Sep 2017 20:40:12 +0200 Subject: [PATCH] Add tests for color.el * lisp/color.el (color-name-to-rgb, color-complement): Clarify in docstrings that RGB triplets should use four digits per component. (color-rgb-to-hsl): Break line to avoid "Hidden behind deeper element" warning. * test/lisp/color-tests.el: New file. --- lisp/color.el | 8 +- test/lisp/color-tests.el | 250 +++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 test/lisp/color-tests.el diff --git a/lisp/color.el b/lisp/color.el index 6dbf3d55cb..044b48114f 100644 --- a/lisp/color.el +++ b/lisp/color.el @@ -42,7 +42,7 @@ (defun color-name-to-rgb (color &optional frame) "Convert COLOR string to a list of normalized RGB components. COLOR should be a color name (e.g. \"white\") or an RGB triplet -string (e.g. \"#ff12ec\"). +string (e.g. \"#ffff1122eecc\"). =20 Normally the return value is a list of three floating-point numbers, (RED GREEN BLUE), each between 0.0 and 1.0 inclusive. @@ -68,7 +68,8 @@ color-rgb-to-hex (defun color-complement (color-name) "Return the color that is the complement of COLOR-NAME. COLOR-NAME should be a string naming a color (e.g. \"white\"), or -a string specifying a color's RGB components (e.g. \"#ff12ec\")." +a string specifying a color's RGB +components (e.g. \"#ffff1212ecec\")." (let ((color (color-name-to-rgb color-name))) (list (- 1.0 (nth 0 color)) (- 1.0 (nth 1 color)) @@ -177,7 +178,8 @@ color-rgb-to-hsl ((=3D r max) (- bc gc)) ((=3D g max) (+ 2.0 rc (- bc))) (t (+ 4.0 gc (- rc)))) - 6.0) 1.0))) + 6.0) + 1.0))) (list h s l))))) =20 (defun color-srgb-to-xyz (red green blue) diff --git a/test/lisp/color-tests.el b/test/lisp/color-tests.el new file mode 100644 index 0000000000..6ed87742f3 --- /dev/null +++ b/test/lisp/color-tests.el @@ -0,0 +1,250 @@ +;;; color-tests.el --- Tests for color.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; Author: Simen Heggest=C3=B8yl +;; Keywords: + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs 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 General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; + +;;; Code: + +(require 'cl-lib) +(require 'color) +(require 'ert) +(require 'seq) + +(defun color-tests--approx-equal (color1 color2) + "Return t if COLOR1 and COLOR2 are approximately equal." + (seq-every-p + (lambda (x) (< (abs x) 0.00001)) + (cl-mapcar #'- color1 color2))) + +(ert-deftest color-tests-name-to-rgb () + (should (equal (color-name-to-rgb "black") '(0.0 0.0 0.0))) + (should (equal (color-name-to-rgb "white") '(1.0 1.0 1.0))) + (should (equal (color-name-to-rgb "red") '(1.0 0.0 0.0))) + (should (equal (color-name-to-rgb "green") '(0.0 1.0 0.0))) + (should (equal (color-name-to-rgb "blue") '(0.0 0.0 1.0))) + (should (equal (color-name-to-rgb "#000000000000") '(0.0 0.0 0.0))) + (should (equal (color-name-to-rgb "#ffffffffffff") '(1.0 1.0 1.0))) + (should (equal (color-name-to-rgb "#ffff00000000") '(1.0 0.0 0.0))) + (should (equal (color-name-to-rgb "#0000ffff0000") '(0.0 1.0 0.0))) + (should (equal (color-name-to-rgb "#00000000ffff") '(0.0 0.0 1.0)))) + +(ert-deftest color-tests-rgb-to-hex () + (should (equal (color-rgb-to-hex 0 0 0) "#000000000000")) + (should (equal (color-rgb-to-hex 0 0 0 2) "#000000")) + (should (equal (color-rgb-to-hex 1 0 0) "#ffff00000000")) + (should (equal (color-rgb-to-hex 1 0 0 2) "#ff0000")) + (should (equal (color-rgb-to-hex 0.1 0.2 0.3) "#199933334ccc")) + (should (equal (color-rgb-to-hex 0.1 0.2 0.3 2) "#19334c"))) + +(ert-deftest color-tests-complement () + (should (equal (color-complement "white") '(0.0 0.0 0.0))) + (should (equal (color-complement "#ffffffffffff") '(0.0 0.0 0.0))) + (should (equal (color-complement "red") '(0.0 1.0 1.0)))) + +(ert-deftest color-tests-gradient () + (should-not (color-gradient '(0 0 0) '(255 255 255) 0)) + (should + (equal (color-gradient '(0 0 0) '(255 255 255) 1) + '((127 127 127)))) + (should + (equal (color-gradient '(0 0 0) '(255 255 255) 2) + '((85 85 85) (170 170 170)))) + (should + (equal (color-gradient '(255 192 203) '(250 128 114) 3) + '((254 176 181) (253 160 159) (252 144 137))))) + +(ert-deftest color-tests-hsl-to-rgb () + (should (equal (color-hsl-to-rgb 0 0 0) '(0 0 0))) + (should (equal (color-hsl-to-rgb 360 0.5 0.5) '(0.75 0.25 0.25))) + (should (equal (color-hsl-to-rgb 123 0.2 0.9) '(0.92 0.88 0.88)))) + +(ert-deftest color-tests-complement-hex () + (should + (equal (color-complement-hex "#000000000000") "#ffffffffffff")) + (should + (equal (color-complement-hex "#ffff00000000") "#0000ffffffff"))) + +(ert-deftest color-tests-rgb-to-hsv () + (should (equal (color-rgb-to-hsv 0 0 0) '(0.0 0.0 0.0))) + (should (equal (color-rgb-to-hsv 1 1 1) '(0.0 0.0 1.0))) + (should (equal (color-rgb-to-hsv 1 0 0) '(0.0 1.0 1.0))) + (should (equal (color-rgb-to-hsv 0.5 0.3 0.3) '(0.0 0.4 0.5)))) + +(ert-deftest color-tests-rgb-to-hsl () + (should (equal (color-rgb-to-hsl 0 0 0) '(0.0 0.0 0.0))) + (should (equal (color-rgb-to-hsl 1 1 1) '(0.0 0.0 1.0))) + (should (equal (color-rgb-to-hsl 1 0 0) '(0.0 1 0.5))) + (should (equal (color-rgb-to-hsl 0.5 0.3 0.3) '(0.0 0.25 0.4)))) + +(ert-deftest color-tests-srgb-to-xyz () + (should (equal (color-srgb-to-xyz 0 0 0) '(0.0 0.0 0.0))) + (should + (equal (color-srgb-to-xyz 0 0 1) '(0.1804375 0.072175 0.9503041))) + (should + (color-tests--approx-equal + (color-srgb-to-xyz 0.1 0.2 0.3) '(0.0291865 0.031092 0.073738)))) + +(ert-deftest color-tests-xyz-to-srgb () + (should (equal (color-xyz-to-srgb 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-xyz-to-srgb 0.1804375 0.072175 0.9503041) '(0 0 1))) + (should + (color-tests--approx-equal + (color-xyz-to-srgb 0.0291865 0.031092 0.073738) '(0.1 0.2 0.3)))) + +(ert-deftest color-tests-xyz-to-lab () + (should (equal (color-xyz-to-lab 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-xyz-to-lab 0.1804375 0.072175 0.9503041) + '(32.2970109 79.1890315 -107.8646674))) + (should + (color-tests--approx-equal + (color-xyz-to-lab 0.1804375 0.072175 0.9503041 '(1 1 1)) + '(32.2970109 74.3625763 -113.3597823))) + (should + (color-tests--approx-equal + (color-xyz-to-lab 0.0291865 0.031092 0.073738) + '(20.4760281 -0.6500752 -18.6340169)))) + +(ert-deftest color-tests-lab-to-xyz () + (should (equal (color-lab-to-xyz 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-lab-to-xyz 32.2970109 79.1890315 -107.8646674) + '(0.1804375 0.072175 0.9503041))) + (should + (color-tests--approx-equal + (color-lab-to-xyz 32.2970109 74.3625763 -113.3597823 '(1 1 1)) + '(0.1804375 0.072175 0.9503041))) + (should + (color-tests--approx-equal + (color-lab-to-xyz 20.4760281 -0.6500752 -18.6340169) + '(0.0291865 0.031092 0.073738)))) + +(ert-deftest color-tests-srgb-to-lab () + (should (equal (color-srgb-to-lab 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-srgb-to-lab 0 1 0) '(87.7347223 -86.1808176 83.1770651))) + (should + (color-tests--approx-equal + (color-srgb-to-lab 0.1 0.2 0.3) + '(20.4762218 -0.6508996 -18.6340085)))) + +(ert-deftest color-tests-lab-to-srgb () + (should (equal (color-lab-to-srgb 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-lab-to-srgb 87.7347223 -86.1808176 83.1770651) '(0 1 0))) + (should + (color-tests--approx-equal + (color-lab-to-srgb 20.4762218 -0.6508996 -18.6340085) + '(0.1 0.2 0.3)))) + +(ert-deftest color-tests-cie-de2000 () + (should (=3D (color-cie-de2000 '(0 0 0) '(0 0 0)) 0.0)) + (should + (color-tests--approx-equal + (list + (color-cie-de2000 + (color-srgb-to-lab 1 0 0) (color-srgb-to-lab 0 0 1))) + '(52.8803934))) + (should + (color-tests--approx-equal + (list + (color-cie-de2000 + (color-srgb-to-lab 0.8 0 0) (color-srgb-to-lab 0.9 0 0))) + '(5.3844503)))) + +(ert-deftest color-tests-clamp () + (should (=3D (color-clamp 0) 0.0)) + (should (=3D (color-clamp -1) 0.0)) + (should (=3D (color-clamp 0.5) 0.5)) + (should (=3D (color-clamp 1) 1.0)) + (should (=3D (color-clamp 1.1) 1.0))) + +(ert-deftest color-tests-saturate-hsl () + (should (equal (color-saturate-hsl 360 0.5 0.5 0) '(360 0.5 0.5))) + (should (equal (color-saturate-hsl 360 0.5 0.5 -10) '(360 0.4 0.5))) + (should + (equal (color-saturate-hsl 360 0.5 0.5 -500) '(360 0.0 0.5))) + (should (equal (color-saturate-hsl 120 0.5 0.8 5) '(120 0.55 0.8))) + (should + (equal (color-saturate-hsl 120 0.5 0.8 500) '(120 1.0 0.8)))) + +(ert-deftest color-tests-saturate-name () + (should (equal (color-saturate-name "black" 100) "#000000000000")) + (should (equal (color-saturate-name "white" 100) "#ffffffffffff")) + (should (equal (color-saturate-name "red" 0) "#ffff00000000")) + (should (equal (color-saturate-name "red" 50) "#ffff00000000"))) + +(ert-deftest color-tests-desaturate-hsl () + (should (equal (color-desaturate-hsl 360 0.5 0.5 0) '(360 0.5 0.5))) + (should + (equal (color-desaturate-hsl 360 0.5 0.5 -10) '(360 0.6 0.5))) + (should + (equal (color-desaturate-hsl 360 0.5 0.5 -500) '(360 1.0 0.5))) + (should + (equal (color-desaturate-hsl 120 0.5 0.8 5) '(120 0.45 0.8))) + (should + (equal (color-desaturate-hsl 120 0.5 0.8 500) '(120 0.0 0.8)))) + +(ert-deftest color-tests-desaturate-name () + (should (equal (color-desaturate-name "black" 100) "#000000000000")) + (should (equal (color-desaturate-name "white" 100) "#ffffffffffff")) + (should (equal (color-desaturate-name "red" 0) "#ffff00000000"))) + +(ert-deftest color-tests-lighten-hsl () + (should (equal (color-lighten-hsl 360 0.5 0.5 0) '(360 0.5 0.5))) + (should (equal (color-lighten-hsl 360 0.5 0.5 -10) '(360 0.5 0.4))) + (should (equal (color-lighten-hsl 360 0.5 0.5 -500) '(360 0.5 0.0))) + (should + (color-tests--approx-equal + (color-lighten-hsl 120 0.5 0.8 5) '(120 0.5 0.85))) + (should + (equal (color-lighten-hsl 120 0.5 0.8 500) '(120 0.5 1.0)))) + +(ert-deftest color-tests-lighten-name () + (should (equal (color-lighten-name "black" 100) "#ffffffffffff")) + (should (equal (color-lighten-name "white" 100) "#ffffffffffff")) + (should (equal (color-lighten-name "red" 0) "#ffff00000000")) + (should (equal (color-lighten-name "red" 10) "#ffff33323332"))) + +(ert-deftest color-tests-darken-hsl () + (should (equal (color-darken-hsl 360 0.5 0.5 0) '(360 0.5 0.5))) + (should (equal (color-darken-hsl 360 0.5 0.5 -10) '(360 0.5 0.6))) + (should (equal (color-darken-hsl 360 0.5 0.5 -500) '(360 0.5 1.0))) + (should (equal (color-darken-hsl 120 0.5 0.8 5) '(120 0.5 0.75))) + (should (equal (color-darken-hsl 120 0.5 0.8 500) '(120 0.5 0.0)))) + +(ert-deftest color-tests-darken-name () + (should (equal (color-darken-name "black" 100) "#000000000000")) + (should (equal (color-darken-name "white" 100) "#000000000000")) + (should (equal (color-darken-name "red" 0) "#ffff00000000")) + (should (equal (color-darken-name "red" 10) "#cccc00000000"))) + +(provide 'color-tests) +;;; color-tests.el ends here --=20 2.14.1 = --=-j682YigBcsA2WpiLTvak-- From unknown Wed Aug 20 05:15:52 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Subject: bug#28386: closed (Re: bug#28386: Acknowledgement ([PATCH] Add tests for color.el)) Message-ID: References: <1505327206.23662.0@smtp.gmail.com> <1504812318.20485.0@smtp.gmail.com> X-Gnu-PR-Message: they-closed 28386 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 28386@debbugs.gnu.org Date: Wed, 13 Sep 2017 18:27:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1505327222-16268-1" This is a multi-part message in MIME format... ------------=_1505327222-16268-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #28386: [PATCH] Add tests for color.el which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 28386@debbugs.gnu.org. --=20 28386: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D28386 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1505327222-16268-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 28386-done) by debbugs.gnu.org; 13 Sep 2017 18:26:56 +0000 Received: from localhost ([127.0.0.1]:38749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsCNE-0004E4-8A for submit@debbugs.gnu.org; Wed, 13 Sep 2017 14:26:56 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:44177) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsCND-0004Ds-EU for 28386-done@debbugs.gnu.org; Wed, 13 Sep 2017 14:26:55 -0400 Received: by mail-lf0-f41.google.com with SMTP id l196so2823064lfl.1 for <28386-done@debbugs.gnu.org>; Wed, 13 Sep 2017 11:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:message-id:in-reply-to:references:mime-version; bh=yD/Muo8DXQHYt34kr6NHY9OBTZWziY3CEjXQXe9M3MA=; b=gebz7RbIrVX9MjXTI4qI9hTFbzi8DEBuC6dpyAcY3puhz6SkO0oRUL3yfpy1CfBJJp AcmtjTZD3W1yqO9ARt4s24zS4DuyBv7JuQXrGr/hHU/nNQZamVWEUREWyfmdoVN5U8mN cgOqpmrnwSFFmf0TUNMNCTz/sfwYKdnepyRQ+fs/ILacAa06SsUeiqkaJ5sKKR5iSFu1 N7lNaLxJzW0IR9stfzpCNx+5yvO60cYF5bpqce7SjApd+mDg4nvX841mh5d66qLZ/9xz 0OBmCpINw823jdCa0VGM8OxZoIP1RasxKX4RaMP0wYaYnnXvMB00hFGvlFFJdOxliw53 mUDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:message-id:in-reply-to :references:mime-version; bh=yD/Muo8DXQHYt34kr6NHY9OBTZWziY3CEjXQXe9M3MA=; b=AZIf7+BCpbzbTrtNqc7mQSfYm/0VU1WH7u2gJQWqkhZPXAnN6H0FluYs//d8IR7I6O 8kDQM+8HKqu5Us+/Z2f742f3gOlFy/1jmH8pUK/uOa70ZMyvsN+Th3tB5JZE51jFoX/6 sxDADEAq6SH1JSVLF/nwo7/Rl9OMtQCMzW7PaK5d3b/3DvGZn1RnkLC/QssJAXHEkoB2 9nA7GrV+N0dzera3woztjKmeExCNT5yp3aW3VHUTqRz1/kRLEWvHXkFWVswpb38s1kBe rypiYCLYFZnMX7TujskyNcKSVZlD+XsqP9omUkS7n65lKP85EFbB4KrkFhH8G9GTL4Uu 3rVg== X-Gm-Message-State: AHPjjUgEB3GDyxS22U7ivjyLCLEalrptAUVBLgAypApCEe9wnf0WwEvg 1WhffT1Crnsj+xg7 X-Google-Smtp-Source: AOwi7QCMW38kTuTzsa0p2Szp370IiIfAeAmlsmjNJOzgV7TsJ69WfGgOSFnoiYUlyRLc0SeYMUwvFA== X-Received: by 10.46.85.76 with SMTP id j73mr7353876ljb.109.1505327208979; Wed, 13 Sep 2017 11:26:48 -0700 (PDT) Received: from [192.168.100.3] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id b75sm2706224lff.38.2017.09.13.11.26.47 for <28386-done@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2017 11:26:48 -0700 (PDT) Date: Wed, 13 Sep 2017 20:26:46 +0200 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#28386: Acknowledgement ([PATCH] Add tests for color.el) To: 28386-done@debbugs.gnu.org Message-Id: <1505327206.23662.0@smtp.gmail.com> In-Reply-To: References: <1504812318.20485.0@smtp.gmail.com> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 28386-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Installed with minor changes to accommodate for 8d433d9b22d2c5f209cb27e80c13576e6d1bf9b7. -- Simen ------------=_1505327222-16268-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 7 Sep 2017 19:25:50 +0000 Received: from localhost ([127.0.0.1]:54691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dq2Qw-000394-21 for submit@debbugs.gnu.org; Thu, 07 Sep 2017 15:25:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51319) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dq2Qu-00038p-Fy for submit@debbugs.gnu.org; Thu, 07 Sep 2017 15:25:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq2Qj-0004yb-EX for submit@debbugs.gnu.org; Thu, 07 Sep 2017 15:25:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42621) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dq2Qj-0004yC-1k for submit@debbugs.gnu.org; Thu, 07 Sep 2017 15:25:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq2Qc-0007Mt-MS for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 15:25:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq2QW-0004oz-Ol for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 15:25:30 -0400 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]:33613) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dq2QW-0004my-BM for bug-gnu-emacs@gnu.org; Thu, 07 Sep 2017 15:25:24 -0400 Received: by mail-lf0-x22a.google.com with SMTP id c80so1300864lfh.0 for ; Thu, 07 Sep 2017 12:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:message-id:mime-version; bh=frDFNDUa6s60LlxTjOYeRto7+75+RIo/UT9OhToMYF8=; b=Sqr4NmHhWy6ShrQrmMK7XWA/rTFbIOBJfhw8hPoEKgPZuM/nosWTCscJCXEnHpCcMk Pfq8eTcp7sxqMbRKNmqS6V/Ycib4Bn1vGFl6Zq+aWfyJ/F6/7ZXfC1/+q2l+MsJ5o73a kczqQzlKcHp2TxccnblCaM3AtBW2qoBSELgYxbnFJj/AhyYmOf4qMpzb8UqTDCzf/E8q YkiWdvM3n3KnDKvtMuD+o9M72Xj/h525j+2exmQVoQzVI9znihF1apfJzbFTQ50Khunn ttU+krYUBqDf3Szxvkz9h3QJmYYsPV8cvl/EVvNrucdMD11fWJc9TlQtTl+CuDtmcn0X plkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:message-id:mime-version; bh=frDFNDUa6s60LlxTjOYeRto7+75+RIo/UT9OhToMYF8=; b=VjJHXqPBTDadBr3PT7wUJHGZFpRX6QtdBjT/E+9UqezINCPrd84E+U8CXIQF50dyvd MZB2ge2O8Azbuc9ZUw2NTSJi6kGikyEH+RkVMiW/7REAQgm0PDQfiXOTIM09Imdd+EYz 0OVFMdRZPmQUflSpwpLOBCG+/i9B6y5TFu87rT5zluZmP4TgHfLOXg8XEytI6PHBhh+L h0vZM1JypgrfLr1v6PnVsudJfP3ptXqTHglMBfO4DKdG8OB5yORXU3K80WXiIqDQ+B/m IKGPoBjKXGZMFCHRRsy3mprhrrOXl0wz8pNaiZImpcx4Ek6rPC/2wLX+UdpURZw8+x40 t9tA== X-Gm-Message-State: AHPjjUheOnAaDuuhWxK2siu2D0InK87CYaZjo0y82PBzavz2k8fcWPx+ zpIj8YQkJ3hzUEtq X-Google-Smtp-Source: AOwi7QDwUecp8eDQcyETqRB98JeQyoXZPUDMhaRgUAU8j2K7dQEBJrnf3PLUnf7XHxGwCWtx0VZA2w== X-Received: by 10.46.68.66 with SMTP id r63mr103632lja.145.1504812321565; Thu, 07 Sep 2017 12:25:21 -0700 (PDT) Received: from [192.168.100.3] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id l18sm13802ljb.41.2017.09.07.12.25.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 12:25:20 -0700 (PDT) Date: Thu, 07 Sep 2017 21:25:18 +0200 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: [PATCH] Add tests for color.el To: bug-gnu-emacs@gnu.org Message-Id: <1504812318.20485.0@smtp.gmail.com> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-j682YigBcsA2WpiLTvak" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-j682YigBcsA2WpiLTvak Content-Type: text/plain; charset=utf-8; format=flowed Hi, I've written some initial tests for color.el. Unless there are any objections I'll install the patch in a couple of days. -- Simen --=-j682YigBcsA2WpiLTvak Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-tests-for-color.el.patch Content-Transfer-Encoding: quoted-printable >From 27e9b944c196ac4110c82bdf5c53efaf469a2f49 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D Date: Thu, 7 Sep 2017 20:40:12 +0200 Subject: [PATCH] Add tests for color.el * lisp/color.el (color-name-to-rgb, color-complement): Clarify in docstrings that RGB triplets should use four digits per component. (color-rgb-to-hsl): Break line to avoid "Hidden behind deeper element" warning. * test/lisp/color-tests.el: New file. --- lisp/color.el | 8 +- test/lisp/color-tests.el | 250 +++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 test/lisp/color-tests.el diff --git a/lisp/color.el b/lisp/color.el index 6dbf3d55cb..044b48114f 100644 --- a/lisp/color.el +++ b/lisp/color.el @@ -42,7 +42,7 @@ (defun color-name-to-rgb (color &optional frame) "Convert COLOR string to a list of normalized RGB components. COLOR should be a color name (e.g. \"white\") or an RGB triplet -string (e.g. \"#ff12ec\"). +string (e.g. \"#ffff1122eecc\"). =20 Normally the return value is a list of three floating-point numbers, (RED GREEN BLUE), each between 0.0 and 1.0 inclusive. @@ -68,7 +68,8 @@ color-rgb-to-hex (defun color-complement (color-name) "Return the color that is the complement of COLOR-NAME. COLOR-NAME should be a string naming a color (e.g. \"white\"), or -a string specifying a color's RGB components (e.g. \"#ff12ec\")." +a string specifying a color's RGB +components (e.g. \"#ffff1212ecec\")." (let ((color (color-name-to-rgb color-name))) (list (- 1.0 (nth 0 color)) (- 1.0 (nth 1 color)) @@ -177,7 +178,8 @@ color-rgb-to-hsl ((=3D r max) (- bc gc)) ((=3D g max) (+ 2.0 rc (- bc))) (t (+ 4.0 gc (- rc)))) - 6.0) 1.0))) + 6.0) + 1.0))) (list h s l))))) =20 (defun color-srgb-to-xyz (red green blue) diff --git a/test/lisp/color-tests.el b/test/lisp/color-tests.el new file mode 100644 index 0000000000..6ed87742f3 --- /dev/null +++ b/test/lisp/color-tests.el @@ -0,0 +1,250 @@ +;;; color-tests.el --- Tests for color.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; Author: Simen Heggest=C3=B8yl +;; Keywords: + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs 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 General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; + +;;; Code: + +(require 'cl-lib) +(require 'color) +(require 'ert) +(require 'seq) + +(defun color-tests--approx-equal (color1 color2) + "Return t if COLOR1 and COLOR2 are approximately equal." + (seq-every-p + (lambda (x) (< (abs x) 0.00001)) + (cl-mapcar #'- color1 color2))) + +(ert-deftest color-tests-name-to-rgb () + (should (equal (color-name-to-rgb "black") '(0.0 0.0 0.0))) + (should (equal (color-name-to-rgb "white") '(1.0 1.0 1.0))) + (should (equal (color-name-to-rgb "red") '(1.0 0.0 0.0))) + (should (equal (color-name-to-rgb "green") '(0.0 1.0 0.0))) + (should (equal (color-name-to-rgb "blue") '(0.0 0.0 1.0))) + (should (equal (color-name-to-rgb "#000000000000") '(0.0 0.0 0.0))) + (should (equal (color-name-to-rgb "#ffffffffffff") '(1.0 1.0 1.0))) + (should (equal (color-name-to-rgb "#ffff00000000") '(1.0 0.0 0.0))) + (should (equal (color-name-to-rgb "#0000ffff0000") '(0.0 1.0 0.0))) + (should (equal (color-name-to-rgb "#00000000ffff") '(0.0 0.0 1.0)))) + +(ert-deftest color-tests-rgb-to-hex () + (should (equal (color-rgb-to-hex 0 0 0) "#000000000000")) + (should (equal (color-rgb-to-hex 0 0 0 2) "#000000")) + (should (equal (color-rgb-to-hex 1 0 0) "#ffff00000000")) + (should (equal (color-rgb-to-hex 1 0 0 2) "#ff0000")) + (should (equal (color-rgb-to-hex 0.1 0.2 0.3) "#199933334ccc")) + (should (equal (color-rgb-to-hex 0.1 0.2 0.3 2) "#19334c"))) + +(ert-deftest color-tests-complement () + (should (equal (color-complement "white") '(0.0 0.0 0.0))) + (should (equal (color-complement "#ffffffffffff") '(0.0 0.0 0.0))) + (should (equal (color-complement "red") '(0.0 1.0 1.0)))) + +(ert-deftest color-tests-gradient () + (should-not (color-gradient '(0 0 0) '(255 255 255) 0)) + (should + (equal (color-gradient '(0 0 0) '(255 255 255) 1) + '((127 127 127)))) + (should + (equal (color-gradient '(0 0 0) '(255 255 255) 2) + '((85 85 85) (170 170 170)))) + (should + (equal (color-gradient '(255 192 203) '(250 128 114) 3) + '((254 176 181) (253 160 159) (252 144 137))))) + +(ert-deftest color-tests-hsl-to-rgb () + (should (equal (color-hsl-to-rgb 0 0 0) '(0 0 0))) + (should (equal (color-hsl-to-rgb 360 0.5 0.5) '(0.75 0.25 0.25))) + (should (equal (color-hsl-to-rgb 123 0.2 0.9) '(0.92 0.88 0.88)))) + +(ert-deftest color-tests-complement-hex () + (should + (equal (color-complement-hex "#000000000000") "#ffffffffffff")) + (should + (equal (color-complement-hex "#ffff00000000") "#0000ffffffff"))) + +(ert-deftest color-tests-rgb-to-hsv () + (should (equal (color-rgb-to-hsv 0 0 0) '(0.0 0.0 0.0))) + (should (equal (color-rgb-to-hsv 1 1 1) '(0.0 0.0 1.0))) + (should (equal (color-rgb-to-hsv 1 0 0) '(0.0 1.0 1.0))) + (should (equal (color-rgb-to-hsv 0.5 0.3 0.3) '(0.0 0.4 0.5)))) + +(ert-deftest color-tests-rgb-to-hsl () + (should (equal (color-rgb-to-hsl 0 0 0) '(0.0 0.0 0.0))) + (should (equal (color-rgb-to-hsl 1 1 1) '(0.0 0.0 1.0))) + (should (equal (color-rgb-to-hsl 1 0 0) '(0.0 1 0.5))) + (should (equal (color-rgb-to-hsl 0.5 0.3 0.3) '(0.0 0.25 0.4)))) + +(ert-deftest color-tests-srgb-to-xyz () + (should (equal (color-srgb-to-xyz 0 0 0) '(0.0 0.0 0.0))) + (should + (equal (color-srgb-to-xyz 0 0 1) '(0.1804375 0.072175 0.9503041))) + (should + (color-tests--approx-equal + (color-srgb-to-xyz 0.1 0.2 0.3) '(0.0291865 0.031092 0.073738)))) + +(ert-deftest color-tests-xyz-to-srgb () + (should (equal (color-xyz-to-srgb 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-xyz-to-srgb 0.1804375 0.072175 0.9503041) '(0 0 1))) + (should + (color-tests--approx-equal + (color-xyz-to-srgb 0.0291865 0.031092 0.073738) '(0.1 0.2 0.3)))) + +(ert-deftest color-tests-xyz-to-lab () + (should (equal (color-xyz-to-lab 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-xyz-to-lab 0.1804375 0.072175 0.9503041) + '(32.2970109 79.1890315 -107.8646674))) + (should + (color-tests--approx-equal + (color-xyz-to-lab 0.1804375 0.072175 0.9503041 '(1 1 1)) + '(32.2970109 74.3625763 -113.3597823))) + (should + (color-tests--approx-equal + (color-xyz-to-lab 0.0291865 0.031092 0.073738) + '(20.4760281 -0.6500752 -18.6340169)))) + +(ert-deftest color-tests-lab-to-xyz () + (should (equal (color-lab-to-xyz 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-lab-to-xyz 32.2970109 79.1890315 -107.8646674) + '(0.1804375 0.072175 0.9503041))) + (should + (color-tests--approx-equal + (color-lab-to-xyz 32.2970109 74.3625763 -113.3597823 '(1 1 1)) + '(0.1804375 0.072175 0.9503041))) + (should + (color-tests--approx-equal + (color-lab-to-xyz 20.4760281 -0.6500752 -18.6340169) + '(0.0291865 0.031092 0.073738)))) + +(ert-deftest color-tests-srgb-to-lab () + (should (equal (color-srgb-to-lab 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-srgb-to-lab 0 1 0) '(87.7347223 -86.1808176 83.1770651))) + (should + (color-tests--approx-equal + (color-srgb-to-lab 0.1 0.2 0.3) + '(20.4762218 -0.6508996 -18.6340085)))) + +(ert-deftest color-tests-lab-to-srgb () + (should (equal (color-lab-to-srgb 0 0 0) '(0.0 0.0 0.0))) + (should + (color-tests--approx-equal + (color-lab-to-srgb 87.7347223 -86.1808176 83.1770651) '(0 1 0))) + (should + (color-tests--approx-equal + (color-lab-to-srgb 20.4762218 -0.6508996 -18.6340085) + '(0.1 0.2 0.3)))) + +(ert-deftest color-tests-cie-de2000 () + (should (=3D (color-cie-de2000 '(0 0 0) '(0 0 0)) 0.0)) + (should + (color-tests--approx-equal + (list + (color-cie-de2000 + (color-srgb-to-lab 1 0 0) (color-srgb-to-lab 0 0 1))) + '(52.8803934))) + (should + (color-tests--approx-equal + (list + (color-cie-de2000 + (color-srgb-to-lab 0.8 0 0) (color-srgb-to-lab 0.9 0 0))) + '(5.3844503)))) + +(ert-deftest color-tests-clamp () + (should (=3D (color-clamp 0) 0.0)) + (should (=3D (color-clamp -1) 0.0)) + (should (=3D (color-clamp 0.5) 0.5)) + (should (=3D (color-clamp 1) 1.0)) + (should (=3D (color-clamp 1.1) 1.0))) + +(ert-deftest color-tests-saturate-hsl () + (should (equal (color-saturate-hsl 360 0.5 0.5 0) '(360 0.5 0.5))) + (should (equal (color-saturate-hsl 360 0.5 0.5 -10) '(360 0.4 0.5))) + (should + (equal (color-saturate-hsl 360 0.5 0.5 -500) '(360 0.0 0.5))) + (should (equal (color-saturate-hsl 120 0.5 0.8 5) '(120 0.55 0.8))) + (should + (equal (color-saturate-hsl 120 0.5 0.8 500) '(120 1.0 0.8)))) + +(ert-deftest color-tests-saturate-name () + (should (equal (color-saturate-name "black" 100) "#000000000000")) + (should (equal (color-saturate-name "white" 100) "#ffffffffffff")) + (should (equal (color-saturate-name "red" 0) "#ffff00000000")) + (should (equal (color-saturate-name "red" 50) "#ffff00000000"))) + +(ert-deftest color-tests-desaturate-hsl () + (should (equal (color-desaturate-hsl 360 0.5 0.5 0) '(360 0.5 0.5))) + (should + (equal (color-desaturate-hsl 360 0.5 0.5 -10) '(360 0.6 0.5))) + (should + (equal (color-desaturate-hsl 360 0.5 0.5 -500) '(360 1.0 0.5))) + (should + (equal (color-desaturate-hsl 120 0.5 0.8 5) '(120 0.45 0.8))) + (should + (equal (color-desaturate-hsl 120 0.5 0.8 500) '(120 0.0 0.8)))) + +(ert-deftest color-tests-desaturate-name () + (should (equal (color-desaturate-name "black" 100) "#000000000000")) + (should (equal (color-desaturate-name "white" 100) "#ffffffffffff")) + (should (equal (color-desaturate-name "red" 0) "#ffff00000000"))) + +(ert-deftest color-tests-lighten-hsl () + (should (equal (color-lighten-hsl 360 0.5 0.5 0) '(360 0.5 0.5))) + (should (equal (color-lighten-hsl 360 0.5 0.5 -10) '(360 0.5 0.4))) + (should (equal (color-lighten-hsl 360 0.5 0.5 -500) '(360 0.5 0.0))) + (should + (color-tests--approx-equal + (color-lighten-hsl 120 0.5 0.8 5) '(120 0.5 0.85))) + (should + (equal (color-lighten-hsl 120 0.5 0.8 500) '(120 0.5 1.0)))) + +(ert-deftest color-tests-lighten-name () + (should (equal (color-lighten-name "black" 100) "#ffffffffffff")) + (should (equal (color-lighten-name "white" 100) "#ffffffffffff")) + (should (equal (color-lighten-name "red" 0) "#ffff00000000")) + (should (equal (color-lighten-name "red" 10) "#ffff33323332"))) + +(ert-deftest color-tests-darken-hsl () + (should (equal (color-darken-hsl 360 0.5 0.5 0) '(360 0.5 0.5))) + (should (equal (color-darken-hsl 360 0.5 0.5 -10) '(360 0.5 0.6))) + (should (equal (color-darken-hsl 360 0.5 0.5 -500) '(360 0.5 1.0))) + (should (equal (color-darken-hsl 120 0.5 0.8 5) '(120 0.5 0.75))) + (should (equal (color-darken-hsl 120 0.5 0.8 500) '(120 0.5 0.0)))) + +(ert-deftest color-tests-darken-name () + (should (equal (color-darken-name "black" 100) "#000000000000")) + (should (equal (color-darken-name "white" 100) "#000000000000")) + (should (equal (color-darken-name "red" 0) "#ffff00000000")) + (should (equal (color-darken-name "red" 10) "#cccc00000000"))) + +(provide 'color-tests) +;;; color-tests.el ends here --=20 2.14.1 = --=-j682YigBcsA2WpiLTvak-- ------------=_1505327222-16268-1--