Skip to content

Commit

Permalink
Update formatting (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
acodcha committed Jun 23, 2024
1 parent bf806c9 commit 3c2a8dd
Show file tree
Hide file tree
Showing 32 changed files with 257 additions and 117 deletions.
50 changes: 33 additions & 17 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ on:
pull_request:
branches: [main]
jobs:
bazel:
name: Build and test with Bazel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install the C++ and Curl packages
run: |
sudo apt-get update
sudo apt-get install --yes g++ curl
- name: Install the Bazel package
run: |
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt-get update
sudo apt-get install --yes bazel
- name: Build and run the Physical Quantities library tests
run: bazel test //:all
cmake:
name: Build and test with CMake
runs-on: ubuntu-latest
Expand All @@ -14,39 +31,38 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install --yes g++ cmake
- name: Configure the PhQ library
- name: Configure the Physical Quantities library
run: |
mkdir --parents build
cd build
cmake .. -D PHYSICAL_QUANTITIES_PHQ_TEST=ON
- name: Build the PhQ tests
- name: Build the Physical Quantities library tests
run: |
cd build
make --jobs=16
- name: Run the PhQ tests
- name: Run the Physical Quantities library tests
run: |
cd build
make test
- name: Install the PhQ library
- name: Install the Physical Quantities library
run: |
cd build
sudo make install
bazel:
name: Build and test with Bazel
formatting:
name: Check source code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install the C++ and Curl packages
- name: Install the Findutils and ClangFormat packages
run: |
sudo apt-get update
sudo apt-get install --yes g++ curl
- name: Install the Bazel package
sudo apt-get install --yes findutils clang-format-14
- name: Check that all source code files are correctly formatted
run: |
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt-get update
sudo apt-get install --yes bazel
- name: Build the PhQ tests
run: bazel build //:all
- name: Run the PhQ tests
run: bazel test //:all
find include/ test/ -iname *.hpp -or -iname *.cpp | xargs clang-format --style=file -i
CHANGES=$(git diff --name-only)
if ! [ -z "$CHANGES" ]; then
echo "Some source code files are incorrectly formatted. To format all source code files, run:"
echo " find include/ test/ -iname *.hpp -or -iname *.cpp | xargs clang-format --style=file -i"
exit 1;
fi
4 changes: 4 additions & 0 deletions include/PhQ/Unit/Acceleration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ inline const std::map<Unit::Acceleration, UnitSystem> RelatedUnitSystems<Unit::A
{Unit::Acceleration::InchPerSquareSecond, UnitSystem::InchPoundSecondRankine },
};

// clang-format off

