-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#240] fixes parseBoolean according spec
- Loading branch information
1 parent
10f8e1a
commit b023399
Showing
3 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
api/src/test/java/org/eclipse/jaxb/api/DatatypeConverterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2023, 2023 Oracle and/or its affiliates. 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.eclipse.jaxb.api; | ||
|
||
import jakarta.xml.bind.DatatypeConverter; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class DatatypeConverterTest { | ||
|
||
@Test | ||
public void testParseBoolean() { | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean(null)); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("11")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("1A")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("non")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("fals")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("falses")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("false s")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("falst")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("tru")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("trux")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("truu")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("truxx")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("truth")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("truelle")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("truec")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("true c")); | ||
Assert.assertThrows(IllegalArgumentException.class, () -> DatatypeConverter.parseBoolean("oui")); | ||
|
||
|
||
Assert.assertEquals(false, DatatypeConverter.parseBoolean("0")); | ||
Assert.assertEquals(false, DatatypeConverter.parseBoolean(" 0")); | ||
Assert.assertEquals(false, DatatypeConverter.parseBoolean(" 0 ")); | ||
Assert.assertEquals(false, DatatypeConverter.parseBoolean("0 ")); | ||
Assert.assertEquals(true, DatatypeConverter.parseBoolean("1")); | ||
Assert.assertEquals(true, DatatypeConverter.parseBoolean(" 1")); | ||
Assert.assertEquals(true, DatatypeConverter.parseBoolean(" 1 ")); | ||
Assert.assertEquals(true, DatatypeConverter.parseBoolean("1 ")); | ||
Assert.assertEquals(false, DatatypeConverter.parseBoolean("false")); | ||
Assert.assertEquals(false, DatatypeConverter.parseBoolean(" false")); | ||
Assert.assertEquals(false, DatatypeConverter.parseBoolean("false ")); | ||
Assert.assertEquals(false, DatatypeConverter.parseBoolean(" false ")); | ||
Assert.assertEquals(true, DatatypeConverter.parseBoolean("true")); | ||
Assert.assertEquals(true, DatatypeConverter.parseBoolean(" true")); | ||
Assert.assertEquals(true, DatatypeConverter.parseBoolean("true ")); | ||
Assert.assertEquals(true, DatatypeConverter.parseBoolean(" true ")); | ||
} | ||
} |