1 /* Reattore HTTP Server 2 3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 $Id: TestPushbackArray.java,v 1.3 2003/01/21 22:43:13 michaelh Exp $ 20 */ 21 22 package test.juju.reattore.util; 23 24 import junit.framework.*; 25 import juju.reattore.util.PushbackArray; 26 27 public class TestPushbackArray 28 extends TestCase { 29 30 private PushbackArray pb = new PushbackArray(); 31 32 public void testRead() { 33 pb.seed(new byte[] { 1, 2, 3, 4, 5 }); 34 35 assertEquals(1, pb.get()); 36 assertEquals(2, pb.get()); 37 assertEquals(3, pb.get()); 38 assertEquals(4, pb.get()); 39 assertEquals(5, pb.get()); 40 assertEquals(PushbackArray.EOF, pb.get()); 41 } 42 43 public void testPushback() { 44 pb.seed(new byte[] { 1, 2, 3, 4, 5 }); 45 46 assertEquals(1, pb.get()); 47 assertEquals(2, pb.get()); 48 assertEquals(3, pb.get()); 49 50 pb.pushback(17); 51 assertEquals(17, pb.get()); 52 53 assertEquals(4, pb.get()); 54 55 pb.pushback(17); 56 assertEquals(17, pb.get()); 57 58 assertEquals(5, pb.get()); 59 assertEquals(PushbackArray.EOF, pb.get()); 60 } 61 62 public void testAtEOF() { 63 pb.seed(new byte[] { 1, 2 }); 64 65 assertEquals(1, pb.get()); 66 assertEquals(2, pb.get()); 67 assertEquals(PushbackArray.EOF, pb.get()); 68 69 pb.pushback(17); 70 assertEquals(17, pb.get()); 71 assertEquals(PushbackArray.EOF, pb.get()); 72 } 73 74 public void testOnEmpty() { 75 assertEquals(PushbackArray.EOF, pb.get()); 76 } 77 78 public void testAcrossSeed() { 79 pb.seed(new byte[] { 1, 2 }); 80 81 assertEquals(1, pb.get()); 82 83 pb.pushback(992); 84 85 pb.seed(new byte[] { 12, 14 }); 86 assertEquals(992, pb.get()); 87 assertEquals(12, pb.get()); 88 assertEquals(14, pb.get()); 89 } 90 91 public static Test suite() { 92 return new TestSuite(TestPushbackArray.class); 93 } 94 }

This page was automatically generated by Maven