Jeff Sharkey | 06c5f8a | 2012-12-04 09:53:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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.text.format; |
| 18 | |
Andrei Stingaceanu | bbe51f8 | 2017-04-28 14:48:17 +0100 | [diff] [blame] | 19 | import static org.junit.Assert.assertFalse; |
| 20 | import static org.junit.Assert.assertTrue; |
| 21 | |
Siyamed Sinir | 68089c8 | 2016-06-29 16:55:35 -0700 | [diff] [blame] | 22 | import android.support.test.filters.SmallTest; |
Andrei Stingaceanu | bbe51f8 | 2017-04-28 14:48:17 +0100 | [diff] [blame] | 23 | import android.support.test.runner.AndroidJUnit4; |
Jeff Sharkey | 06c5f8a | 2012-12-04 09:53:44 -0800 | [diff] [blame] | 24 | |
Andrei Stingaceanu | bbe51f8 | 2017-04-28 14:48:17 +0100 | [diff] [blame] | 25 | import org.junit.Test; |
| 26 | import org.junit.runner.RunWith; |
Jeff Sharkey | 06c5f8a | 2012-12-04 09:53:44 -0800 | [diff] [blame] | 27 | |
Joachim Sauer | 20c5ef7 | 2017-06-01 11:22:26 +0100 | [diff] [blame] | 28 | import java.util.Locale; |
| 29 | |
Andrei Stingaceanu | bbe51f8 | 2017-04-28 14:48:17 +0100 | [diff] [blame] | 30 | @SmallTest |
| 31 | @RunWith(AndroidJUnit4.class) |
| 32 | public class DateFormatTest { |
Siyamed Sinir | 68089c8 | 2016-06-29 16:55:35 -0700 | [diff] [blame] | 33 | |
Andrei Stingaceanu | bbe51f8 | 2017-04-28 14:48:17 +0100 | [diff] [blame] | 34 | @Test |
| 35 | public void testHasDesignator() { |
Jeff Sharkey | 06c5f8a | 2012-12-04 09:53:44 -0800 | [diff] [blame] | 36 | assertTrue(DateFormat.hasDesignator("hh:mm:ss", DateFormat.MINUTE)); |
| 37 | assertTrue(DateFormat.hasDesignator("myyyy", DateFormat.MINUTE)); |
| 38 | assertTrue(DateFormat.hasDesignator("mmm", DateFormat.MINUTE)); |
| 39 | |
| 40 | assertFalse(DateFormat.hasDesignator("hh:MM:ss", DateFormat.MINUTE)); |
| 41 | } |
| 42 | |
Andrei Stingaceanu | bbe51f8 | 2017-04-28 14:48:17 +0100 | [diff] [blame] | 43 | @Test |
| 44 | public void testHasDesignatorEscaped() { |
Jeff Sharkey | 06c5f8a | 2012-12-04 09:53:44 -0800 | [diff] [blame] | 45 | assertTrue(DateFormat.hasDesignator("hh:mm 'LOL'", DateFormat.MINUTE)); |
| 46 | |
| 47 | assertFalse(DateFormat.hasDesignator("hh:mm 'yyyy'", DateFormat.YEAR)); |
| 48 | } |
Joachim Sauer | 20c5ef7 | 2017-06-01 11:22:26 +0100 | [diff] [blame] | 49 | |
| 50 | @Test |
| 51 | public void testIs24HourLocale() { |
| 52 | assertFalse(DateFormat.is24HourLocale(Locale.US)); |
| 53 | assertTrue(DateFormat.is24HourLocale(Locale.GERMANY)); |
| 54 | } |
Jeff Sharkey | 06c5f8a | 2012-12-04 09:53:44 -0800 | [diff] [blame] | 55 | } |