fordon_greeman / voidfiles

Branch: 2079ec5
Switch branches/tags
main
theidioticdev add emacs 2079ec5 1d ago
61 lines · 2.3 KB Raw Blame History
1 ;;; emms-tests.el --- Test suite for EMMS core -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2023 Free Software Foundation, Inc.
4
5 ;; Author: Petteri Hintsanen <petterih@iki.fi>
6
7 ;; This file is part of EMMS.
8
9 ;; EMMS is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; any later version.
13
14 ;; EMMS is distributed in the hope that it will be useful, but WITHOUT
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 ;; License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with EMMS; see the file COPYING. If not, write to the Free
21 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 ;; MA 02110-1301, USA.
23
24 ;;; Code:
25
26 (require 'emms)
27 (require 'ert)
28
29 (ert-deftest emms-test-le-to-int ()
30 (should (= (emms-le-to-int nil) 0))
31 (should (= (emms-le-to-int [0]) 0))
32 (should (= (emms-le-to-int [127]) 127))
33 (should (= (emms-le-to-int [255]) 255))
34 (should (= (emms-le-to-int [0 1]) 256))
35 (should (= (emms-le-to-int [1 0]) 1))
36 (should (= (emms-le-to-int [0 128]) 32768))
37 (should (= (emms-le-to-int [1 2 4 8]) 134480385)))
38
39 (ert-deftest emms-test-from-twos-complement ()
40 (should (= (emms-from-twos-complement 0 8) 0))
41 (should (= (emms-from-twos-complement 1 8) 1))
42 (should (= (emms-from-twos-complement 127 8) 127))
43 (should (= (emms-from-twos-complement 128 8) -128))
44 (should (= (emms-from-twos-complement 129 8) -127))
45 (should (= (emms-from-twos-complement 254 8) -2))
46 (should (= (emms-from-twos-complement 255 8) -1))
47 (should (= (emms-from-twos-complement 0 10) 0))
48 (should (= (emms-from-twos-complement 511 10) 511))
49 (should (= (emms-from-twos-complement 512 10) -512))
50 (should (= (emms-from-twos-complement 1023 10) -1)))
51
52 (ert-deftest emms-test-extract-bits ()
53 (should (= (emms-extract-bits 128 7) 1))
54 (should (= (emms-extract-bits 64 6 7) 1))
55 (should (= (emms-extract-bits 128 6 7) 2))
56 (should (= (emms-extract-bits 192 6 7) 3))
57 (should (eq (emms-extract-bits 192 7 6) nil))
58 (should (= (emms-extract-bits 128 32) 0))
59 (should (= (emms-extract-bits 4294688772 21 31) 2047)))
60
61 ;;; emms-tests.el ends here