Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
/shard.lock
/wave.wav
/spec/data/write.wav
spec/data/write.ogg
spec/data/write3.wav
spec/data/write5.wav
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors:
- mjago <martyn.jago@btinternet.com>

libraries:
libsndfile: ~> 1.0.26
libsndfile: ~> 1.2.22

crystal: 0.20.1
crystal: 1.0.0

license: MIT
33 changes: 17 additions & 16 deletions spec/soundfile_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "./spec_helper"
require "tempfile"
require "./../../soundfile/src/soundfile.cr"

include SoundFile
Expand Down Expand Up @@ -71,31 +70,33 @@ describe SFile do
end

describe "#open_fd" do
File.open(test_wav, "r") do |f|
it "can open a file given a file descriptor" do
a.open_fd(f.fd, :read).should be_true
a.close
File.open(test_wav, "r") do |f|
a.open_fd(f.fd, :read).should be_true
a.close
end
end

it "can be invoked with a block" do
a.open_fd(f.fd, :read) do |sf|
sf.class.should eq SFile
sf.info.class.should eq SFile.info.class
File.open(test_wav, "r") do |f|
a.open_fd(f.fd, :read) do |sf|
sf.class.should eq SFile
sf.info.class.should eq SFile.info.class
end
end
end
end
end

describe "#open_file" do
File.open(test_wav, "r") do |f|
it "can open a file given a file object" do
it "can open a file given a file object" do
File.open(test_wav, "r") do |f|
a.open_file(f, :read).should be_true
a.close
end
end

File.open(test_wav, "r") do |f|
it "can be invoked with a block" do
it "can be invoked with a block" do
File.open(test_wav, "r") do |f|
a.open_file(f, :read) do |sf|
sf.class.should eq SFile
sf.info.class.should eq SFile.info.class
Expand Down Expand Up @@ -623,7 +624,7 @@ describe SFile do
describe "#get_simple_format_count" do
it "retrieves the number of simple formats supported" do
a.open(test_wav, :read)
a.get_simple_format_count.should eq 14
a.get_simple_format_count.should eq 17 # 17 for libsndfile 1.2.2
a.close
end
end
Expand All @@ -633,7 +634,7 @@ describe SFile do
a.open(test_wav, :read)
sf = a.get_simple_format
sf.class.should eq LibSndFile::SFFormatInfo
sf.not_nil!.format.should eq 0x10002
sf.not_nil!.format.should eq 0x00010002
String.new(sf.not_nil!.extension).should eq "wav"
String.new(sf.not_nil!.name).should eq "WAV (Microsoft 16 bit PCM)"
a.close
Expand Down Expand Up @@ -662,7 +663,7 @@ describe SFile do

describe "#get_format_major_count" do
it "retrieves the number of major formats" do
a.get_format_major_count.should eq 25
a.get_format_major_count.should eq 26 # 26 for libsndfile 1.2.2
a.close
end
end
Expand All @@ -682,7 +683,7 @@ describe SFile do

describe "#get_format_subtype_count" do
it "retrieves the number of major formats" do
a.get_format_subtype_count.should eq 21
a.get_format_subtype_count.should eq 33 # 33 for libsndfile 1.2.2
a.close
end
end
Expand Down
Loading