Sha256: 96478c6670dfe74d2edc9c5b4d95193e82a157c257f2eabb09f3ead79bc4c89f

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require './test/helper'
require 'tempfile'
require 'dtas/player'

class TestPlayer < Testcase
  def setup
    @player = nil
    tmp = Tempfile.new(%w(dtas-player-test .sock))
    @path = tmp.path
    File.unlink(@path)
  end

  def teardown
    @player.close if @player
  end

  def test_player_new
    player = DTAS::Player.new
    player.socket = @path
    player.bind
    assert File.socket?(@path)
  ensure
    player.close
    refute File.socket?(@path)
  end

  def test_player_serialize
    @player = DTAS::Player.new
    @player.socket = @path
    @player.bind
    hash = @player.to_hsh
    assert_equal({"socket" => @path}, hash)
  end

  def test_player_serialize_format
    fmt = DTAS::Format.new
    fmt.type = "f32"
    fmt.rate = 48000
    player = DTAS::Player.load("format" => fmt.to_hsh)
    fhash = player.to_hsh["format"]
    assert_equal "f32", fhash["type"]
    assert_equal 48000, fhash["rate"]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dtas-0.9.0 test/test_player.rb
dtas-0.8.0 test/test_player.rb