-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple tests for sht3x and refactor the driver
- Loading branch information
1 parent
c8463d5
commit f618da5
Showing
6 changed files
with
130 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (C) 2024 Dmitry Ponomarev <ponomarevda96@gmail.com> | ||
# Distributed under the terms of the GPL v3 license, available in the file LICENSE. | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
project(sht3x) | ||
|
||
add_library(sht3x | ||
../sht3x.cpp | ||
../../../Src/platform/ubuntu/i2c.cpp | ||
) | ||
|
||
target_include_directories(sht3x PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
find_package(GTest REQUIRED) | ||
include_directories( | ||
${GTEST_INCLUDE_DIRS} | ||
../../../../Src | ||
) | ||
|
||
add_executable(test_sht3x | ||
test_sht3x.cpp | ||
) | ||
|
||
target_link_libraries(test_sht3x | ||
sht3x | ||
GTest::GTest | ||
GTest::Main | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* This program is free software under the GNU General Public License v3. | ||
* See <https://www.gnu.org/licenses/> for details. | ||
* Author: Dmitry Ponomarev <ponomarevda96@gmail.com> | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
#include "drivers/sht3x/sht3x.hpp" | ||
|
||
TEST(Shx3xTest, HelloWorld) { | ||
EXPECT_EQ(1, 1); | ||
} | ||
|
||
TEST(Shx3xTest, init) { | ||
Driver::SHT3X sht3x(Driver::SHT3X::DEV_ADDR_PIN_LOW); | ||
} | ||
|
||
TEST(Shx3xTest, read) { | ||
Driver::SHT3X sht3x(Driver::SHT3X::DEV_ADDR_PIN_LOW); | ||
|
||
float temperature; | ||
float humidity; | ||
sht3x.read(&temperature, &humidity); | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |