From 19efc2989ad81c7652a64ba5e7d8a25e47aa27a3 Mon Sep 17 00:00:00 2001 From: Sandeep Gupta Date: Thu, 1 Oct 2015 14:34:45 +0530 Subject: [PATCH] Added unit-tests for RangeUtils class --- .../sangupta/jerry/util/TestRangeUtils.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/test/java/com/sangupta/jerry/util/TestRangeUtils.java diff --git a/src/test/java/com/sangupta/jerry/util/TestRangeUtils.java b/src/test/java/com/sangupta/jerry/util/TestRangeUtils.java new file mode 100644 index 0000000..19c7c35 --- /dev/null +++ b/src/test/java/com/sangupta/jerry/util/TestRangeUtils.java @@ -0,0 +1,62 @@ +/** + * + * jerry - Common Java Functionality + * Copyright (c) 2012-2015, Sandeep Gupta + * + * http://sangupta.com/projects/jerry + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.sangupta.jerry.util; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Unit tests for {@link RangeUtils} class + * + * @author sangupta + * + */ +public class TestRangeUtils { + + @Test + public void testInt() { + Assert.assertTrue(RangeUtils.isInt(0, 0, 5)); + Assert.assertTrue(RangeUtils.isInt(5, 0, 5)); + Assert.assertTrue(RangeUtils.isInt(3, 0, 5)); + Assert.assertFalse(RangeUtils.isInt(-1, 0, 5)); + Assert.assertFalse(RangeUtils.isInt(6, 0, 5)); + } + + @Test + public void testLong() { + Assert.assertTrue(RangeUtils.isLong(0, 0, 5)); + Assert.assertTrue(RangeUtils.isLong(5, 0, 5)); + Assert.assertTrue(RangeUtils.isLong(3, 0, 5)); + Assert.assertFalse(RangeUtils.isLong(-1, 0, 5)); + Assert.assertFalse(RangeUtils.isLong(6, 0, 5)); + } + + @Test + public void testChar() { + Assert.assertTrue(RangeUtils.isChar('a', 'a', 'z')); + Assert.assertTrue(RangeUtils.isChar('z', 'a', 'z')); + Assert.assertTrue(RangeUtils.isChar('c', 'a', 'z')); + Assert.assertFalse(RangeUtils.isChar('0', 'a', 'z')); + Assert.assertFalse(RangeUtils.isChar('A', 'a', 'z')); + } + +}