Archived
3
0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
libipc-old/zig-impl/crystal/some-crystal-app/tests/test-bindings.cr

47 lines
818 B
Crystal
Raw Normal View History

2023-02-03 04:06:18 +01:00
require "../main.cr"
2023-01-25 04:52:27 +01:00
def test_high_level
ipc = IPC.new
fd = ipc.connect("pong")
ipc.write(fd, "hello this is some value")
event = ipc.wait()
m = event.message
if m.nil?
puts "No message"
else
pp! String.new(m.to_unsafe, m.size)
end
end
def test_loop
ipc = IPC.new
fd = ipc.connect("pong")
ipc.schedule(fd, "hello this is some value")
ipc.loop do |event|
case event.type
when LibIPC::EventType::MessageRx
m = event.message
if m.nil?
puts "No message"
else
pp! String.new(m.to_unsafe, m.size)
end
exit 0
when LibIPC::EventType::MessageTx
puts "A message has been sent"
else
puts "Unexpected: #{event.type}"
exit 1
end
end
end
# TODO: Write documentation for `Some::Crystal::App`
module Some::Crystal::App
VERSION = "0.1.0"
test_high_level
test_loop
end