Skip to content

Commit

Permalink
some test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matakleo committed Jun 3, 2024
1 parent 79e4bec commit b99a9b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cdm/core/src/main/java/ucar/nc2/filter/Classifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public InvalidValueException(String message) {
public int classifyArray(double val) {
int classifiedVal;
if (val >= 0) {
classifiedVal = 10;
classifiedVal = 1;
} else {
classifiedVal = 0;
}
Expand Down Expand Up @@ -72,7 +72,7 @@ public int classifyArray(int val) {
*/

/** Classify integer array */
public int[] classifyArray(int[] inputArray) throws InvalidValueException {
public int[] classifyArray(int[] inputArray) {
int[] classifiedArray = new int[inputArray.length];

for (int i = 0; i < inputArray.length; i++) {
Expand Down
15 changes: 5 additions & 10 deletions cdm/core/src/test/java/ucar/nc2/filter/TestClassifier.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
package ucar.nc2.filter;

import static com.google.common.truth.Truth.assertThat;
import static ucar.ma2.MAMath.nearlyEquals;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.Test;
import ucar.ma2.Array;
import ucar.ma2.DataType;
import ucar.ma2.IndexIterator;

import ucar.nc2.filter.Classifier.InvalidValueException;

public class TestClassifier {
@Test
public void testClassifyIntArray_AllPositive() throws InvalidValueException {
public void testClassifyIntArray_AllPositive() {
Classifier classifier = new Classifier();
int[] input = {1, 2, 3};
int[] expected = {1, 1, 1};
assertArrayEquals(expected, classifier.classifyArray(input));
}

@Test
public void testClassifyIntArray_AllNegative() throws InvalidValueException {
public void testClassifyIntArray_AllNegative() {
Classifier classifier = new Classifier();
int[] input = {-1, -2, -3};
int[] expected = {0, 0, 0};
assertArrayEquals(expected, classifier.classifyArray(input));
}

@Test
public void testClassifyIntArray_Mixed() throws InvalidValueException {
public void testClassifyIntArray_Mixed() {
Classifier classifier = new Classifier();
int[] input = {-1, 2, -3, 4};
int[] expected = {0, 1, 0, 1};
assertArrayEquals(expected, classifier.classifyArray(input));
}

@Test
public void testClassifyIntArray_WithZero() throws InvalidValueException {
public void testClassifyIntArray_WithZero() {
Classifier classifier = new Classifier();
int[] input = {0, -1, 1, 0, 0, 0};
int[] expected = {1, 0, 1, 1, 1, 1};
Expand Down

0 comments on commit b99a9b4

Please sign in to comment.