Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
chiphogg committed Oct 28, 2024
1 parent b45d4b2 commit 2e84035
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
17 changes: 17 additions & 0 deletions au/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
29 changes: 29 additions & 0 deletions au/code/au/fwd_test.cc
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions au/code/au/fwd_test_lib.cc
Original file line number Diff line number Diff line change
@@ -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 <sstream>
#include <string>

#include "au/io.hh"
#include "au/quantity.hh"
#include "au/units/meters.hh"

namespace au {

std::string print_to_string(const QuantityI<Meters> &q) {
std::ostringstream oss;
oss << q;
return oss.str();
}

} // namespace au
26 changes: 26 additions & 0 deletions au/code/au/fwd_test_lib.hh
Original file line number Diff line number Diff line change
@@ -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 <string>

#include "au/fwd.hh"
#include "au/units/meters_fwd.hh"

namespace au {

std::string print_to_string(const QuantityI<Meters> &q);

} // namespace au

0 comments on commit 2e84035

Please sign in to comment.