Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

FastOutputStreamTest.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2002-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: FastOutputStreamTest.java,v 12.1 2005/08/01 20:25:35 mark Exp $
00008  */
00009 
00010 package com.sleepycat.util.test;
00011 
00012 import junit.framework.Test;
00013 import junit.framework.TestCase;
00014 import junit.framework.TestSuite;
00015 
00016 import com.sleepycat.collections.test.DbTestUtil;
00017 import com.sleepycat.util.FastOutputStream;
00018 
00022 public class FastOutputStreamTest extends TestCase {
00023 
00024     public static void main(String[] args)
00025         throws Exception {
00026 
00027         junit.framework.TestResult tr =
00028             junit.textui.TestRunner.run(suite());
00029         if (tr.errorCount() > 0 ||
00030             tr.failureCount() > 0) {
00031             System.exit(1);
00032         } else {
00033             System.exit(0);
00034         }
00035     }
00036 
00037     public static Test suite()
00038         throws Exception {
00039 
00040         TestSuite suite = new TestSuite(FastOutputStreamTest.class);
00041         return suite;
00042     }
00043 
00044     public FastOutputStreamTest(String name) {
00045 
00046         super(name);
00047     }
00048 
00049     public void setUp() {
00050 
00051         DbTestUtil.printTestName("FastOutputStreamTest." + getName());
00052     }
00053 
00054     public void testBufferSizing()
00055         throws Exception {
00056 
00057         FastOutputStream fos = new FastOutputStream();
00058         assertEquals
00059             (FastOutputStream.DEFAULT_INIT_SIZE, fos.getBufferBytes().length);
00060 
00061         /* Write X+1 bytes, expect array size 2X+1 */
00062         fos.write(new byte[FastOutputStream.DEFAULT_INIT_SIZE + 1]);
00063         assertEquals
00064             ((FastOutputStream.DEFAULT_INIT_SIZE * 2) + 1,
00065              fos.getBufferBytes().length);
00066 
00067         /* Write X+1 bytes, expect array size 4X+3 = (2(2X+1) + 1) */
00068         fos.write(new byte[FastOutputStream.DEFAULT_INIT_SIZE + 1]);
00069         assertEquals
00070             ((FastOutputStream.DEFAULT_INIT_SIZE * 4) + 3,
00071              fos.getBufferBytes().length);
00072     }
00073 }

Generated on Sun Dec 25 12:14:56 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2