rubyx/test/sof.rb

36 lines
970 B
Ruby
Raw Normal View History

require_relative "helper"
class ObjectWithAttributes
def initialize
@name = "some object"
@number = 1234
end
end
class BasicSof < MiniTest::Test
def test_true
out = Sof::Writer.write(true)
assert_equal "true" , out
end
def test_num
out = Sof::Writer.write(124)
assert_equal "124" , out
end
def test_object
out = Sof::Writer.write(ObjectWithAttributes.new)
2014-08-14 19:24:26 +02:00
assert_equal "ObjectWithAttributes(name: 'some object' ,number: 1234)\n" , out
end
def test_simple_array
out = Sof::Writer.write([true, 1234])
assert_equal "-true\n-1234\n" , out
end
2014-08-15 13:59:38 +02:00
def test_array_with_object
out = Sof::Writer.write([true, 1234 , ObjectWithAttributes.new])
assert_equal "-true\n-1234\n-ObjectWithAttributes(name: 'some object' ,number: 1234)\n\n" , out
end
2014-08-15 14:04:13 +02:00
def test_array_with_array
out = Sof::Writer.write([true, 1234 , [true , 12 ]])
assert_equal "-true\n-1234\n--true\n -12\n\n" , out
end
2014-08-15 13:59:38 +02:00
end