diff --git a/.clang-format b/.clang-format index 08d7585..16d753d 100644 --- a/.clang-format +++ b/.clang-format @@ -16,4 +16,4 @@ AccessModifierOffset: -4 ConstructorInitializerIndentWidth: 0 BreakConstructorInitializers: BeforeColon ConstructorInitializerAllOnOneLineOrOnePerLine: true -NamespaceIndentation: All \ No newline at end of file +NamespaceIndentation: All diff --git a/.vscode/settings.json b/.vscode/settings.json index c0d3a20..b856275 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -67,5 +67,8 @@ "stack": "cpp", "random": "cpp" }, - "C_Cpp.clang_format_style": "file" -} \ No newline at end of file + "C_Cpp.clang_format_style": "file", + + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true +} diff --git a/docker/Dockerfile b/docker/Dockerfile index 6da7f84..060d54c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -52,4 +52,3 @@ COPY --from=builder /source/JetsonGPIO/build/install/ /usr/local/ # for debug COPY --from=builder /source/JetsonGPIO/build/samples/ /samples COPY --from=builder /source/JetsonGPIO/build/tests/ /tests - diff --git a/include/private/DictionaryLike.h b/include/private/DictionaryLike.h index f845fa0..5bbe6a3 100644 --- a/include/private/DictionaryLike.h +++ b/include/private/DictionaryLike.h @@ -21,6 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #pragma once #ifndef DICTIONARY_LIKE_H #define DICTIONARY_LIKE_H @@ -49,4 +50,4 @@ namespace GPIO }; } // namespace GPIO -#endif \ No newline at end of file +#endif diff --git a/include/private/ExceptionHandling.h b/include/private/ExceptionHandling.h index bbf50aa..08fd5ed 100644 --- a/include/private/ExceptionHandling.h +++ b/include/private/ExceptionHandling.h @@ -35,4 +35,4 @@ namespace GPIO std::runtime_error _error(const std::exception& e, const std::string& from); } // namespace GPIO -#endif \ No newline at end of file +#endif diff --git a/include/private/MainModule.h b/include/private/MainModule.h index 2e9fc4a..0c4c0d0 100644 --- a/include/private/MainModule.h +++ b/include/private/MainModule.h @@ -22,6 +22,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #pragma once #ifndef MAIN_MODULE_H #define MAIN_MODULE_H diff --git a/include/private/Model.h b/include/private/Model.h index bd26275..9422e55 100644 --- a/include/private/Model.h +++ b/include/private/Model.h @@ -58,4 +58,4 @@ namespace GPIO constexpr Model JETSON_ORIN = Model::JETSON_ORIN; } // namespace GPIO -#endif \ No newline at end of file +#endif diff --git a/include/private/ModelUtility.h b/include/private/ModelUtility.h index aaae425..6156b50 100644 --- a/include/private/ModelUtility.h +++ b/include/private/ModelUtility.h @@ -40,4 +40,4 @@ namespace GPIO } // namespace GPIO -#endif \ No newline at end of file +#endif diff --git a/include/private/SysfsRoot.h b/include/private/SysfsRoot.h index 0f7eb5d..1adab0c 100644 --- a/include/private/SysfsRoot.h +++ b/include/private/SysfsRoot.h @@ -37,4 +37,4 @@ namespace GPIO } // namespace GPIO #undef _MACRO_SYSFS_ROOT -#endif \ No newline at end of file +#endif diff --git a/include/private/TestUtility.h b/include/private/TestUtility.h index fce6a7b..aa952df 100644 --- a/include/private/TestUtility.h +++ b/include/private/TestUtility.h @@ -28,17 +28,16 @@ DEALINGS IN THE SOFTWARE. #define SIMPLE_UNIT_TEST_H #include +#include #include #include -#include namespace assert { void is_true(bool b, std::string msg = ""); void expect_exception(const std::function& func, std::string msg = ""); - template - void are_equal(const T1& expected, const T2& actual, std::string msg = "") + template void are_equal(const T1& expected, const T2& actual, std::string msg = "") { std::ostringstream s{}; s << msg << "(expected: " << expected << ", actual: " << actual << ")"; @@ -71,4 +70,4 @@ class TestSuit std::vector tests; }; -#endif \ No newline at end of file +#endif diff --git a/samples/button_interrupt.cpp b/samples/button_interrupt.cpp index dd37033..bb04d42 100644 --- a/samples/button_interrupt.cpp +++ b/samples/button_interrupt.cpp @@ -87,4 +87,4 @@ int main() GPIO::cleanup(); return 0; -} \ No newline at end of file +} diff --git a/samples/jetson_model.cpp b/samples/jetson_model.cpp index 913fd8d..ad4cd84 100644 --- a/samples/jetson_model.cpp +++ b/samples/jetson_model.cpp @@ -30,4 +30,4 @@ int main() std::string model = GPIO::model; std::cout << model << std::endl; return 0; -} \ No newline at end of file +} diff --git a/src/Callback.cpp b/src/Callback.cpp index d76d88e..922c4e8 100644 --- a/src/Callback.cpp +++ b/src/Callback.cpp @@ -36,4 +36,4 @@ namespace GPIO bool operator==(const Callback& A, const Callback& B) { return A.comparer(A.function, B.function); } bool operator!=(const Callback& A, const Callback& B) { return !(A == B); } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/DictionaryLike.cpp b/src/DictionaryLike.cpp index c245e3b..04402f2 100644 --- a/src/DictionaryLike.cpp +++ b/src/DictionaryLike.cpp @@ -85,4 +85,4 @@ namespace GPIO dictionary = std::move(_dictionary); } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/ExceptionHandling.cpp b/src/ExceptionHandling.cpp index 9188627..cf60919 100644 --- a/src/ExceptionHandling.cpp +++ b/src/ExceptionHandling.cpp @@ -39,4 +39,4 @@ namespace GPIO { return std::runtime_error(_error_message(e, from)); } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/GPIOEvent.cpp b/src/GPIOEvent.cpp index 1bb9395..3ad676c 100644 --- a/src/GPIOEvent.cpp +++ b/src/GPIOEvent.cpp @@ -49,7 +49,6 @@ constexpr size_t MAX_EPOLL_EVENTS = 20; namespace GPIO { - // Error messages for all errors produced by this module std::map event_error_code_to_message = { {EventResultCode::SysFD_EdgeOpen, "Failure to open the /sys/class/gpio/gpio{$ch}/edge file"}, @@ -864,4 +863,4 @@ namespace GPIO void _event_cleanup(int gpio, const std::string& gpio_name) { _remove_edge_detect(gpio); } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/GPIOPinData.cpp b/src/GPIOPinData.cpp index 6aeee1e..295e2c6 100644 --- a/src/GPIOPinData.cpp +++ b/src/GPIOPinData.cpp @@ -38,10 +38,10 @@ DEALINGS IN THE SOFTWARE. #include "JetsonGPIO.h" #include "private/ExceptionHandling.h" +#include "private/GPIOPinData.h" #include "private/ModelUtility.h" #include "private/PinDefinition.h" #include "private/PythonFunctions.h" -#include "private/GPIOPinData.h" using namespace std; using namespace std::string_literals; // enables s-suffix for std::string literals diff --git a/src/JetsonGPIO.cpp b/src/JetsonGPIO.cpp index 5070078..5c7fd26 100644 --- a/src/JetsonGPIO.cpp +++ b/src/JetsonGPIO.cpp @@ -401,4 +401,4 @@ namespace GPIO { return wait_for_edge(std::to_string(channel), edge, bounce_time, timeout); } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/LazyString.cpp b/src/LazyString.cpp index 2126e3e..daac7ae 100644 --- a/src/LazyString.cpp +++ b/src/LazyString.cpp @@ -53,4 +53,4 @@ namespace GPIO is_cached = true; } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/MainModule.cpp b/src/MainModule.cpp index fca2d96..38ce772 100644 --- a/src/MainModule.cpp +++ b/src/MainModule.cpp @@ -382,4 +382,4 @@ namespace GPIO } } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/ModelUtility.cpp b/src/ModelUtility.cpp index d562d7c..216706a 100644 --- a/src/ModelUtility.cpp +++ b/src/ModelUtility.cpp @@ -23,8 +23,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "private/Model.h" #include "private/ModelUtility.h" +#include "private/Model.h" #include "private/PythonFunctions.h" #include @@ -64,4 +64,4 @@ namespace GPIO Model name_to_model(const std::string& name) { return index_to_model(model_name_index(name)); } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/PWM.cpp b/src/PWM.cpp index 0f179ad..7bace60 100644 --- a/src/PWM.cpp +++ b/src/PWM.cpp @@ -222,4 +222,4 @@ namespace GPIO void PWM::stop() { pImpl->stop(); } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/src/WaitResult.cpp b/src/WaitResult.cpp index fbb1034..9dafd75 100644 --- a/src/WaitResult.cpp +++ b/src/WaitResult.cpp @@ -30,4 +30,4 @@ namespace GPIO { WaitResult::WaitResult(const std::string& channel) : _channel(channel) {} bool WaitResult::is_event_detected() const { return !is_None(channel()); } -} // namespace GPIO \ No newline at end of file +} // namespace GPIO diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 75c2820..3244e5a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,8 +15,9 @@ set(_unit_test_targets "test_model_name" ) + foreach (test ${_unit_test_targets}) add_executable(${test} unit-tests/${test}.cpp TestUtility.cpp) add_test(NAME ${test} COMMAND $) target_link_libraries(${test} PRIVATE JetsonGPIO) -endforeach () \ No newline at end of file +endforeach () diff --git a/tests/TestUtility.cpp b/tests/TestUtility.cpp index ed6b44d..9d14854 100644 --- a/tests/TestUtility.cpp +++ b/tests/TestUtility.cpp @@ -89,4 +89,4 @@ void TestSuit::run() void TestSuit::reserve(size_t n) { tests.reserve(n); } -void TestSuit::add(const TestFunction& test) { tests.emplace_back(test); } \ No newline at end of file +void TestSuit::add(const TestFunction& test) { tests.emplace_back(test); } diff --git a/tests/unit-tests/test_dictionary_like.cpp b/tests/unit-tests/test_dictionary_like.cpp index ec29a26..001b957 100644 --- a/tests/unit-tests/test_dictionary_like.cpp +++ b/tests/unit-tests/test_dictionary_like.cpp @@ -93,4 +93,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/tests/unit-tests/test_lazy_string.cpp b/tests/unit-tests/test_lazy_string.cpp index e92bba0..0ac7ea8 100644 --- a/tests/unit-tests/test_lazy_string.cpp +++ b/tests/unit-tests/test_lazy_string.cpp @@ -174,4 +174,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/tests/unit-tests/test_model_name.cpp b/tests/unit-tests/test_model_name.cpp index 34c2503..e80761d 100644 --- a/tests/unit-tests/test_model_name.cpp +++ b/tests/unit-tests/test_model_name.cpp @@ -57,4 +57,4 @@ int main() } return 0; -} \ No newline at end of file +}