From 0fad8b7f2378b1ce598212fea43fd30c5e52dbe9 Mon Sep 17 00:00:00 2001 From: J141 Date: Fri, 29 Oct 2021 20:06:59 +0200 Subject: [PATCH 1/2] fix: correct unit tests in hyper-optimised-telemetry exercise --- .../hyper-optimized-telemetry/HyperOptimizedTelemetryTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/concept/hyper-optimized-telemetry/HyperOptimizedTelemetryTests.cs b/exercises/concept/hyper-optimized-telemetry/HyperOptimizedTelemetryTests.cs index 2e7576c5f3..3dd13b2d0e 100644 --- a/exercises/concept/hyper-optimized-telemetry/HyperOptimizedTelemetryTests.cs +++ b/exercises/concept/hyper-optimized-telemetry/HyperOptimizedTelemetryTests.cs @@ -73,7 +73,7 @@ public void ToBuffer_lower_ushort() public void ToBuffer_upper_short() { var bytes = TelemetryBuffer.ToBuffer(Int16.MaxValue); - Assert.Equal(new byte[] { 0xfe, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes); + Assert.Equal(new byte[] { 0x2, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes); } [Fact] @@ -81,7 +81,7 @@ public void ToBuffer_upper_short() public void ToBuffer_Zero() { var bytes = TelemetryBuffer.ToBuffer(0); - Assert.Equal(new byte[] { 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes); + Assert.Equal(new byte[] { 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes); } [Fact] From 720458ec820b115a36ca702807e7de935488d9ed Mon Sep 17 00:00:00 2001 From: J141 Date: Tue, 2 Nov 2021 22:56:01 +0100 Subject: [PATCH 2/2] fix: update Exemplar.cs to match new unit tests --- .../concept/hyper-optimized-telemetry/.meta/Exemplar.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/exercises/concept/hyper-optimized-telemetry/.meta/Exemplar.cs b/exercises/concept/hyper-optimized-telemetry/.meta/Exemplar.cs index 8ea5d3314c..8817109b51 100644 --- a/exercises/concept/hyper-optimized-telemetry/.meta/Exemplar.cs +++ b/exercises/concept/hyper-optimized-telemetry/.meta/Exemplar.cs @@ -25,15 +25,9 @@ public static byte[] ToBuffer(long reading) bytes = BitConverter.GetBytes((int)reading); bytes.CopyTo(allBytes, 1); } - else if (reading > Int16.MaxValue) - { - allBytes[0] = 0x2; - bytes = BitConverter.GetBytes((ushort)reading); - bytes.CopyTo(allBytes, 1); - } else if (reading >= 0) { - allBytes[0] = 0xfe; + allBytes[0] = 0x2; bytes = BitConverter.GetBytes((ushort)reading); bytes.CopyTo(allBytes, 1); }