1
+ // DISABLED AS NOT ALL STD LIBRARIES ARE MOCKED / INCLUDEABLE
2
+
3
+ //
4
+ // FILE: unit_test_001.cpp
5
+ // AUTHOR: Miles Burton / Rob Tillaart
6
+ // DATE: 2021-01-10
7
+ // PURPOSE: unit tests for the Arduino-Temperature-Control-Library
8
+ // https://github.com/MilesBurton/Arduino-Temperature-Control-Library
9
+ //
10
+
11
+ // #include <ArduinoUnitTests.h>
12
+ // #include <Arduino.h>
13
+ // #include <OneWire.h>
14
+ // #include <DallasTemperature.h>
15
+
16
+ // // Mock pin for testing
17
+ // #define ONE_WIRE_BUS 2
18
+
19
+ // unittest_setup() {
20
+ // fprintf(stderr, "VERSION: %s\n", DALLASTEMPLIBVERSION);
21
+ // }
22
+
23
+ // unittest_teardown() {
24
+ // fprintf(stderr, "\n");
25
+ // }
26
+
27
+ // // Test constants defined in the library
28
+ // unittest(test_models) {
29
+ // assertEqual(0x10, DS18S20MODEL);
30
+ // assertEqual(0x28, DS18B20MODEL);
31
+ // assertEqual(0x22, DS1822MODEL);
32
+ // assertEqual(0x3B, DS1825MODEL);
33
+ // assertEqual(0x42, DS28EA00MODEL);
34
+ // }
35
+
36
+ // // Test error codes defined in the library
37
+ // unittest(test_error_code) {
38
+ // assertEqual(DEVICE_DISCONNECTED_C, -127);
39
+ // assertEqual(DEVICE_DISCONNECTED_F, -196.6);
40
+ // assertEqual(DEVICE_DISCONNECTED_RAW, -7040);
41
+
42
+ // assertEqual(DEVICE_FAULT_OPEN_C, -254);
43
+ // assertEqualFloat(DEVICE_FAULT_OPEN_F, -425.2, 0.1);
44
+ // assertEqual(DEVICE_FAULT_OPEN_RAW, -32512);
45
+
46
+ // assertEqual(DEVICE_FAULT_SHORTGND_C, -253);
47
+ // assertEqualFloat(DEVICE_FAULT_SHORTGND_F, -423.4, 0.1);
48
+ // assertEqual(DEVICE_FAULT_SHORTGND_RAW, -32384);
49
+
50
+ // assertEqual(DEVICE_FAULT_SHORTVDD_C, -252);
51
+ // assertEqualFloat(DEVICE_FAULT_SHORTVDD_F, -421.6, 0.1);
52
+ // assertEqual(DEVICE_FAULT_SHORTVDD_RAW, -32256);
53
+ // }
54
+
55
+ // // Test basic initialization and functionality of the DallasTemperature library
56
+ // unittest(test_initialization) {
57
+ // OneWire oneWire(ONE_WIRE_BUS);
58
+ // DallasTemperature sensors(&oneWire);
59
+
60
+ // sensors.begin();
61
+
62
+ // // Initially, there should be no devices detected
63
+ // assertEqual(0, sensors.getDeviceCount());
64
+ // assertFalse(sensors.isParasitePowerMode());
65
+ // }
66
+
67
+ // // Simulate a basic temperature read (mocked)
68
+ // unittest(test_temperature_read) {
69
+ // OneWire oneWire(ONE_WIRE_BUS);
70
+ // DallasTemperature sensors(&oneWire);
71
+
72
+ // sensors.begin();
73
+
74
+ // // Mock reading temperature
75
+ // float tempC = sensors.getTempCByIndex(0);
76
+ // assertEqual(DEVICE_DISCONNECTED_C, tempC); // Simulated no device connected
77
+ // }
78
+
79
+ // unittest_main()
80
+
81
+ // --------
0 commit comments