test/lays_test.rb in lays-0.0.5 vs test/lays_test.rb in lays-0.1.0

- old
+ new

@@ -98,13 +98,25 @@ assert_equal res, "*n*#" end scope do # width and height - test "width" do + setup do + frame = Frame.new + frame[3] = "a" + frame[2] = "bcde" + frame[1] = "fg" + frame + end + test "width" do |frame| + assert_equal frame.width, 4 end + + test "height" do |frame| + assert_equal frame.height, 3 + end end scope do # Transparency test "transparent char" do @@ -147,6 +159,85 @@ frame[1] = "000000$0 " assert_equal frame.to_s, "321$$0 3 " end +end + +scope do + # Space + test "space char" do + frame = Frame.new + + frame[6] = "0=0 0" + frame[6].space_char = "=" + frame[3] = "11111" + assert_equal frame.to_s, "0 010" + end + + + test "setting space char beforehand" do + frame = Frame.new + + frame[6].space_char = "#" + frame[6] = "2 # 2" + frame[3] = "11111" + assert_equal frame.to_s, "21 12" + end + + test "setting global space char for frame" do + frame = Frame.new + frame.space_char = "$" + + frame[6] = "2 $ 2" + frame[3] = "11111" + assert_equal frame.to_s, "21 12" + end + + test "full space example" do + frame = Frame.new + frame.space_char = "$" + + frame[9].space_char = "*" + frame[6].space_char = "%" + + frame[9] = "3**$***3 " + frame[6] = "22%2$%%2 " + frame[3] = "11111$$1 " + frame[1] = "000000$00" + assert_equal frame.to_s, "3 30" + end +end + +scope do + test "Space and Transparency" do + frame = Frame.new + frame.space_char = "-" + frame.transparent_char = "." + + + frame[9].space_char = "_" + frame[6].transparent_char = "," + + frame[9] = "3 .,..-_. " + frame[6] = "2222,,22--" + frame[3] = "11111.1111" + frame[1] = "0000000000" + assert_equal frame.to_s, "3 2,10- - " + end + + test "Space and Transparency" do + frame = Frame.new + frame.transparent_char = "." + frame.space_char = "-" + + + frame[6].transparent_char = "," + frame[9].space_char = "_" + + frame[9] = "3 .,..-_. " + frame[6] = "2222,,22--" + frame[3] = "11111.1111" + frame[1] = "0000000000" + assert_equal frame.to_s, "32.,.. . " + end end