Add default implementation for PgMoney (#3018)

This commit is contained in:
Paweł Urbanek 2024-01-30 22:23:45 +01:00 committed by GitHub
parent 235604fbce
commit 0299959ca6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,7 +48,7 @@ use std::{
/// https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/cash.c#L114-L123
///
/// [`MONEY`]: https://www.postgresql.org/docs/current/datatype-money.html
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
pub struct PgMoney(
/// The raw integer value sent over the wire; for locales with `frac_digits=2` (i.e. most
/// of them), this will be the value in whole cents.
@ -278,6 +278,13 @@ mod tests {
assert_eq!(PgMoney(-1), money);
}
#[test]
fn default_value() {
let money = PgMoney::default();
assert_eq!(money, PgMoney(0));
}
#[test]
#[should_panic]
fn add_overflow_panics() {