diff options
| author | Mark Oteiza | 2017-09-15 23:49:42 -0400 |
|---|---|---|
| committer | Mark Oteiza | 2017-09-15 23:49:42 -0400 |
| commit | f5f261c6901e51b28deaa05dab157a38adf08912 (patch) | |
| tree | 096d0d991bab7e6cd5a98afb6c2fa8b977099cf2 /test/src | |
| parent | 30c955b1725258546c6152a6dda8f634867a6319 (diff) | |
| download | emacs-f5f261c6901e51b28deaa05dab157a38adf08912.tar.gz emacs-f5f261c6901e51b28deaa05dab157a38adf08912.zip | |
Add lcms-temp->white-point and initial tests
* src/lcms.c (lcms-temp->white-point): New function.
* test/src/lcms-tests.el: New file.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/lcms-tests.el | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/src/lcms-tests.el b/test/src/lcms-tests.el new file mode 100644 index 00000000000..0d6b8db3d4b --- /dev/null +++ b/test/src/lcms-tests.el | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | ;;; lcms-tests.el --- tests for Little CMS interface -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Maintainer: emacs-devel@gnu.org | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; Some "exact" values computed using the colorspacious python library | ||
| 25 | ;; written by Nathaniel J. Smith. See | ||
| 26 | ;; https://colorspacious.readthedocs.io/en/v1.1.0/ | ||
| 27 | |||
| 28 | ;; Other references: | ||
| 29 | ;; http://www.babelcolor.com/index_htm_files/A%20review%20of%20RGB%20color%20spaces.pdf | ||
| 30 | |||
| 31 | ;;; Code: | ||
| 32 | |||
| 33 | (require 'ert) | ||
| 34 | (require 'color) | ||
| 35 | |||
| 36 | (defun lcms-approx-p (a b &optional delta) | ||
| 37 | "Check if A and B are within relative error DELTA of one another. | ||
| 38 | B is considered the exact value." | ||
| 39 | (> (or delta 0.001) (abs (1- (/ a b))))) | ||
| 40 | |||
| 41 | (defun lcms-triple-approx-p (a b &optional delta) | ||
| 42 | "Like `lcms-approx-p' except for color triples." | ||
| 43 | (pcase-let ((`(,a1 ,a2 ,a3) a) | ||
| 44 | (`(,b1 ,b2 ,b3) b)) | ||
| 45 | (and (lcms-approx-p a1 b1 delta) | ||
| 46 | (lcms-approx-p a2 b2 delta) | ||
| 47 | (lcms-approx-p a3 b3 delta)))) | ||
| 48 | |||
| 49 | (ert-deftest lcms-whitepoint () | ||
| 50 | "Test use of `lcms-temp->white-point'." | ||
| 51 | (should-error (lcms-temp->white-point 3999)) | ||
| 52 | (should-error (lcms-temp->white-point 25001)) | ||
| 53 | ;; D55 | ||
| 54 | (should | ||
| 55 | (lcms-triple-approx-p | ||
| 56 | (apply #'color-xyz-to-xyy (lcms-temp->white-point 5503)) | ||
| 57 | '(0.33242 0.34743 1.0))) | ||
| 58 | ;; D65 | ||
| 59 | (should | ||
| 60 | (lcms-triple-approx-p | ||
| 61 | (apply #'color-xyz-to-xyy (lcms-temp->white-point 6504)) | ||
| 62 | '(0.31271 0.32902 1.0))) | ||
| 63 | ;; D75 | ||
| 64 | (should | ||
| 65 | (lcms-triple-approx-p | ||
| 66 | (apply #'color-xyz-to-xyy (lcms-temp->white-point 7504)) | ||
| 67 | '(0.29902 0.31485 1.0)))) | ||
| 68 | |||
| 69 | ;;; lcms-tests.el ends here | ||