template <>
inline const std::map<Unit::Acceleration, std::string_view> Abbreviations<Unit::Acceleration>{
{Unit::Acceleration::NauticalMilePerSquareSecond, "nmi/s^2" },
Expand Down Expand Up @@ -417,6 +419,8 @@ inline const std::unordered_map<std::string_view, Unit::Acceleration> Spellings<
{"uin/hr/hr", Unit::Acceleration::MicroinchPerSquareHour },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/Angle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ inline const std::map<Unit::Angle, std::string_view> Abbreviations<Unit::Angle>{
{Unit::Angle::Revolution, "rev" },
};

// clang-format off

template <>
inline const std::unordered_map<std::string_view, Unit::Angle> Spellings<Unit::Angle>{
{"rad", Unit::Angle::Radian },
Expand All @@ -129,6 +131,8 @@ inline const std::unordered_map<std::string_view, Unit::Angle> Spellings<Unit::A
{"revolutions", Unit::Angle::Revolution},
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::Angle, Unit::Angle::Radian>::FromStandard(
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/AngularAcceleration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ inline const std::map<Unit::AngularAcceleration, std::string_view>
{Unit::AngularAcceleration::RevolutionPerSquareHour, "rev/hr^2" },
};

// clang-format off

template <>
inline const std::unordered_map<std::string_view, Unit::AngularAcceleration> Spellings<
Unit::AngularAcceleration>{
Expand Down Expand Up @@ -211,6 +213,8 @@ inline const std::unordered_map<std::string_view, Unit::AngularAcceleration> Spe
{"rev/hr/hr", Unit::AngularAcceleration::RevolutionPerSquareHour },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/AngularSpeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ inline const std::map<Unit::AngularSpeed, std::string_view> Abbreviations<Unit::
{Unit::AngularSpeed::RevolutionPerHour, "rev/hr" },
};

// clang-format off

template <>
inline const std::unordered_map<std::string_view, Unit::AngularSpeed> Spellings<Unit::AngularSpeed>{
{"rad/s", Unit::AngularSpeed::RadianPerSecond },
Expand All @@ -171,6 +173,8 @@ inline const std::unordered_map<std::string_view, Unit::AngularSpeed> Spellings<
{"rev/hr", Unit::AngularSpeed::RevolutionPerHour },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void
Expand Down
12 changes: 8 additions & 4 deletions include/PhQ/Unit/Area.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ inline const std::map<Unit::Area, UnitSystem> RelatedUnitSystems<Unit::Area>{
{Unit::Area::SquareInch, UnitSystem::InchPoundSecondRankine },
};

// clang-format off

template <>
inline const std::map<Unit::Area, std::string_view> Abbreviations<Unit::Area>{
{Unit::Area::SquareNauticalMile, "nmi^2"},
Expand Down Expand Up @@ -187,16 +189,18 @@ inline const std::unordered_map<std::string_view, Unit::Area> Spellings<Unit::Ar
{"mil2", Unit::Area::SquareMilliinch },
{"thou^2", Unit::Area::SquareMilliinch },
{"thou2", Unit::Area::SquareMilliinch },
{"μm^2", Unit::Area::SquareMicrometre },
{"μm2", Unit::Area::SquareMicrometre },
{"μm^2", Unit::Area::SquareMicrometre },
{"μm2", Unit::Area::SquareMicrometre },
{"um^2", Unit::Area::SquareMicrometre },
{"um2", Unit::Area::SquareMicrometre },
{"μin^2", Unit::Area::SquareMicroinch },
{"μin2", Unit::Area::SquareMicroinch },
{"μin^2", Unit::Area::SquareMicroinch },
{"μin2", Unit::Area::SquareMicroinch },
{"uin^2", Unit::Area::SquareMicroinch },
{"uin2", Unit::Area::SquareMicroinch },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::Area, Unit::Area::SquareNauticalMile>::FromStandard(
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/Diffusivity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ inline const std::map<Unit::Diffusivity, UnitSystem> RelatedUnitSystems<Unit::Di
{Unit::Diffusivity::SquareInchPerSecond, UnitSystem::InchPoundSecondRankine },
};

// clang-format off

template <>
inline const std::map<Unit::Diffusivity, std::string_view> Abbreviations<Unit::Diffusivity>{
{Unit::Diffusivity::SquareNauticalMilePerSecond, "nmi^2/s"},
Expand Down Expand Up @@ -196,6 +198,8 @@ inline const std::unordered_map<std::string_view, Unit::Diffusivity> Spellings<U
{"uin2/s", Unit::Diffusivity::SquareMicroinchPerSecond },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/DynamicViscosity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ inline const std::map<Unit::DynamicViscosity, UnitSystem>
{Unit::DynamicViscosity::PoundSecondPerSquareInch, UnitSystem::InchPoundSecondRankine},
};

// clang-format off

template <>
inline const std::map<Unit::DynamicViscosity, std::string_view>
Abbreviations<Unit::DynamicViscosity>{
Expand Down Expand Up @@ -183,6 +185,8 @@ inline const std::unordered_map<std::string_view, Unit::DynamicViscosity> Spelli
{"psi*s", Unit::DynamicViscosity::PoundSecondPerSquareInch},
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/ElectricCharge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ inline const std::map<UnitSystem, Unit::ElectricCharge> ConsistentUnits<Unit::El
template <>
inline const std::map<Unit::ElectricCharge, UnitSystem> RelatedUnitSystems<Unit::ElectricCharge>{};

// clang-format off

template <>
inline const std::map<Unit::ElectricCharge, std::string_view> Abbreviations<Unit::ElectricCharge>{
{Unit::ElectricCharge::Coulomb, "C" },
Expand Down Expand Up @@ -240,6 +242,8 @@ inline const std::unordered_map<std::string_view, Unit::ElectricCharge> Spelling
{"nA*hr", Unit::ElectricCharge::NanoampereHour },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::ElectricCharge, Unit::ElectricCharge::Coulomb>::FromStandard(
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/ElectricCurrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ template <>
inline const std::map<Unit::ElectricCurrent, UnitSystem>
RelatedUnitSystems<Unit::ElectricCurrent>{};

// clang-format off

template <>
inline const std::map<Unit::ElectricCurrent, std::string_view> Abbreviations<Unit::ElectricCurrent>{
{Unit::ElectricCurrent::Ampere, "A" },
Expand Down Expand Up @@ -151,6 +153,8 @@ inline const std::unordered_map<std::string_view, Unit::ElectricCurrent>
{"e/hr", Unit::ElectricCurrent::ElementaryChargePerHour },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/Energy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ inline const std::map<Unit::Energy, UnitSystem> RelatedUnitSystems<Unit::Energy>
{Unit::Energy::InchPound, UnitSystem::InchPoundSecondRankine },
};

// clang-format off

template <>
inline const std::map<Unit::Energy, std::string_view> Abbreviations<Unit::Energy>{
{Unit::Energy::Joule, "J" },
Expand Down Expand Up @@ -292,6 +294,8 @@ inline const std::unordered_map<std::string_view, Unit::Energy> Spellings<Unit::
{"btu", Unit::Energy::BritishThermalUnit},
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::Energy, Unit::Energy::Joule>::FromStandard(
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/EnergyFlux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ inline const std::map<Unit::EnergyFlux, UnitSystem> RelatedUnitSystems<Unit::Ene
{Unit::EnergyFlux::InchPoundPerSquareInchPerSecond, UnitSystem::InchPoundSecondRankine },
};

// clang-format off

template <>
inline const std::map<Unit::EnergyFlux, std::string_view> Abbreviations<Unit::EnergyFlux>{
{Unit::EnergyFlux::WattPerSquareMetre, "W/m^2" },
Expand Down Expand Up @@ -169,6 +171,8 @@ inline const std::unordered_map<std::string_view, Unit::EnergyFlux> Spellings<Un
{"slinch/s3", Unit::EnergyFlux::InchPoundPerSquareInchPerSecond},
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/Force.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ inline const std::map<Unit::Force, UnitSystem> RelatedUnitSystems<Unit::Force>{
{Unit::Force::Micronewton, UnitSystem::MillimetreGramSecondKelvin},
};

// clang-format off

template <>
inline const std::map<Unit::Force, std::string_view> Abbreviations<Unit::Force>{
{Unit::Force::Newton, "N" },
Expand Down Expand Up @@ -153,6 +155,8 @@ inline const std::unordered_map<std::string_view, Unit::Force> Spellings<Unit::F
{"lb", Unit::Force::Pound },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::Force, Unit::Force::Newton>::FromStandard(
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/HeatCapacity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ inline const std::map<Unit::HeatCapacity, UnitSystem> RelatedUnitSystems<Unit::H
{Unit::HeatCapacity::InchPoundPerRankine, UnitSystem::InchPoundSecondRankine },
};

// clang-format off

template <>
inline const std::map<Unit::HeatCapacity, std::string_view> Abbreviations<Unit::HeatCapacity>{
{Unit::HeatCapacity::JoulePerKelvin, "J/K" },
Expand Down Expand Up @@ -154,6 +156,8 @@ inline const std::unordered_map<std::string_view, Unit::HeatCapacity> Spellings<
{"in*lb/R", Unit::HeatCapacity::InchPoundPerRankine},
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/Length.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ inline const std::map<Unit::Length, UnitSystem> RelatedUnitSystems<Unit::Length>
{Unit::Length::Inch, UnitSystem::InchPoundSecondRankine },
};

// clang-format off

template <>
inline const std::map<Unit::Length, std::string_view> Abbreviations<Unit::Length>{
{Unit::Length::NauticalMile, "nmi"},
Expand Down Expand Up @@ -211,6 +213,8 @@ inline const std::unordered_map<std::string_view, Unit::Length> Spellings<Unit::
{"microinches", Unit::Length::Microinch },
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::Length, Unit::Length::NauticalMile>::FromStandard(
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/Power.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ inline const std::map<Unit::Power, UnitSystem> RelatedUnitSystems<Unit::Power>{
{Unit::Power::InchPoundPerSecond, UnitSystem::InchPoundSecondRankine },
};

// clang-format off

template <>
inline const std::map<Unit::Power, std::string_view> Abbreviations<Unit::Power>{
{Unit::Power::Watt, "W" },
Expand Down Expand Up @@ -171,6 +173,8 @@ inline const std::unordered_map<std::string_view, Unit::Power> Spellings<Unit::P
{"in*lb/s", Unit::Power::InchPoundPerSecond},
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::Power, Unit::Power::Watt>::FromStandard(
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/Pressure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ inline const std::map<Unit::Pressure, std::string_view> Abbreviations<Unit::Pres
{Unit::Pressure::PoundPerSquareInch, "lbf/in^2"},
};

// clang-format off

template <>
inline const std::unordered_map<std::string_view, Unit::Pressure> Spellings<Unit::Pressure>{
{"Pa", Unit::Pressure::Pascal },
Expand Down Expand Up @@ -162,6 +164,8 @@ inline const std::unordered_map<std::string_view, Unit::Pressure> Spellings<Unit
{"psi", Unit::Pressure::PoundPerSquareInch},
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::Pressure, Unit::Pressure::Pascal>::FromStandard(
Expand Down
4 changes: 4 additions & 0 deletions include/PhQ/Unit/SolidAngle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ inline const std::map<Unit::SolidAngle, std::string_view> Abbreviations<Unit::So
{Unit::SolidAngle::SquareArcsecond, "arcsec^2"},
};

// clang-format off

template <>
inline const std::unordered_map<std::string_view, Unit::SolidAngle> Spellings<Unit::SolidAngle>{
{"sr", Unit::SolidAngle::Steradian },
Expand Down Expand Up @@ -143,6 +145,8 @@ inline const std::unordered_map<std::string_view, Unit::SolidAngle> Spellings<Un
{"arcseconds2", Unit::SolidAngle::SquareArcsecond},
};

// clang-format on

template <>
template <typename NumericType>
inline constexpr void Conversion<Unit::SolidAngle, Unit::SolidAngle::Steradian>::FromStandard(
Expand Down
Loading

0 comments on commit 3c2a8dd

Please sign in to comment.