- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Add hedron and extend test suite #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,18 +1,37 @@ | ||
| load("@rules_swiftnav//cc:defs.bzl", "UNIT", "swift_cc_library", "swift_cc_test") | ||
|  | ||
| swift_cc_library( | ||
| name = "base_math", | ||
| srcs = ["base_math.cc"], | ||
| hdrs = ["base_math.hpp"], | ||
| name = "add", | ||
| srcs = ["add.cc"], | ||
| hdrs = ["add.hpp"], | ||
| standard = 20, | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|  | ||
| swift_cc_test( | ||
| name = "base_math_test", | ||
| srcs = ["base_math_test.cc"], | ||
| name = "add_test", | ||
| srcs = ["add_test.cc"], | ||
| type = UNIT, | ||
| deps = [ | ||
| ":base_math", | ||
| ":add", | ||
| "@googletest//:gtest_main", | ||
| ], | ||
| ) | ||
|  | ||
| swift_cc_library( | ||
| name = "sign", | ||
| srcs = ["sign.cc"], | ||
| hdrs = ["sign.hpp"], | ||
| standard = 20, | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|  | ||
| swift_cc_test( | ||
| name = "sign_test", | ||
| srcs = ["sign_test.cc"], | ||
| type = UNIT, | ||
| deps = [ | ||
| ":sign", | ||
| "@googletest//:gtest_main", | ||
| ], | ||
| ) | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #include "base_math.hpp" | ||
| #include "add.hpp" | ||
|  | ||
| int add(int x, int y) { | ||
| return x + y; | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #ifndef ADD_HPP | ||
| #define ADD_HPP | ||
|  | ||
| int add(int x, int y); | ||
|  | ||
| #endif | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,13 +1,8 @@ | ||
| #include "base_math.hpp" | ||
| #include "add.hpp" | ||
| #include "gtest/gtest.h" | ||
|  | ||
| TEST(BaseMathTest, Add) { | ||
| EXPECT_EQ(add(1, 2), 3); | ||
| EXPECT_EQ(add(-1, 1), 0); | ||
| EXPECT_EQ(add(-1, -1), -2); | ||
| } | ||
|  | ||
| TEST(BaseMathTest, SignPlus) { | ||
| EXPECT_EQ(Math::sign(10), 1); | ||
| //EXPECT_EQ(Math::sign(-10), -1); | ||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #include "sign.hpp" | ||
|  | ||
| int add(int x, int y) { | ||
| return x + y; | ||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| #ifndef BASE_MATH_HPP | ||
| #define BASE_MATH_HPP | ||
| #ifndef SIGN_HPP | ||
| #define SIGN_HPP | ||
|  | ||
| int add(int x, int y); | ||
|  | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #include "sign.hpp" | ||
| #include "gtest/gtest.h" | ||
|  | ||
| TEST(BaseMathTest, SignPlus) { | ||
| EXPECT_EQ(Math::sign(10), 1); | ||
| //EXPECT_EQ(Math::sign(-10), -1); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| load("@rules_swiftnav//cc:defs.bzl", "UNIT", "swift_cc_library", "swift_cc_test") | ||
| load("@rules_swiftnav//cc:defs.bzl", "UNIT", "swift_cc_test") | ||
|  | ||
| swift_cc_library( | ||
| cc_library( | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this not use the swift macro? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to test the behavior of the toolchains, when the normal rules are used (mimic behavior from 3rd party libs) | ||
| name = "old_folder_structure", | ||
| srcs = ["src/old_folder_structure.cc"], | ||
| hdrs = ["include/old_folder_structure/old_folder_structure.hpp"], | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| load("@rules_swiftnav//cc:defs.bzl", "UNIT", "swift_cc_library", "swift_cc_test") | ||
|  | ||
| swift_cc_library( | ||
| name = "use_external_dep", | ||
| srcs = ["use_external_dep.cc"], | ||
| hdrs = ["use_external_dep.hpp"], | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "@eigen", | ||
| ], | ||
| ) | ||
|  | ||
| swift_cc_test( | ||
| name = "use_external_dep_test", | ||
| srcs = ["use_external_dep_test.cc"], | ||
| type = UNIT, | ||
| deps = [ | ||
| ":use_external_dep", | ||
| "@googletest//:gtest_main", | ||
| ], | ||
| ) | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #include "use_external_dep.hpp" | ||
|  | ||
| double compute_dot_product(const Eigen::Vector3d& a, const Eigen::Vector3d& b) { | ||
| return a.dot(b); | ||
| } | ||
|  | ||
| double compute_magnitude(const Eigen::Vector3d& v) { | ||
| return v.norm(); | ||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #ifndef USE_EXTERNAL_DEP_HPP | ||
| #define USE_EXTERNAL_DEP_HPP | ||
|  | ||
| #include <Eigen/Dense> | ||
|  | ||
| // Compute the dot product of two 3D vectors using Eigen | ||
| double compute_dot_product(const Eigen::Vector3d& a, const Eigen::Vector3d& b); | ||
|  | ||
| // Compute the magnitude of a 3D vector using Eigen | ||
| double compute_magnitude(const Eigen::Vector3d& v); | ||
|  | ||
| #endif | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #include "use_external_dep.hpp" | ||
| #include "gtest/gtest.h" | ||
|  | ||
| TEST(UseExternalDepTest, DotProduct) { | ||
| Eigen::Vector3d a(1.0, 2.0, 3.0); | ||
| Eigen::Vector3d b(4.0, 5.0, 6.0); | ||
|  | ||
| // Expected dot product: 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32 | ||
| EXPECT_DOUBLE_EQ(compute_dot_product(a, b), 32.0); | ||
| } | ||
|  | ||
| TEST(UseExternalDepTest, DotProductOrthogonal) { | ||
| Eigen::Vector3d a(1.0, 0.0, 0.0); | ||
| Eigen::Vector3d b(0.0, 1.0, 0.0); | ||
|  | ||
| // Orthogonal vectors have dot product of 0 | ||
| EXPECT_DOUBLE_EQ(compute_dot_product(a, b), 0.0); | ||
| } | ||
|  | ||
| TEST(UseExternalDepTest, Magnitude) { | ||
| Eigen::Vector3d v(3.0, 4.0, 0.0); | ||
|  | ||
| // Expected magnitude: sqrt(3^2 + 4^2) = sqrt(9 + 16) = sqrt(25) = 5 | ||
| EXPECT_DOUBLE_EQ(compute_magnitude(v), 5.0); | ||
| } | ||
|  | ||
| TEST(UseExternalDepTest, MagnitudeUnitVector) { | ||
| Eigen::Vector3d v(1.0, 0.0, 0.0); | ||
|  | ||
| // Unit vector has magnitude of 1 | ||
| EXPECT_DOUBLE_EQ(compute_magnitude(v), 1.0); | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I do not want to reach 100% coverage intentionally.