2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.impl.codec;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
12 import org.junit.jupiter.api.Test;
13 import org.opendaylight.yangtools.yang.data.api.codec.BooleanCodec;
14 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
17 * Unit tests for BooleanCodecString.
19 * @author Thomas Pantelis
21 class BooleanCodecStringTest {
22 @SuppressWarnings("unchecked")
24 void testSerialize() {
25 final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.booleanType(),
28 assertEquals("true", codec.serialize(Boolean.TRUE), "serialize");
29 assertEquals("false", codec.serialize(Boolean.FALSE), "serialize");
32 @SuppressWarnings("unchecked")
34 void testDeserialize() {
35 final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.booleanType(),
38 assertEquals(Boolean.TRUE, codec.deserialize("true"), "deserialize");
39 assertEquals(Boolean.FALSE, codec.deserialize("false"), "deserialize");
40 TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "TRUE");
41 TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "FALSE");
42 TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "foo");
43 TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "");