test-ob-C.el 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ;;; test-ob-awk.el --- tests for ob-awk.el
  2. ;; Copyright (c) 2010-2014 Sergey Litvinov
  3. ;; Authors: Sergey Litvinov
  4. ;; This file is not part of GNU Emacs.
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Code:
  16. (unless (featurep 'ob-C)
  17. (signal 'missing-test-dependency "Support for C code blocks"))
  18. (ert-deftest ob-C/assert ()
  19. (should t))
  20. (ert-deftest ob-C/simple-program ()
  21. "Hello world program."
  22. (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
  23. (org-babel-next-src-block)
  24. (should (= 42 (org-babel-execute-src-block)))))
  25. (ert-deftest ob-C/integer-var ()
  26. "Test of an integer variable."
  27. (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
  28. (org-babel-next-src-block 2)
  29. (should (= 12 (org-babel-execute-src-block)))))
  30. (ert-deftest ob-C/two-integer-var ()
  31. "Test of two input variables"
  32. (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
  33. (org-babel-next-src-block 3)
  34. (should (= 22 (org-babel-execute-src-block)))))
  35. (ert-deftest ob-C/string-var ()
  36. "Test of a string input variable"
  37. (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
  38. (org-babel-next-src-block 4)
  39. (should (equal "word 4" (org-babel-execute-src-block)))))
  40. (ert-deftest ob-C/preprocessor ()
  41. "Test of a string variable"
  42. (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577"
  43. (org-babel-next-src-block 5)
  44. (should (= 42 (org-babel-execute-src-block)))))
  45. (ert-deftest ob-C/table ()
  46. "Test of a table output"
  47. (org-test-at-id "2df1ab83-3fa3-462a-a1f3-3aef6044a874"
  48. (org-babel-next-src-block)
  49. (should (equal '((1) (2)) (org-babel-execute-src-block)))))
  50. (ert-deftest ob-C/list-var ()
  51. "Test of a list input variable"
  52. (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
  53. (org-babel-next-src-block 1)
  54. (should (string= "abcdef2" (org-babel-execute-src-block)))))
  55. (ert-deftest ob-C/vector-var ()
  56. "Test of a vector input variable"
  57. (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
  58. (org-babel-next-src-block 2)
  59. (should (equal 122 (org-babel-execute-src-block)))))
  60. (ert-deftest ob-C/list-list-var ()
  61. "Test of a list list input variable"
  62. (org-test-at-id "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5"
  63. (org-babel-next-src-block 3)
  64. (should (equal '((1 3) (2 4)) (org-babel-execute-src-block)))))
  65. ;;; test-ob-C.el ends here