Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/XMLDecoder/spec/TestLong.java
41155 views
1
/*
2
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @summary Tests <long> element
27
* @run main/othervm -Djava.security.manager=allow TestLong
28
* @author Sergey Malenkov
29
*/
30
31
import java.beans.XMLDecoder;
32
33
public final class TestLong extends AbstractTest {
34
public static final String XML
35
= "<java>\n"
36
+ " <long>0</long>\n"
37
+ " <long>127</long>\n"
38
+ " <long>-128</long>\n"
39
+ " <long>32767</long>\n"
40
+ " <long>-32768</long>\n"
41
+ " <long>2147483647</long>\n"
42
+ " <long>-2147483648</long>\n"
43
+ " <long>9223372036854775807</long>\n"
44
+ " <long>-9223372036854775808</long>\n"
45
+ "</java>";
46
47
public static void main(String[] args) {
48
new TestLong().test(true);
49
}
50
51
@Override
52
protected void validate(XMLDecoder decoder) {
53
validate(0L, decoder.readObject());
54
validate((long) Byte.MAX_VALUE, decoder.readObject());
55
validate((long) Byte.MIN_VALUE, decoder.readObject());
56
validate((long) Short.MAX_VALUE, decoder.readObject());
57
validate((long) Short.MIN_VALUE, decoder.readObject());
58
validate((long) Integer.MAX_VALUE, decoder.readObject());
59
validate((long) Integer.MIN_VALUE, decoder.readObject());
60
validate(Long.MAX_VALUE, decoder.readObject());
61
validate(Long.MIN_VALUE, decoder.readObject());
62
}
63
64
private static void validate(long value, Object object) {
65
if (!object.equals(Long.valueOf(value))) {
66
throw new Error("long " + value + " expected");
67
}
68
}
69
}
70
71