package org.josast.ModuleSoundModem;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class kissTest {

	@BeforeAll
	static void setUpBeforeClass() throws Exception {
	}

	@AfterAll
	static void tearDownAfterClass() throws Exception {
	}

	@BeforeEach
	void setUp() throws Exception {
	}

	@AfterEach
	void tearDown() throws Exception {
	}

	@Test
	void testToRaw() {
		byte [] temp = new byte [] { (byte)0xc0, 0x4f, (byte)0xd0,
			    0x20, (byte)0xea, 0x3a, 0x69, 0x10, (byte)0xa2, (byte)0xd8, 0x08, 0x00, 0x2b,
			    0x30, 0x30, (byte)0xc0};
		byte [] out = new byte [] { 0x4f, (byte)0xd0,
			    0x20, (byte)0xea, 0x3a, 0x69, 0x10, (byte)0xa2, (byte)0xd8, 0x08, 0x00, 0x2b,
			    0x30, 0x30,  };
		kiss k = new kiss(temp);
		try {
			byte [] res =  k.toRaw();
			assertArrayEquals(res,out);
			
		} catch (KissException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
		@Test
		void testToRawFEND() {
			byte [] temp = new byte [] { (byte)0xc0, 0x4f, (byte)0xd0,
				    0x20, (byte)0xea, 0x3a, 0x69,(byte) 0xDB, (byte)0xDC, (byte)0xd8, 0x08, 0x00, 0x2b,
				    0x30, 0x30, (byte)0xc0};
			byte [] out = new byte [] { 0x4f, (byte)0xd0,
				    0x20, (byte)0xea, 0x3a, 0x69,(byte) 0xC0, (byte)0xd8, 0x08, 0x00, 0x2b,
				    0x30, 0x30,  };
			kiss k = new kiss(temp);
			try {
				byte [] res =  k.toRaw();
				assertArrayEquals(res,out);
				
			} catch (KissException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		
	}
		@Test
		void testToRawFESC() {
			byte [] temp = new byte [] { (byte)0xc0, 0x4f, (byte)0xd0,
				    0x20, (byte)0xea, 0x3a, 0x69,(byte) 0xDB, (byte)0xDD, (byte)0xd8, 0x08, 0x00, 0x2b,
				    (byte) 0xDB, (byte)0xDD, (byte)0xc0};
			byte [] out = new byte [] { 0x4f, (byte)0xd0,
				    0x20, (byte)0xea, 0x3a, 0x69,(byte)  0xDB, (byte)0xd8, 0x08, 0x00, 0x2b,
				    (byte) 0xDB,  };
			kiss k = new kiss(temp);
			try {
				byte [] res =  k.toRaw();
				assertArrayEquals(res,out);
				
			} catch (KissException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		
	}

}
