|
| 1 | +/* |
| 2 | + * Copyright (C) 2014-2016 Stichting Mapcode Foundation (http://www.mapcode.com) |
| 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 com.mapcode; |
| 18 | + |
| 19 | +import org.junit.Test; |
| 20 | +import org.slf4j.Logger; |
| 21 | +import org.slf4j.LoggerFactory; |
| 22 | + |
| 23 | +@SuppressWarnings({"OverlyBroadThrowsClause", "ProhibitedExceptionDeclared"}) |
| 24 | +public class CheckArgsTest { |
| 25 | + private static final Logger LOG = LoggerFactory.getLogger(CheckArgsTest.class); |
| 26 | + |
| 27 | + public void testCheckNonnullOK() throws Exception { |
| 28 | + LOG.info("testCheckNonnullOK"); |
| 29 | + CheckArgs.checkNonnull("test", this); |
| 30 | + } |
| 31 | + |
| 32 | + @Test(expected = IllegalArgumentException.class) |
| 33 | + public void testCheckNonnullError() throws Exception { |
| 34 | + LOG.info("testCheckNonnullError"); |
| 35 | + CheckArgs.checkNonnull("test", null); |
| 36 | + } |
| 37 | + |
| 38 | + public void testCheckDefinedOK() throws Exception { |
| 39 | + LOG.info("testCheckDefinedOK"); |
| 40 | + CheckArgs.checkDefined("test", Point.fromDeg(0.0, 0.0)); |
| 41 | + } |
| 42 | + |
| 43 | + @Test(expected = IllegalArgumentException.class) |
| 44 | + public void testCheckDefinedError() throws Exception { |
| 45 | + LOG.info("testCheckDefinedError"); |
| 46 | + CheckArgs.checkDefined("test", Point.undefined()); |
| 47 | + } |
| 48 | + |
| 49 | + public void testMapcodeCodeOK() throws Exception { |
| 50 | + LOG.info("testCheckMapcodeCodeOK"); |
| 51 | + CheckArgs.checkMapcodeCode("test", "XX.XX"); |
| 52 | + } |
| 53 | + |
| 54 | + @Test(expected = IllegalArgumentException.class) |
| 55 | + public void testMapcodeCodeError() throws Exception { |
| 56 | + LOG.info("testCheckMapcodeCodeError"); |
| 57 | + CheckArgs.checkMapcodeCode("test", "XX.XX-"); |
| 58 | + } |
| 59 | +} |
0 commit comments