• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.healthconnect.cts;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import android.health.connect.datatypes.units.Length;
22 import android.platform.test.annotations.AppModeFull;
23 
24 import androidx.test.runner.AndroidJUnit4;
25 
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 
29 @AppModeFull(reason = "HealthConnectManager is not accessible to instant apps")
30 @RunWith(AndroidJUnit4.class)
31 public class LengthTest {
32     @Test
testCreate()33     public void testCreate() {
34         assertThat(Length.fromMeters(10.0)).isInstanceOf(Length.class);
35         assertThat(Length.fromMeters(10.0).getInMeters()).isEqualTo(10.0);
36     }
37 
38     @Test
testEquals()39     public void testEquals() {
40         Length Length1 = Length.fromMeters(10.0);
41         Length Length2 = Length.fromMeters(10.0);
42         Length Length3 = Length.fromMeters(20.0);
43 
44         assertThat(Length1.equals(Length2)).isEqualTo(true);
45         assertThat(Length1.equals(Length3)).isEqualTo(false);
46     }
47 
48     @Test
testCompare()49     public void testCompare() {
50         Length Length1 = Length.fromMeters(10.0);
51         Length Length2 = Length.fromMeters(10.0);
52         Length Length3 = Length.fromMeters(20.0);
53 
54         assertThat(Length1.compareTo(Length2)).isEqualTo(0);
55         assertThat(Length1.compareTo(Length3)).isEqualTo(-1);
56         assertThat(Length3.compareTo(Length1)).isEqualTo(1);
57     }
58 }
59