java/nekurak.net-lib/test/cz/frantovo/nekurak/util/HashTest.java
author František Kučera <franta-hg@frantovo.cz>
Mon Jun 07 23:14:02 2010 +0200 (2010-06-07)
changeset 126 d47f6a75d20e
parent 124 e720890878ac
child 145 0efefbf5f8b6
permissions -rw-r--r--
Komentáře: kostra, značka
     1 package cz.frantovo.nekurak.util;
     2 
     3 import org.junit.Test;
     4 import static org.junit.Assert.*;
     5 
     6 /**
     7  * Kromě Hashe otestujeme i to, zda správně fungují i názvy metod napsané česky :-)
     8  *
     9  * <blockquote>
    10  * „Letters and digits may be drawn from the entire Unicode character set,
    11  * which supports most writing scripts in use in the world today,
    12  * including the large sets for Chinese, Japanese, and Korean.
    13  * This allows programmers to use identifiers in their programs that are written in their native languages.“
    14  * </blockquote>
    15  *
    16  * @see <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#40625">Java Language Specification – 3.8 Identifiers</a>
    17  * @author fiki
    18  */
    19 public class HashTest {
    20 
    21     String 外滩 = "Bund";
    22     String 南京东路 = "Nanjing Road East";
    23 
    24     @Test
    25     public void prázdnýŘetězec() throws Exception {
    26 	testuj("", "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e");
    27     }
    28 
    29     @Test
    30     public void prázdnýŘádek() throws Exception {
    31 	testuj("\n", "be688838ca8686e5c90689bf2ab585cef1137c999b48c70b92f67a5c34dc15697b5d11c982ed6d71be1e1e7f7b4e0733884aa97c3f7a339a8ed03577cf74be09");
    32     }
    33 
    34     @Test(expected = NullPointerException.class)
    35     public void nullHodnota() throws Exception {
    36 	testuj(null, "Při null vstupu má být vyhozena NullPointerException.");
    37     }
    38 
    39     @Test
    40     public void něco() throws Exception {
    41 	testuj("Ahoj, jak to jde? :-)", "87e6e3c6487dc5ffee93d05cdc71a196f21181e357e61e1820d652ed9b601e179db92c1aaafc9cf57384498c1a52b89c82714dabdfd30b9eb8c7fd8d3fe53685");
    42     }
    43 
    44     @Test
    45     public void čeština() throws Exception {
    46 	testuj("čeština a další unicode – → | @{#@$%${*&…˙×ׄ东方明珠塔“‚&‘‚“‚", "f9750a7f3fa04356510285af61bbdd40b108e04c2abad69130c5929561fa2765e263707147f779ac5f4be348005ce0fc810334822ba0a50f1d5c41719413277e");
    47     }
    48 
    49     private void testuj(String vstup, String pozadovanyVystup) throws Exception {
    50 	String vystup = Hash.hashuj(vstup);
    51 	assertEquals(pozadovanyVystup, vystup);
    52     }
    53 }