47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
/*
|
|
* Copyright 2020 Adler Neves.
|
|
*
|
|
* 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 br.ufes.inf.decisionelement;
|
|
import br.ufes.inf.decisionelement.wheelreinventions.json.JsonElement;
|
|
import org.junit.After;
|
|
import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
/**
|
|
* Tests JSON serialization consistency.
|
|
*/
|
|
public class JsonSerializationTest {
|
|
@Before
|
|
public void setUp() {
|
|
}
|
|
@After
|
|
public void tearDown() {
|
|
}
|
|
@Test
|
|
public void basics() throws Exception {
|
|
JsonElement<?> je;
|
|
je = JsonElement.parseJson("null");
|
|
Assert.assertEquals(je.toString(), "null");
|
|
je = JsonElement.parseJson("true");
|
|
Assert.assertEquals(je.toString(), "true");
|
|
je = JsonElement.parseJson("false");
|
|
Assert.assertEquals(je.toString(), "false");
|
|
je = JsonElement.parseJson("[1, 2]");
|
|
Assert.assertEquals(je.toString(), "[1.0,2.0]");
|
|
je = JsonElement.parseJson("{\"c\": 3, \"b\": 2, \"a\": 1}");
|
|
Assert.assertEquals(je.toString(), "{\"a\":1.0,\"b\":2.0,\"c\":3.0}");
|
|
}
|
|
}
|