Skip to content

Commit

Permalink
Test - fix Tau tests to reflect new osc bundle decode structure
Browse files Browse the repository at this point in the history
  • Loading branch information
samaaron committed Jun 19, 2024
1 parent 01f13a5 commit 93bef1a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/server/beam/tau/test/erlang_tau_osc_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,31 @@ defmodule ErlangTauOSCTest do
use ExUnit.Case

test "basic osc encode/decode" do
a = :osc.encode(['/test', 1, 3.5, -100, -3.5, 'bar', true, false])
{:cmd, ['/test', 1, 3.5, -100, -3.5, 'bar', true, false]} = :osc.decode(a)
a = :osc.encode([~c"/test", 1, 3.5, -100, -3.5, ~c"bar", true, false])
{:cmd, [~c"/test", 1, 3.5, -100, -3.5, ~c"bar", true, false]} = :osc.decode(a)
end

test "osc encode/decode int64" do
a = :osc.encode(['/testi64', {:int64, 347_873_045_749_854}])
{:cmd, ['/testi64', 347_873_045_749_854]} = :osc.decode(a)
a = :osc.encode([~c"/testi64", {:int64, 347_873_045_749_854}])
{:cmd, [~c"/testi64", 347_873_045_749_854]} = :osc.decode(a)
end

test "decode osc binary" do
bin =
<<35, 98, 117, 110, 100, 108, 101, 0, 218, 114, 254, 188, 137, 88, 216, 0, 0, 0, 0, 16, 47,
102, 111, 111, 0, 0, 0, 0, 44, 115, 0, 0, 98, 97, 114, 0>>

{:bundle, _, [{_n, internal_osc}]} = :osc.decode(bin)
{:cmd, ['/foo', 'bar']} = :osc.decode(internal_osc)
{:bundle, _, [[~c"/foo", ~c"bar"]]} = :osc.decode(bin)
end

test "making a bundle with a timestamp" do
t = :osc.now()
bin = :osc.pack_ts(t, ['/forward', 'localhost', 6000, '/sendmidi', 12, 34, 56])
{:bundle, new_t, [{_n, internal_osc}]} = :osc.decode(bin)
bin = :osc.pack_ts(t, [~c"/forward", ~c"localhost", 6000, ~c"/sendmidi", 12, 34, 56])

{:bundle, new_t, [[~c"/forward", ~c"localhost", 6000, ~c"/sendmidi", 12, 34, 56]]} =
:osc.decode(bin)

# take into account encoding/decoding rounding differences
assert(abs(t - new_t) < 0.0001)
{:cmd, ['/forward', 'localhost', 6000, '/sendmidi', 12, 34, 56]} = :osc.decode(internal_osc)
end
end

0 comments on commit 93bef1a

Please sign in to comment.