blob: f17715a099a324f17f18b27585ca91930e83845f [file] [log] [blame]
Remi NGUYEN VAN98bab002021-04-14 09:37:30 +00001/*
2 * Copyright (C) 2021 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
17import android.net.ParseException
18import androidx.test.ext.junit.runners.AndroidJUnit4
19import androidx.test.filters.SmallTest
20import junit.framework.Assert.assertEquals
21import junit.framework.Assert.assertNull
22import org.junit.Test
23import org.junit.runner.RunWith
24
25@SmallTest
26@RunWith(AndroidJUnit4::class)
27class ParseExceptionTest {
28 @Test
29 fun testConstructor_WithCause() {
30 val testMessage = "Test message"
31 val base = Exception("Test")
32 val exception = ParseException(testMessage, base)
33
34 assertEquals(testMessage, exception.response)
35 assertEquals(base, exception.cause)
36 }
37
38 @Test
39 fun testConstructor_NoCause() {
40 val testMessage = "Test message"
41 val exception = ParseException(testMessage)
42
43 assertEquals(testMessage, exception.response)
44 assertNull(exception.cause)
45 }
46}