Skip to content

Commit

Permalink
test: Add test for integer scalar key-value pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Apr 28, 2022
1 parent 060c38b commit c872e9e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 27 deletions.
63 changes: 36 additions & 27 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ specification defined below.
* Library Completion Status [0/6]
- [-] Scalar
- [X] Boolean
- [X] Integer
- [ ] String
- [ ] Integer
- [ ] Float
- [ ] Date + Time with Offset
- [ ] Date
Expand All @@ -47,14 +47,16 @@ https://toml.io/en/v1.0.0#boolean
(bool2 . :false))
#+end_src
**** TOML
#+begin_src emacs-lisp :noweb yes :exports results
#+begin_src emacs-lisp :noweb yes :exports results :wrap src toml
(tomelr-encode
<<scalar-boolean>>)
#+end_src

#+RESULTS:
: bool1 = true
: bool2 = false
#+begin_src toml
bool1 = true
bool2 = false
#+end_src
**** JSON Reference
#+begin_src emacs-lisp :noweb yes :exports results
(json-encode-pretty
Expand All @@ -66,29 +68,8 @@ https://toml.io/en/v1.0.0#boolean
: "bool1": true,
: "bool2": false
: }
*** String
https://toml.io/en/v1.0.0#string
**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref scalar-string
'((str . "Roses are red\nViolets are blue"))
#+end_src
**** TOML
#+begin_src toml
str = """
Roses are red
Violets are blue"""
#+end_src
**** JSON Reference
#+begin_src emacs-lisp :noweb yes :exports results
(json-encode-pretty
<<scalar-string>>)
#+end_src

#+RESULTS:
: {
: "str": "Roses are red\nViolets are blue"
: }
*** Integer
*** DONE Integer
CLOSED: [2022-04-28 Thu 17:11]
https://toml.io/en/v1.0.0#integer
**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref scalar-integer
Expand All @@ -98,6 +79,12 @@ https://toml.io/en/v1.0.0#integer
(int4 . -17))
#+end_src
**** TOML
#+begin_src emacs-lisp :noweb yes :exports results :wrap src toml
(tomelr-encode
<<scalar-integer>>)
#+end_src

#+RESULTS:
#+begin_src toml
int1 = 99
int2 = 42
Expand All @@ -117,6 +104,28 @@ int4 = -17
: "int3": 0,
: "int4": -17
: }
*** String
https://toml.io/en/v1.0.0#string
**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref scalar-string
'((str . "Roses are red\nViolets are blue"))
#+end_src
**** TOML
#+begin_src toml
str = """
Roses are red
Violets are blue"""
#+end_src
**** JSON Reference
#+begin_src emacs-lisp :noweb yes :exports results
(json-encode-pretty
<<scalar-string>>)
#+end_src

#+RESULTS:
: {
: "str": "Roses are red\nViolets are blue"
: }
*** Float
https://toml.io/en/v1.0.0#float
**** S-expression
Expand Down
15 changes: 15 additions & 0 deletions test/tscalar.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,20 @@
(push (tomelr-encode el) out))
(should (equal ref (nreverse out)))))

;;;; Scalar - Integer
(ert-deftest test-scalar-int ()
(let ((inp '(((int1 . +99))
((int2 . 42))
((int3 . 0))
((int4 . -17))))
(ref '("int1 = 99"
"int2 = 42"
"int3 = 0"
"int4 = -17"))
out)
(dolist (el inp)
(push (tomelr-encode el) out))
(should (equal ref (nreverse out)))))


(provide 'tscalar)

0 comments on commit c872e9e

Please sign in to comment.