1
exercism fetch clojure bracket-push

test/bracket_push_test.clj

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(ns bracket-push-test
  (:require [clojure.test :refer [deftest is]]
            bracket-push))

(deftest paired-square
  (is (bracket-push/valid? "[]") "paired square brackets"))

(deftest empty-string
  (is (bracket-push/valid? "") "empty string"))

(deftest unpaired-brackets
  (is (false? (bracket-push/valid? "[[")) "unpaired brackets"))

(deftest wrong-ordered-brackets
  (is (false? (bracket-push/valid? "}{")) "wrong ordered brackets"))

(deftest paired-with-whitespace
  (is (bracket-push/valid? "{ }") "paired with whitespace"))

(deftest simple-nested-brackets
  (is (bracket-push/valid? "{[]}")
      "simple nested brackets"))

(deftest several-paired-brackets
  (is (bracket-push/valid? "{}[]")
      "several paired brackets"))

(deftest paired-and-nested-brackets
  (is (bracket-push/valid? "([{}({}[])])")
      "paired and nested brackets"))

(deftest unopened-closing-brackets
  (is (false? (bracket-push/valid? "{[)][]}"))
      "unopened closing brackets"))
 
(deftest unpaired-and-nested-brackets
  (is (false? (bracket-push/valid? "([{])"))
      "unpaired and nested brackets"))

(deftest paired-and-wrong-nested-brackets
  (is (false? (bracket-push/valid? "[({]})"))
      "paired and wrong nested brackets"))

(deftest math-expression
  (is (bracket-push/valid? "(((185 + 223.85) * 15) - 543)/2")
      "math expression"))

(deftest complex-latex-expression
  (is (bracket-push/valid? "\\\\left(\\\\begin{array}{cc} \\\\frac{1}{3} & x\\\\\\\\ \\\\mathrm{e}^{x} &... x^2 \\\\end{array}\\\\right)")
      "complex latex expression"))