diff --git a/au/BUILD.bazel b/au/BUILD.bazel index 6f5ac26f..826f55b8 100644 --- a/au/BUILD.bazel +++ b/au/BUILD.bazel @@ -47,6 +47,23 @@ cc_library( visibility = ["//visibility:public"], ) +cc_test( + name = "fwd_test", + size = "small", + srcs = [ + "code/au/fwd_test.cc", + "code/au/fwd_test_lib.cc", + "code/au/fwd_test_lib.hh", + ], + deps = [ + ":fwd", + ":io", + ":quantity", + ":units", + "@com_google_googletest//:gtest_main", + ], +) + cc_library( name = "io", hdrs = ["code/au/io.hh"], diff --git a/au/code/au/fwd_test.cc b/au/code/au/fwd_test.cc new file mode 100644 index 00000000..67c5ded4 --- /dev/null +++ b/au/code/au/fwd_test.cc @@ -0,0 +1,29 @@ +// Copyright 2024 Aurora Operations, Inc. +// +// 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. + +#include "au/fwd_test_lib.hh" +#include "au/quantity.hh" +#include "au/units/meters.hh" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +using ::testing::StrEq; + +namespace au { + +TEST(Fwd, CanCallFunctionDeclaredWithOnlyFwdFiles) { + EXPECT_THAT(print_to_string(meters(1)), StrEq("1 m")); +} + +} // namespace au diff --git a/au/code/au/fwd_test_lib.cc b/au/code/au/fwd_test_lib.cc new file mode 100644 index 00000000..14ea6a9d --- /dev/null +++ b/au/code/au/fwd_test_lib.cc @@ -0,0 +1,32 @@ +// Copyright 2024 Aurora Operations, Inc. +// +// 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. + +#include "au/fwd_test_lib.hh" + +#include +#include + +#include "au/io.hh" +#include "au/quantity.hh" +#include "au/units/meters.hh" + +namespace au { + +std::string print_to_string(const QuantityI &q) { + std::ostringstream oss; + oss << q; + return oss.str(); +} + +} // namespace au diff --git a/au/code/au/fwd_test_lib.hh b/au/code/au/fwd_test_lib.hh new file mode 100644 index 00000000..c870897d --- /dev/null +++ b/au/code/au/fwd_test_lib.hh @@ -0,0 +1,26 @@ +// Copyright 2024 Aurora Operations, Inc. +// +// 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. + +#pragma once + +#include + +#include "au/fwd.hh" +#include "au/units/meters_fwd.hh" + +namespace au { + +std::string print_to_string(const QuantityI &q); + +} // namespace au