Skip to content

Commit 8a6cfbe

Browse files
committed
Split is_even and is_odd tests into separate files
1 parent 0933541 commit 8a6cfbe

2 files changed

Lines changed: 36 additions & 33 deletions

File tree

test/unit/math/prim/fun/is_even_odd_test.cpp renamed to test/unit/math/prim/fun/is_even_test.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,13 @@ TEST(MathFunctions, is_even_scalar) {
1313
EXPECT_EQ(0, stan::math::is_even(-3));
1414
}
1515

16-
TEST(MathFunctions, is_odd_scalar) {
17-
EXPECT_EQ(0, stan::math::is_odd(0));
18-
EXPECT_EQ(1, stan::math::is_odd(1));
19-
EXPECT_EQ(0, stan::math::is_odd(2));
20-
EXPECT_EQ(1, stan::math::is_odd(3));
21-
22-
EXPECT_EQ(1, stan::math::is_odd(-1));
23-
EXPECT_EQ(0, stan::math::is_odd(-2));
24-
EXPECT_EQ(1, stan::math::is_odd(-3));
25-
}
26-
2716
TEST(MathFunctions, is_even_vector) {
2817
std::vector<int> input{0, 1, 2, 3, -3, -4};
2918
std::vector<int> expected{1, 0, 1, 0, 0, 1};
3019

3120
EXPECT_EQ(expected, stan::math::is_even(input));
3221
}
3322

34-
TEST(MathFunctions, is_odd_vector) {
35-
std::vector<int> input{0, 1, 2, 3, -3, -4};
36-
std::vector<int> expected{0, 1, 0, 1, 1, 0};
37-
38-
EXPECT_EQ(expected, stan::math::is_odd(input));
39-
}
40-
4123
TEST(MathFunctions, is_even_nested_vector) {
4224
std::vector<std::vector<int>> input{{1, 2}, {3, 4}};
4325

@@ -46,24 +28,9 @@ TEST(MathFunctions, is_even_nested_vector) {
4628
EXPECT_EQ(expected, stan::math::is_even(input));
4729
}
4830

49-
TEST(MathFunctions, is_odd_nested_vector) {
50-
std::vector<std::vector<int>> input{{1, 2}, {3, 4}};
51-
52-
std::vector<std::vector<int>> expected{{1, 0}, {1, 0}};
53-
54-
EXPECT_EQ(expected, stan::math::is_odd(input));
55-
}
56-
5731
TEST(MathFunctions, is_even_empty_vector) {
5832
std::vector<int> input;
5933
std::vector<int> expected;
6034

6135
EXPECT_EQ(expected, stan::math::is_even(input));
6236
}
63-
64-
TEST(MathFunctions, is_odd_empty_vector) {
65-
std::vector<int> input;
66-
std::vector<int> expected;
67-
68-
EXPECT_EQ(expected, stan::math::is_odd(input));
69-
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <stan/math/prim.hpp>
2+
#include <gtest/gtest.h>
3+
#include <vector>
4+
5+
TEST(MathFunctions, is_odd_scalar) {
6+
EXPECT_EQ(0, stan::math::is_odd(0));
7+
EXPECT_EQ(1, stan::math::is_odd(1));
8+
EXPECT_EQ(0, stan::math::is_odd(2));
9+
EXPECT_EQ(1, stan::math::is_odd(3));
10+
11+
EXPECT_EQ(1, stan::math::is_odd(-1));
12+
EXPECT_EQ(0, stan::math::is_odd(-2));
13+
EXPECT_EQ(1, stan::math::is_odd(-3));
14+
}
15+
16+
TEST(MathFunctions, is_odd_vector) {
17+
std::vector<int> input{0, 1, 2, 3, -3, -4};
18+
std::vector<int> expected{0, 1, 0, 1, 1, 0};
19+
20+
EXPECT_EQ(expected, stan::math::is_odd(input));
21+
}
22+
23+
TEST(MathFunctions, is_odd_nested_vector) {
24+
std::vector<std::vector<int>> input{{1, 2}, {3, 4}};
25+
26+
std::vector<std::vector<int>> expected{{1, 0}, {1, 0}};
27+
28+
EXPECT_EQ(expected, stan::math::is_odd(input));
29+
}
30+
31+
TEST(MathFunctions, is_odd_empty_vector) {
32+
std::vector<int> input;
33+
std::vector<int> expected;
34+
35+
EXPECT_EQ(expected, stan::math::is_odd(input));
36+
}

0 commit comments

Comments
 (0)