]> git.basschouten.com Git - openhab-addons.git/blob
70ee8d1a867bce4a9a5797ab3c98e6b21b848cd5
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.netatmo.internal.api;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.toQuantityType;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.Test;
20 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.MeasureClass;
21 import org.openhab.core.types.State;
22
23 /**
24  * @author Gaël L'hopital - Initial contribution
25  */
26 @NonNullByDefault
27 public class MeasureTest {
28
29     @Test
30     public void testMeasurePrecision() {
31         State value = toQuantityType(25.0, MeasureClass.INSIDE_TEMPERATURE);
32         assertEquals("25 °C", value.toString());
33         value = toQuantityType(52.0, MeasureClass.INSIDE_TEMPERATURE);
34         assertEquals("50 °C", value.toString());
35         value = toQuantityType(-10.0, MeasureClass.INSIDE_TEMPERATURE);
36         assertEquals("0 °C", value.toString());
37     }
38 }