Skip to content

Commit

Permalink
Increase IntegerAssert test coverage to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
sarajuhosova committed Mar 5, 2022
1 parent 8fa8010 commit f84ad2e
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.
*
* Copyright 2012-2022 the original author or authors.
*/
package org.assertj.core.api.integer_;

import org.assertj.core.api.IntegerAssert;
import org.assertj.core.api.IntegerAssertBaseTest;
import org.assertj.core.data.Percentage;

import static org.assertj.core.data.Percentage.withPercentage;
import static org.mockito.Mockito.verify;

class IntegerAssert_isCloseToPercentage_int_Test extends IntegerAssertBaseTest {

private final Percentage percentage = withPercentage(3);
private final int value = 42;

@Override
protected IntegerAssert invoke_api_method() {
return assertions.isCloseTo(value, percentage);
}

@Override
protected void verify_internal_effects() {
verify(integers).assertIsCloseToPercentage(getInfo(assertions), getActual(assertions), value, percentage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.
*
* Copyright 2012-2022 the original author or authors.
*/
package org.assertj.core.api.integer_;

import org.assertj.core.api.IntegerAssert;
import org.assertj.core.api.IntegerAssertBaseTest;
import org.assertj.core.data.Offset;

import static org.assertj.core.data.Offset.offset;
import static org.mockito.Mockito.verify;

class IntegerAssert_isCloseTo_int_Test extends IntegerAssertBaseTest {

private final Offset<Integer> offset = offset(13);
private final int value = 7;

@Override
protected IntegerAssert invoke_api_method() {
return assertions.isCloseTo(value, offset);
}

@Override
protected void verify_internal_effects() {
verify(integers).assertIsCloseTo(getInfo(assertions), getActual(assertions), value, offset);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.
*
* Copyright 2012-2022 the original author or authors.
*/
package org.assertj.core.api.integer_;

import org.assertj.core.api.IntegerAssert;
import org.assertj.core.api.IntegerAssertBaseTest;

import static org.mockito.Mockito.verify;

class IntegerAssert_isEqualTo_large_long_Test extends IntegerAssertBaseTest {

private final long expected = ((long) Integer.MAX_VALUE) + 2L;

@Override
protected IntegerAssert invoke_api_method() {
return assertions.isEqualTo(expected);
}

@Override
protected void verify_internal_effects() {
verify(integers).assertEqual(getInfo(assertions), getActual(assertions), expected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.
*
* Copyright 2012-2022 the original author or authors.
*/
package org.assertj.core.api.integer_;

import org.assertj.core.api.IntegerAssert;
import org.assertj.core.api.IntegerAssertBaseTest;
import org.assertj.core.data.Percentage;

import static org.assertj.core.data.Percentage.withPercentage;
import static org.mockito.Mockito.verify;

/**
* Tests for <code>{@link IntegerAssert#isNotCloseTo(Integer, Percentage)}</code>.
*
* @author Chris Arnott
*/
class IntegerAssert_isNotCloseToPercentage_int_Test extends IntegerAssertBaseTest {

private final Percentage percentage = withPercentage(3);
private final int value = 42;

@Override
protected IntegerAssert invoke_api_method() {
return assertions.isNotCloseTo(value, percentage);
}

@Override
protected void verify_internal_effects() {
verify(integers).assertIsNotCloseToPercentage(getInfo(assertions), getActual(assertions), value, percentage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.
*
* Copyright 2012-2022 the original author or authors.
*/
package org.assertj.core.api.integer_;

import org.assertj.core.api.IntegerAssert;
import org.assertj.core.api.IntegerAssertBaseTest;
import org.assertj.core.data.Offset;

import static org.assertj.core.data.Offset.offset;
import static org.mockito.Mockito.verify;

/**
* Tests for <code>{@link IntegerAssert#isNotCloseTo(Integer, Offset)}</code>.
*
* @author Chris Arnott
*/
class IntegerAssert_isNotCloseTo_int_Test extends IntegerAssertBaseTest {

private final Offset<Integer> offset = offset(13);
private final int value = 7;

@Override
protected IntegerAssert invoke_api_method() {
return assertions.isNotCloseTo(value, offset);
}

@Override
protected void verify_internal_effects() {
verify(integers).assertIsNotCloseTo(getInfo(assertions), getActual(assertions), value, offset);
}
}

0 comments on commit f84ad2e

Please sign in to comment.