X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Ftest%2Fnet%2Fsf%2Fopenrocket%2Futil%2FTextUtilTest.java;h=b880cee0c6a3e84ee094cf9f4dcccd814c1a8147;hb=d93d4d6f070bb55e6a86e9817acfd29266a3482e;hp=8ac8319d0aa6b998702aa0cd98fa13dd022f9d64;hpb=7440c8499fffb774c790def5063fb7a91e3e6966;p=debian%2Fopenrocket diff --git a/core/test/net/sf/openrocket/util/TextUtilTest.java b/core/test/net/sf/openrocket/util/TextUtilTest.java index 8ac8319d..b880cee0 100644 --- a/core/test/net/sf/openrocket/util/TextUtilTest.java +++ b/core/test/net/sf/openrocket/util/TextUtilTest.java @@ -3,12 +3,43 @@ package net.sf.openrocket.util; import static java.lang.Math.PI; import static org.junit.Assert.assertEquals; +import java.nio.charset.Charset; import java.util.Random; import org.junit.Test; public class TextUtilTest { + @Test + public void testConvertStringToBytes() { + + Charset us_ascii = Charset.forName("US-ASCII"); + + byte[] ZIP_SIGNATURE_CORRECT = "PK".getBytes(us_ascii); + byte[] ZIP_SIGNATURE_TEST = TextUtil.convertStringToBytes( "PK", us_ascii); + + assertEquals( ZIP_SIGNATURE_CORRECT.length, ZIP_SIGNATURE_TEST.length ); + for( int i =0; i< ZIP_SIGNATURE_CORRECT.length; i++ ) { + assertEquals(ZIP_SIGNATURE_CORRECT[i], ZIP_SIGNATURE_TEST[i]); + } + + byte[] OPENROCKET_SIGNATURE_CORRECT = "