From 26d612029495c55317efb04e2fbe48ba74151d71 Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
Date: Fri, 30 Sep 2016 17:03:41 -0400
Subject: [PATCH] added write test.
---
lib/kiss/kiss.rb | 8 ++++----
test/tc_kiss.rb | 9 ++++++++-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/kiss/kiss.rb b/lib/kiss/kiss.rb
index 4a4fd00..312b87d 100644
--- a/lib/kiss/kiss.rb
+++ b/lib/kiss/kiss.rb
@@ -39,8 +39,8 @@ module KISS
else
encoded_bytes += [raw_code_byte]
end
- return encoded_bytes
end
+ return encoded_bytes
end
private
@@ -152,10 +152,10 @@ module KISS
public
def write(frame_bytes, port=0)
@lock.synchronize do
- kiss_packet = [FEND] + [command_byte_combine(port, DATA_FRAME)] +
- escape_special_codes(frame_bytes) + [FEND]
+ kiss_packet = [FEND] + [KISS.command_byte_combine(port, DATA_FRAME)] +
+ KISS.escape_special_codes(frame_bytes) + [FEND]
- return self.write_interface(kiss_packet)
+ return write_interface(kiss_packet)
end
end
end
diff --git a/test/tc_kiss.rb b/test/tc_kiss.rb
index 489fffa..5d1b9b4 100644
--- a/test/tc_kiss.rb
+++ b/test/tc_kiss.rb
@@ -2,7 +2,7 @@ require 'test/unit'
require_relative '../lib/kiss/kiss'
module KISS
-# KG6WTF>S7TSUV,MTOSO-2,WIDE2*,qAR,KF6FIR-10:`17El#X-/kg6wtf@gosselinfamily.com
+ # KG6WTF>S7TSUV,MTOSO-2,WIDE2*,qAR,KF6FIR-10:`17El#X-/kg6wtf@gosselinfamily.com
ENCODED_FRAME = [192, 0, 75, 71, 54, 87, 84, 70, 62, 83, 55, 84, 83, 85, 86, 44, 77, 84, 79, 83, 79, 45, 50, 44, 87, 73,
68, 69, 50, 42, 44, 113, 65, 82, 44, 75, 70, 54, 70, 73, 82, 45, 49, 48, 58, 96, 49, 55, 69, 108, 35,
88, 45, 47, 107, 103, 54, 119, 116, 102, 64, 103, 111, 115, 115, 101, 108, 105, 110, 102, 97, 109, 105,
@@ -57,6 +57,13 @@ module KISS
translated_frame = kiss_mock.read
assert DECODED_FRAME == translated_frame
end
+
+ def test_write
+ kiss_mock = KISSMock.new
+ kiss_mock.write(DECODED_FRAME)
+ all_raw_frames = kiss_mock.get_sent_to_interface
+ assert ENCODED_FRAME == all_raw_frames[0]
+ end
end
end
\ No newline at end of file
--
GitLab