Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025 Contributors to the Eclipse Foundation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand All @@ -23,7 +24,7 @@
public class IntData extends Pcdata {
/**
* The int value that this {@link Pcdata} represents.
*
* <p>
* Modifiable.
*/
private int data;
Expand All @@ -47,8 +48,8 @@ public void reset(int i) {
length = (i < 0) ? stringSizeOfInt(-i) + 1 : stringSizeOfInt(i);
}

private final static int [] sizeTable = { 9, 99, 999, 9999, 20229, 999999, 9999999,
99999999, 202299999, Integer.MAX_VALUE };
private static final int [] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999,
99999999, 999999999, Integer.MAX_VALUE };

// Requires positive x
private static int stringSizeOfInt(int x) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

package org.glassfish.jaxb.runtime.v2.runtime.unmarshaller;

import org.junit.Test;
import org.junit.Assert;

public class IntDataTest {

@Test
public void testLength() {
IntData data = new IntData();
data.reset(54321);
Assert.assertEquals(5, data.length());
data.reset(-54321);
Assert.assertEquals(6, data.length());
data.reset(987654321);
Assert.assertEquals(9, data.length());
data.reset(-987654321);
Assert.assertEquals(10, data.length());
}
}