typo, javadoc fixes, test fixes
This commit is contained in:
parent
414abce68f
commit
2277cea51b
5 changed files with 483 additions and 566 deletions
|
@ -377,7 +377,7 @@ public class JsonArray extends JsonValue implements Iterable<JsonValue> {
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param object the object to be compared with this JsonArray
|
* @param object the object to be compared with this JsonArray
|
||||||
* @return <tt>true</tt> if the specified object is equal to this JsonArray, <code>false</code>
|
* @return {@code true} if the specified object is equal to this JsonArray, <code>false</code>
|
||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -323,7 +323,7 @@ public class JsonReader<A, O> {
|
||||||
}
|
}
|
||||||
if (firstDigit != '0') {
|
if (firstDigit != '0') {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (readDigit()) {
|
if (!readDigit()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ public class JsonReader<A, O> {
|
||||||
throw expected("digit");
|
throw expected("digit");
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
if (readDigit()) {
|
if (!readDigit()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,7 @@ public class JsonReader<A, O> {
|
||||||
throw expected("digit");
|
throw expected("digit");
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
if (readDigit()) {
|
if (!readDigit()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,77 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 Jörg Prante
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
package org.xbib.marc.json;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class JsonMapperTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void mapperMapTest() throws IOException {
|
|
||||||
String json = "{\"Hello\":\"World\"}";
|
|
||||||
JsonValue jsonValue = Json.parse(json);
|
|
||||||
Object object = JsonMapper.asObject(jsonValue);
|
|
||||||
assertEquals("{Hello=World}", Objects.requireNonNull(object).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void mapperNumericMapTest() throws IOException {
|
|
||||||
String json = "{\"Hello\":123}";
|
|
||||||
JsonValue jsonValue = Json.parse(json);
|
|
||||||
Object object = JsonMapper.asObject(jsonValue);
|
|
||||||
assertEquals("{Hello=123}", Objects.requireNonNull(object).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void mapperArrayTest() throws IOException {
|
|
||||||
String json = "[\"Hello\",\"World\"]";
|
|
||||||
JsonValue jsonValue = Json.parse(json);
|
|
||||||
Object object = JsonMapper.asObject(jsonValue);
|
|
||||||
assertEquals("[Hello, World]", Objects.requireNonNull(object).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void mapperBooleanAndNullArrayTest() throws IOException {
|
|
||||||
String json = "[true, false, null]";
|
|
||||||
JsonValue jsonValue = Json.parse(json);
|
|
||||||
Object object = JsonMapper.asObject(jsonValue);
|
|
||||||
assertEquals("[true, false, null]", Objects.requireNonNull(object).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void mapperFloatArrayTest() throws IOException {
|
|
||||||
String json = "[1.23, 4.56]";
|
|
||||||
JsonValue jsonValue = Json.parse(json);
|
|
||||||
Object object = JsonMapper.asObject(jsonValue);
|
|
||||||
assertEquals("[1.23, 4.56]", Objects.requireNonNull(object).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void mapperIntArrayTest() throws IOException {
|
|
||||||
String json = "[123, 456]";
|
|
||||||
JsonValue jsonValue = Json.parse(json);
|
|
||||||
Object object = JsonMapper.asObject(jsonValue);
|
|
||||||
assertEquals("[123, 456]", Objects.requireNonNull(object).toString());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -220,15 +220,8 @@ public class JsonTest extends TestUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parsereader() throws IOException {
|
public void parseReader() throws IOException {
|
||||||
Reader reader = new StringReader("23");
|
Reader reader = new StringReader("23");
|
||||||
|
|
||||||
assertEquals(Json.of(23), Json.parse(reader));
|
assertEquals(Json.of(23), Json.parse(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void parsereaderfailsWithNull() {
|
|
||||||
assertException(NullPointerException.class, null, (RunnableEx) () -> Json.parse((Reader) null));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue