Fix BaseDecimalType scales
[yangtools.git] / model / yang-model-ri / src / test / java / org / opendaylight / yangtools / yang / model / ri / type / BaseDecimalTest.java
1 /*
2  * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.ri.type;
9
10 import static org.junit.Assert.assertEquals;
11
12 import com.google.common.collect.Iterables;
13 import com.google.common.collect.Range;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.Decimal64;
16
17 public class BaseDecimalTest {
18     @Test
19     public void testImplicitRanges() {
20         assertEquals(
21             Range.closed(Decimal64.valueOf("-922337203685477580.8"), Decimal64.valueOf("922337203685477580.7")),
22             Iterables.getOnlyElement(BaseDecimalType.constraintsForDigits(1).getAllowedRanges().asRanges()));
23
24         assertEquals(Range.closed(
25             Decimal64.valueOf("-9.223372036854775808"), Decimal64.valueOf("9.223372036854775807")),
26             Iterables.getOnlyElement(BaseDecimalType.constraintsForDigits(18).getAllowedRanges().asRanges()));
27     }
28 }