Skip to content

Commit

Permalink
Merge pull request #69 from Sensirion/add_tests_to_style_check
Browse files Browse the repository at this point in the history
Add tests to style check
  • Loading branch information
Zifzaf authored Sep 23, 2020
2 parents 7ad8373 + 52ace16 commit 4a0ab75
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 34 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ IndentCaseLabels: true
SpacesBeforeTrailingComments: 2
PointerAlignment: Left
AlignEscapedNewlines: Left
ForEachMacros: ['TEST_GROUP', 'TEST']
...
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ style-fix:
echo "Refusing to run on dirty git state. Commit your changes first."; \
exit 1; \
fi; \
git ls-files | grep -e '\.\(c\|h\|cpp\)$$'| grep -v '^tests\/' | xargs clang-format -i -style=file;
git ls-files | grep -e '\.\(c\|h\|cpp\)$$' | xargs clang-format -i -style=file;

style-check: style-fix
@if [ $$(git status --porcelain -uno 2> /dev/null | wc -l) -gt "0" ]; \
Expand Down
11 changes: 4 additions & 7 deletions tests/sht3x-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ static void sht3x_run_test() {
CHECK_ZERO_TEXT(ret, "sht3x_read");
CHECK_TRUE_TEXT(temperature >= 5000 && temperature <= 45000,
"sht3x_read temperature");
CHECK_TRUE_TEXT(humidity >= 0 && humidity <= 100000,
"sht3x_read humidity");
CHECK_TRUE_TEXT(humidity >= 0 && humidity <= 100000, "sht3x_read humidity");

ret = sht3x_read_serial(&serial);
CHECK_ZERO_TEXT(ret, "sht3x_read_serial");
printf("SHT3X serial: %u\n", serial);

const char *version = sht3x_get_driver_version();
const char* version = sht3x_get_driver_version();
printf("sht3x_get_driver_version: %s\n", version);

uint8_t addr = sht3x_get_configured_address();
Expand All @@ -55,7 +54,7 @@ static void test_teardown() {
sensirion_i2c_release();
}

TEST_GROUP(SHT31_Tests) {
TEST_GROUP (SHT31_Tests) {
void setup() {
sensirion_i2c_init();
int16_t ret = sensirion_i2c_mux_set_single_channel(0x72, 0);
Expand All @@ -67,6 +66,4 @@ TEST_GROUP(SHT31_Tests) {
}
};

TEST(SHT31_Tests, SHT31Test) {
sht3x_test_all_power_modes();
}
TEST (SHT31_Tests, SHT31Test) { sht3x_test_all_power_modes(); }
11 changes: 4 additions & 7 deletions tests/sht4x-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ static void sht4x_run_test() {
CHECK_ZERO_TEXT(ret, "sht4x_read");
CHECK_TRUE_TEXT(temperature >= 5000 && temperature <= 45000,
"sht4x_read temperature");
CHECK_TRUE_TEXT(humidity >= 0 && humidity <= 100000,
"sht4x_read humidity");
CHECK_TRUE_TEXT(humidity >= 0 && humidity <= 100000, "sht4x_read humidity");

ret = sht4x_read_serial(&serial);
CHECK_ZERO_TEXT(ret, "sht4x_read_serial");
printf("SHT4X serial: %u\n", serial);

const char *version = sht4x_get_driver_version();
const char* version = sht4x_get_driver_version();
printf("sht4x_get_driver_version: %s\n", version);

uint8_t addr = sht4x_get_configured_address();
Expand All @@ -55,7 +54,7 @@ static void test_teardown() {
sensirion_i2c_release();
}

TEST_GROUP(SHT4X_Tests) {
TEST_GROUP (SHT4X_Tests) {
void setup() {
sensirion_i2c_init();
int16_t ret = sensirion_i2c_mux_set_single_channel(0x71, 7);
Expand All @@ -67,6 +66,4 @@ TEST_GROUP(SHT4X_Tests) {
}
};

TEST(SHT4X_Tests, SHT4XTest) {
sht4x_test_all_power_modes();
}
TEST (SHT4X_Tests, SHT4XTest) { sht4x_test_all_power_modes(); }
31 changes: 12 additions & 19 deletions tests/shtc1-test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sensirion_test_setup.h"
#include "sensirion_common.h"
#include "sensirion_test_setup.h"
#include "shtc1.h"

static void shtc1_run_test() {
Expand All @@ -24,14 +24,13 @@ static void shtc1_run_test() {
CHECK_ZERO_TEXT(ret, "shtc1_read");
CHECK_TRUE_TEXT(temperature >= 5000 && temperature <= 45000,
"shtc1_read temperature");
CHECK_TRUE_TEXT(humidity >= 0 && humidity <= 100000,
"shtc1_read humidity");
CHECK_TRUE_TEXT(humidity >= 0 && humidity <= 100000, "shtc1_read humidity");

ret = shtc1_read_serial(&serial);
CHECK_ZERO_TEXT(ret, "shtc1_read_serial");
printf("SHTC1 serial: %u\n", serial);

const char *version = shtc1_get_driver_version();
const char* version = shtc1_get_driver_version();
printf("shtc1_get_driver_version: %s\n", version);

uint8_t addr = shtc1_get_configured_address();
Expand Down Expand Up @@ -80,7 +79,7 @@ static void test_teardown() {
sensirion_i2c_release();
}

TEST_GROUP(SHTC1_Tests) {
TEST_GROUP (SHTC1_Tests) {
void setup() {
sensirion_i2c_init();
int16_t ret = sensirion_i2c_mux_set_single_channel(0x71, 6);
Expand All @@ -92,7 +91,7 @@ TEST_GROUP(SHTC1_Tests) {
}
};

TEST_GROUP(SHTC3_Tests) {
TEST_GROUP (SHTC3_Tests) {
void setup() {
sensirion_i2c_init();
int16_t ret = sensirion_i2c_mux_set_single_channel(0x72, 0);
Expand All @@ -104,7 +103,7 @@ TEST_GROUP(SHTC3_Tests) {
}
};

TEST_GROUP(SHTW2_Tests) {
TEST_GROUP (SHTW2_Tests) {
void setup() {
sensirion_i2c_init();
int16_t ret = sensirion_i2c_mux_set_single_channel(0x71, 0);
Expand All @@ -116,29 +115,23 @@ TEST_GROUP(SHTW2_Tests) {
}
};

TEST(SHTC1_Tests, SHTC1Test) {
shtc1_test_all_power_modes();
}
TEST (SHTC1_Tests, SHTC1Test) { shtc1_test_all_power_modes(); }

TEST(SHTC1_Tests, SHTC1Test_sleep) {
TEST (SHTC1_Tests, SHTC1Test_sleep) {
shtc1_sleep_fail();
shtc1_test_all_power_modes();
}

TEST(SHTC3_Tests, SHTC3Test) {
shtc1_test_all_power_modes();
}
TEST (SHTC3_Tests, SHTC3Test) { shtc1_test_all_power_modes(); }

TEST(SHTC3_Tests, SHTC3Test_sleep) {
TEST (SHTC3_Tests, SHTC3Test_sleep) {
shtc1_sleep_success();
shtc1_test_all_power_modes();
}

TEST(SHTW2_Tests, SHTW2Test) {
shtc1_test_all_power_modes();
}
TEST (SHTW2_Tests, SHTW2Test) { shtc1_test_all_power_modes(); }

TEST(SHTW2_Tests, SHTW2Test_sleep) {
TEST (SHTW2_Tests, SHTW2Test_sleep) {
shtc1_sleep_fail();
shtc1_test_all_power_modes();
}

0 comments on commit 4a0ab75

Please sign in to comment.