<commit_before>package org.yamcs.tctm;

import org.junit.Assert;
import org.junit.Test;
import org.yamcs.tctm.CcsdsPacket;
import org.yamcs.utils.TimeEncoding;

import java.nio.ByteBuffer;

public class CcsdsPacketTest {

    // Non multiple of 16 bytes
    byte[] testPacketOf34Bytes = new byte[] {
            (byte)0x1b,(byte)0x8a,(byte)0xe1,(byte)0x54,(byte)0x00,(byte)0x5b,(byte)0x46,(byte)0x7f,(byte)0xb3,(byte)0x56,(byte)0x72,(byte)0x45,(byte)0x13,(byte)0x00,(byte)0xe2,(byte)0x2b,
            (byte)0xa1,(byte)0x92,(byte)0x03,(byte)0x00,(byte)0x00,(byte)0x26,(byte)0x00,(byte)0x01,(byte)0x00,(byte)0x90,(byte)0x00,(byte)0x30,(byte)0x07,(byte)0xe1,(byte)0x01,(byte)0x33,
            (byte)0x00,(byte)0xec
    };

    // Multiple of 16 bytes
    byte[] testPacketOf32Bytes = new byte[] {
            (byte)0x1b,(byte)0x8a,(byte)0xe1,(byte)0x54,(byte)0x00,(byte)0x5b,(byte)0x46,(byte)0x7f,(byte)0xb3,(byte)0x56,(byte)0x72,(byte)0x45,(byte)0x13,(byte)0x00,(byte)0xe2,(byte)0x2b,
            (byte)0xa1,(byte)0x92,(byte)0x03,(byte)0x00,(byte)0x00,(byte)0x26,(byte)0x00,(byte)0x01,(byte)0x00,(byte)0x90,(byte)0x00,(byte)0x30,(byte)0x07,(byte)0xe1,(byte)0x01,(byte)0x33,
    };

    @Test
    public void testToString() {
        CcsdsPacket ccsdsPacket = new CcsdsPacket(ByteBuffer.wrap(testPacketOf34Bytes));
        // Initialize TimeEncoding to be able to call CcsdsPacket.toString()
        TimeEncoding.setUp();

        String packetString = ccsdsPacket.toString();
        Assert.assertEquals("apid: 906\n" +
                "packetId: 318825003\n" +
                "0000: 1b8a e154 005b 467f b356 7245 1300 e22b ...T.[F\u007F.VrE...+\n" +
                "0010: a192 0300 0026 0001 0090 0030 07e1 0133 .....&.....0...3\n" +
                "0020: 00ec                                    ..              \n\n", packetString);
    }


    @Test
    public void testToString16() {
        CcsdsPacket ccsdsPacket = new CcsdsPacket(ByteBuffer.wrap(testPacketOf32Bytes));
        // Initialize TimeEncoding to be able to call CcsdsPacket.toString()
        TimeEncoding.setUp();

        String packetString = ccsdsPacket.toString();
        Assert.assertEquals("apid: 906\n" +
                "packetId: 318825003\n" +
                "0000: 1b8a e154 005b 467f b356 7245 1300 e22b ...T.[F\u007F.VrE...+\n" +
                "0010: a192 0300 0026 0001 0090 0030 07e1 0133 .....&.....0...3\n\n", packetString);
    }

}<commit_msg>Removed the packetId from the basic CCSDS packet because it's a Columbus/ISS thing<commit_after>package org.yamcs.tctm;

import org.junit.Assert;
import org.junit.Test;
import org.yamcs.tctm.CcsdsPacket;
import org.yamcs.utils.TimeEncoding;

import java.nio.ByteBuffer;

public class CcsdsPacketTest {

    // Non multiple of 16 bytes
    byte[] testPacketOf34Bytes = new byte[] {
            (byte)0x1b,(byte)0x8a,(byte)0xe1,(byte)0x54,(byte)0x00,(byte)0x5b,(byte)0x46,(byte)0x7f,(byte)0xb3,(byte)0x56,(byte)0x72,(byte)0x45,(byte)0x13,(byte)0x00,(byte)0xe2,(byte)0x2b,
            (byte)0xa1,(byte)0x92,(byte)0x03,(byte)0x00,(byte)0x00,(byte)0x26,(byte)0x00,(byte)0x01,(byte)0x00,(byte)0x90,(byte)0x00,(byte)0x30,(byte)0x07,(byte)0xe1,(byte)0x01,(byte)0x33,
            (byte)0x00,(byte)0xec
    };

    // Multiple of 16 bytes
    byte[] testPacketOf32Bytes = new byte[] {
            (byte)0x1b,(byte)0x8a,(byte)0xe1,(byte)0x54,(byte)0x00,(byte)0x5b,(byte)0x46,(byte)0x7f,(byte)0xb3,(byte)0x56,(byte)0x72,(byte)0x45,(byte)0x13,(byte)0x00,(byte)0xe2,(byte)0x2b,
            (byte)0xa1,(byte)0x92,(byte)0x03,(byte)0x00,(byte)0x00,(byte)0x26,(byte)0x00,(byte)0x01,(byte)0x00,(byte)0x90,(byte)0x00,(byte)0x30,(byte)0x07,(byte)0xe1,(byte)0x01,(byte)0x33,
    };

    @Test
    public void testToString() {
        CcsdsPacket ccsdsPacket = new CcsdsPacket(ByteBuffer.wrap(testPacketOf34Bytes));
        // Initialize TimeEncoding to be able to call CcsdsPacket.toString()
        TimeEncoding.setUp();

        String packetString = ccsdsPacket.toString();
        Assert.assertEquals("apid: 906\n" +
                "0000: 1b8a e154 005b 467f b356 7245 1300 e22b ...T.[F\u007F.VrE...+\n" +
                "0010: a192 0300 0026 0001 0090 0030 07e1 0133 .....&.....0...3\n" +
                "0020: 00ec                                    ..              \n", packetString);
    }


    @Test
    public void testToString16() {
        CcsdsPacket ccsdsPacket = new CcsdsPacket(ByteBuffer.wrap(testPacketOf32Bytes));
        // Initialize TimeEncoding to be able to call CcsdsPacket.toString()
        TimeEncoding.setUp();

        String packetString = ccsdsPacket.toString();
        Assert.assertEquals("apid: 906\n" +
                "0000: 1b8a e154 005b 467f b356 7245 1300 e22b ...T.[F\u007F.VrE...+\n" +
                "0010: a192 0300 0026 0001 0090 0030 07e1 0133 .....&.....0...3\n", packetString);
    }

}
{'fraction_non_alphanumeric': 0.1631307929969104, 'fraction_numerical': 0.14212152420185376, 'mean_word_length': 3.1082910321489003, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3870459', 'n_tokens_mistral': 2255, 'n_tokens_neox': 1886, 'n_words': 268}