public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
* New Adler32 test
@ 2005-09-01 17:26 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2005-09-01 17:26 UTC (permalink / raw)
  To: mauve-discuss


[-- Attachment #1.1: Type: text/plain, Size: 393 bytes --]

Hi,

Just added the following Adler32 tests.
I couldn't find official test vectors, but these results are for
gij/classpath (kaffe seems to have several bugs, patch submitted).
Please let me know if anybody know official test vectors for adler32.

2005-09-01  Mark Wielaard  <mark@klomp.org>

       * gnu/testlet/java/util/zip/Adler32/checksum.java: New test.

Committed,

Mark

[-- Attachment #1.2: checksum.java --]
[-- Type: text/x-java, Size: 2840 bytes --]

// Tags: JDK1.1

// Copyright (C) 2005 Mark J. Wielaard (mark@klomp.org)

// This file is part of Mauve.

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to
// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.

package gnu.testlet.java.util.zip.Adler32;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import java.util.zip.*;

public class checksum implements Testlet
{
  // 1000, 6000, ..., 96000 arrays filled with value = (byte) index.
  private final long[] someMore = new long[] { 486795068L,
					       1525910894L,
					       3543032800L,
					       2483946130L,
					       4150712693L,
					       3878123687L,
					       3650897945L,
					       1682829244L,
					       1842395054L,
					       460416992L,
					       3287492690L,
					       479453429L,
					       3960773095L,
					       2008242969L,
					       4130540683L,
					       1021367854L,
					       4065361952L,
					       2081116754L,
					       4033606837L,
					       1162071911L };

  public void test(TestHarness harness)
  {
    byte[] bs;
    for (int i = 0; i < 20; i++)
      {
	int length = i * 5000 + 1000;
	bs = new byte[length];
	for (int j = 0; j < bs.length; j++)
	  bs[j] = (byte) j;
	test(harness, bs, someMore[i]);
      }
  }

  private void test(TestHarness harness, byte[] bs, long result)
  {
    Adler32 adler = new Adler32();
    harness.check(adler.getValue(), 1);
    adler.update(bs);
    harness.check(adler.getValue(), result);

    adler.reset();
    harness.check(adler.getValue(), 1);
    for (int i = 0; i < bs.length; i += 1000)
      adler.update(bs, i, 1000);
    harness.check(adler.getValue(), result);

    adler.reset();
    harness.check(adler.getValue(), 1);
    for (int i = 0; i < bs.length; i++)
      adler.update(bs[i]);
    harness.check(adler.getValue(), result);

    adler.reset();
    harness.check(adler.getValue(), 1);
    for (int i = 0; i < 250; i++)
      adler.update(bs[i]);
    for (int i = 250; i < bs.length - 250; i += 250)
      adler.update(bs, i, 250);
    for (int i = bs.length - 250; i < bs.length; i++)
      adler.update(bs[i]);
    harness.check(adler.getValue(), result);
  }
}

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-09-01 17:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-01 17:26 New Adler32 test Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).