From 7ec06722923d96d2e51300bafb44b920ca341d58 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Fri, 10 Mar 2023 16:49:58 +0100 Subject: ssb unit tests --- .../org/uic/barcode/ssbFrame/SsbReservation.java | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java') diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java b/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java index c7f520d..73017d7 100644 --- a/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java +++ b/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java @@ -30,17 +30,17 @@ public class SsbReservation extends SsbCommonTicketPart { @Override - protected void decodeContent(byte[] bytes) { + protected int decodeContent(byte[] bytes, int offset) { - int offset = decodeCommonPart(bytes); + offset = offset + decodeCommonPart(bytes); BitBuffer bits = new ByteBitBuffer(bytes); ticketSubType = bits.getInteger(offset, 2); - offset = offset + 4; + offset = offset + 2; stations = new SsbStations(); - stations.decode(offset, bytes); + offset = stations.decode(offset, bytes); /* * Departure date : First day of validity from the issuing date Num (<367) 9,000 @@ -60,7 +60,7 @@ public class SsbReservation extends SsbCommonTicketPart { offset = offset + 11; train = bits.getChar6String(offset, 30); - offset = offset +30; + offset = offset + 30; coach = bits.getInteger(offset, 10); offset = offset + 10; @@ -76,17 +76,19 @@ public class SsbReservation extends SsbCommonTicketPart { text = bits.getChar6String(offset, 162); offset = offset + 162; + + return offset; } @Override - protected void encodeContent(byte[] bytes) { + protected int encodeContent(byte[] bytes, int offset) { - int offset = encodeCommonPart(bytes); + offset = offset + encodeCommonPart(bytes, offset); BitBuffer bits = new ByteBitBuffer(bytes); bits.putInteger(offset, 2,ticketSubType); - offset = offset + 4; + offset = offset + 2; offset = stations.encode(offset, bytes); @@ -108,7 +110,7 @@ public class SsbReservation extends SsbCommonTicketPart { offset = offset + 11; bits.putChar6String(offset, 30,train); - offset = offset +30; + offset = offset + 30; bits.putInteger(offset, 10,coach); offset = offset + 10; @@ -117,7 +119,7 @@ public class SsbReservation extends SsbCommonTicketPart { offset = offset + 18; bits.put(offset, overbooking); - offset++; + offset++; bits.putInteger(offset, 14, infoCode); offset = offset + 14; @@ -125,6 +127,8 @@ public class SsbReservation extends SsbCommonTicketPart { bits.putChar6String(offset, 162, text); offset = offset + 162; + return offset; + } public SsbStations getStations() { -- cgit v1.2.3