KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > BytesTest


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * DrFTPD is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with DrFTPD; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package net.sf.drftpd;
19
20 import junit.framework.TestCase;
21 import junit.framework.TestSuite;
22
23 /**
24  * @author mog
25  * @version $Id: BytesTest.java,v 1.3.2.1 2004/06/11 00:59:57 mog Exp $
26  */

27 public class BytesTest extends TestCase {
28     public static TestSuite suite() {
29         return new TestSuite(BytesTest.class);
30     }
31
32     public BytesTest() {
33         super();
34     }
35
36     public BytesTest(String JavaDoc fName) {
37         super(fName);
38     }
39
40
41     protected void setUp() throws Exception JavaDoc {
42         super.setUp();
43     }
44
45     protected void tearDown() throws Exception JavaDoc {
46         super.tearDown();
47     }
48     public void testFormat50KB() {
49         assertEquals("50.0KB", Bytes.formatBytes(Bytes.KILO*50, false));
50     }
51     public void testFormat50KiB() {
52         assertEquals("50.0KiB", Bytes.formatBytes(Bytes.KIBI*50, true));
53     }
54     
55     public void testFormatByte() {
56         assertEquals("123B", Bytes.formatBytes(123, false));
57     }
58     public void testFormatGB() {
59         assertEquals("1.0GB", Bytes.formatBytes(Bytes.GIGA, false));
60     }
61     public void testFormatGiB() {
62         assertEquals("1.0GiB", Bytes.formatBytes(Bytes.GIBI, true));
63     }
64     public void testFormatKB() {
65         assertEquals("1.0KB", Bytes.formatBytes(Bytes.KILO, false));
66     }
67     public void testFormatKiB() {
68         assertEquals("1.0KiB", Bytes.formatBytes(Bytes.KIBI, true));
69     }
70
71     public void testFormatMB() {
72         assertEquals("1.0MB", Bytes.formatBytes(Bytes.MEGA, false));
73     }
74     
75     public void testFormatMib() {
76         assertEquals("1.0MiB", Bytes.formatBytes(Bytes.MEBI, true));
77     }
78     public void testFormatTB() {
79         assertEquals("1.0TB", Bytes.formatBytes(Bytes.TERRA, false));
80     }
81     public void testFormatTiB() {
82         assertEquals("1.0TiB", Bytes.formatBytes(Bytes.TEBI, true));
83     }
84     public void testParse1GB() {
85         assertEquals(Bytes.GIGA, Bytes.parseBytes("1GB"));
86     }
87     public void testParse1GiB() {
88         assertEquals(Bytes.GIBI, Bytes.parseBytes("1GiB"));
89     }
90     public void testParse1KB() {
91         assertEquals(Bytes.KILO, Bytes.parseBytes("1KB"));
92     }
93     public void testParse1KiB() {
94         assertEquals(Bytes.KIBI, Bytes.parseBytes("1KiB"));
95     }
96     public void testParse1MB() {
97         assertEquals(Bytes.MEGA, Bytes.parseBytes("1MB"));
98     }
99     public void testParse1MiB() {
100         assertEquals(Bytes.MEBI, Bytes.parseBytes("1MiB"));
101     }
102     public void testParse1TB() {
103         assertEquals(Bytes.TERRA, Bytes.parseBytes("1TB"));
104     }
105     public void testParse1TiB() {
106         assertEquals(Bytes.TEBI, Bytes.parseBytes("1TiB"));
107     }
108
109     public void testParseByte() {
110         assertEquals(123, Bytes.parseBytes("123"));
111     }
112 }
113
Popular Tags