From 1fb65fadebf03bf5626cd02fd2924f7788a3afba Mon Sep 17 00:00:00 2001 From: Jeremy Lloyd Conlin Date: Thu, 13 Sep 2018 16:11:41 -0600 Subject: [PATCH] Adding first physical constant. --- .gitignore | 1 + .gitmodules | 3 + CMakeLists.txt | 188 ++++++++++-------- README.md | 12 +- dependencies/dimwits | 1 + metaconfigure/description.json | 8 +- src/constants/physics/CODATA.hpp | 10 +- src/constants/physics/CODATA2014.hpp | 5 + .../physics/CODATA2014/test/CMakeLists.txt | 14 ++ .../CODATA2014/test/CODATA2014.test.cpp | 15 ++ 10 files changed, 159 insertions(+), 98 deletions(-) create mode 160000 dependencies/dimwits create mode 100644 src/constants/physics/CODATA2014/test/CMakeLists.txt create mode 100644 src/constants/physics/CODATA2014/test/CODATA2014.test.cpp diff --git a/.gitignore b/.gitignore index 57ccd72..f74ae76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin subprojects +__pycache__ diff --git a/.gitmodules b/.gitmodules index 039d166..60c1425 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "dependencies/catch-adapter"] path = dependencies/catch-adapter url = https://github.com/njoy/catch-adapter.git +[submodule "dependencies/dimwits"] + path = dependencies/dimwits + url = https://github.com/njoy/DimensionalAnalysis.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 8da14c3..67e2e78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,9 +33,9 @@ project( constants LANGUAGES CXX ) get_directory_property( is_subproject PARENT_DIRECTORY ) include( CMakeDependentOption REQUIRED ) -set( constants_Clang_minimum_version 3.8 ) -set( constants_GNU_minimum_version 6.2 ) set( constants_AppleClang_minimum_version 8.0 ) +set( constants_GNU_minimum_version 6.2 ) +set( constants_Clang_minimum_version 3.8 ) if( constants_${CMAKE_CXX_COMPILER_ID}_minimum_version ) if( CMAKE_CXX_COMPILER_VERSION AND @@ -75,66 +75,30 @@ if ( profile_generate ) file( MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/profiling" ) endif() -set( constants_Clang_Windows_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) -set( constants_Clang_Windows_DEBUG_flags "-O0" "-g" "-gdwarf-3" ) -set( constants_Clang_Windows_RELEASE_flags "-O3" "-DNDEBUG" ) -set( constants_Clang_Windows_strict_flags "-Werror" ) -set( constants_Clang_Windows_coverage_flags "--coverage" ) -set( constants_Clang_Windows_subproject_flags ) -set( constants_Clang_Windows_base_project_flags ) -set( constants_Clang_Windows_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_Windows_link_time_optimization_flags "-flto" ) -set( constants_Clang_Windows_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_Windows_nonportable_optimization_flags "-march=native" ) -set( constants_Clang_Windows_static_flags "-static" ) -set( constants_Clang_Darwin_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) -set( constants_Clang_Darwin_DEBUG_flags "-O0" "-g" "-gdwarf-3" ) -set( constants_Clang_Darwin_RELEASE_flags "-O3" "-DNDEBUG" ) -set( constants_Clang_Darwin_strict_flags "-Werror" ) -set( constants_Clang_Darwin_coverage_flags "--coverage" ) -set( constants_Clang_Darwin_subproject_flags ) -set( constants_Clang_Darwin_base_project_flags ) -set( constants_Clang_Darwin_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_Darwin_link_time_optimization_flags "-flto" ) -set( constants_Clang_Darwin_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_Darwin_nonportable_optimization_flags "-march=native" ) -set( constants_Clang_Darwin_static_flags "-static" ) -set( constants_Clang_CYGWIN_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=gnu++14" ) -set( constants_Clang_CYGWIN_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" ) -set( constants_Clang_CYGWIN_RELEASE_flags "-O3" "-DNDEBUG" ) -set( constants_Clang_CYGWIN_strict_flags "-Werror" ) -set( constants_Clang_CYGWIN_coverage_flags "--coverage" ) -set( constants_Clang_CYGWIN_subproject_flags ) -set( constants_Clang_CYGWIN_base_project_flags ) -set( constants_Clang_CYGWIN_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_CYGWIN_link_time_optimization_flags "-flto" ) -set( constants_Clang_CYGWIN_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_CYGWIN_nonportable_optimization_flags "-march=native" ) -set( constants_Clang_CYGWIN_static_flags "-static" ) -set( constants_Clang_Linux_common_flags "-stdlib=libstdc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) -set( constants_Clang_Linux_DEBUG_flags "-O0" "-g" "-gdwarf-3" ) -set( constants_Clang_Linux_RELEASE_flags "-O3" "-DNDEBUG" ) -set( constants_Clang_Linux_strict_flags "-Werror" ) -set( constants_Clang_Linux_coverage_flags "--coverage" ) -set( constants_Clang_Linux_subproject_flags ) -set( constants_Clang_Linux_base_project_flags ) -set( constants_Clang_Linux_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_Linux_link_time_optimization_flags "-flto" ) -set( constants_Clang_Linux_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_Linux_nonportable_optimization_flags "-march=native" ) -set( constants_Clang_Linux_static_flags "-static" ) -set( constants_Clang_MinGW_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) -set( constants_Clang_MinGW_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" ) -set( constants_Clang_MinGW_RELEASE_flags "-O3" "-DNDEBUG" ) -set( constants_Clang_MinGW_strict_flags "-Werror" ) -set( constants_Clang_MinGW_coverage_flags "--coverage" ) -set( constants_Clang_MinGW_subproject_flags ) -set( constants_Clang_MinGW_base_project_flags ) -set( constants_Clang_MinGW_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_MinGW_link_time_optimization_flags "-flto" ) -set( constants_Clang_MinGW_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_Clang_MinGW_nonportable_optimization_flags "-march=native" ) -set( constants_Clang_MinGW_static_flags "-static" ) +set( constants_AppleClang_Darwin_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) +set( constants_AppleClang_Darwin_DEBUG_flags "-O0" "-g" "-gdwarf-3" ) +set( constants_AppleClang_Darwin_RELEASE_flags "-O3" "-DNDEBUG" ) +set( constants_AppleClang_Darwin_strict_flags "-Werror" ) +set( constants_AppleClang_Darwin_coverage_flags "--coverage" ) +set( constants_AppleClang_Darwin_subproject_flags ) +set( constants_AppleClang_Darwin_base_project_flags ) +set( constants_AppleClang_Darwin_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_AppleClang_Darwin_link_time_optimization_flags "-flto" ) +set( constants_AppleClang_Darwin_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_AppleClang_Darwin_nonportable_optimization_flags "-march=native" ) +set( constants_AppleClang_Darwin_static_flags "-static" ) +set( constants_GNU_MinGW_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) +set( constants_GNU_MinGW_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" ) +set( constants_GNU_MinGW_RELEASE_flags "-O3" "-DNDEBUG" ) +set( constants_GNU_MinGW_strict_flags "-Werror" ) +set( constants_GNU_MinGW_coverage_flags "--coverage" ) +set( constants_GNU_MinGW_subproject_flags ) +set( constants_GNU_MinGW_base_project_flags ) +set( constants_GNU_MinGW_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_GNU_MinGW_link_time_optimization_flags "-flto" ) +set( constants_GNU_MinGW_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_GNU_MinGW_nonportable_optimization_flags "-march=native" ) +set( constants_GNU_MinGW_static_flags "-static" ) set( constants_GNU_Windows_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) set( constants_GNU_Windows_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" ) set( constants_GNU_Windows_RELEASE_flags "-O3" "-DNDEBUG" ) @@ -183,36 +147,80 @@ set( constants_GNU_Linux_link_time_optimization_flags "-flto" ) set( constants_GNU_Linux_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) set( constants_GNU_Linux_nonportable_optimization_flags "-march=native" ) set( constants_GNU_Linux_static_flags "-static" ) -set( constants_GNU_MinGW_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) -set( constants_GNU_MinGW_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" ) -set( constants_GNU_MinGW_RELEASE_flags "-O3" "-DNDEBUG" ) -set( constants_GNU_MinGW_strict_flags "-Werror" ) -set( constants_GNU_MinGW_coverage_flags "--coverage" ) -set( constants_GNU_MinGW_subproject_flags ) -set( constants_GNU_MinGW_base_project_flags ) -set( constants_GNU_MinGW_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_GNU_MinGW_link_time_optimization_flags "-flto" ) -set( constants_GNU_MinGW_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_GNU_MinGW_nonportable_optimization_flags "-march=native" ) -set( constants_GNU_MinGW_static_flags "-static" ) -set( constants_AppleClang_Darwin_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) -set( constants_AppleClang_Darwin_DEBUG_flags "-O0" "-g" "-gdwarf-3" ) -set( constants_AppleClang_Darwin_RELEASE_flags "-O3" "-DNDEBUG" ) -set( constants_AppleClang_Darwin_strict_flags "-Werror" ) -set( constants_AppleClang_Darwin_coverage_flags "--coverage" ) -set( constants_AppleClang_Darwin_subproject_flags ) -set( constants_AppleClang_Darwin_base_project_flags ) -set( constants_AppleClang_Darwin_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_AppleClang_Darwin_link_time_optimization_flags "-flto" ) -set( constants_AppleClang_Darwin_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) -set( constants_AppleClang_Darwin_nonportable_optimization_flags "-march=native" ) -set( constants_AppleClang_Darwin_static_flags "-static" ) +set( constants_Clang_MinGW_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) +set( constants_Clang_MinGW_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" ) +set( constants_Clang_MinGW_RELEASE_flags "-O3" "-DNDEBUG" ) +set( constants_Clang_MinGW_strict_flags "-Werror" ) +set( constants_Clang_MinGW_coverage_flags "--coverage" ) +set( constants_Clang_MinGW_subproject_flags ) +set( constants_Clang_MinGW_base_project_flags ) +set( constants_Clang_MinGW_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_MinGW_link_time_optimization_flags "-flto" ) +set( constants_Clang_MinGW_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_MinGW_nonportable_optimization_flags "-march=native" ) +set( constants_Clang_MinGW_static_flags "-static" ) +set( constants_Clang_Windows_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) +set( constants_Clang_Windows_DEBUG_flags "-O0" "-g" "-gdwarf-3" ) +set( constants_Clang_Windows_RELEASE_flags "-O3" "-DNDEBUG" ) +set( constants_Clang_Windows_strict_flags "-Werror" ) +set( constants_Clang_Windows_coverage_flags "--coverage" ) +set( constants_Clang_Windows_subproject_flags ) +set( constants_Clang_Windows_base_project_flags ) +set( constants_Clang_Windows_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_Windows_link_time_optimization_flags "-flto" ) +set( constants_Clang_Windows_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_Windows_nonportable_optimization_flags "-march=native" ) +set( constants_Clang_Windows_static_flags "-static" ) +set( constants_Clang_Darwin_common_flags "-stdlib=libc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) +set( constants_Clang_Darwin_DEBUG_flags "-O0" "-g" "-gdwarf-3" ) +set( constants_Clang_Darwin_RELEASE_flags "-O3" "-DNDEBUG" ) +set( constants_Clang_Darwin_strict_flags "-Werror" ) +set( constants_Clang_Darwin_coverage_flags "--coverage" ) +set( constants_Clang_Darwin_subproject_flags ) +set( constants_Clang_Darwin_base_project_flags ) +set( constants_Clang_Darwin_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_Darwin_link_time_optimization_flags "-flto" ) +set( constants_Clang_Darwin_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_Darwin_nonportable_optimization_flags "-march=native" ) +set( constants_Clang_Darwin_static_flags "-static" ) +set( constants_Clang_CYGWIN_common_flags "-Wno-subobject-linkage" "-Wall" "-Wextra" "-Wpedantic" "-std=gnu++14" ) +set( constants_Clang_CYGWIN_DEBUG_flags "-O0" "-g" "-gdwarf-3" "-fsignaling-nans" ) +set( constants_Clang_CYGWIN_RELEASE_flags "-O3" "-DNDEBUG" ) +set( constants_Clang_CYGWIN_strict_flags "-Werror" ) +set( constants_Clang_CYGWIN_coverage_flags "--coverage" ) +set( constants_Clang_CYGWIN_subproject_flags ) +set( constants_Clang_CYGWIN_base_project_flags ) +set( constants_Clang_CYGWIN_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_CYGWIN_link_time_optimization_flags "-flto" ) +set( constants_Clang_CYGWIN_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_CYGWIN_nonportable_optimization_flags "-march=native" ) +set( constants_Clang_CYGWIN_static_flags "-static" ) +set( constants_Clang_Linux_common_flags "-stdlib=libstdc++" "-Wall" "-Wextra" "-Wpedantic" "-std=c++14" ) +set( constants_Clang_Linux_DEBUG_flags "-O0" "-g" "-gdwarf-3" ) +set( constants_Clang_Linux_RELEASE_flags "-O3" "-DNDEBUG" ) +set( constants_Clang_Linux_strict_flags "-Werror" ) +set( constants_Clang_Linux_coverage_flags "--coverage" ) +set( constants_Clang_Linux_subproject_flags ) +set( constants_Clang_Linux_base_project_flags ) +set( constants_Clang_Linux_profile_generate_flags "-fprofile-generate='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_Linux_link_time_optimization_flags "-flto" ) +set( constants_Clang_Linux_profile_use_flags "-fprofile-use='${CMAKE_BINARY_DIR}/profiling'" ) +set( constants_Clang_Linux_nonportable_optimization_flags "-march=native" ) +set( constants_Clang_Linux_static_flags "-static" ) get_directory_property( is_subproject PARENT_DIRECTORY ) if( NOT TARGET catch-adapter ) add_subdirectory( ${ROOT_DIRECTORY}/subprojects/catch-adapter ) endif() +if( NOT TARGET hana-adapter ) + add_subdirectory( ${ROOT_DIRECTORY}/subprojects/hana-adapter ) +endif() + +if( NOT TARGET dimwits ) + add_subdirectory( ${ROOT_DIRECTORY}/subprojects/dimwits ) +endif() + if ( NOT GIT_EXECUTABLE ) find_package( Git ) @@ -245,7 +253,10 @@ message( STATUS "-----------------------------------------------------------" ) add_library( constants INTERFACE ) target_sources( constants INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/constants.hpp" - "${CMAKE_CURRENT_SOURCE_DIR}/src/constants/math.hpp" ) + "${CMAKE_CURRENT_SOURCE_DIR}/src/constants/math.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/constants/physics.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/constants/physics/CODATA.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/constants/physics/CODATA2014.hpp" ) target_include_directories( constants INTERFACE src ) @@ -253,12 +264,13 @@ set( PREFIX constants_${CMAKE_CXX_COMPILER_ID}_${CMAKE_SYSTEM_NAME} ) target_link_libraries( constants INTERFACE "$<$,$>:${${PREFIX}_RELEASE_flags};${${PREFIX}_link_time_optimization_flags}$<$:${${PREFIX}_profile_generate_flags};>$<$:${${PREFIX}_profile_use_flags};>$<$:${${PREFIX}_nonportable_optimization_flags};>>$<$:$<$:${${PREFIX}_coverage_flags};>>$<$:${CXX_appended_flags};>$<$:${constants_appended_flags};>" ) -target_link_libraries( constants INTERFACE catch-adapter ) +target_link_libraries( constants INTERFACE catch-adapter INTERFACE dimwits ) if( NOT is_subproject ) enable_testing() if ( unit_tests ) add_subdirectory( src/constants/math/test ) + add_subdirectory( src/constants/physics/CODATA2014/test ) endif() endif() diff --git a/README.md b/README.md index 845ddd0..4a9765b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # constants This repository contains a collection of mathematical and physical constants. +**Note:** For the mathematical constants, their values are actually given in three places in this repository: + +1. Here in the `README.md` file, +2. In the header file that defines the value for C++, and +3. In the files used to test/verify the values. +While every effort is made to ensure that each of these values are the same, inconsistencies may appear. If discovered, please [file an issue](https://github.com/njoy/constants/issues). ## Mathematical Constants The (short) list of mathematical constants was taken from [Wikipedia:Mathematical constant](https://en.wikipedia.org/wiki/Mathematical_constant). While there are many more constants given there, we have limited this initially to the [Basic mathematical constants](https://en.wikipedia.org/wiki/Mathematical_constant#Basic_mathematical_constants). @@ -11,12 +17,6 @@ The (short) list of mathematical constants was taken from [Wikipedia:Mathematica | Euler's number (e) | `e` | `2.718281828459045` | [http://mathworld.wolfram.com/e.html]() | 2018-09-13 | | Pythagoras' constant (√2) | `root2` | `1.414213562373095` | [http://mathworld.wolfram.com/PythagorassConstant.html]() | 2018-09-13 | -**Note:** For the mathematical constants, their values are actually given in three places in this repository: - -1. Here in the `README.md` file, -2. In the header file that defines the value for C++, and -3. In the `math.test.cpp` file used to test/verify the values. -While every effort is made to ensure that each of these values are the same, inconsistencies may appear. If discovered, please [file an issue](https://github.com/njoy/constants/issues). ### Using mathematical constants Here is an example of how the mathematical constants can be used. diff --git a/dependencies/dimwits b/dependencies/dimwits new file mode 160000 index 0000000..d60dddd --- /dev/null +++ b/dependencies/dimwits @@ -0,0 +1 @@ +Subproject commit d60ddddf82f3f77b566d11383c0c633b4414556e diff --git a/metaconfigure/description.json b/metaconfigure/description.json index 65a49dc..192f463 100644 --- a/metaconfigure/description.json +++ b/metaconfigure/description.json @@ -574,7 +574,10 @@ }, "header files": [ "src/constants.hpp", - "src/constants/math.hpp" + "src/constants/math.hpp", + "src/constants/physics.hpp", + "src/constants/physics/CODATA.hpp", + "src/constants/physics/CODATA2014.hpp" ], "ignore pattern": "$^", "implementation files": [], @@ -594,6 +597,9 @@ "tests": { "constants.math": [ "src/constants/math/test/math.test.cpp" + ], + "constants.physics.CODATA2014": [ + "src/constants/physics/CODATA2014/test/CODATA2014.test.cpp" ] }, "update": true diff --git a/src/constants/physics/CODATA.hpp b/src/constants/physics/CODATA.hpp index 1e6fdcb..59399b5 100644 --- a/src/constants/physics/CODATA.hpp +++ b/src/constants/physics/CODATA.hpp @@ -1,13 +1,17 @@ #ifndef NJOY_CONSTANTS_PHYSICS_CODATA_HPP #define NJOY_CONSTANTS_PHYSICS_CODATA_HPP +#include "dimwits.hpp" +using namespace dimwits; + namespace njoy{ namespace constants{ namespace physics{ -static SpeedOfLight_t{}; -static constexpr SpeedOfLight_t c{}; -static constexpr SpeedOfLight_t speedOfLight{}; +struct SpeedOfLight: hana::type< SpeedOfLight >{}; +static constexpr SpeedOfLight speedOfLight{}; +struct C: hana::type< C >{}; +static constexpr C c{}; } } // namespace constants diff --git a/src/constants/physics/CODATA2014.hpp b/src/constants/physics/CODATA2014.hpp index a481ef3..874cbaa 100644 --- a/src/constants/physics/CODATA2014.hpp +++ b/src/constants/physics/CODATA2014.hpp @@ -7,6 +7,11 @@ namespace njoy{ namespace constants{ namespace physics{ +auto CODATA2014 = hana::make_map( + hana::make_pair( speedOfLight, 299792458*meter/second ), + hana::make_pair( c, 299792458*meter/second ) +); + } } // namespace constants } // namespace njoy diff --git a/src/constants/physics/CODATA2014/test/CMakeLists.txt b/src/constants/physics/CODATA2014/test/CMakeLists.txt new file mode 100644 index 0000000..90d434c --- /dev/null +++ b/src/constants/physics/CODATA2014/test/CMakeLists.txt @@ -0,0 +1,14 @@ + +add_executable( constants.physics.CODATA2014.test CODATA2014.test.cpp ) +target_compile_options( constants.physics.CODATA2014.test PRIVATE ${${PREFIX}_common_flags} +$<$:${${PREFIX}_strict_flags}>$<$: +${${PREFIX}_DEBUG_flags} +$<$:${${PREFIX}_coverage_flags}>> +$<$: +${${PREFIX}_RELEASE_flags} +$<$:${${PREFIX}_link_time_optimization_flags}> +$<$:${${PREFIX}_nonportable_optimization_flags}>> + +${CXX_appended_flags} ${constants_appended_flags} ) +target_link_libraries( constants.physics.CODATA2014.test PUBLIC constants ) +add_test( NAME constants.physics.CODATA2014 COMMAND constants.physics.CODATA2014.test ) \ No newline at end of file diff --git a/src/constants/physics/CODATA2014/test/CODATA2014.test.cpp b/src/constants/physics/CODATA2014/test/CODATA2014.test.cpp new file mode 100644 index 0000000..7ed9715 --- /dev/null +++ b/src/constants/physics/CODATA2014/test/CODATA2014.test.cpp @@ -0,0 +1,15 @@ +#define CATCH_CONFIG_MAIN + +#include "catch.hpp" + +#include "constants/physics/CODATA2014.hpp" + +using namespace njoy; +using namespace dimwits; + +SCENARIO( "Testing CODATA2014 physical constants and uncertainties" ){ + auto constants = njoy::constants::physics::CODATA2014; + + REQUIRE( 299792458*meter/second == njoy::constants::physics::CODATA2014[constants::physics::speedOfLight] ); + REQUIRE( 299792458*meter/second == constants[constants::physics::c] ); +}