test_serdes.rb 524 B

12345678910111213141516171819202122232425262728293031323334
  1. require 'atto'
  2. include Atto::Test
  3. require_relative '../lib/sitef'
  4. require_relative '../lib/serdes'
  5. class Try
  6. include Serdes
  7. serdes_reader :id
  8. serdes_accessor :foo
  9. serdes_reader :bar
  10. serdes_reader :hp, :Integer
  11. end
  12. @t = nil
  13. assert do
  14. @t = Try.new(:id => 'try79', :foo => 'fooo', :bar => "bar\nbar\bar", :hp => 45)
  15. @t
  16. end
  17. assert do
  18. @t.save_one
  19. end
  20. assert do
  21. @tl = Try.load_one('try79')
  22. @tl && @tl.id == 'try79' && @tl.foo == @t.foo && @tl.bar == @t.bar && @tl.hp == @t.hp
  23. end