Sha256: 8dd1e81260172465317797f59fdcb2dbb82d65aa85b95877046320e6bbbce143

Contents?: true

Size: 1.38 KB

Versions: 14

Compression:

Stored size: 1.38 KB

Contents

require "spec"
require "./bracket_push"

describe "Brackets" do
  describe "#are_valid?" do
    it "paired square brackets" do
      Brackets.are_valid?("[]").should be_true
    end
    it "empty string" do
      Brackets.are_valid?("").should be_true
    end
    it "unpaired brackets" do
      Brackets.are_valid?("[[").should be_false
    end
    it "wrong ordered brackets" do
      Brackets.are_valid?("}{").should be_false
    end
    it "paired with whitespace" do
      Brackets.are_valid?("{ }").should be_true
    end
    it "simple nested brackets" do
      Brackets.are_valid?("{[]}").should be_true
    end
    it "several paired brackets" do
      Brackets.are_valid?("{}[]").should be_true
    end
    it "paired and nested brackets" do
      Brackets.are_valid?("([{}({}[])])").should be_true
    end
    it "unopened closing brackets" do
      Brackets.are_valid?("{[)][]}").should be_false
    end
    it "unpaired and nested brackets" do
      Brackets.are_valid?("([{])").should be_false
    end
    it "paired and wrong nested brackets" do
      Brackets.are_valid?("[({]})").should be_false
    end
    it "math expression" do
      Brackets.are_valid?("(((185 + 223.85) * 15) - 543)/2").should be_true
    end
    it "complex latex expression" do
      Brackets.are_valid?("\left(\begin{array}{cc} \frac{1}{3} & x\\ \mathrm{e}^{x} &... x^2 \end{array}\right)").should be_true
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
trackler-2.0.0.3 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-2.0.0.2 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-2.0.0.1 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-2.0.0.0 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.4.1 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.4.0 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.3.0 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.2.1 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.2.0 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.1.2 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.1.1 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.1.0 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.0.1 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr
trackler-1.0.0 tracks/crystal/exercises/bracket-push/bracket_push_spec.cr