package org.jsmpp.bean;


import static org.testng.Assert.assertEquals;

<<<<<<< HEAD
import org.jsmpp.util.HexUtil;
=======
>>>>>>> opentelecoms-org/master
import org.testng.annotations.Test;

/**
 * @author pmoerenhout
 */
public class DataCodingsTest {

  @Test
  public void testDataCodingsZero() {
<<<<<<< HEAD
    byte expected = (byte) (0x00);
    DataCoding dataCoding = DataCodings.ZERO;
    assertEquals(dataCoding.toByte(), expected);
    assertEquals(new GeneralDataCoding(), dataCoding);
  }

  @Test
  public void testDataCodings00() {
    byte expected = (byte) 0x00;
    DataCoding dataCoding = DataCodings.newInstance(expected);
    assertEquals(dataCoding.toByte(), expected);

    assertEquals(new GeneralDataCoding(), dataCoding);
  }

  @Test
  public void testDataCodings11() {
    byte expected = (byte) 0x11;
    DataCoding dataCoding = DataCodings.newInstance(expected);
    assertEquals(dataCoding.toByte(), expected);

    DataCoding buildedInstance = DataCodings.newInstance(dataCoding.toByte());
    assertEquals(buildedInstance, dataCoding);
  }

  @Test
  public void testAllDataCodings() {
    for (int i = 0; i < 256; i++) {
      byte expected = (byte) (0xff & i);
      DataCoding dataCoding = DataCodings.newInstance(expected);
      System.out.println("byte " + expected + " " + HexUtil
          .conventBytesToHexString(new byte[]{ expected }) + " " + (0xff & expected) + " => " + dataCoding);
      if (i < 64) {
        assertEquals("org.jsmpp.bean.GeneralDataCoding", DataCodings.newInstance(expected).getClass().getName());
      }
      else if (i < 192) {
        assertEquals("org.jsmpp.bean.RawDataCoding", DataCodings.newInstance(expected).getClass().getName());
      }
      else if (i < 240) {
        assertEquals("org.jsmpp.bean.MessageWaitingDataCoding", DataCodings.newInstance(expected).getClass().getName());
      }
      else {
        assertEquals("org.jsmpp.bean.SimpleDataCoding", DataCodings.newInstance(expected).getClass().getName());
=======
    DataCoding dataCoding = DataCodings.ZERO;
    assertEquals(dataCoding.toByte(), (byte) 0x00);
  }

  @Test
  public void testDataCodingsFactories() {
    for (int i = 0; i < 256; i++) {
      byte expected = (byte) (0xff & i);
      DataCoding dataCoding = DataCodings.newInstance(expected);
      if (i < 64) {
        assertEquals(DataCodings.newInstance(expected).getClass().getName(), "org.jsmpp.bean.GeneralDataCoding");
      }
      else if (i < 192) {
        assertEquals(DataCodings.newInstance(expected).getClass().getName(), "org.jsmpp.bean.RawDataCoding");
      }
      else if (i < 240) {
        assertEquals(DataCodings.newInstance(expected).getClass().getName(), "org.jsmpp.bean.MessageWaitingDataCoding");
      }
      else {
        assertEquals(DataCodings.newInstance(expected).getClass().getName(), "org.jsmpp.bean.SimpleDataCoding");
>>>>>>> opentelecoms-org/master
      }

      if (i < 192) {
        assertEquals(dataCoding.toByte(), expected);
      }
<<<<<<< HEAD
      assertEquals(dataCoding, DataCodings.newInstance(expected));
=======
>>>>>>> opentelecoms-org/master
    }
  }


}
@@ -70,92 +70,8 @@
 s;%0A%0A
-%3C%3C%3C%3C%3C%3C%3C HEAD%0Aimport org.jsmpp.util.HexUtil;%0A=======%0A%3E%3E%3E%3E%3E%3E%3E opentelecoms-org/master%0A
 impo
@@ -216,1713 +216,8 @@
 ) %7B%0A
-%3C%3C%3C%3C%3C%3C%3C HEAD%0A    byte expected = (byte) (0x00);%0A    DataCoding dataCoding = DataCodings.ZERO;%0A    assertEquals(dataCoding.toByte(), expected);%0A    assertEquals(new GeneralDataCoding(), dataCoding);%0A  %7D%0A%0A  @Test%0A  public void testDataCodings00() %7B%0A    byte expected = (byte) 0x00;%0A    DataCoding dataCoding = DataCodings.newInstance(expected);%0A    assertEquals(dataCoding.toByte(), expected);%0A%0A    assertEquals(new GeneralDataCoding(), dataCoding);%0A  %7D%0A%0A  @Test%0A  public void testDataCodings11() %7B%0A    byte expected = (byte) 0x11;%0A    DataCoding dataCoding = DataCodings.newInstance(expected);%0A    assertEquals(dataCoding.toByte(), expected);%0A%0A    DataCoding buildedInstance = DataCodings.newInstance(dataCoding.toByte());%0A    assertEquals(buildedInstance, dataCoding);%0A  %7D%0A%0A  @Test%0A  public void testAllDataCodings() %7B%0A    for (int i = 0; i %3C 256; i++) %7B%0A      byte expected = (byte) (0xff & i);%0A      DataCoding dataCoding = DataCodings.newInstance(expected);%0A      System.out.println(%22byte %22 + expected + %22 %22 + HexUtil%0A          .conventBytesToHexString(new byte%5B%5D%7B expected %7D) + %22 %22 + (0xff & expected) + %22 =%3E %22 + dataCoding);%0A      if (i %3C 64) %7B%0A        assertEquals(%22org.jsmpp.bean.GeneralDataCoding%22, DataCodings.newInstance(expected).getClass().getName());%0A      %7D%0A      else if (i %3C 192) %7B%0A        assertEquals(%22org.jsmpp.bean.RawDataCoding%22, DataCodings.newInstance(expected).getClass().getName());%0A      %7D%0A      else if (i %3C 240) %7B%0A        assertEquals(%22org.jsmpp.bean.MessageWaitingDataCoding%22, DataCodings.newInstance(expected).getClass().getName());%0A      %7D%0A      else %7B%0A        assertEquals(%22org.jsmpp.bean.SimpleDataCoding%22, DataCodings.newInstance(expected).getClass().getName());%0A=======%0A
     
@@ -1079,40 +1079,8 @@
 %22);%0A
-%3E%3E%3E%3E%3E%3E%3E opentelecoms-org/master%0A
     
@@ -1158,24 +1158,24 @@
 ected);%0A
+
       %7D%0A
 %3C%3C%3C%3C%3C%3C%3C 
@@ -1170,128 +1170,8 @@
   %7D%0A
-%3C%3C%3C%3C%3C%3C%3C HEAD%0A      assertEquals(dataCoding, DataCodings.newInstance(expected));%0A=======%0A%3E%3E%3E%3E%3E%3E%3E opentelecoms-org/master%0A
     

Fix merge conflict