Skip to content

Commit 071a1bd

Browse files
committed
Extend test suite
1 parent 85ddfca commit 071a1bd

File tree

17 files changed

+316
-19
lines changed

17 files changed

+316
-19
lines changed

examples/small_world/MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ register_toolchains(
3535
bazel_dep(name = "googletest", version = "1.16.0", dev_dependency = True)
3636
bazel_dep(name = "lcov", version = "2.3.1", dev_dependency = True)
3737

38+
bazel_dep(name = "eigen", version = "5.0.0")
39+
3840
# Register the buildifier toolchain
3941
bazel_dep(
4042
name = "buildifier_prebuilt",

examples/small_world/MODULE.bazel.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
11
load("@rules_swiftnav//cc:defs.bzl", "UNIT", "swift_cc_library", "swift_cc_test")
22

33
swift_cc_library(
4-
name = "base_math",
5-
srcs = ["base_math.cc"],
6-
hdrs = ["base_math.hpp"],
4+
name = "add",
5+
srcs = ["add.cc"],
6+
hdrs = ["add.hpp"],
7+
standard = 20,
78
visibility = ["//visibility:public"],
89
)
910

1011
swift_cc_test(
11-
name = "base_math_test",
12-
srcs = ["base_math_test.cc"],
12+
name = "add_test",
13+
srcs = ["add_test.cc"],
1314
type = UNIT,
1415
deps = [
15-
":base_math",
16+
":add",
17+
"@googletest//:gtest_main",
18+
],
19+
)
20+
21+
swift_cc_library(
22+
name = "sign",
23+
srcs = ["sign.cc"],
24+
hdrs = ["sign.hpp"],
25+
standard = 20,
26+
visibility = ["//visibility:public"],
27+
)
28+
29+
swift_cc_test(
30+
name = "sign_test",
31+
srcs = ["sign_test.cc"],
32+
type = UNIT,
33+
deps = [
34+
":sign",
1635
"@googletest//:gtest_main",
1736
],
1837
)

examples/small_world/src/base_math/base_math.cc renamed to examples/small_world/src/base_math/add.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "base_math.hpp"
1+
#include "add.hpp"
22

33
int add(int x, int y) {
44
return x + y;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef ADD_HPP
2+
#define ADD_HPP
3+
4+
int add(int x, int y);
5+
6+
#endif
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
#include "base_math.hpp"
1+
#include "add.hpp"
22
#include "gtest/gtest.h"
33

44
TEST(BaseMathTest, Add) {
55
EXPECT_EQ(add(1, 2), 3);
66
EXPECT_EQ(add(-1, 1), 0);
77
EXPECT_EQ(add(-1, -1), -2);
88
}
9-
10-
TEST(BaseMathTest, SignPlus) {
11-
EXPECT_EQ(Math::sign(10), 1);
12-
//EXPECT_EQ(Math::sign(-10), -1);
13-
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "sign.hpp"
2+
3+
int add(int x, int y) {
4+
return x + y;
5+
}

examples/small_world/src/base_math/base_math.hpp renamed to examples/small_world/src/base_math/sign.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef BASE_MATH_HPP
2-
#define BASE_MATH_HPP
1+
#ifndef SIGN_HPP
2+
#define SIGN_HPP
33

44
int add(int x, int y);
55

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "sign.hpp"
2+
#include "gtest/gtest.h"
3+
4+
TEST(BaseMathTest, SignPlus) {
5+
EXPECT_EQ(Math::sign(10), 1);
6+
//EXPECT_EQ(Math::sign(-10), -1);
7+
}

examples/small_world/src/fibonacci/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ swift_cc_library(
55
srcs = ["fibonacci.cc"],
66
hdrs = ["fibonacci.hpp"],
77
visibility = ["//visibility:public"],
8-
deps = ["//src/base_math"],
8+
deps = ["//src/base_math:add"],
99
)
1010

1111
swift_cc_test(

0 commit comments

Comments
 (0)