mirror of https://github.com/eldruin/ds323x-rs
Compare commits
3 Commits
57409f96dc
...
887f4ced89
| Author | SHA1 | Date |
|---|---|---|
|
|
887f4ced89 | |
|
|
97db2af80e | |
|
|
b803d3b4d3 |
|
|
@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
<!-- next-header -->
|
||||
## [Unreleased] - ReleaseDate
|
||||
|
||||
### Added
|
||||
|
||||
- [breaking-change] Return Error::InvalidInputData when attempting to set the year to something
|
||||
outside of the range 2000-2099 because all chips have a problem with the year 2100 and beyond.
|
||||
- [breaking-change] Return Error::InvalidDeviceCentury when attempting to get a date and/or time value
|
||||
and the the device's century bit is set because all chips have a problem withe year 2100 and beyond.
|
||||
|
||||
## [0.7.0] - 2025-10-11
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ macro_rules! get_invalid_device_century_test {
|
|||
[I2cTrans::write_read(
|
||||
DEV_ADDR,
|
||||
vec![Register::MONTH],
|
||||
vec![BitFlags::CENTURY]
|
||||
vec![BitFlags::CENTURY | 0]
|
||||
)]
|
||||
);
|
||||
get_invalid_test!(
|
||||
|
|
@ -165,7 +165,7 @@ macro_rules! get_invalid_device_century_test {
|
|||
[I2cTrans::write_read(
|
||||
DEV_ADDR,
|
||||
vec![Register::MONTH],
|
||||
vec![BitFlags::CENTURY]
|
||||
vec![BitFlags::CENTURY | 0]
|
||||
)]
|
||||
);
|
||||
get_invalid_test!(
|
||||
|
|
@ -358,6 +358,26 @@ macro_rules! dt_test {
|
|||
$destroy_method(dev);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_datetime_invalid_century() {
|
||||
let _dt = new_datetime(2018, 8, 13, 23, 59, 58);
|
||||
let mut dev = $create_method(&$mac_trans_read!(
|
||||
SECONDS,
|
||||
[
|
||||
0b0101_1000,
|
||||
0b0101_1001,
|
||||
0b0010_0011,
|
||||
0b0000_0010,
|
||||
0b0001_0011,
|
||||
0b0000_1000 | BitFlags::CENTURY,
|
||||
0b0001_1000
|
||||
],
|
||||
[0, 0, 0, 0, 0, 0, 0]
|
||||
));
|
||||
assert_invalid_device_century!(dev.datetime());
|
||||
$destroy_method(dev);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_datetime() {
|
||||
let dt = new_datetime(2018, 8, 13, 23, 59, 58);
|
||||
|
|
@ -389,6 +409,18 @@ macro_rules! dt_test {
|
|||
$destroy_method(dev);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_date_invalid_century() {
|
||||
let _d = new_date(2018, 8, 13);
|
||||
let mut dev = $create_method(&$mac_trans_read!(
|
||||
DOM,
|
||||
[0b0001_0011, 0b0000_1000 | BitFlags::CENTURY, 0b0001_1000],
|
||||
[0, 0, 0]
|
||||
));
|
||||
assert_invalid_device_century!(dev.date());
|
||||
$destroy_method(dev);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_date() {
|
||||
let d = new_date(2018, 8, 13);
|
||||
|
|
@ -403,7 +435,7 @@ macro_rules! dt_test {
|
|||
#[test]
|
||||
fn get_time() {
|
||||
let t = NaiveTime::from_hms_opt(23, 59, 58).unwrap();
|
||||
let month_transaction = $mac_trans_read!(MONTH, [0], [0]);
|
||||
let month_transaction = $mac_trans_read!(MONTH, [1], [0]);
|
||||
let time_transaction =
|
||||
$mac_trans_read!(SECONDS, [0b0101_1000, 0b0101_1001, 0b0010_0011], [0, 0, 0]);
|
||||
let mut transactions = vec![];
|
||||
|
|
@ -422,6 +454,14 @@ macro_rules! dt_test {
|
|||
$destroy_method(dev);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_time_invalid_century() {
|
||||
let transactions = $mac_trans_read!(MONTH, [0 | BitFlags::CENTURY], [0]);
|
||||
let mut dev = $create_method(&transactions);
|
||||
assert_invalid_device_century!(dev.time());
|
||||
$destroy_method(dev);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_time() {
|
||||
let t = NaiveTime::from_hms_opt(23, 59, 58).unwrap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue