ox: Support unnumbered headlines via property
[org-mode/org-kjn.git] / testing / lisp / test-ob-C.el
blob4639004ae20bd89a7361a282c298236673e7e0fc
1 ;;; test-ob-C.el --- tests for ob-C.el
3 ;; Copyright (c) 2010-2014 Sergey Litvinov, Thierry Banel
4 ;; Authors: Sergey Litvinov, Thierry Banel
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ;;; Code:
22 (unless (featurep 'ob-C)
23 (signal 'missing-test-dependency "Support for C code blocks"))
25 (ert-deftest ob-C/assert ()
26 (should t))
28 (ert-deftest ob-C/simple-program ()
29 "Hello world program."
30 (if (executable-find org-babel-C++-compiler)
31 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
32 (org-babel-next-src-block 1)
33 (should (= 42 (org-babel-execute-src-block))))))
35 (ert-deftest ob-D/simple-program ()
36 "Hello world program."
37 (if (executable-find org-babel-D-compiler)
38 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
39 (org-babel-next-src-block 2)
40 (should (= 42 (org-babel-execute-src-block))))))
42 (ert-deftest ob-C/integer-var ()
43 "Test of an integer variable."
44 (if (executable-find org-babel-C++-compiler)
45 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
46 (org-babel-next-src-block 3)
47 (should (= 12 (org-babel-execute-src-block))))))
49 (ert-deftest ob-D/integer-var ()
50 "Test of an integer variable."
51 (if (executable-find org-babel-D-compiler)
52 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
53 (org-babel-next-src-block 4)
54 (should (= 12 (org-babel-execute-src-block))))))
56 (ert-deftest ob-C/two-integer-var ()
57 "Test of two input variables"
58 (if (executable-find org-babel-C++-compiler)
59 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
60 (org-babel-next-src-block 5)
61 (should (= 22 (org-babel-execute-src-block))))))
63 (ert-deftest ob-D/two-integer-var ()
64 "Test of two input variables"
65 (if (executable-find org-babel-D-compiler)
66 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
67 (org-babel-next-src-block 6)
68 (should (= 22 (org-babel-execute-src-block))))))
70 (ert-deftest ob-C/string-var ()
71 "Test of a string input variable"
72 (if (executable-find org-babel-C++-compiler)
73 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
74 (org-babel-next-src-block 7)
75 (should (equal "word 4" (org-babel-execute-src-block))))))
77 (ert-deftest ob-D/string-var ()
78 "Test of a string input variable"
79 (if (executable-find org-babel-D-compiler)
80 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
81 (org-babel-next-src-block 8)
82 (should (equal "word 4" (org-babel-execute-src-block))))))
84 (ert-deftest ob-C/preprocessor ()
85 "Test of a string variable"
86 (if (executable-find org-babel-C++-compiler)
87 (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
88 (org-babel-next-src-block 9)
89 (should (= 42 (org-babel-execute-src-block))))))
91 (ert-deftest ob-C/table ()
92 "Test of a table output"
93 (if (executable-find org-babel-C++-compiler)
94 (org-test-at-id "2df1ab83-3fa3-462a-a1f3-3aef6044a874"
95 (org-babel-next-src-block 1)
96 (should (equal '((1) (2)) (org-babel-execute-src-block))))))
98 (ert-deftest ob-D/table ()
99 "Test of a table output"
100 (if (executable-find org-babel-D-compiler)
101 (org-test-at-id "2df1ab83-3fa3-462a-a1f3-3aef6044a874"
102 (org-babel-next-src-block 2)
103 (should (equal '((1) (2)) (org-babel-execute-src-block))))))
105 (ert-deftest ob-C/list-var ()
106 "Test of a list input variable"
107 (if (executable-find org-babel-C++-compiler)
108 (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
109 (org-babel-next-src-block 1)
110 (should (string= "abcdef2" (org-babel-execute-src-block))))))
112 (ert-deftest ob-D/list-var ()
113 "Test of a list input variable"
114 (if (executable-find org-babel-D-compiler)
115 (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
116 (org-babel-next-src-block 2)
117 (should (string= "abcdef2" (org-babel-execute-src-block))))))
119 (ert-deftest ob-C/vector-var ()
120 "Test of a vector input variable"
121 (if (executable-find org-babel-C++-compiler)
122 (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
123 (org-babel-next-src-block 3)
124 (should (equal 122 (org-babel-execute-src-block))))))
126 (ert-deftest ob-D/vector-var ()
127 "Test of a vector input variable"
128 (if (executable-find org-babel-D-compiler)
129 (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
130 (org-babel-next-src-block 4)
131 (should (equal 122 (org-babel-execute-src-block))))))
133 (ert-deftest ob-C/list-list-var ()
134 "Test of a list list input variable"
135 (if (executable-find org-babel-C++-compiler)
136 (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
137 (org-babel-next-src-block 5)
138 (should (equal '((1 3) (2 4)) (org-babel-execute-src-block))))))
140 (ert-deftest ob-D/list-list-var ()
141 "Test of a list list input variable"
142 (if (executable-find org-babel-D-compiler)
143 (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
144 (org-babel-next-src-block 6)
145 (should (equal '((1 3) (2 4)) (org-babel-execute-src-block))))))
147 (ert-deftest ob-C/inhomogeneous_table ()
148 "Test inhomogeneous input table"
149 (if (executable-find org-babel-C++-compiler)
150 (org-test-at-id "e112bc2e-419a-4890-99c2-7ac4779531cc"
151 (org-babel-next-src-block 1)
152 (should (equal
153 '(("monday" 34)
154 ("tuesday" 41)
155 ("wednesday" 56)
156 ("thursday" 17)
157 ("friday" 12)
158 ("saturday" 7)
159 ("sunday" 4)
160 ("Friday" "friday"))
161 (org-babel-execute-src-block))))))
163 (ert-deftest ob-D/inhomogeneous_table ()
164 "Test inhomogeneous input table"
165 (if (executable-find org-babel-D-compiler)
166 (org-test-at-id "e112bc2e-419a-4890-99c2-7ac4779531cc"
167 (org-babel-next-src-block 2)
168 (should (equal
169 '(("monday" 34)
170 ("tuesday" 41)
171 ("wednesday" 56)
172 ("thursday" 17)
173 ("friday" 12)
174 ("saturday" 7)
175 ("sunday" 4)
176 ("Friday" "friday"))
177 (org-babel-execute-src-block))))))
179 ;;; test-ob-C.el ends here