emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sławomir Grochowski" <slawomir.grochowski@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [test] org-colview/org-columns
Date: Mon, 17 Apr 2023 19:42:47 +0200	[thread overview]
Message-ID: <CABnDLzHXp72ErqSHnxgL_Ym+-PvhCER39ewCkqZ23kYT8Sx2DA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 275 bytes --]

Dear All,

I'm trying to better understand 'org-colview/org-columns'.
So I wrote some tests. File in attachment.
I hope the commit message is correct.

I will be very grateful for your comments & feedback on what can be done
better.

Regards,
Sławomir Grochowski

[-- Attachment #1.2: Type: text/html, Size: 435 bytes --]

[-- Attachment #2: 0001-testing-lisp-test-org-colview.el-Add-tests.patch --]
[-- Type: text/x-patch, Size: 3103 bytes --]

From 2768ecfd896d2dd950b23f0134a3779523479d35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C5=82awomir=20Grochowski?= <slawomir.grochowski@gmail.com>
Date: Mon, 17 Apr 2023 19:18:16 +0200
Subject: [PATCH] testing/lisp/test-org-colview.el: Add tests

* test-org-colview.el (test-org-colview/uncompile-format,
test-org-colview/compile-format): Add tests for functions:
org-columns-uncompile-format & org-columns-compile-format
---
 testing/lisp/test-org-colview.el | 66 ++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el
index 9daec18e2..a80763622 100644
--- a/testing/lisp/test-org-colview.el
+++ b/testing/lisp/test-org-colview.el
@@ -26,6 +26,72 @@
 (require 'org-duration)
 (require 'org-inlinetask)
 
+(ert-deftest test-org-colview/uncompile-format ()
+  "Test `org-columns-uncompile-format' specifications."
+  ;; With minimum data, one element
+  (should
+   (equal "%ITEM"
+          (org-columns-uncompile-format '(("ITEM" "ITEM" nil nil nil)))))
+  ;; With minimum data, two element
+  (should
+   (equal "%ITEM %TODO"
+          (org-columns-uncompile-format
+           `(("ITEM" "ITEM" nil nil nil) ("TODO" "TODO" nil nil nil)))))
+  ;; Read width
+  (should
+   (equal "%10ITEM"
+          (org-columns-uncompile-format `(("ITEM" "ITEM" 10 nil nil)))))
+  ;; Read title
+  (should
+   (equal "%ITEM(some title)"
+          (org-columns-uncompile-format `(("ITEM" "some title" nil nil nil)))))
+  ;; Read operator
+  (should
+   (equal "%ITEM{+}"
+          (org-columns-uncompile-format `(("ITEM" "ITEM" nil "+" nil)))))
+  ;; Read operator printf
+  (should
+   (equal "%ITEM{+;%.1f}"
+          (org-columns-uncompile-format  `(("ITEM" "ITEM" nil "+" "%.1f"))))))
+
+(ert-deftest test-org-colview/compile-format ()
+  "Test `org-columns-compile-format' specifications."
+  ;; With minimum data, one element
+  (should
+   (equal `(("ITEM" "ITEM" nil nil nil))
+          (org-columns-compile-format
+           "%ITEM")))
+  ;; With minimum data, two element
+  (should
+   (equal `(("ITEM" "ITEM" nil nil nil) ("TODO" "TODO" nil nil nil))
+          (org-columns-compile-format
+           "%ITEM %TODO")))
+  ;; Read width
+  (should
+   (equal `(("ITEM" "ITEM" 10 nil nil))
+          (org-columns-compile-format
+           "%10ITEM")))
+  ;; Upcase property name
+  (should
+   (equal `(("ITEM" "item" nil nil nil))
+          (org-columns-compile-format
+           "%item")))
+  ;; Read title
+  (should
+   (equal `(("ITEM" "some title" nil nil nil))
+          (org-columns-compile-format
+           "%ITEM(some title)")))
+  ;; Read operator
+  (should
+   (equal `(("ITEM" "ITEM" nil "+" nil))
+          (org-columns-compile-format
+           "%ITEM{+}")))
+  ;; Read operator printf
+  (should
+   (equal `(("ITEM" "ITEM" nil "+" "%.1f"))
+          (org-columns-compile-format
+           "%ITEM{+;%.1f}"))))
+
 (ert-deftest test-org-colview/get-format ()
   "Test `org-columns-get-format' specifications."
   ;; Without any clue, use `org-columns-default-format'.
-- 
2.30.2


             reply	other threads:[~2023-04-17 19:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17 17:42 Sławomir Grochowski [this message]
2023-04-18 11:23 ` [test] org-colview/org-columns Ihor Radchenko
2023-05-14 14:11   ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABnDLzHXp72ErqSHnxgL_Ym+-PvhCER39ewCkqZ23kYT8Sx2DA@mail.gmail.com \
    --to=slawomir.grochowski@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).